All pastes #13245 Raw Edit

Master Lexx

public c v1 · immutable
#13245 ·published 2005-06-03 04:31 UTC
rendered paste body
#include "nw_i0_spells"#include "x2_i0_spells"#include "x2_inc_spellhook"void main(){    if (!X2PreSpellCastCode())      return; //for spellhooking    int nDamType = IP_CONST_DAMAGETYPE_FIRE;    int nItemEffect = ITEM_VISUAL_FIRE;    int nVisEffect2 = VFX_IMP_PULSE_FIRE;    int nVisEffect1 = VFX_IMP_FLAME_M;    effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);    int nCasterLvl = GetCasterLevel(OBJECT_SELF);    int nDuration = 2 * nCasterLvl;    int nMetaMagic = GetMetaMagicFeat();    object oTarget = GetSpellTargetObject();    if(nCasterLvl > 10)     //cap at lv 10, was intended so from beginning on        nCasterLvl = 10;    //iprp_damagecost.2da -> 16=6 damage, 17=7 damage, ... 30=20 damage    int nDamConst = 13 + nCasterLvl; //10 for dam const, 3 for "variable" damage (1d6), lv for add damage    if (GetLastSpellCastClass() != CLASS_TYPE_CLERIC)   //if sorc/wiz -> flameweapon    {        nDamConst -= 1;   //if wiz/sorc (1d4) -> 2 (1 less than cleric (1d6))        //iprp_damagecost.2da -> 15=2d12 damage, but 5=5 damage (variable damage from value 6 to 15)        if (nCasterLvl == 3)   nDamConst = 5;  //if lv3 wiz -> 3+2=5 damage    }    if (nMetaMagic == METAMAGIC_EXTEND)     nDuration = nDuration * 2; //Duration is +100%    float fDuration = TurnsToSeconds(nDuration);    object oMyWeapon;   //replaced original for my little improved check    if (IPGetIsMeleeWeapon(oTarget))    //is weapon        oMyWeapon = oTarget;    else if (GetCreatureSize(oTarget) != CREATURE_SIZE_INVALID)     //is creature    {        object oRightWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oTarget);        if (IPGetIsMeleeWeapon(oRightWeapon))   //has melee weapon in hand            oMyWeapon = oRightWeapon;        else    //sometimes players unequip weapon just before spell is cast at, this is a fix        {            oMyWeapon = GetLastWeaponUsed(oTarget);            if (!IPGetIsMeleeWeapon(oMyWeapon))     //last weapon is no melee weapon (blinded caster?)                oMyWeapon = OBJECT_INVALID;        }    }    else     //is no creature or player        oMyWeapon = OBJECT_INVALID;    if(GetIsObjectValid(oMyWeapon) )    {        itemproperty ipLoop=GetFirstItemProperty(oMyWeapon);        while (GetIsItemPropertyValid(ipLoop))  //because same damage types don`t stack        {          if (GetItemPropertyType(ipLoop) == ITEM_PROPERTY_DAMAGE_BONUS)          {            if (GetItemPropertyDurationType(ipLoop) == DURATION_TYPE_PERMANENT)            {                int nSubType = GetItemPropertySubType(ipLoop);                if (nSubType == nDamType)   //apply different damage if weapon already has the same                {                    nDamType = IP_CONST_DAMAGETYPE_ELECTRICAL;                    nItemEffect = ITEM_VISUAL_ELECTRICAL;                    nVisEffect2 = VFX_IMP_PULSE_WIND;                    nVisEffect1 = VFX_IMP_LIGHTNING_S;                }//if subtype            }//if permanent          }//if bonus        ipLoop=GetNextItemProperty(oMyWeapon);        }//while        effect eVis1 = EffectVisualEffect(nVisEffect1);        effect eVis2 = EffectVisualEffect(nVisEffect2);        effect eVis = EffectLinkEffects(eVis1 ,eVis2);        SignalEvent(GetItemPossessor(oMyWeapon), EventSpellCastAt(OBJECT_SELF, GetSpellId(), FALSE));        if (nDuration>0)        {            ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oMyWeapon));            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, GetItemPossessor(oMyWeapon), fDuration);            itemproperty ipElemDam = ItemPropertyDamageBonus(nDamType, nDamConst);            IPSafeAddItemProperty(oMyWeapon, ipElemDam, fDuration, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING);            itemproperty ipElemVis = ItemPropertyVisualEffect(nItemEffect);            IPSafeAddItemProperty(oMyWeapon, ipElemVis, fDuration, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING,FALSE,TRUE);        }//if duration    }//if valid    else        FloatingTextStrRefOnCreature(83615, OBJECT_SELF);}