• 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.

Rare spawn?

Status
Not open for further replies.
Level 7
Joined
Dec 5, 2013
Messages
280
How to create rare monster spawn? for an example there is 1% chance that certain npc spawns in the map and the monster could spawn at any time, even multiple times during the game.
 
Level 7
Joined
Dec 5, 2013
Messages
280
Why cant I just add in first trigger "create unit of unit type" and then in second if there are no alive units of unit type then start the periodic event.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
And how is the game supposed to know if there are any alive? The only thing you could do is check EVERY unit in map and check if any of them is Rare unit and is alive... and you would have to do this either periodically or whenever any unit dies - veeery inefficient and lag-prone.

I don't really understand your problem with variables and why you are trying to avoid it.
Instead of this:
Code:
Timer expires
-> Spawn Rare
-> Set unit_var = spawned rare creep



Unit dies
- dying unit = unit_var
-> start timer

you're trying to avoid variable and instead try to think of an "easier" way, which in the code is actually far longer and very inefficient.
 
Level 7
Joined
Dec 5, 2013
Messages
280
Condition number of alive unit of units of unit type

This has worked for me in previous unit spawn systems without any problem.
 
Level 7
Joined
Dec 5, 2013
Messages
280
It hasnt slowed my game, so why should I make things complicated if there is simple solution?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Exactly. Afaik "Number of unit-type units in (Map)" would look like this in GUI:
*for simplicity, imagine I check number of Footman-type units*
Code:
X = 0
Pick every unit in (Playable map area) and do (actions)
    Loop
        If (conditions)
            Unit-type of (Picked unit) == Footman
        Then (actions)
            set X = X + 1
        Else (actions)
            *nothing*
... return X (X is number of Footmen in map)
To conclude this: The "number of units in *somewhere*" creates unit group and iterates through each unit in that group.
The creation of unit group is a heavy process and should be used as little as possible, since in conjuction with other heavy process it will start lagging your game.
As I wrote, it iterates through each unit in map - Now, it's fine and all when you have ~10 units in map, however it will be quite the problem when you have 100 units in map.
Add to it that you would either need to use this periodically, or whenever any unit dies.

So yeah - it's definitely possible to do it like that, but the playability of your map will drop a lot during actual game.
 
Status
Not open for further replies.
Top