EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=590)
-   -   IsPureNukeSpell issue? (https://www.eqemulator.org/forums/showthread.php?t=32913)

bad_captain 01-18-2011 03:16 PM

IsPureNukeSpell issue?
 
I have been looking into this function while working on bots. Is this intended to allow heal spells through? The current code is below.

Code:

bool IsPureNukeSpell(int16 spell_id)
{
        int i, effect_count = 0;

        if(!IsValidSpell(spell_id))
                return false;

        for(i = 0; i < EFFECT_COUNT; i++)
        {
                if(!IsBlankSpellEffect(spell_id, i))
                        effect_count++;
        }

        return
        (
                effect_count == 1 && IsEffectInSpell(spell_id, SE_CurrentHP) &&
                spells[spell_id].buffduration == 0
        );
}

This will return true for any single effect heal, as it does not check for negative values (damage spells). To do some testing, I have added && IsDamageSpell(spellid) in the return after checking the buffduration, which has a lot of redundant code, but you can't really just do a quick && spells[spell_id].base[0] < 0, since I guess you can't be guaranteed that even though it has only 1 effect, that it is in slot 0. Instead of rewriting what's already there in IsDamageSpell, I would just use it..

Or is this working as intended?

I can use IsDamageSpell in what I'm working on for bots in conjunction with this, or it could be added here, if there isn't a reason for needing heals to be run through this. (This is called from IsPartialCapableSpell)

gaeorn 01-20-2011 12:25 PM

I vaguely recall this issue coming up before. I thought a negative value check had been added in to the test already.

In any case, I'd take a peek through where it is used to make sure it won't break anything (it shouldn't, but then I have been surprised before) and then I would add the negative value check. Or alternatively, check that the spell is detrimental.

bad_captain 01-20-2011 01:24 PM

For the bot code I am submitting, I just did a check for this as well as being a damage spell (I could have used IsDetrimental, but IsDamage seemed like less code for speed), since I wasn't sure if it would break anything. Just thought I'd point this out when I noticed it.

I know something similar was changed when the bot clerics would heal mobs and was fixed, but the same issue currently occurs for hybrids who are healing mobs. Anyway, I am submitting fixed bot code that works around this to make sure nothing outside of bots are affected.


All times are GMT -4. The time now is 12:16 AM.

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