Advertisement
Guest User

Untitled

a guest
May 27th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. //! zinc
  2. library BarrelofRum requires Damage{
  3.  
  4. private{
  5. constant integer UNIT_ID = 'u011';
  6. constant real DAMAGE = 18.75; //150.0
  7. constant real TICK = 0.25; //Damage dealt every .25 seconds.
  8. constant real DURATION = 2.01;
  9. }
  10.  
  11. struct data{
  12. unit caster;
  13. unit target;
  14. real tick;
  15. IgniteDoused myBuff;
  16.  
  17. method onDestroy(){
  18. caster=null;
  19. target=null;
  20. }
  21. }
  22.  
  23. function onTimer(){
  24. timer t=GetExpiredTimer();
  25. data this=GetTimerData(t);
  26. UnitDamageTargetEx(this.caster,this.target,DAMAGE,false,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_FIRE,WEAPON_TYPE_WHOKNOWS);
  27. this.tick+=TICK;
  28. if (this.tick>=DURATION){
  29. ReleaseTimer(t);
  30. this.myBuff.setUnit(null);
  31. this.destroy();
  32. }
  33. t=null;
  34. }
  35.  
  36. function onAction()->boolean{
  37. data this=data.create();
  38. timer t=NewTimer();
  39. this.caster=GetEventDamageSource();
  40. this.target=GetTriggerUnit();
  41. this.tick=0.0;
  42. if (Damage_GetType()==DAMAGE_TYPE_FIRE&&!IgniteDoused.isOn(this.target)&&Doused.isOn(this.target)){
  43. this.myBuff=this.myBuff.create(this.caster);
  44. this.myBuff.destroyTimed(DURATION);
  45. TimerStart(t,TICK,true,function onTimer);
  46. SetTimerData(t,this);
  47. }else{
  48. ReleaseTimer(t);
  49. this.destroy();
  50. }
  51. t=null;
  52. return false;
  53. }
  54.  
  55. function onInit(){
  56. trigger t=CreateTrigger();
  57. Damage_RegisterEvent(t);
  58. TriggerAddCondition(t,Condition(function onAction));
  59. t=null;
  60. }
  61. }
  62. //! endzinc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement