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

Simple question about Variables

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2010
Messages
344
Hey!

I want to do this kind of individual dungeon system. You buy an item (Quest). You get teleported to the dungeon.

Now, I wanna have 1 variable for each player, because they only have 1 hero each.
Since it is an individual dungeon. There can only be one at a time.
So when 1 enters, the remaining minions will be removed (if one has been there but failed and only killed half of them.) It will be like a variable set to the entering hero. So when he dies, it will remove the minions. But if he fails and gives up and goes to level. He will still have the variable. So if he dies leveling, the minions in the dungeon will still be reset, even with other people inside. How do I prevent that?

Question: Can I like, remove the set of a variable?
How?

Other options?
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
1. use a array insted of x variables.
  • Actions
    • Set variable1 = Paladin 0000 <gen>
    • Set variable2 = Archmage 0001 <gen>
>
  • Actions
    • Set variable[1] = Paladin 0000 <gen>
    • Set variable[2] = Archmage 0001 <gen>
2. you can't "remove" it but you can set it to "nothing"
  • Set somevariable = (Level of No unit)
EDIT

on the other hand you could try this
  • Custom script: set udg_VariableName = null
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
do you tryed make 1 integer variable array (like was wrote above) and a integer variable?

Add + 1 to integer variable each time when a unit enter and -1 if unit leave/die etc, and when it is 0 then reset the dungeon?

like enter a unit then Dungeon_Usage = Dungeon_Usage + 1
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Now, I wanna have 1 variable for each player, because they only have 1 hero each.
You want an array. You can use the player slot number as the array index to do the mapping.

So when 1 enters, the remaining minions will be removed (if one has been there but failed and only killed half of them.) It will be like a variable set to the entering hero. So when he dies, it will remove the minions. But if he fails and gives up and goes to level. He will still have the variable. So if he dies leveling, the minions in the dungeon will still be reset, even with other people inside. How do I prevent that?
You keep a count of the number of players in the dungeon. If a person enters, you increment it (add 1 to its value). If a person dies or leaves you decrement it (remove 1 from the value). If the value becomes 0 (check after decrement) you remove all minions in the dungeon. If the value becomes 1 (check after increment) you spawn all minions.

Question: Can I like, remove the set of a variable?
That makes little sense. You can restore a variable to a previous state but it should always have a state. JASS is an exception since it will only initialize the variable entry inside the variable hashtable on the first set (initial value) and any attempts to read a value from the variable before then will cause a thread crash (as it cannot find the variable).
 
Level 8
Joined
Jun 13, 2010
Messages
344
RE:

1. use a array insted of x variables.
  • Actions
    • Set variable1 = Paladin 0000 <gen>
    • Set variable2 = Archmage 0001 <gen>
>
  • Actions
    • Set variable[1] = Paladin 0000 <gen>
    • Set variable[2] = Archmage 0001 <gen>
2. you can't "remove" it but you can set it to "nothing"
  • Set somevariable = (Level of No unit)
EDIT

on the other hand you could try this
  • Custom script: set udg_VariableName = null

Thank you! I will use the set variable to no unit.
I guess it works the way with variables that it can only be bonded to one thing at a time?
 
Status
Not open for further replies.
Top