Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. //! zinc
  2. library NetherWarp requires PathingLib,GroupUtils,TimerUtils,Snipplets{
  3.  
  4. private constant integer ABIL_ID = 'A0DN';
  5. private constant integer DBIL_ID = 'A05H';
  6. private constant integer NODE_ID = 'h02C';
  7. private constant integer DUMM_ID = 'h047';
  8. private constant integer MRADIUS = 3600; //Minimum Radius
  9. private constant string ISSUE_ID = "banish";
  10.  
  11. struct data{
  12. unit whichUnit;
  13. player whichPlayer;
  14. real whichX,whichY;
  15.  
  16. method destroy(){
  17. whichUnit=null;
  18. whichPlayer=null;
  19. deallocate();
  20. }
  21. }
  22.  
  23. private function onCondition()->boolean{
  24. unit f=GetFilterUnit();
  25. boolean b=false;
  26. if (GetUnitTypeId(f)==NODE_ID){b=true;}
  27. f=null;
  28. return b;
  29. }
  30.  
  31. private function onTimer(){
  32. timer t=GetExpiredTimer();
  33. data this=GetTimerData(t);
  34. if (GetWidgetLife(this.whichUnit)>0.405){
  35. SetUnitPosition(this.whichUnit,this.whichX,this.whichY);
  36. if (GetLocalPlayer()==this.whichPlayer){PanCameraToTimed(this.whichX,this.whichY,0.00);}
  37. }
  38. ReleaseTimer(t);
  39. t=null;
  40. this.destroy();
  41. }
  42.  
  43. private function onAction()->boolean{
  44. data this=data.create();
  45. unit u=GetTriggerUnit(),d;
  46. player p=GetOwningPlayer(u);
  47. group g=NewGroup();
  48. timer t=NewTimer();
  49. real x=GetUnitX(u),y=GetUnitY(u);
  50. location l;
  51. integer i=GetRandomInt(1,4);
  52. boolexpr b=Condition(function onCondition);
  53. boolean f=false;
  54. GroupEnumUnitsOfPlayer(g,p,b);
  55. d=CreateUnit(p,DUMM_ID,x,y,0.00);
  56. UnitAddAbility(d,DBIL_ID);
  57. IssueTargetOrder(d,ISSUE_ID,u);
  58. UnitApplyTimedLife(d,'BTLF',1.0);
  59. d=FirstOfGroup(g);
  60. if (d!=null){x=GetUnitX(d),y=GetUnitY(d);}
  61. else{
  62. l=GetRandomLocInRect(bj_mapInitialPlayableArea);
  63. d=CreateUnitAtLoc(p,DUMM_ID,l,0.00);
  64. x=GetUnitX(d),y=GetUnitY(d);
  65. while(f==false){
  66. if (IsTerrainWalkable(x,y)&&DistanceBetweenUnitAndPoint(u,x,y)>MRADIUS){f=true;}
  67. else{
  68. l=GetRandomLocInRect(bj_mapInitialPlayableArea);
  69. SetUnitPositionLoc(d,l);
  70. x=GetUnitX(d),y=GetUnitY(d);
  71. }
  72. }
  73. }
  74. UnitApplyTimedLife(d,'BTLF',1.00);
  75. TimerStart(t,1.00,false,function onTimer);
  76. this.whichUnit=u;
  77. this.whichPlayer=p;
  78. this.whichX=x,this.whichY=y;
  79. SetTimerData(t,this);
  80. RemoveLocation(l);
  81. ReleaseGroup(g);
  82. DestroyBoolExpr(b);
  83. u=null;
  84. d=null;
  85. p=null;
  86. b=null;
  87. g=null;
  88. l=null;
  89. t=null;
  90. return false;
  91. }
  92.  
  93. function onInit(){
  94. trigger t=CreateTrigger();
  95. TriggerAddCondition(GT_RegisterStartsEffectEvent(t,ABIL_ID),Filter(function onAction));
  96. t=null;
  97. }
  98. }
  99. //! endzinc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement