Guest User

Untitled

a guest
Jan 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. library Overgrowth requires TimerUtils,GroupUtils,Damage,GT
  2. {
  3. constant integer ABIL_ID = 'A001';
  4. constant real PERIODIC = 1.00;
  5. constant real EFFECT_DURATION = 0.50;
  6. constant string TARGET_ID = "Abilities\\Spells\\NightElf\\Barkskin\\BarkSkinTarget.mdl";
  7. constant string EFFECT_ID = "Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl";
  8. constant string ATTACH_ID = "origin";
  9. constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL;
  10. constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_MAGIC;
  11. constant weapontype WEAPON_TYPE = null;
  12.  
  13. function Delay(integer level) -> real
  14. {
  15. return 3.00;
  16. }
  17.  
  18. function Damage(integer level) -> real
  19. {
  20. return 20.00*level+125.00;
  21. }
  22.  
  23. function AreaOfEffect(integer level) -> real
  24. {
  25. return 50.00*level+300.00;
  26. }
  27.  
  28. function IsUnitInvulnerable(unit whichUnit) -> boolean
  29. {
  30. return (GetUnitAbilityLevel(whichUnit,'Avul')>0);
  31. }
  32.  
  33. struct Overgrowth
  34. {
  35. unit caster;
  36. unit target;
  37. effect sfx;
  38. integer level;
  39. }
  40.  
  41. unit Caster;
  42. player Owner;
  43. integer Tick=0;
  44. integer Level;
  45. group Group;
  46.  
  47. function destroyEffect()
  48. {
  49. timer t = GetExpiredTimer();
  50. Overgrowth this = Overgrowth(GetTimerData(t));
  51. DestroyEffect(this.sfx);
  52. ReleaseTimer(t);
  53. t=null;
  54. }
  55.  
  56. function AddSpecialEffectUnitTimed(string effectID,unit whichUnit,real duration)
  57. {
  58. timer t = NewTimer();
  59. Overgrowth this = Overgrowth.create();
  60. this.sfx=AddSpecialEffectTarget(EFFECT_ID,whichUnit,ATTACH_ID);
  61. SetTimerData(t,this);
  62. TimerStart(t,duration,false,function destroyEffect);
  63. t=null;
  64. }
  65.  
  66.  
  67. function onDamage() -> boolean
  68. {
  69. unit t = GetFilterUnit();
  70. if (IsUnitEnemy(t,GetOwningPlayer(Caster)) && (IsUnitVisible(t,Owner)) &&! (IsUnitType(t,UNIT_TYPE_STRUCTURE)) &&! (IsUnitType(t,UNIT_TYPE_MAGIC_IMMUNE)) &&! IsUnitInvulnerable(t))
  71. {
  72. AddSpecialEffectUnitTimed(
  73. EFFECT_ID,
  74. t,
  75. EFFECT_DURATION);
  76. UnitDamageTargetEx(
  77. Caster,
  78. t,
  79. Damage(Level),
  80. true,
  81. false,
  82. ATTACK_TYPE,
  83. DAMAGE_TYPE,
  84. WEAPON_TYPE);
  85. }
  86. t=null;
  87. ReleaseGroup(Group);
  88. return false;
  89. }
  90.  
  91. function onLoop()
  92. {
  93. timer t = GetExpiredTimer();
  94. boolexpr b = Filter(function onDamage);
  95. real x;
  96. real y;
  97. Overgrowth this = Overgrowth(GetTimerData(t));
  98. x=GetUnitX(this.target);
  99. y=GetUnitY(this.target);
  100. Tick=Tick+1;
  101. if(Tick>=Delay(Level))
  102. {
  103. GroupEnumUnitsInArea(
  104. Group,
  105. x,
  106. y,
  107. AreaOfEffect(Level),
  108. b);
  109. UnitShareVision(this.target,GetOwningPlayer(this.caster),false);
  110. DestroyEffect(this.sfx);
  111. DestroyBoolExpr(b);
  112. ReleaseTimer(t);
  113. b=null;
  114. }
  115. else
  116. {
  117. if (UnitAlive(this.target))
  118. {
  119. Tick=Tick+1;
  120. }
  121. else
  122. {
  123. ReleaseTimer(t);
  124. ReleaseGroup(Group);
  125. DestroyEffect(this.sfx);
  126. }
  127. }
  128. t=null;
  129. }
  130.  
  131. function onEffect() -> boolean
  132. {
  133. timer t = NewTimer();
  134. Overgrowth this = Overgrowth.create();
  135. this.caster=GetTriggerUnit();
  136. Caster=this.caster;
  137. Owner=GetOwningPlayer(this.caster);
  138. Level=GetUnitAbilityLevel(this.caster,ABIL_ID);
  139. this.target=GetSpellTargetUnit();
  140. UnitShareVision(this.target,GetOwningPlayer(this.caster),true);
  141. this.sfx=AddSpecialEffectTarget(TARGET_ID,this.target,ATTACH_ID);
  142. Group=NewGroup();
  143. SetTimerData(t,integer(this));
  144. TimerStart(t,PERIODIC,true,function onLoop);
  145. t=null;
  146. return false;
  147. }
  148.  
  149. function onInit()
  150. {
  151. trigger trig = CreateTrigger();
  152. TriggerAddCondition(GT_RegisterStartsEffectEvent(trig,ABIL_ID),Condition(function onEffect));
  153. trig=null;
  154. }
  155. }
  156. //! endzinc
Add Comment
Please, Sign In to add comment