Well, hello there,
this question might be asked a thousand times already, but either im too stupid to search correctly or im using the wrong keywords...nvm, here´s my problem:
After a unit gets trained, he shall automove from point A-B with a few checkpoints (I have three lines in total, up, middle and down)
When I first Order the unit to "attack" move to the next Point, all units are moving as they should.
Ignore GetRandomX and Y, it just gives a random real out of RectMaxX/Y and MinX/Y to get a random point inside the given rect~
Now, when they step into one of the 2 Checkpoints of any line (Each line has 2 Checkpoints), they should recieve the order to "attack" move to the next checkpoint. Quite simple, but something is broken here:
Some units wont move. If I manually select them and give them a move order, they start moving towards the given Checkpoint once again, but only then.
I am using the following stuff to make the continuos movement:
(Variables are globals) First, Creating a few regions...
After that, Add the Rect (Saved in a global too)...
And finally adding the Event with the previously created Regons...
Is this way too slow for wc3 to handle more than like 30-40 units at once? Im saving every unit in a local variable (wich gets nulled afterwards ofcourse) so it should not overlap at all (That´s what im thinking at least)
I thought about doing something with unit groups and make the order apply to the specific unit group (Depends on how far the unit has actually moved, unit_group0 for moving to checkpoint 1, unit_group1 for moving to checkpoint 2 etc..), maybe that would work?
Has anyone of you had this kind of problem before too? A good solution is appreciatet aswell, im willing to just delete the trigger and redo it completly~
Cheers
PS: If youre interested, here is the complete trigger (It´s just made to work, not to be fancy~):
this question might be asked a thousand times already, but either im too stupid to search correctly or im using the wrong keywords...nvm, here´s my problem:
After a unit gets trained, he shall automove from point A-B with a few checkpoints (I have three lines in total, up, middle and down)
When I first Order the unit to "attack" move to the next Point, all units are moving as they should.
JASS:
call IssuePointOrder(wichUnit, "attack", GetRandomX(RECT[6]), GetRandomY(RECT[6]))
Ignore GetRandomX and Y, it just gives a random real out of RectMaxX/Y and MinX/Y to get a random point inside the given rect~
Now, when they step into one of the 2 Checkpoints of any line (Each line has 2 Checkpoints), they should recieve the order to "attack" move to the next checkpoint. Quite simple, but something is broken here:
Some units wont move. If I manually select them and give them a move order, they start moving towards the given Checkpoint once again, but only then.
I am using the following stuff to make the continuos movement:
(Variables are globals) First, Creating a few regions...
JASS:
set ENTERREGION[1] = CreateRegion()
...
After that, Add the Rect (Saved in a global too)...
JASS:
call RegionAddRect(ENTERREGION[1], RECT[3])
...
And finally adding the Event with the previously created Regons...
JASS:
call TriggerRegisterEnterRegion(MOVE, ENTERREGION[1], null)
...
Is this way too slow for wc3 to handle more than like 30-40 units at once? Im saving every unit in a local variable (wich gets nulled afterwards ofcourse) so it should not overlap at all (That´s what im thinking at least)
I thought about doing something with unit groups and make the order apply to the specific unit group (Depends on how far the unit has actually moved, unit_group0 for moving to checkpoint 1, unit_group1 for moving to checkpoint 2 etc..), maybe that would work?
Has anyone of you had this kind of problem before too? A good solution is appreciatet aswell, im willing to just delete the trigger and redo it completly~
Cheers
PS: If youre interested, here is the complete trigger (It´s just made to work, not to be fancy~):
JASS:
library MoveOn initializer MOVE_INIT requires Settings
globals
private trigger MOVE = CreateTrigger()
private region array ENTERREGION
endglobals
/*
*RECT[1] = WEST_SPAWN
*RECT[2] = EAST_SPAWN
*RECT[3] = WEST_UP
*RECT[4] = EAST_UP
*RECT[5] = WEST_DOWN
*RECT[6] = EAST_DOWN
*RECT[7] = WEST_MIDDLE
*RECT[8] = EAST_MIDDLE
*RECT[9] = WEST_MAIN
*RECT[10] = EAST_MAIN
*RECT[11] = HERO_WEST
*RECT[12] = HERO_EAST
*/
private function MOVE_CONDITION takes nothing returns boolean
return(not IsUnitType(GetEnteringUnit(), UNIT_TYPE_HERO))
endfunction
private function MOVE_ACTION takes nothing returns nothing
local real x
local real y
local unit u = GetEnteringUnit()
local integer i = GetPlayerId(GetOwningPlayer(u))
if IsPlayerInForce(Player(i), forceWest) then
if IsUnitInRegion(ENTERREGION[1], u) then
set x = GetRandomX(RECT[4])
set y = GetRandomY(RECT[4])
elseif IsUnitInRegion(ENTERREGION[2], u) then
set x = GetRandomX(RECT[10])
set y = GetRandomY(RECT[10])
elseif IsUnitInRegion(ENTERREGION[3], u) then
set x = GetRandomX(RECT[6])
set y = GetRandomY(RECT[6])
elseif IsUnitInRegion(ENTERREGION[4], u) then
set x = GetRandomX(RECT[10])
set y = GetRandomY(RECT[10])
elseif IsUnitInRegion(ENTERREGION[5], u) then
set x = GetRandomX(RECT[8])
set y = GetRandomY(RECT[8])
elseif IsUnitInRegion(ENTERREGION[6], u) then
set x = GetRandomX(RECT[10])
set y = GetRandomY(RECT[10])
endif
else
if IsUnitInRegion(ENTERREGION[1], u) then
set x = GetRandomX(RECT[3])
set y = GetRandomY(RECT[3])
elseif IsUnitInRegion(ENTERREGION[2], u) then
set x = GetRandomX(RECT[9])
set y = GetRandomY(RECT[9])
elseif IsUnitInRegion(ENTERREGION[3], u) then
set x = GetRandomX(RECT[5])
set y = GetRandomY(RECT[5])
elseif IsUnitInRegion(ENTERREGION[4], u) then
set x = GetRandomX(RECT[9])
set y = GetRandomY(RECT[9])
elseif IsUnitInRegion(ENTERREGION[5], u) then
set x = GetRandomX(RECT[7])
set y = GetRandomY(RECT[7])
elseif IsUnitInRegion(ENTERREGION[6], u) then
set x = GetRandomX(RECT[9])
set y = GetRandomY(RECT[9])
endif
endif
call IssuePointOrder(u, "attack", x, y)
set u = null
endfunction
private function MOVE_INIT takes nothing returns nothing
set ENTERREGION[1] = CreateRegion()
set ENTERREGION[2] = CreateRegion()
set ENTERREGION[3] = CreateRegion()
set ENTERREGION[4] = CreateRegion()
set ENTERREGION[5] = CreateRegion()
set ENTERREGION[6] = CreateRegion()
call RegionAddRect(ENTERREGION[1], RECT[3])
call RegionAddRect(ENTERREGION[2], RECT[4])
call RegionAddRect(ENTERREGION[3], RECT[5])
call RegionAddRect(ENTERREGION[4], RECT[6])
call RegionAddRect(ENTERREGION[5], RECT[7])
call RegionAddRect(ENTERREGION[6], RECT[8])
call TriggerRegisterEnterRegion(MOVE, ENTERREGION[1], null)
call TriggerRegisterEnterRegion(MOVE, ENTERREGION[2], null)
call TriggerRegisterEnterRegion(MOVE, ENTERREGION[3], null)
call TriggerRegisterEnterRegion(MOVE, ENTERREGION[4], null)
call TriggerRegisterEnterRegion(MOVE, ENTERREGION[5], null)
call TriggerRegisterEnterRegion(MOVE, ENTERREGION[6], null)
call TriggerAddCondition(MOVE, function MOVE_CONDITION)
call TriggerAddAction(MOVE, function MOVE_ACTION)
endfunction
endlibrary