• 🏆 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 unit spawn

Status
Not open for further replies.
Level 4
Joined
Feb 19, 2011
Messages
53
hi, i want a trigger, that when a unit(boss) dies, there is a chance to spawn 1 of 6 units...but how?!?
 
Level 3
Joined
Nov 14, 2010
Messages
34
it should be something like
Create Variable, let's call it K - integer
Event:
Unit X dies

Condition:
None

Action:
Set K = random number between 1 and 6.
If K = 1, then create A unit.
If K = 2, then create B unit.
etc...

edit: i made this fast for you

  • Trigger
    • Events
      • Unit - Doom Beast 0041 <gen> Dies
    • Conditions
    • Actions
      • -------- Doom Beast is my Boss --------
      • Set Random = (Random integer number between 1 and 6)
      • If (Random Equal to 1) then do (Unit - Create 1 Peasant for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees) else do (Do nothing)
      • If (Random Equal to 2) then do (Unit - Create 1 Peon for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees) else do (Do nothing)
      • -------- And go on until 6.. --------
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I think this trigger performs at a higher speed (since it doesn't use IF/THEN/ELSE Multiple Functions to check the integer)
  • INIT
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set RandomUnit[1] = Footman
      • Set RandomUnit[2] = Knight
      • Set RandomUnit[3] = Rifleman
      • Set RandomUnit[4] = Mortar Team
      • Set RandomUnit[5] = Sorceress
      • Set RandomUnit[6] = Priest
      • Set ReviveLoc = (Center of (Playable map area))
      • Game - Display to (All players) for 1000000000.00 seconds the text: Mission: Kill that ...
  • SRSS
    • Events
      • Unit - Blood Mage 0002 <gen> Dies
    • Conditions
    • Actions
      • Set DyingLoc = (Position of (Triggering unit))
      • Unit - Create 1 RandomUnit[(Random integer number between 1 and 6)] for (Triggering player) at DyingLoc facing Default building facing degrees
      • Unit - Set life of (Last created unit) to 25.00%
      • Custom script: call RemoveLocation(udg_DyingLoc)
Test map attached
 

Attachments

  • Simple Random Spawn System.w3x
    13.3 KB · Views: 325
Level 4
Joined
Feb 19, 2011
Messages
53
-Kobas- yours i didn't understood, defskull's is more complicated than Akhetaton, and his works perfect :)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
As you can see Akhetaton's trigger, performs at a slower speed than mine, why ?
Because it uses IF/THEN/ELSE Multiple Function
The trigger, first, needs to check the current random number and decide which number is the unit related to
While mine, instant check, done.
It's up to you though to choose which one :)
(Have you downloaded my test map?)
 
Open Object Manager and select abilities, hit Ctrl+F and write: "Spawn Hydra"
This spell and few others summon units when unit with ability die, if you add same unit with ability to this ability you will create infinite loop, in other words unit will be spawned as soon as it die :D

Play a little with it, maybe you find it useful :)

Anyway, trigger shown to you above is very basic, if you can't understand how it works, go check some tutorials fast, you will need skill for making good maps :)
 
Status
Not open for further replies.
Top