• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Region Arrays Question

Status
Not open for further replies.

Sota

S

Sota

I need a quick answer. I'm trying to make a spawn trigger that creates a unit at a random point in a collage of 6 different regions every 2 seconds of game time. It looks like this currently, and I know it's wrong. I'm looking for a way to combine the parts of the array into one huge region.

--------------
Create The Desolace1
Events
Time - Every 2.00 seconds of game time
Conditions
(Number of units in (Units in Desolace[(Integer A)] matching (((Matching unit) belongs to an enemy of Neutral Hostile) Equal to True))) Greater than 0
(Number of units in (Units in Desolace[(Integer A)] matching (((Matching unit) is in (Units owned by Neutral Hostile)) Equal to True))) Less than or equal to 20
Actions
Set RandomDice = (Random integer number between 1 and 1)
If (RandomDice Equal to 1) then do (Unit - Create 1 Wild Pig for Neutral Hostile at (Random point in Desolace[(Random integer number between 1 and 6)]) facing (Random point in (Playable map area))) else do (Do nothing)
------------
 
The most correct way to do this would be (assuming you want the probability of unit being spawned in every point inside collage to be the same):

AT MAP INIT:
1 - Create an array of regions with Desolace[0]=#1, Desolace[1]=#2, ans so on (see image)
answerjb1.png


2 - Create an array of integers with

Array[0]=4 (area of first region)
Array[1]=6 (sum of area of second region and Array[0])
Array[2]=7 (sum of area of third region and Array[1])
Array[3]=9
Array[4]=13
Array[5]=17

EVERY 2 SECONDS
1 - Generate a random integer between 0 and (Array[5]-1)

2 - Do a loop from 0 to (6 - 1), if Array[loop iterator] is less than your random number, spawn unit, skip remaining actions
 
Create The Desolace1
Events
Time - Every 2.00 seconds of game time
Conditions
(Number of units in (Units in Desolace[(Integer A)] matching (((Matching unit) belongs to an enemy of Neutral Hostile) Equal to True))) Greater than 0
(Number of units in (Units in Desolace[(Integer A)] matching (((Matching unit) is in (Units owned by Neutral Hostile)) Equal to True))) Less than or equal to 20
Actions
Set RandomDice = (Random integer number between 1 and 1)
If (RandomDice Equal to 1) then do (Unit - Create 1 Wild Pig for Neutral Hostile at (Random point in Desolace[(Random integer number between 1 and 6)]) facing (Random point in (Playable map area))) else do (Do nothing)
<< I noticed here is anywhere a For Loop Index from 1 to *count of rects*

You have to pick all the rects first than you can do something with them , lol!!!

Use :
General - For Each Integer A From 1 to *yourintegerofrects* do ( multiplicate actions )

Love it to help lol! :D :wink:
 
Status
Not open for further replies.
Back
Top