- Joined
- Jun 14, 2008
- Messages
- 176
If anyone hasn't played Worm War before, it's a map where each player gets Worm(hero), there are tons of sheep and pigs in around the map. If a Worm passes through the sheep or pig, it gets a unit(Segment) that follows the Worm.
Anyway, a Worm dies if it bumps into another Worm or a Worm trail or a fire elemental.
Basically, I am trying to make an AI for the map and I want to make it so that the AI Worm tries to avoid anything that kills it.
Right now, I have a very simple trigger that orders the (AI) Worm to move a random point in the map area every few seconds, that's basically is it.
Now, what I want to do now is make it so that the worm tries to avoid anything that kills it, I made a couple of tries at this but am unsuccessful.
What I basically tried to do for the trigger to check for any "Death Obstacles", is I made periodic trigger that happens once every 0.5 seconds.
It sets a point to the Worm, then makes a Unit Group "Within 300 range" of the worm "matching" unit equals <Segment> or <Fire Elemental>(both which kills the worm when touched).
Then, it sets a second point <position of random unit of Unit Group>. Then it checks if "Distance between Point1 and Point 2 is less than or equal to 300", if it's true, it orders the unit to move another random location.
Now, in game, it doesn't seem to be working at all, it doesn't make the computer move a random location if there is a segment or fire elemental nearby.
Here's some example triggers I have:
(Note - Computer Player Groups = All players equal computer and ComputerUnitGroupArray is all worms owned by a computer, both these variables is set before the game start and they do work because my move trigger is based off of them and that trigger works)
Note - The main difference between the above trigger and the bottom trigger is that the bottom trigger sets the location to the "Picked" unit in the unit group instead of a "Random Unit"
Does setting a point to "Picked" unit of a unit group function properly?
So, does anyone know a way for me to make a trigger that checks if there is a unit within 300 range of the Worm(that can kill it), and if it's true, then it moves another location away from the location.
A trigger which tries to help the AI worm not get killed?
Any help will be appreciated.
Anyway, a Worm dies if it bumps into another Worm or a Worm trail or a fire elemental.
Basically, I am trying to make an AI for the map and I want to make it so that the AI Worm tries to avoid anything that kills it.
Right now, I have a very simple trigger that orders the (AI) Worm to move a random point in the map area every few seconds, that's basically is it.
Now, what I want to do now is make it so that the worm tries to avoid anything that kills it, I made a couple of tries at this but am unsuccessful.
What I basically tried to do for the trigger to check for any "Death Obstacles", is I made periodic trigger that happens once every 0.5 seconds.
It sets a point to the Worm, then makes a Unit Group "Within 300 range" of the worm "matching" unit equals <Segment> or <Fire Elemental>(both which kills the worm when touched).
Then, it sets a second point <position of random unit of Unit Group>. Then it checks if "Distance between Point1 and Point 2 is less than or equal to 300", if it's true, it orders the unit to move another random location.
Now, in game, it doesn't seem to be working at all, it doesn't make the computer move a random location if there is a segment or fire elemental nearby.
Here's some example triggers I have:
(Note - Computer Player Groups = All players equal computer and ComputerUnitGroupArray is all worms owned by a computer, both these variables is set before the game start and they do work because my move trigger is based off of them and that trigger works)
-
Example 1
-
Events
- Time - Every 0.50 seconds of game time
- Conditions
-
Actions
-
Player Group - Pick every player in ComputerPlayerGroup and do (Actions)
-
Loop - Actions
-
Unit Group - Pick every unit in ComputerUnitGroupArray[(Player number of (Picked player))] and do (Actions)
-
Loop - Actions
- Set ComputerCheckPoint[(Player number of (Owner of (Picked unit)))] = (Position of (Picked unit))
- Set ComputerCheckGroup[(Player number of (Owner of (Picked unit)))] = (Units within 300.00 of ComputerCheckPoint[(Player number of (Owner of (Picked unit)))] matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) Equal to Segment) or ((Unit-type of (Matching unit)) Equal to Fire Element))))
- Set ComputerCheckPoint2[(Player number of (Owner of (Picked unit)))] = (Position of (Random unit from ComputerCheckGroup[(Player number of (Owner of (Picked unit)))]))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Distance between ComputerCheckPoint[(Player number of (Owner of (Picked unit)))] and ComputerCheckPoint2[(Player number of (Owner of (Picked unit)))]) Less than or equal to 300.00
-
Then - Actions
- Custom script: call RemoveLocation(udg_ComputerRandomPointArray[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))])
- Set ComputerRandomPointArray[(Player number of (Owner of (Picked unit)))] = (Random point in Arena <gen>)
- Set ComputerChatSegmentInteger[(Player number of (Picked player))] = (Number of living Segment units owned by (Picked player))
- Unit - Order (Picked unit) to Move To ComputerRandomPointArray[(Player number of (Owner of (Picked unit)))]
- Custom script: call RemoveLocation(udg_ComputerRandomPointArray[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Else - Actions
-
If - Conditions
-
Loop - Actions
-
Unit Group - Pick every unit in ComputerUnitGroupArray[(Player number of (Picked player))] and do (Actions)
-
Loop - Actions
- Wait 0.10 seconds
- Custom script: call RemoveLocation(udg_ComputerRandomPointArray[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))])
- Custom script: call DestroyGroup(udg_ComputerCheckGroup[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))])
-
Player Group - Pick every player in ComputerPlayerGroup and do (Actions)
-
Events
Does setting a point to "Picked" unit of a unit group function properly?
-
Example 2
-
Events
- Time - Every 0.50 seconds of game time
- Conditions
-
Actions
-
Player Group - Pick every player in ComputerPlayerGroup and do (Actions)
-
Loop - Actions
-
Unit Group - Pick every unit in ComputerUnitGroupArray[(Player number of (Picked player))] and do (Actions)
-
Loop - Actions
- Set ComputerCheckPoint[(Player number of (Owner of (Picked unit)))] = (Position of (Picked unit))
- Set ComputerCheckGroup[(Player number of (Owner of (Picked unit)))] = (Units within 300.00 of ComputerCheckPoint[(Player number of (Owner of (Picked unit)))] matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) Equal to Segment) or ((Unit-type of (Matching unit)) Equal to Fire Element))))
-
Unit Group - Pick every unit in ComputerCheckGroup[(Player number of (Owner of (Picked unit)))] and do (Actions)
-
Loop - Actions
- Set ComputerCheckPoint2[(Player number of (Owner of (Picked unit)))] = (Position of (Picked unit))
-
Loop - Actions
- Wait 0.10 seconds
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Distance between ComputerCheckPoint[(Player number of (Owner of (Picked unit)))] and ComputerCheckPoint2[(Player number of (Owner of (Picked unit)))]) Less than or equal to 300.00
-
Then - Actions
- Custom script: call RemoveLocation(udg_ComputerRandomPointArray[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))])
- Set ComputerRandomPointArray[(Player number of (Owner of (Picked unit)))] = (Random point in Arena <gen>)
- Set ComputerChatSegmentInteger[(Player number of (Picked player))] = (Number of living Segment units owned by (Picked player))
- Unit - Order (Picked unit) to Move To ComputerRandomPointArray[(Player number of (Owner of (Picked unit)))]
- Custom script: call RemoveLocation(udg_ComputerRandomPointArray[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Else - Actions
-
If - Conditions
-
Loop - Actions
-
Unit Group - Pick every unit in ComputerUnitGroupArray[(Player number of (Picked player))] and do (Actions)
-
Loop - Actions
- Wait 0.10 seconds
- Custom script: call RemoveLocation(udg_ComputerRandomPointArray[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))])
- Custom script: call DestroyGroup(udg_ComputerCheckGroup[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))])
-
Player Group - Pick every player in ComputerPlayerGroup and do (Actions)
-
Events
-
Example 3
-
Events
- Unit - A unit Is issued an order targeting a point
-
Conditions
- ((Owner of (Triggering unit)) controller) Equal to Computer
- (Unit-type of (Triggering unit)) Equal to Worm
-
Actions
-
Player Group - Pick every player in ComputerPlayerGroup and do (Actions)
-
Loop - Actions
-
Unit Group - Pick every unit in ComputerUnitGroupArray[(Player number of (Picked player))] and do (Actions)
- Loop - Actions
-
Unit Group - Pick every unit in ComputerUnitGroupArray[(Player number of (Picked player))] and do (Actions)
-
Loop - Actions
- Set ComputerCheckPoint[(Player number of (Owner of (Triggering unit)))] = (Target point of issued order)
- Set ComputerTargetIssuePoint[(Player number of (Owner of (Triggering unit)))] = ((Position of (Picked unit)) offset by 200.00 towards (Current movement speed of (Picked unit)) degrees)
- Set ComputerCheckGroup[(Player number of (Owner of (Triggering unit)))] = (Units within 300.00 of ComputerTargetIssuePoint[(Player number of (Owner of (Triggering unit)))] matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) Equal to Segment) or ((Unit-type of (Matching unit)) Equal to Fire Ele
-
Unit Group - Pick every unit in ComputerCheckGroup[(Player number of (Owner of (Triggering unit)))] and do (Actions)
-
Loop - Actions
- Set ComputerCheckPoint2[(Player number of (Owner of (Triggering unit)))] = (Position of (Picked unit))
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Distance between ComputerCheckPoint[(Player number of (Owner of (Triggering unit)))] and ComputerCheckPoint2[(Player number of (Owner of (Triggering unit)))]) Less than or equal to 300.00
-
Then - Actions
- Custom script: call RemoveLocation(udg_ComputerRandomPointArray[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Custom script: call RemoveLocation(udg_ComputerTargetIssuePoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Set ComputerRandomPointArray[(Player number of (Owner of (Triggering unit)))] = (Random point in Arena <gen>)
- Set ComputerChatSegmentInteger[(Player number of (Picked player))] = (Number of living Segment units owned by (Picked player))
- Unit - Order (Triggering unit) to Move To ComputerRandomPointArray[(Player number of (Owner of (Triggering unit)))]
- Custom script: call RemoveLocation(udg_ComputerRandomPointArray[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Custom script: call RemoveLocation(udg_ComputerTargetIssuePoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Else - Actions
-
If - Conditions
- Wait 0.10 seconds
- Custom script: call DestroyGroup(udg_ComputerCheckGroup[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Custom script: call RemoveLocation(udg_ComputerTargetIssuePoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
- Custom script: call RemoveLocation(udg_ComputerRandomPointArray[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
-
Player Group - Pick every player in ComputerPlayerGroup and do (Actions)
-
Events
A trigger which tries to help the AI worm not get killed?
Any help will be appreciated.