Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library Overgrowth requires TimerUtils,GroupUtils,Damage,GT
- {
- constant integer ABIL_ID = 'A001';
- constant real PERIODIC = 1.00;
- constant real EFFECT_DURATION = 0.50;
- constant string TARGET_ID = "Abilities\\Spells\\NightElf\\Barkskin\\BarkSkinTarget.mdl";
- constant string EFFECT_ID = "Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl";
- constant string ATTACH_ID = "origin";
- constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL;
- constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_MAGIC;
- constant weapontype WEAPON_TYPE = null;
- function Delay(integer level) -> real
- {
- return 3.00;
- }
- function Damage(integer level) -> real
- {
- return 20.00*level+125.00;
- }
- function AreaOfEffect(integer level) -> real
- {
- return 50.00*level+300.00;
- }
- function IsUnitInvulnerable(unit whichUnit) -> boolean
- {
- return (GetUnitAbilityLevel(whichUnit,'Avul')>0);
- }
- struct Overgrowth
- {
- unit caster;
- unit target;
- effect sfx;
- integer level;
- }
- unit Caster;
- player Owner;
- integer Tick=0;
- integer Level;
- group Group;
- function destroyEffect()
- {
- timer t = GetExpiredTimer();
- Overgrowth this = Overgrowth(GetTimerData(t));
- DestroyEffect(this.sfx);
- ReleaseTimer(t);
- t=null;
- }
- function AddSpecialEffectUnitTimed(string effectID,unit whichUnit,real duration)
- {
- timer t = NewTimer();
- Overgrowth this = Overgrowth.create();
- this.sfx=AddSpecialEffectTarget(EFFECT_ID,whichUnit,ATTACH_ID);
- SetTimerData(t,this);
- TimerStart(t,duration,false,function destroyEffect);
- t=null;
- }
- function onDamage() -> boolean
- {
- unit t = GetFilterUnit();
- if (IsUnitEnemy(t,GetOwningPlayer(Caster)) && (IsUnitVisible(t,Owner)) &&! (IsUnitType(t,UNIT_TYPE_STRUCTURE)) &&! (IsUnitType(t,UNIT_TYPE_MAGIC_IMMUNE)) &&! IsUnitInvulnerable(t))
- {
- AddSpecialEffectUnitTimed(
- EFFECT_ID,
- t,
- EFFECT_DURATION);
- UnitDamageTargetEx(
- Caster,
- t,
- Damage(Level),
- true,
- false,
- ATTACK_TYPE,
- DAMAGE_TYPE,
- WEAPON_TYPE);
- }
- t=null;
- ReleaseGroup(Group);
- return false;
- }
- function onLoop()
- {
- timer t = GetExpiredTimer();
- boolexpr b = Filter(function onDamage);
- real x;
- real y;
- Overgrowth this = Overgrowth(GetTimerData(t));
- x=GetUnitX(this.target);
- y=GetUnitY(this.target);
- Tick=Tick+1;
- if(Tick>=Delay(Level))
- {
- GroupEnumUnitsInArea(
- Group,
- x,
- y,
- AreaOfEffect(Level),
- b);
- UnitShareVision(this.target,GetOwningPlayer(this.caster),false);
- DestroyEffect(this.sfx);
- DestroyBoolExpr(b);
- ReleaseTimer(t);
- b=null;
- }
- else
- {
- if (UnitAlive(this.target))
- {
- Tick=Tick+1;
- }
- else
- {
- ReleaseTimer(t);
- ReleaseGroup(Group);
- DestroyEffect(this.sfx);
- }
- }
- t=null;
- }
- function onEffect() -> boolean
- {
- timer t = NewTimer();
- Overgrowth this = Overgrowth.create();
- this.caster=GetTriggerUnit();
- Caster=this.caster;
- Owner=GetOwningPlayer(this.caster);
- Level=GetUnitAbilityLevel(this.caster,ABIL_ID);
- this.target=GetSpellTargetUnit();
- UnitShareVision(this.target,GetOwningPlayer(this.caster),true);
- this.sfx=AddSpecialEffectTarget(TARGET_ID,this.target,ATTACH_ID);
- Group=NewGroup();
- SetTimerData(t,integer(this));
- TimerStart(t,PERIODIC,true,function onLoop);
- t=null;
- return false;
- }
- function onInit()
- {
- trigger trig = CreateTrigger();
- TriggerAddCondition(GT_RegisterStartsEffectEvent(trig,ABIL_ID),Condition(function onEffect));
- trig=null;
- }
- }
- //! endzinc
Add Comment
Please, Sign In to add comment