Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. //! zinc
  2. library Entanglement {
  3. //Entanglement (Arborius) code:
  4. private constant integer Unique = 'TAAR';
  5. private constant integer ArboriusCode = 'TITA';
  6. //Static stats:
  7. private constant integer Enemy_Info = 'A0KQ';
  8. private constant integer DamageReduction = 'TAAV';
  9. private constant integer AttackSpeedBurst = 'TAAT';
  10. private constant integer BurstAttacks = 2;
  11. private constant real BurstDuration = 3;
  12. private constant real BurstRange = 200;
  13. private constant real EntanglementChance = 0.15;
  14. private constant real EntanglementDuration = 6;
  15. //Hashtable
  16. hashtable Hash = InitHashtable();
  17. //---------------------------------------------
  18.  
  19. private function EntangleExpiration() {
  20. timer Timer = GetExpiredTimer();
  21. unit Attacker = LoadUnitHandle(Hash, 0, GetHandleId(Timer));
  22. UnitRemoveAbility(Attacker, DamageReduction);
  23. UnitRemoveAbility(Attacker, Enemy_Info);
  24. FlushChildHashtable(Hash, GetHandleId(Timer));
  25. Attacker = null;
  26. Timer = null;
  27. }
  28.  
  29. private function BurstExpiration() {
  30. timer BurstTimer = GetExpiredTimer();
  31. unit Arborius = LoadUnitHandle(Hash, 0, GetHandleId(BurstTimer));
  32. SetUnitAbilityLevel(Arborius, AttackSpeedBurst, 1);
  33. UnitRemoveAbility(Arborius, AttackSpeedBurst);
  34. FlushChildHashtable(Hash, GetHandleId(BurstTimer));
  35. FlushChildHashtable(Hash, GetHandleId(Arborius));
  36. BJDebugMsg("Removing burst, timer out");
  37. Arborius = null;
  38. BurstTimer = null;
  39. }
  40.  
  41. private function onInit() {
  42. trigger t = CreateTrigger();
  43. TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DAMAGED);
  44. TriggerAddCondition(t, function() -> boolean {
  45. unit Attacker = GetEventDamageSource();
  46. unit Arborius = GetTriggerUnit();
  47. real Roll;
  48. timer Timer = CreateTimer();
  49. timer BurstTimer = CreateTimer();
  50. if(GetUnitTypeId(Arborius) == ArboriusCode && GetUnitAbilityLevel(Arborius, Unique) > 0 && IsUnitEnemy(Attacker, GetOwningPlayer(Arborius)) && IsUnitType(Attacker, UNIT_TYPE_STRUCTURE) == true) {
  51. Roll = GetRandomReal(0, 1);
  52. if(Roll <= EntanglementChance) {
  53. BJDebugMsg("Entanglement Activated");
  54. //Let's check that the unit is not already Entangled:
  55. if(GetUnitAbilityLevel(Attacker, DamageReduction) == 0) {
  56. BJDebugMsg("New entangle!");
  57. UnitAddAbility(Attacker, DamageReduction);
  58. SetUnitAbilityLevel(Attacker, DamageReduction, GetUnitAbilityLevel(Arborius, Unique));
  59. UnitAddAbility(Attacker, Enemy_Info);
  60. UnitAddAbility(Arborius, AttackSpeedBurst);
  61. if(GetUnitAbilityLevel(Arborius, AttackSpeedBurst) < 7) {
  62. SetUnitAbilityLevel(Arborius, AttackSpeedBurst, GetUnitAbilityLevel(Arborius, AttackSpeedBurst) + BurstAttacks);
  63. }
  64. SaveUnitHandle(Hash, 0, GetHandleId(Timer), Attacker);
  65. SaveUnitHandle(Hash, 0, GetHandleId(BurstTimer), Arborius);
  66. SaveTimerHandle(Hash, 0, GetHandleId(Arborius), BurstTimer);
  67. TimerStart(Timer, EntanglementDuration, false, function EntangleExpiration);
  68. TimerStart(BurstTimer, BurstDuration, false, function BurstExpiration);
  69. } else {
  70. BJDebugMsg("Already entangled, renew!");
  71. TimerStart(Timer, EntanglementDuration, false, function EntangleExpiration);
  72. }
  73. }
  74. }
  75. if(GetUnitAbilityLevel(Attacker, AttackSpeedBurst) > 0 && GetUnitTypeId(Attacker) == ArboriusCode && IsUnitEnemy(Attacker, GetOwningPlayer(Arborius)) && BlzGetEventDamageType() == DAMAGE_TYPE_NORMAL){
  76. BJDebugMsg("Burst attack!");
  77. DecUnitAbilityLevel(Attacker, AttackSpeedBurst);
  78. if(GetUnitAbilityLevel(Attacker, AttackSpeedBurst) == 1) {
  79. UnitRemoveAbility(Attacker, AttackSpeedBurst);
  80. BurstTimer = LoadTimerHandle(Hash, GetHandleId(Attacker), 0);
  81. FlushChildHashtable(Hash, GetHandleId(BurstTimer));
  82. FlushChildHashtable(Hash, GetHandleId(Attacker));
  83. DestroyTimer(BurstTimer);
  84. BJDebugMsg("Removing burst, all spent");
  85. }
  86. }
  87. Attacker = null;
  88. Arborius = null;
  89. Timer = null;
  90. BurstTimer = null;
  91. return false;
  92. });
  93. t = null;
  94. }
  95.  
  96. }
  97. //! endzinc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement