Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //! zinc
- library NetherWarp requires PathingLib,GroupUtils,TimerUtils,Snipplets{
- private constant integer ABIL_ID = 'A0DN';
- private constant integer DBIL_ID = 'A05H';
- private constant integer NODE_ID = 'h02C';
- private constant integer DUMM_ID = 'h047';
- private constant integer MRADIUS = 3600; //Minimum Radius
- private constant string ISSUE_ID = "banish";
- struct data{
- unit whichUnit;
- player whichPlayer;
- real whichX,whichY;
- method destroy(){
- whichUnit=null;
- whichPlayer=null;
- deallocate();
- }
- }
- private function onCondition()->boolean{
- unit f=GetFilterUnit();
- boolean b=false;
- if (GetUnitTypeId(f)==NODE_ID){b=true;}
- f=null;
- return b;
- }
- private function onTimer(){
- timer t=GetExpiredTimer();
- data this=GetTimerData(t);
- if (GetWidgetLife(this.whichUnit)>0.405){
- SetUnitPosition(this.whichUnit,this.whichX,this.whichY);
- if (GetLocalPlayer()==this.whichPlayer){PanCameraToTimed(this.whichX,this.whichY,0.00);}
- }
- ReleaseTimer(t);
- t=null;
- this.destroy();
- }
- private function onAction()->boolean{
- data this=data.create();
- unit u=GetTriggerUnit(),d;
- player p=GetOwningPlayer(u);
- group g=NewGroup();
- timer t=NewTimer();
- real x=GetUnitX(u),y=GetUnitY(u);
- location l;
- integer i=GetRandomInt(1,4);
- boolexpr b=Condition(function onCondition);
- boolean f=false;
- GroupEnumUnitsOfPlayer(g,p,b);
- d=CreateUnit(p,DUMM_ID,x,y,0.00);
- UnitAddAbility(d,DBIL_ID);
- IssueTargetOrder(d,ISSUE_ID,u);
- UnitApplyTimedLife(d,'BTLF',1.0);
- d=FirstOfGroup(g);
- if (d!=null){x=GetUnitX(d),y=GetUnitY(d);}
- else{
- l=GetRandomLocInRect(bj_mapInitialPlayableArea);
- d=CreateUnitAtLoc(p,DUMM_ID,l,0.00);
- x=GetUnitX(d),y=GetUnitY(d);
- while(f==false){
- if (IsTerrainWalkable(x,y)&&DistanceBetweenUnitAndPoint(u,x,y)>MRADIUS){f=true;}
- else{
- l=GetRandomLocInRect(bj_mapInitialPlayableArea);
- SetUnitPositionLoc(d,l);
- x=GetUnitX(d),y=GetUnitY(d);
- }
- }
- }
- UnitApplyTimedLife(d,'BTLF',1.00);
- TimerStart(t,1.00,false,function onTimer);
- this.whichUnit=u;
- this.whichPlayer=p;
- this.whichX=x,this.whichY=y;
- SetTimerData(t,this);
- RemoveLocation(l);
- ReleaseGroup(g);
- DestroyBoolExpr(b);
- u=null;
- d=null;
- p=null;
- b=null;
- g=null;
- l=null;
- t=null;
- return false;
- }
- function onInit(){
- trigger t=CreateTrigger();
- TriggerAddCondition(GT_RegisterStartsEffectEvent(t,ABIL_ID),Filter(function onAction));
- t=null;
- }
- }
- //! endzinc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement