Uszi
New Member
- Reaction score
- 5
So, the following triggers deal with barricades and zombie AI in a survival map I've been working on...
Basically, with the barricades, I've found that making them units that the zombies can walk around makes it a lot easier on me, because if the zombies couldn't walk through them their default AI has them start running around all willy nilly trying to find a path into the base.
The problem now is that I needed to create several triggers that force the zombies to attack the barricades rather than just walk through.
One of these triggers is causing WC3 to crash to the desktop if more than one zombie is in the "door area" at a a time when the barricades fall:
Thing is, this trigger used to be fine with an old Zombie AI trigger that I was using. Problem with the old trigger was that it worked by frequently telling the zombies to attack a random enemy unit.
I wanted to change their AI to instead attack move to an average point between players, and every time the trigger ran to prioritize targets closer to them.
After saving my changes though and testing it out, I started getting the game crashes I described above. :banghead:
This is the new Zombie AI trigger:
As it turns out, it still has a few problems... Namely, if the zombies kill a barricade, then they dance around for a few seconds, and if there isn't an enemy within 500 range, they go home to wherever they spawned from.
Basically, with the barricades, I've found that making them units that the zombies can walk around makes it a lot easier on me, because if the zombies couldn't walk through them their default AI has them start running around all willy nilly trying to find a path into the base.
The problem now is that I needed to create several triggers that force the zombies to attack the barricades rather than just walk through.
One of these triggers is causing WC3 to crash to the desktop if more than one zombie is in the "door area" at a a time when the barricades fall:
Code:
Attack the Damn Barricades II
Events
Unit - A unit Is issued an order targeting a point
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
BarricadeUp[1] Equal to True
((Ordered unit) is in (Units in Room01 East Door <gen> owned by Player 12 (Brown))) Equal to True
Then - Actions
Unit - Order (Ordered unit) to Stop
Unit Group - Pick every unit in (Units in Room01 East Door <gen> owned by Player 12 (Brown)) and do (Unit - Order (Picked unit) to Attack Barricade[1])
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
BarricadeUp[2] Equal to True
((Ordered unit) is in (Units in Room01 North Door <gen> owned by Player 12 (Brown))) Equal to True
Then - Actions
Unit - Order (Ordered unit) to Stop
Unit Group - Pick every unit in (Units in Room01 North Door <gen> owned by Player 12 (Brown)) and do (Unit - Order (Picked unit) to Attack Barricade[2])
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
BarricadeUp[3] Equal to True
((Ordered unit) is in (Units in Room01 West Door <gen> owned by Player 12 (Brown))) Equal to True
Then - Actions
Unit - Order (Ordered unit) to Stop
Unit Group - Pick every unit in (Units in Room01 West Door <gen> owned by Player 12 (Brown)) and do (Unit - Order (Picked unit) to Attack Barricade[3])
Else - Actions
Do nothing
Thing is, this trigger used to be fine with an old Zombie AI trigger that I was using. Problem with the old trigger was that it worked by frequently telling the zombies to attack a random enemy unit.
I wanted to change their AI to instead attack move to an average point between players, and every time the trigger ran to prioritize targets closer to them.
After saving my changes though and testing it out, I started getting the game crashes I described above. :banghead:
This is the new Zombie AI trigger:
Code:
Zombie AI
Events
Conditions
Actions
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Set ZombieAI_PlayerPT[(Integer A)] = (Position of PlayerUnit[(Integer A)])
Set ZombieAI_PlayerPT_X_Real[(Integer A)] = (X of ZombieAI_PlayerPT[(Integer A)])
Set ZombieAI_PlayerPT_Y_Real[(Integer A)] = (Y of ZombieAI_PlayerPT[(Integer A)])
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
((Player((Integer A))) slot status) Equal to Is unused
((Player((Integer A))) slot status) Equal to Has left the game
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 1 (Red) slot status) Equal to Is playing
Then - Actions
Set ZombieAI_PlayerPT[(Integer A)] = (Position of PlayerUnit[1])
Set ZombieAI_PlayerPT_X_Real[(Integer A)] = (X of ZombieAI_PlayerPT[1])
Set ZombieAI_PlayerPT_Y_Real[(Integer A)] = (Y of ZombieAI_PlayerPT[1])
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 2 (Blue) slot status) Equal to Is playing
Then - Actions
Set ZombieAI_PlayerPT[(Integer A)] = (Position of PlayerUnit[2])
Set ZombieAI_PlayerPT_X_Real[(Integer A)] = (X of ZombieAI_PlayerPT[2])
Set ZombieAI_PlayerPT_Y_Real[(Integer A)] = (Y of ZombieAI_PlayerPT[2])
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 3 (Teal) slot status) Equal to Is playing
Then - Actions
Set ZombieAI_PlayerPT[(Integer A)] = (Position of PlayerUnit[3])
Set ZombieAI_PlayerPT_X_Real[(Integer A)] = (X of ZombieAI_PlayerPT[3])
Set ZombieAI_PlayerPT_Y_Real[(Integer A)] = (Y of ZombieAI_PlayerPT[3])
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 4 (Purple) slot status) Equal to Is playing
Then - Actions
Set ZombieAI_PlayerPT[(Integer A)] = (Position of PlayerUnit[4])
Set ZombieAI_PlayerPT_X_Real[(Integer A)] = (X of ZombieAI_PlayerPT[4])
Set ZombieAI_PlayerPT_Y_Real[(Integer A)] = (Y of ZombieAI_PlayerPT[4])
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 5 (Yellow) slot status) Equal to Is playing
Then - Actions
Set ZombieAI_PlayerPT[(Integer A)] = (Position of PlayerUnit[5])
Set ZombieAI_PlayerPT_X_Real[(Integer A)] = (X of ZombieAI_PlayerPT[5])
Set ZombieAI_PlayerPT_Y_Real[(Integer A)] = (Y of ZombieAI_PlayerPT[5])
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 6 (Orange) slot status) Equal to Is playing
Then - Actions
Set ZombieAI_PlayerPT[(Integer A)] = (Position of PlayerUnit[6])
Set ZombieAI_PlayerPT_X_Real[(Integer A)] = (X of ZombieAI_PlayerPT[6])
Set ZombieAI_PlayerPT_Y_Real[(Integer A)] = (Y of ZombieAI_PlayerPT[6])
Else - Actions
Do nothing
Else - Actions
Do nothing
Set ZombieAI_AvgPlayerPT_X = ((((((ZombieAI_PlayerPT_X_Real[1] + ZombieAI_PlayerPT_X_Real[2]) + ZombieAI_PlayerPT_X_Real[3]) + ZombieAI_PlayerPT_X_Real[4]) + ZombieAI_PlayerPT_X_Real[5]) + ZombieAI_PlayerPT_X_Real[6]) / 6.00)
Set ZombieAI_AvgPlayerPT_Y = ((((((ZombieAI_PlayerPT_Y_Real[1] + ZombieAI_PlayerPT_Y_Real[2]) + ZombieAI_PlayerPT_Y_Real[3]) + ZombieAI_PlayerPT_Y_Real[4]) + ZombieAI_PlayerPT_Y_Real[5]) + ZombieAI_PlayerPT_Y_Real[6]) / 6.00)
Set ZombieAI_AvgPlayerPT = (Point(ZombieAI_AvgPlayerPT_X, ZombieAI_AvgPlayerPT_Y))
Set TempUnitGroup = (Units owned by Player 12 (Brown))
Unit Group - Pick every unit in TempUnitGroup and do (Actions)
Loop - Actions
Set TempPoint = (Position of (Picked unit))
Unit - Order (Picked unit) to Attack-Move To ZombieAI_AvgPlayerPT
Set ZombieAI_Victims = (Units within 125.00 of TempPoint matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(ZombieAI_Victims is empty) Equal to False
Then - Actions
Unit - Order (Picked unit) to Attack (Random unit from ZombieAI_Victims)
Else - Actions
Set ZombieAI_Victims = (Units within 200.00 of TempPoint matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(ZombieAI_Victims is empty) Equal to False
Then - Actions
Unit - Order (Picked unit) to Attack (Random unit from ZombieAI_Victims)
Else - Actions
Set ZombieAI_Victims = (Units within 350.00 of TempPoint matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(ZombieAI_Victims is empty) Equal to False
Then - Actions
Unit - Order (Picked unit) to Attack (Random unit from ZombieAI_Victims)
Else - Actions
Set ZombieAI_Victims = (Units within 500.00 of TempPoint matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(ZombieAI_Victims is empty) Equal to False
Then - Actions
Unit - Order (Picked unit) to Attack (Random unit from ZombieAI_Victims)
Else - Actions
Do nothing
Wait 0.01 seconds
-------- Leak Clean up: --------
Custom script: call RemoveLocation (udg_TempPoint)
Custom script: call DestroyGroup (udg_TempUnitGroup)
Custom script: call DestroyGroup (udg_ZombieAI_Victims)
Set TempUnit = No unit
As it turns out, it still has a few problems... Namely, if the zombies kill a barricade, then they dance around for a few seconds, and if there isn't an enemy within 500 range, they go home to wherever they spawned from.