Aller au contenu

Photo

Spellscript Impact Event


  • Veuillez vous connecter pour répondre
Aucune réponse à ce sujet

#1
Anomaly-

Anomaly-
  • Members
  • 366 messages
I've taken the code from the original Spell Shaping mod and have been expanding on it. My own mod allows for the majority of spells (helpful or hostile) to effect any target (friendly or hostile), so expanding on this was a natural fit. The problem is, the way the mod is currently set up, it overrides EVENT_TYPE_APPLY_EFFECT to stop it from applying when you have the required skill, the effect is hostile, and your target is friendly. However, this only prevents the effect from actually applying to the target, but the effect is still there and when it is removed the target receives additional stats they shouldn't.

Heres an example: You cast weakness on an ally, and he/she loses 10 attack/defense. Now if the caster has this skill, when you cast weakness on that ally the effect is there, but they lose nothing. Then when the effect is removed, they GAIN 10 attack/defense. I suspect I could probably apply the same changes for EVENT_TYPE_REMOVE_EFFECT, but I have additional spells that rely on the number of hostile effects nearby, so they would gain bonuses from allies that have hostile effects when they shouldn't.

The only solution I've found to this problem, was to actually go into spell_singletarget and modify EVENT_TYPE_SPELLSCRIPT_IMPACT. These were my original changes:

if (HasAbility(stEvent.oCaster, 43434))
            {
                if (HasAbility(stEvent.oCaster, 43436))
                {
                    if (!IsObjectHostile(stEvent.oCaster, stEvent.oTarget))
                    {
                        return;
                    }
                    else
                    {
                        // Handle impact
                        if (CheckSpellResistance(stEvent.oTarget, stEvent.oCaster, stEvent.nAbility) == FALSE)
                        {
                             _HandleImpact(stEvent);
                        } else
                        {
                            UI_DisplayMessage(stEvent.oTarget, UI_MESSAGE_RESISTED);
                        }
                    }
                }
                else
                {
                    if (IsPartyMember(stEvent.oTarget))
                    {
                        return;
                    }
                    else
                    {
                        // Handle impact
                        if (CheckSpellResistance(stEvent.oTarget, stEvent.oCaster, stEvent.nAbility) == FALSE)
                        {
                             _HandleImpact(stEvent);
                        } else
                        {
                            UI_DisplayMessage(stEvent.oTarget, UI_MESSAGE_RESISTED);
                        }
                    }
                }
            }
            else
            {
                // Handle impact
                if (CheckSpellResistance(stEvent.oTarget, stEvent.oCaster, stEvent.nAbility) == FALSE)
                {
                    _HandleImpact(stEvent);
                } else
                {
                    UI_DisplayMessage(stEvent.oTarget, UI_MESSAGE_RESISTED);
                }
            }

This works because it stops the spell from applying altogether. However, it stops ALL spells from applying to friendly targets, including beneficial spells. So, I tried this modification:

           effect eEffect = GetCurrentEffect();
            int nEffectType = GetEffectType(eEffect);


            if (HasAbility(stEvent.oCaster, 43434) && IsEffectTypeHostile(nEffectType) || nEffectType == EFFECT_TYPE_DAMAGE)
            {
                if (HasAbility(stEvent.oCaster, 43436))
                {
                    if (!IsObjectHostile(stEvent.oCaster, stEvent.oTarget))
                    {
                        return;
                    }
                    else
                    {
                        // Handle impact
                        if (CheckSpellResistance(stEvent.oTarget, stEvent.oCaster, stEvent.nAbility) == FALSE)
                        {
                             _HandleImpact(stEvent);
                        } else
                        {
                            UI_DisplayMessage(stEvent.oTarget, UI_MESSAGE_RESISTED);
                        }
                    }
                }
                else
                {
                    if (IsPartyMember(stEvent.oTarget))
                    {
                        return;
                    }
                    else
                    {
                        // Handle impact
                        if (CheckSpellResistance(stEvent.oTarget, stEvent.oCaster, stEvent.nAbility) == FALSE)
                        {
                             _HandleImpact(stEvent);
                        } else
                        {
                            UI_DisplayMessage(stEvent.oTarget, UI_MESSAGE_RESISTED);
                        }
                    }
                }
            }
            else
            {
                // Handle impact
                if (CheckSpellResistance(stEvent.oTarget, stEvent.oCaster, stEvent.nAbility) == FALSE)
                {
                    _HandleImpact(stEvent);
                } else
                {
                    UI_DisplayMessage(stEvent.oTarget, UI_MESSAGE_RESISTED);
                }
            }

Now I'm back to the exact same problem, the spell applies but doesn't do anything, then when it is removed it INCREASES stats. I need a way to either stop the spell from applying altogether AND be able to distinguish between friendly and hostile spells, OR have some other way of finding whether or not the spell is hostile without the use of GetCurrentEffect (which requires that the effect be applied).

Any thoughts? Help would be GREATLY appreciated.