EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Bug Reports (https://www.eqemulator.org/forums/forumdisplay.php?f=591)
-   -   Reverse Procs fire of attackers dex? (https://www.eqemulator.org/forums/showthread.php?t=28696)

ChaosSlayerZ 06-26-2009 06:42 PM

Reverse Procs fire of attackers dex?
 
I have doen extensive testing of Proc Buff and Reverse Proc buffs (those which fire when you get hit), and it seems that Reverse Procs ALSO fire more when hiting side has more DEX, which is UMM kind of illogical.

Basicly what happens if you cast reverse proc buff on yourself as means of DEFENCE and an enemy has very low DEX - it simply not gona proc, making buff rather useless. On other hand, if attacker have a lot of dex, the buff procs like MAD.

Is this how it suppose to be?

I belive that the reverse proc buff are NOT supose to be based of attacker DEX and thats why they come with 400% modifiers (or sometimes more) - so they proc equaly for everyone

AndMetal 06-28-2009 12:45 PM

Here's the code:

zone/attack.cpp
Code:

        if (damage > 0)
        {
                // Give the opportunity to throw back a defensive proc, if we are successful in affecting damage on our target
                other->TriggerDefensiveProcs(this);
               
        return true;
        }
        else
                return false;

zone/mob.cpp
Code:

void Mob::TriggerDefensiveProcs(Mob *on)
{
        if (this->HasDefensiveProcs()) {
                this->TryDefensiveProc(on);
        }

        return;
}

zone/attack.cpp
Code:

bool Mob::HasDefensiveProcs() const
{
        for (int i = 0; i < MAX_PROCS; i++)
        if (DefensiveProcs[i].spellID != SPELL_UNKNOWN)
            return true;
    return false;
}

zone/attack.cpp
Code:

void Mob::TryDefensiveProc(Mob *on) {
        // this should have already been checked, but just in case...
        if (!this->HasDefensiveProcs())
                return;

        if (!on) {
                SetTarget(NULL);
                LogFile->write(EQEMuLog::Error, "A null Mob object was passed to Mob::TryDefensiveProc for evaluation!");
                return;
        }

        // iterate through our defensive procs and try each of them
        for (int i = 0; i < MAX_PROCS; i++) {
                if (DefensiveProcs[i].spellID != SPELL_UNKNOWN &&
                        IsValidSpell(DefensiveProcs[i].spellID)) {
                                if (MakeRandomInt(0, 100) < MakeRandomInt(0, 20)) {
                                        ExecWeaponProc(DefensiveProcs[i].spellID, on);
                                }
                }
        }

        return;
}

zone/mob.cpp
Code:

void Mob::ExecWeaponProc(uint16 spell_id, Mob *on) {
        // Trumpcard: Changed proc targets to look up based on the spells goodEffect flag.
        // This should work for the majority of weapons.
        if(spell_id == SPELL_UNKNOWN)
                return;
        if ( IsBeneficialSpell(spell_id) )
                SpellFinished(spell_id, this, 10, 0);
        else if(!(on->IsClient() && on->CastToClient()->dead))        //dont proc on dead clients
                SpellFinished(spell_id, on, 10, 0);
}

From what I can see, it looks like the only thing that affects the probability of a reverse proc proccing (and maybe a woodchuck chucking?) is the random number generator. I must say though, creating 2 random numbers could create some funny odds of proccing, which may be the issue. I had to create a little program to calculate the probability, but using a sample size of 100,000,000 tries consistently gives a probability to proc of about 9.91% (specifically 9912469/100000000), at least on Windows:
Code:

#include <iostream>
using namespace std;

int MakeRandomInt(int low, int high) {
        if(low >= high)
                return(low);
        return (rand()%(high-low+1) + (low));
}

int main() {
        int l1 = 0;
        int h1 = 100;
        int l2 = 0;
        int h2 = 20;
        cout << "MakeRandomInt(" << l1 << ", " << h1 << ") < MakeRandomInt(" << l2 << ", " << h2 << ")" << endl;
        int tries = 100000000;        //100,000,000
        int count_true = 0;
        cout << "Running";
        for (int i = 0; i < tries; i++) {
                if ((i % 1000000) == 0)
                        cout << ".";
                if (MakeRandomInt(l1, h1) < MakeRandomInt(l2, h2))
                        count_true++;
        }
        cout << endl;
        int count_false = tries - count_true;
        float percent_true = ((float)count_true / (float)tries) * 100;
        float percent_false = ((float)count_false / (float)tries) * 100;
        cout << "After " << tries << " tries, " << count_true << " (" << percent_true << "%) were true & " << count_false << " (" << percent_false << "%) were false." << endl;


ChaosSlayerZ 06-28-2009 01:07 PM

yeah 9% sounds about right - with 3% default chance +300% modifier- that should get to 9%

but does it works the same way for PCs and NPCs?

cuase spell is expected to be a PC buff, but technicly even NPC can have it, and from my testing it seem like, when npc was beating on me it would proc once in in 3-4 Dozens of hits. (I have specificly choosen hasted quading npc for the test)
When I casted this buff on npc and started beating on him myself, it procced back on to me like every 8-10 hits (which is about 3-4 times as often). Considering my DEX was much higher (and DEX is abse for normal procs), this is where I turned for the posible problem.

AndMetal 06-28-2009 01:17 PM

If I remember correctly, the info above is for a PC attacking an NPC that has a Reverse Proc Buff.


All times are GMT -4. The time now is 04:39 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.