I used the second loop, but removed the section that removes the spell effects and replaced it with regular EffectDispelMagic since I only needed the loop to determine how many effects were on the target, and used nSize.
From what you're saying though, the only way to accurately determine the number of effects would be for me to completely replicate both dispel magic loops inside my spell script, and use the counter to determine the number of effects?
This is what my current script for Drain Mana looks like:
// -----------------------------------------------------------------------------
// talent_single_target.nss
// -----------------------------------------------------------------------------
/*
Generic Ability Script for single target abilities
*/
// -----------------------------------------------------------------------------
// georg / petert
// -----------------------------------------------------------------------------
#include "log_h"
#include "abi_templates"
#include "sys_traps_h"
#include "spell_constants_h_arcarts"
#include "plt_cod_aow_spellcombo6"
const int DRAIN_MANA_PROJECTILE = 136;
void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
switch(nEventType)
{
case EVENT_TYPE_SPELLSCRIPT_PENDING:
{
Ability_SetSpellscriptPendingEventResult(COMMAND_RESULT_SUCCESS);
break;
}
case EVENT_TYPE_SPELLSCRIPT_CAST:
{
// Get a structure with the event parameters
struct EventSpellScriptCastStruct stEvent = Events_GetEventSpellScriptCastParameters(ev);
// Hand this through to cast_impact
SetAbilityResult(stEvent.oCaster, stEvent.nResistanceCheckResult);
break;
}
case EVENT_TYPE_SPELLSCRIPT_IMPACT:
{
// Get a structure with the event parameters
struct EventSpellScriptImpactStruct stEvent = Events_GetEventSpellScriptImpactParameters(ev);
Log_Trace(LOG_CHANNEL_COMBAT_ABILITY, GetCurrentScriptName() + ".EVENT_TYPE_SPELLSCRIPT_IMPACT",Log_GetAbilityNameById(stEvent.nAbility));
effect[] arSpell = GetEffects(stEvent.oTarget);
int nSize = GetArraySize (arSpell);
int i;
int nId;
for (i = 0; i < nSize; i++)
{
nId = GetEffectAbilityID(arSpell[i]);
} // if target is spellcaster or has spell effects
if (IsMagicUser(stEvent.oTarget) == TRUE
|| (Ability_GetAbilityType(nId) == ABILITY_TYPE_SPELL && HasAbility(stEvent.oCaster, ABILITY_SPELL_MANA_CLEANSE) == TRUE)) {
if (CheckSpellResistance(stEvent.oTarget, stEvent.oCaster, stEvent.nAbility) == FALSE)
{
// Mana Cleanse spell removal
if (Ability_GetAbilityType(nId) == ABILITY_TYPE_SPELL)
{
effect eEffect = EffectDispelMagic();
ApplyEffectOnObject(EFFECT_DURATION_TYPE_INSTANT, eEffect, stEvent.oTarget, 0.0f, stEvent.oCaster, stEvent.nAbility);
} float fManaMax = (100.0f + GetCreatureSpellPower(stEvent.oCaster)) * MANA_DRAIN_FACTOR;
float fManaSpell = ((100.0f + GetCreatureSpellPower(stEvent.oCaster)) * MANA_CLEANSE_FACTOR) * nSize; float fTargetMana = IntToFloat(GetCreatureMana(stEvent.oTarget));
if (fTargetMana > 0.0f)
{
float fMana;
// spell combo - vulnerability hex
if (GetHasEffects(stEvent.oTarget, EFFECT_TYPE_INVALID, ABILITY_SPELL_MASS_SLOW) == TRUE)
{
fManaMax = (100.0f + GetCreatureSpellPower(stEvent.oCaster)) * IMPROVED_DRAIN_MANA_FACTOR;
effect eEffect = EffectVisualEffect(IMPROVED_DRAIN_MANA_VFX);
ApplyEffectOnObject(EFFECT_DURATION_TYPE_INSTANT, eEffect, stEvent.oTarget, 0.0f, stEvent.oCaster, stEvent.nAbility);
// combo effect codex - improved drain
if (IsFollower(stEvent.oCaster) == TRUE)
{
WR_SetPlotFlag(PLT_COD_AOW_SPELLCOMBO6, COD_AOW_SPELLCOMBO_6_STEAM_CLOUD, TRUE);
}
}
fMana = MinF(fManaMax, fTargetMana);
if (IsMagicUser(stEvent.oTarget) == TRUE)
{
// mana loss
effect eEffect = EffectModifyManaStamina(fMana * -1.0f);
eEffect = SetEffectEngineInteger(eEffect, EFFECT_INTEGER_VFX, Ability_GetImpactObjectVfxId(stEvent.nAbility));
ApplyEffectOnObject(EFFECT_DURATION_TYPE_INSTANT, eEffect, stEvent.oTarget, 0.0f, stEvent.oCaster, stEvent.nAbility);
}
fMana = MinF(fManaMax, fTargetMana) + fManaSpell; //Mana Clash effects
if (HasAbility(stEvent.oCaster, ABILITY_SPELL_MANA_CLASH) == TRUE)
{
effect eEffect = EffectDamage(fMana, DAMAGE_TYPE_SPIRIT, DAMAGE_EFFECT_FLAG_NONE, Ability_GetImpactObjectVfxId(stEvent.nAbility));
ApplyEffectOnObject(EFFECT_DURATION_TYPE_INSTANT, eEffect, stEvent.oTarget, 0.0f, stEvent.oCaster, stEvent.nAbility);
}
// create event
event ev = Event(90210);
ev = SetEventInteger(ev, 0, stEvent.nAbility);
ev = SetEventObject(ev, 0, stEvent.oCaster);
ev = SetEventObject(ev, 1, stEvent.oCaster);
ev = SetEventFloat(ev, 0, fMana);
// fire projectile
vector v = GetPosition(stEvent.oTarget);
v.z += 1.5f;
object oProjectile = FireHomingProjectile(DRAIN_MANA_PROJECTILE, v, stEvent.oCaster, 0, stEvent.oCaster);
SetProjectileImpactEvent(oProjectile, ev);
}
} else
{
UI_DisplayMessage(stEvent.oTarget, UI_MESSAGE_RESISTED);
}
} else
{
UI_DisplayMessage(stEvent.oTarget, UI_MESSAGE_OUT_OF_MANA);
}
break;
}
case 90210:
{
// Get a structure with the event parameters
struct EventSpellScriptImpactStruct stEvent = Events_GetEventSpellScriptImpactParameters(ev);
// mana gain
float fMana = GetEventFloat(ev, 0);
effect eEffect = EffectModifyManaStamina(fMana);
eEffect = SetEffectEngineInteger(eEffect, EFFECT_INTEGER_VFX, MANA_DRAIN_CASTER_VFX);
ApplyEffectOnObject(EFFECT_DURATION_TYPE_INSTANT, eEffect, stEvent.oCaster, 0.0f, stEvent.oCaster, stEvent.nAbility);
break;
}
}
}
So I have to add in the first loop as well, change DispelMagic back to RemoveEffect, add a counter after that, and replace the nSize multiplication with nCounter?
I'm a little confused on how the "loop" actually occurs, rather than the code just running once after I activate the spell and making the counter always return either 0 or 1.
If the loop does function in that code above then I assume using DispelMagic would likely stop it from passing through a second time
Modifié par Kesaru, 01 avril 2010 - 04:01 .