• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to get random point in radius/range?

Status
Not open for further replies.
Level 12
Joined
Aug 12, 2008
Messages
349
I currently trying to make a spell that channels explosion at random point within 1000 range of radius of caster.
For those who play DotA, it is the same as the Crystal Maiden's ultimate spell, Freezing Field.
The problem is that I do not know how to pick a random point. I only manage to find a trigger that pick a random point in region instead of random point within 1000 range of radius of caster.
 
Last edited:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
EDIT: I'm sorry. Just figured it out on how to pick a random point.
For those who need, search for "Random point in region". Click the (Playable Map Area) and choose the "Conversion - Convert Point With Size To Region". The (Width) determine the range of radius of caster.

What!?
Better do this properly like it should be done:
  • Actions
    • Set tempp = (Position of (Triggering unit))
    • Set tempp2 = (tempp offset by (Random number between 1 and 1000) towards (Random angle))
Thats way how to create random point in circle around the caster.
Dont forgot about leak removal latter.
 
  • Like
Reactions: Kam
Level 12
Joined
Aug 12, 2008
Messages
349
Hmm... Why can't use this function "Random point in region"?
I thought it's good enough if it function properly :p
Anyway, I will use yours opinion. Thanks Spinnaker :D

The above idea's (my first post) had been re-edit in order not to confused any readers. The post before was the post quoted by Spinnaker. Sorry if there are any readers got confused.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Just to explain 'why':
Region isn't circle - it's rectangle.
You have to create/destroy region dynamicaly or (what's better) create region at map initialization and use 'move region' action. However, it still punishes you. You is somewhat constant and you have to non stop change it's size.

Using location is just simpler and faster. REMEMBER TO REMOVE leaks faterwards.
  • Custom script: call RemoveLocation (udg_tempp1)
Do that for each point used at the end of function.
 
Status
Not open for further replies.
Top