Random Point in Region is always the same

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 25
Joined
Jan 29, 2010
Messages
2,018

Sunken City

Hello, guys. I got another weird issue I ran into.
I have this "tower" that shoots all the way at the enemy base, but at a random point. However, it seems to always shoot at the same place. Here is the trigger:
[trigger=""]Artilleries
Events
Unit - A unit Is attacked
Conditions
(Unit-type of (Attacking unit)) Equal to Artillery
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player number of (Owner of (Attacking unit))) Less than 5
Then - Actions
Set Artillery_Point = (Random point in East Base <gen>)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player number of (Owner of (Attacking unit))) Greater than 5
Then - Actions
Set Artillery_Point = (Random point in West Base <gen>)
Else - Actions
Unit - Order (Attacking unit) to Attack Ground Artillery_Point
Custom script: call RemoveLocation (udg_Artillery_Point)
[/trigger]
 
File -> Preferences -> Test Map -> Checkbox "Use Fixed Random Seed"

uncheck that.
 
Once it starts attack ground on a point, it will keep hitting that point, so your trigger will never run again.

What you need to do is to "reset" the tower. After a short delay, simply order the tower to stop. It will then re-acquire a target and attack a new random location.

Set the tower to a local unit variable, wait 1 second, order unit to stop.
 
Once it starts attack ground on a point, it will keep hitting that point, so your trigger will never run again.

What you need to do is to "reset" the tower. After a short delay, simply order the tower to stop. It will then re-acquire a target and attack a new random location.

Set the tower to a local unit variable, wait 1 second, order unit to stop.

Works flawlessly. Thanks. Posting the trigger in case someone needs it:
[trigger=""]Artilleries
Events
Unit - A unit Is attacked
Conditions
(Unit-type of (Attacking unit)) Equal to Artillery
Actions
Custom script: local unit udg_Artillery
Set Artillery = (Attacking unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player number of (Owner of (Attacking unit))) Less than 5
Then - Actions
Set Artillery_Point = (Random point in East Base <gen>)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player number of (Owner of (Attacking unit))) Greater than 5
Then - Actions
Set Artillery_Point = (Random point in West Base <gen>)
Else - Actions
Unit - Order Artillery to Attack Ground Artillery_Point
Custom script: call RemoveLocation (udg_Artillery_Point)
Wait 1.00 game-time seconds
Unit - Order Artillery to Stop
Custom script: set udg_Artillery = null
[/trigger]
 
Status
Not open for further replies.
Back
Top