• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

trigger that there is a 30% chance that a unit will spawn upon kill them by a specific unit

Status
Not open for further replies.
Level 3
Joined
Sep 25, 2020
Messages
36
Hi Team,

Can someone please help me with a trigger that "there is a 30% chance that a unit will spawn upon kill them by a specific unit then dies after 5 seconds"

I dont want to use the "arrow of darkness orb" because of the effect and can only be used in ranged units.



Much appreciated
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
here you go sir

  • spawnstuff
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Random real number between 0.00 and 1.00) Greater than 0.70
      • (Killing unit) Equal to Paladin 0000 <gen>
    • Actions
      • Set VariableSet SpawnPoint = (Position of (Dying unit))
      • Unit - Create 1 Vile Temptress for (Owner of (Dying unit)) at SpawnPoint facing Default building facing degrees
      • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_SpawnPoint)
 
Level 3
Joined
Sep 25, 2020
Messages
36
Oh man thank's alot bro, Can you put this in a map so I can study them, I'm really confused with variables. I can finally move on with my map.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
In general a variable is just a box (conceptually). when you create the variable, you are just creating an empty box, giving the box a name, and specifying what kind of content that box can hold (thats the variable type).

when you assign a value to the variable, you are just putting something in the box. lets say it's a "unit" variable -> First I create a "Unit" variable, a box that can hold a specific unit. I name it FrogWhackerUnit bc that has to do with the spell I am creating and that way I will remember what it's for (variable names can't contain spaces). then, during my spell, in actions I set variable -> FrogWhackerUnit = triggering unit. Now my box "holds" the triggering unit. now, any time I want to refer to the casting unit in my trigger, I just refer to FrogWhackerUnit instead. since these variables are global, you can also retain and pass data from trigger to trigger this way, which on the one hand is very useful, but also takes getting the hang of -bc you can overwrite variables without meaning to and cause a lot of things to bug out.


SpawnPoint is a point type variable (A saved point on the x,y grid that makes up the geography of you map). after you set it (with the "set variable" action) it will be readily available to insert in functions that use a point type variable. The reason I used it here instead of directly just referring to "Position of (Dying unit)" is bc that would leak (what are memory leaks?). What directly referring to it does is - it creates a variable behind the scenes, just you don't have access to it, and can't delete it, so it just sticks around and bogs up your memory. By using a variable that you define, it can be deleted and won't leak.

good luck!
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
First I create a Unit type variable
Just to clarify, you mean a Unit variable, not a Unit-Type variable :p

I know people can get confused by these similar variables like Ability/Ability Code, Unit/Unit-Type, Item/Item-Type.

@Warpath
A good strategy to use is to put the Variable type in the name of your variable. So like what Cheshire did -> SpawnPoint is a Point variable. Obviously users are free to name their variables whatever they want but a lot of the time you'll see this naming convention. I recommend naming things in your own map with the idea that someone else could open the map and immediately know what they do and where they belong.
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
Just to clarify, you mean a Unit variable, not a Unit-Type variable :p

I know people can get confused by these similar variables like Ability/Ability Code, Unit/Unit-Type, Item/Item-Type.

@Warpath
A good strategy to use is to put the Variable type in the name of your variable. So like what Cheshire did -> SpawnPoint is a Point variable. Obviously users are free to name their variables whatever they want but a lot of the time this naming convention is used which can be helpful. I recommend naming things in your own map with the idea that someone else could open the map and immediately know what goes with what.

edited it, hopefully it's more foolproof now
 
Status
Not open for further replies.
Top