| 05-16-2004, 09:10 PM | #1 |
Well I built a system for my map, my system allowing the computer players to return back to attack the opponents while he is turning back like I had a problem while one of my map heroes, Did something like blizzard, the spell effect my units force and the units were turning back while they were effected from the spell, So I loop through the rects of my map, and order them to attack back, I just want you to see the code and tell me if I can improve it or even missed something, or something is wrong, thanks for the help. Code:
function Trig_Forces_Orders_Actions takes nothing returns nothing
local integer i = 0
local group array arrTempGroup
loop
// Initialize the local array to destory the groups after
set arrTempGroup[0] = GetUnitsInRectOfPlayer(udg_arrTheAlliancePathRect[i], Player(10))
set arrTempGroup[1] = GetUnitsInRectOfPlayer(udg_arrTheScourgePathRect[i], Player(11))
exitwhen i > 9
// Order to attack opponents
if(i == 2) then
call GroupPointOrderLoc(arrTempGroup[0], "attack", GetRectCenter(gg_rct_The_Scourge_Center))
call GroupPointOrderLoc(arrTempGroup[1], "attack", GetRectCenter(gg_rct_The_Alliance_Center))
//=== S: Memory Clean Up ===//
call RemoveLocation(GetRectCenter(gg_rct_The_Alliance_Center))
call RemoveLocation(GetRectCenter(gg_rct_The_Scourge_Center))
//=== E: Memory Clean Up ===//
else
call GroupPointOrderLoc(arrTempGroup[0], "attack", GetRectCenter(udg_arrTheScourgePathRect[i]))
call GroupPointOrderLoc(arrTempGroup[1], "attack", GetRectCenter(udg_arrTheAlliancePathRect[i]))
//=== S: Memory Clean Up ===//
call RemoveLocation(GetRectCenter(udg_arrTheScourgePathRect[i]))
call RemoveLocation(GetRectCenter(udg_arrTheAlliancePathRect[i]))
//=== E: Memory Clean Up ===//
endif
//=== S: Memory Clean Up ===//
call DestroyGroup(arrTempGroup[0])
call DestroyGroup(arrTempGroup[1])
//=== E: Memory Clean Up ===//
set i = i + 1
endloop
//=== S: Memory Clean Up ===//
set arrTempGroup[0] = null
set arrTempGroup[1] = null
//=== E: Memory Clean Up ===//
endfunction
function InitTrig_Forces_Orders takes nothing returns nothing
set gg_trg_Forces_Orders = CreateTrigger()
call TriggerRegisterTimerEventPeriodic(gg_trg_Forces_Orders, 3.00)
call TriggerAddAction(gg_trg_Forces_Orders, function Trig_Forces_Orders_Actions)
endfunction |
| 05-17-2004, 03:29 AM | #2 |
is this usable on melee maps or would it work with the units the comp already has? |
| 05-17-2004, 11:20 PM | #3 |
Could you use some punctuation? I couldn't understand a thing you said. |
| 05-18-2004, 06:29 PM | #4 |
Well no, the system isn't for melee map since in melee maps the AI should control the computer units, also in this mechnisem you need to specified the source rects (regions) and destination rects the units need to return to, and target back, in melee the logic should be different. TheFlame what you didn't understand ? Well, in simple words I built this system to my map 'cause one of my heroes on my map, like I said for example the archmage's blizzard spell is effected on the computer units that aren't the opponents, once the spell is effected on the units, they were turning back to the place they were spawn, and wait there 'till next spawn only then i'm given order issue to attack the opponents again, so what I did is a global array of my rects (regoin) for both of my forces, and loop through them every 3 seconds to order the returning units to attack again if they are found on any rect of my map. |
