You just need to check if the order isn't smart, attack, harvest, move. Then you need to know if jets aren't casting any ability, you need to implemente this http://www.hiveworkshop.com/forums/jass-resources-412/snippet-isunitchanneling-211254/To get jets that are doing nothing at a certain moment check if current order is "no order" or "null". (idk in GUI atm)
I find this is much simpler if you give the jets a custom movement system.
Every 0.03 sec
Set p1 = position of jet
Set p2 = p1 offset by X towards facing angle
call SetUnitX(jet, x of p2)
call SetUnitY(jet, y of p2)
Such a trigger would cause your jet(s) to "slide" forward constantly. Give them a low turn rate (try 0.05 for starters) for greater effect.
When the jet reaches the position it was ordered to move to, the trigger will cause it to slide over, and since the jet is no longer at the position where it wants to be, it will turn around and attempt to reach it again, and loop in this manner continuously.
This system will also prevent your jets from stopping when they attack. They'll attack once or twice as they approach a target, then fly over and circle around automatically to try again.
Thx,but i already figured it outInstead of "PickedUnit", you need to use a variable name.
It should look like this:
- Use GetEnumUnit() for picked unit
- Jet Units Loop
- Events
- Time - Every 0.03 seconds of game time
- Conditions
- Actions
- Unit Group - Pick every unit in JetGroup and do (Actions)
- Loop - Actions
- Set loc1 = (Position of (Picked unit))
- Set loc2 = (loc1 offset by 20.00 towards (Facing of (Picked unit)) degrees)
- Custom script: call SetUnitX(GetEnumUnit(), GetLocationX(udg_loc2))
- Custom script: call SetUnitY(GetEnumUnit(), GetLocationY(udg_loc2))
- Custom script: call RemoveLocation(udg_loc1)
- Custom script: call RemoveLocation(udg_loc2)
- Clean the memory leaks with RemoveLocation
In my testmap I've noticed a problem with this method - if the unit approaches the location from far away enough, it will indeed reach its target location and just continue going straight instead of circling around. We'll need to add some way to detect this and order it to move somewhere nearby.
A move order is different from SetUnitX/Y. So is SetUnitPos (Move Unit instantly in GUI).
Oops i forgot about that group leak,thx for pointing it outOne thing: you're leaking a unit group.
At the end of the trigger, put this custom script:
call DestroyGroup(udg_Loc)
Well in the map i'm making all the players are restricted to only 1 Predator Drone,and also all the players can ride/drive/fly vehicles(like tanks,jets,gunships etc.) but they can only have 1.Wietlol;2653999 EDIT: "Is_Idle[(Player number of (Owner of (Triggering unit))) said:Equal to True" I assume that there is only one plane per player...
In that case it is right to do this. However you should change (Triggering Unit) to (Picked Unit).
Nope... you pick every unit in the group.
Then you destroy the group when you picked the first unit.
Then you want to pick the second unit but the group is destroyed... so it won't work.
You should either do this:
or this:
- Set Loc = (Units in (Playable map area))
- Unit Group - Pick every unit in Loc and do (Actions)
- Loop - Actions
- Custom script: call DestroyGroup(udg_Loc)
But still make a group that is a collection of planes if you can do that... otherwise wait until the map becomes laggy and then ask for others to help or see that you have developed enough to handle that yourself by then.
- Custom script: set bj_wantDestroyGroup = true
- Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
- Loop - Actions
Ok thx,tho i have another problem,i tried this vJass code from another thread/topic of mine,i wanted it to be that when a certain unit uses an ability then a dummy unit(missile) will spawn and follow that targeted unit but i get alot of compile errors,heres the code.In this case, they function the same.
But in some other triggers, the DestroyGroup() method is better to use since it allows you to perform other functions using the group.
e.g. if you search a group for units to filter out, you can remove them from this group, then pick them all later.
globals
location dummyLoc = Location(0, 0)
endglobals
function GetUnitZ takes unit u returns real
call MoveLocation(dummyLoc, GetUnitX(u), GetUnitY(u))
return (GetLocationZ(dummyLoc) + GetUnitFlyHeight(u))
endfunction
function SetUnitXYZ takes unit u, real x, real y, real z returns nothing
call SetUnitX(u, x)
call SetUnitY(u, y)
call MoveLocation(dummyLoc, x, y)
call SetUnitFlyHeight(u, z - GetLocationZ(dummyLoc), 0)
endfunction
struct Missile
static hashtable ht=InitHashtable()
static constant real INTERVAL=0.03125
unit dummy
timer moveTimer
real x
real y
real z
real moveLen
real moveLenSqr
unit target
method destroy takes nothing returns nothing
call RemoveSavedInteger(ht, GetHandleId(this.moveTimer), 0)
call PauseTimer(this.moveTimer)
call DestroyTimer(this.moveTimer)
call RemoveUnit(this.dummy)
call this.deallocate()
endmethod
method move takes nothing returns nothing
local real targetX = GetUnitX(this.target)
local real targetY = GetUnitY(this.target)
local real targetZ = GetUnitZ(this.target)
local real dX = targetX - this.x
local real dY = targetY - this.y
local real dZ = targetZ - this.z
local real dSqr = dX*dX+dY*dY+dZ*dZ
local real d
if (dSqr < this.moveLenSqr) then
call this.destroy()
else
set d = SquareRoot(dSqr)
set this.x = this.x + dX / d * this.moveLen
set this.y = this.y + dY / d * this.moveLen
set this.z = this.z + dZ / d * this.moveLen
call SetUnitXYZ(this.dummy, this.x, this.y, this.z)
endif
endmethod
static method moveByTimer takes nothing returns nothing
call thistype(LoadInteger(ht, GetHandleId(GetExpiredTimer()), 0)).move()
endmethod
static method create takes integer id, real x, real y, real z, unit target, real speed returns thistype
local thistype this = thistype.allocate()
set this.dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), id, 0, 0, 0)
set this.x = x
set this.y = y
set this.z = z
set this.moveLen = speed*INTERVAL
set this.moveLenSqr = speed*speed*INTERVAL*INTERVAL
set this.target = target
set this.moveTimer = CreateTimer()
call SaveInteger(ht, GetHandleId(this.moveTimer), 0, this)
call UnitAddAbility(this.dummy, 'Amrf')
call UnitRemoveAbility(this.dummy, 'Amrf')
call UnitAddAbility(this.dummy, 'Aloc')
call SetUnitXYZ(this.dummy, x, y, z)
call TimerStart(this.moveTimer, INTERVAL, true, function thistype.moveByTimer)
return this
endmethod
endstruct
Ok i'll try thatFor vJASS you need to use the JNGP editor (jass newgen pack, find it in tools section)