Lazarus Magni wrote...
Can you elaborate on that concept FB? I am not sure if I am understanding what you are saying. Keep in mind I am not a scripter...
Something like this:
// In a seperate routine so the creation of the affects can be applied by the
// creator of choice.
void ApplyDDEffects (object oPC);
// Checks to see if oTarget has an effect created by oCreator
int GetHasEffectByCreator (object oTarget, object oCreator);
void main()
{
// Include bypassing event activation check.
if (GetLocalInt(OBJECT_SELF,"X2_L_LAST_ITEM_EVENT") != 0) return;
// if(!GetUserDefinedItemEventNumber() == X2_ITEM_EVENT_ACTIVATE) return;
object oPC = GetItemActivator();
object oItem = GetItemActivated();
if (!GetHasFeat(FEAT_DWARVEN_DEFENDER_DEFENSIVE_STANCE, oPC))
{
FloatingTextStringOnCreature ("You have no uses of this feat left.", oPC, FALSE);
return;
}
if (GetHasEffectByCreator (oPC, oItem))
{
FloatingTextStringOnCreature("Feat still in cool down.", oPC, FALSE);
return;
}
// By moving the effect declarations to an assigned subscript, you can control
// what object creates the effect in order to compare against it later.
AssignCommand (oItem, ApplyDDEffects (oPC));
}
void ApplyDDEffects (object oPC)
{
PlayVoiceChat(VOICE_CHAT_BATTLECRY1, oPC);
int nclassLevel = GetLevelByclass(class_TYPE_DWARVENDEFENDER, oPC);
int nPercent = nclassLevel/10 *5;
int nHP = (nclassLevel + GetAbilityModifier(ABILITY_CONSTITUTION, oPC)) *10;
effect eHP = EffectTemporaryHitpoints(nHP);
effect eVis = EffectVisualEffect(VFX_DUR_AURA_PULSE_RED_YELLOW);
effect eLink = EffectDamageImmunityIncrease(DAMAGE_TYPE_ACID, nPercent);
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_BLUDGEONING, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_COLD, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_DIVINE, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_ELECTRICAL, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_FIRE, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_MAGICAL, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_NEGATIVE, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_PIERCING, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_POSITIVE, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_SLASHING, nPercent));
eLink = EffectLinkEffects(eLink, EffectDamageImmunityIncrease(DAMAGE_TYPE_SONIC, nPercent));
eLink = EffectLinkEffects(eLink, eVis);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oPC, 60.0);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eHP, oPC, 60.0);
DecrementRemainingFeatUses(oPC, FEAT_DWARVEN_DEFENDER_DEFENSIVE_STANCE);
}
int GetHasEffectByCreator (object oTarget, object oCreator)
{
effect eEffect = GetFirstEffect (oTarget);
while (GetIsEffectValid (eEffect))
{
if (GetEffectCreator (eEffect) == oCreator) return TRUE;
eEffect = GetNextEffect (oTarget);
}
return FALSE;
}
Whatever object is running the script at the time the effect is created gets stored with the effect. Since it's the module originally running the script, it's better to assign the creation of the effect to an object that won't be making any other effects to check against.
Edited to add the formatting back in. The "class" alterations you'll have to fix yourself after copying. It's just something these boards do.
Modifié par Failed.Bard, 22 septembre 2011 - 10:46 .