• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

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,993
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,993
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