View Single Post
Old 01-18-2010, 10:48 AM   #39
Sinnergy
User
 
Sinnergy's Avatar
 
Join Date: Apr 2009
Posts: 173

Sinnergy has little to show at this moment (8)

Default

ok I have this simple spell that just modifies the received damage of the targeted unit to deal more damage, but I'm just confused if I still need to this function function RunDamageModifiers takes nothing returns real
If I need to call that function, then where should I call it?
The spell code:
//! zinc
library BOY requires AutoIndex, SpellEvent, DamageModifiers, TimerUtils{
    constant integer spell = 'A01I';
    constant string sfx = "Abilities\\Spells\\NightElf\\Barkskin\\BarkSkinTarget.mdl";
    
    struct boyDamage extends DamageModifier{
        integer l;
        method onDamageTaken(unit c, real dmg)->real{
            return dmg*(0.13*l);
        }
    }
    
    struct data{
        unit u;
        effect fx;
        real ctr;
        boyDamage dm;
        method onDestroy(){
            DestroyEffect(fx);
            ctr = 0.0;
        }
    }
    
    function act(){
        unit c = SpellEvent.CastingUnit;
        unit u = SpellEvent.TargetUnit;
        timer t = NewTimer();
        data d = data.create();
        d.u = u;
        d.fx= AddSpecialEffectTarget(sfx,u,"origin");
        d.ctr = 0.0;
        d.dm= boyDamage.create(u,0);
        d.dm.l = GetUnitAbilityLevel(c,spell);
        SetTimerData(t,d);
        TimerStart(t,0.035,true,function(){
            timer t = GetExpiredTimer();
            data d = GetTimerData(t);
            if(d.ctr >= 8.0 || GetWidgetLife(d.u) <= 0.405){
                d.dm.destroy();
                ReleaseTimer(t);
                d.destroy();
            }
            d.ctr += 0.035;
            t = null;
        });
        t = null;
        u = null;
        c = null;
    }
    
    function onInit(){
        RegisterSpellEffectResponse(spell,act);
    }
}
//! endzinc
__________________
Current Project:
Rise of Sinnergy v1.00
Sinnergy is offline   Reply With Quote