• 🏆 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!

Random Group Spawning?

Status
Not open for further replies.
Level 4
Joined
Jul 28, 2009
Messages
64
I'm trying to figure out how to create a random group spawn system.

I already have a good random unit spawn system, but I'm struggling figuring out how exactly to set a group of units as a variable, or series of variables, and then creating those specific units as a pre-made unit group.

I'm not sure that makes sense so here is an example:

Right now I have a system that creates random units based upon a pre-defined set of monsters that is either randomly selected or set based upon the level. So lets say I wanted 10 units, for each unit it would create a random unit from a list of possible units allowed by that monster group.

What I want is to be able to set different groups up, so instead of having randomly chosen units, it would have randomly chosen groups. So now those ten units would be 5 gnolls and 5 assassins, or 2 overlords and 8 ghouls...

This is basically to avoid unpleasant randomness like 10 of the same, very strong unit (however unlikely based upon the array), and also allows me to set up more interesting random encounters because I can guarantee that with each overlord there are 8 ghouls, and they could provide interesting synergy because I know the group make up.

I hope this is understood, If not I can try to clarify.
 
Level 8
Joined
Feb 15, 2009
Messages
463
JASS:
globals
integer array Spawn [2] [1]
endglobals

function SetUp takes nothing returns nothing
set Spawn[0][0] = 'U000'
set Spawn[1][0] = 'U001'
set Spawn[2][0] = 'U002'

set Spawn[0][1] = 'X000'
set Spawn[1][1] = 'X001'
set Spawn[2][1] = 'X002'

endfunction

function Create takes nothing returns nothing
local integer t = GetRandomInt(0,1)

local unit u = CreateUnit(Player , Spawn[0][t] , x , y , 0)
set u = CreateUnit(Player , Spawn[1][t] , x , y , 0)
set u = CreateUnit(Player , Spawn[2][t] , x , y , 0)

set u = null
endfunction

Hope my thoughts are clear
i realized this through 2D arrays ,JNGP needed(which is standart so get it if u don't have)
 
Level 4
Joined
Jul 28, 2009
Messages
64
yes I thought it would have to be 2 arrays, seeing it like this does make it look simpler than it did in my head.

I don't know jass or anything, but I think I understand it.

Is this impossible in GUI you think? I've been messing around with that for a bit and it didn't seem so.

Perhaps I could find a solution using hashtables...? seems like an alternate way to assign an index.

Maybe something like:

Save(Unit-type) as (1) of (1) in RandomGroup hashtable
Save(Unit-type2) as (2) of (1) in RandomGroup hashtable
Save(Unit-type3) as (3) of (1) in RandomGroup hashtable
Save(10) as 0 of (1) in RandomGroup hashtable

Save(Unit-type) as (1) of (2) in RandomGroup hashtable
Save(Unit-type2) as (2) of (2) in RandomGroup hashtable
Save(Unit-type3) as (3) of (2) in RandomGroup hashtable
Save(10) as 0 of (2) in RandomGroup hashtable

Set RandomGroupInteger = Random number between 1 and 2

For each integer(X) from 1 to (Load 0 of (RandomGroupInteger) in RandomGroup hashtable) to do actions:
Create 1 (Load integer(x) of (RandomGroupInteger) in RandomGroup hashtable

Perhaps that would work...

thanks for your help :)

+rep

any more feedback or ideas, folks?
 
Level 8
Joined
Feb 15, 2009
Messages
463
Since 2D arrays are not possible without JNGP not but u can do it with a workaround
just use 1integer array , a single Integer and a if then else loop instead

like

1st Trigger and 1 integer array called Spawn needed

sets the array up


like:


set udg_Spawn[1] = unit_type1
set udg_Spawn[2] = unit_type2
set udg_Spawn[3] = unit_type3
...



another trigger firing whenever spawn




udg_Int = GetRandomInt(x,y)

if udg_Int = x then

Create x units of udg_Spawn[1] at ..
Create x units of udg_Spawn[2] at ..

else udg_Int = y then

Create x units of udg_Spawn[3] at ..
Create x units of udg_Spawn[4] at ..

endif

:fp:
All clear for you now? i just gave you a very raw example but background should be clear =D
 
Status
Not open for further replies.
Top