• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

Region Arrays Question

Status
Not open for further replies.
Level 1
Joined
Apr 11, 2004
Messages
2
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)
------------
 
Level 8
Joined
Feb 10, 2006
Messages
466
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
 
Level 8
Joined
Nov 20, 2005
Messages
372
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.
Top