• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Random Point in Region is always the same

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,994
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]
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
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.
 

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,994
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.
Top