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

Hero Repick Question

Status
Not open for further replies.
Level 12
Joined
Jun 10, 2008
Messages
1,043
Alright, so I've been thinking about this for a couple of hours yesterday and now today. Everytime I try to make a trigger, I can almost sense the answer trying to spring itself forth with no effect, so I'm asking you.

I cannot figure out how to make a repick system. Right now, I have:

Warrior
Events
Unit - A unit enters WarriorChoose <gen>
Conditions
(Unit-type of (Entering unit)) Equal to Wisp
Actions
Unit - Create 1 Lord Villus Malsarian Male for (Triggering player) at (Center of HeroSpawnRegion <gen>) facing Default building facing degrees
Unit - Remove (Entering unit) from the game


Ranger
Events
Unit - A unit enters RangerChoose <gen>
Conditions
(Unit-type of (Entering unit)) Equal to Wisp
Actions
Unit - Create 1 Aliria the Peaceful Female for (Triggering player) at (Center of HeroSpawnRegion <gen>) facing Default building facing degrees
Unit - Remove (Entering unit) from the game


Guardian
Events
Unit - A unit enters GuardianChoose <gen>
Conditions
(Unit-type of (Entering unit)) Equal to Wisp
Actions
Unit - Create 1 Vallus the Worthy Male for (Triggering player) at (Center of HeroSpawnRegion <gen>) facing Default building facing degrees
Unit - Remove (Entering unit) from the game


Necromancer
Events
Unit - A unit enters NecromancerChoose <gen>
Conditions
(Unit-type of (Entering unit)) Equal to Wisp
Actions
Unit - Create 1 Varian the Darkened Male for (Triggering player) at (Center of HeroSpawnRegion <gen>) facing Default building facing degrees
Unit - Remove (Entering unit) from the game


Paragon
Events
Unit - A unit enters ParagonChoose <gen>
Conditions
(Unit-type of (Entering unit)) Equal to Wisp
Actions
Unit - Create 1 Arthurian Gevenald Male for (Triggering player) at (Center of HeroSpawnRegion <gen>) facing Default building facing degrees
Unit - Remove (Entering unit) from the game

Priest
Events
Unit - A unit enters PriestChoose <gen>
Conditions
(Unit-type of (Entering unit)) Equal to Wisp
Actions
Unit - Create 1 Lunaris Vaenlith Male for (Triggering player) at (Center of HeroSpawnRegion <gen>) facing Default building facing degrees
Unit - Remove (Entering unit) from the game


and then I have:
Repick
Events
Player - Player 1 (Red) types a chat message containing -repick as An exact match
Conditions
Actions
Unit - Create 1 Wisp for Player 1 (Red) at (Center of HeroSpawnRegion <gen>) facing Default building facing degrees

For each player. I cannot figure out what to add in "Repick" to remove the hero (I'd make it "Last Created Unit", but you might be able to create more units, and I tried setting a variable as Last Created Unit, but would that glitch? If say HeroRed = Last Created Unit is up and then you do Remove HeroRed and the player hasn't chosen a hero, would they still get a wisp? Also, they can repick multiple times, so would that make the variable glitch?) Please help!
 
Level 13
Joined
Mar 24, 2010
Messages
950
this is very fast to show you how its done you of course need to remove unit group leaks and point leaks

  • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game
      • Unit - Create 1 Wisp for (Triggering player) at ((Center of HeroSpawnRegion <gen>) facing Default building facing degrees
      • Camera - Pan camera for (Triggering player) to (Center of HeroSpawnRegion <gen>)) over 0.50 seconds
      • Selection - Select (Last created unit) for (Triggering player)
that will work assuming only 1 hero per player at start.

or you can do it this way as well
  • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game
  • Unit - Create 1 Wisp for (Triggering player) at ((Center of HeroSpawnRegion <gen>) facing Default building facing degrees
  • Camera - Pan camera for (Triggering player) to (Center of HeroSpawnRegion <gen>)) over 0.50 seconds
  • Selection - Select (Last created unit) for (Triggering player)
either way works
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Careful: Using the action "Unit - Remove Unit" will cause that particular unit to be likely, leaks.
Furthermore, you said that they can use the -repick command multiple of times right ?
Will likely cause a multiple of unit leak
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
You store their hero in an array. When they pick you store the hero you create into the array at an index of the player who owns the hero. When they repick you remove the hero at the slot of the triggering player index and create a wisp for the triggering player.
 
Level 12
Joined
Jun 10, 2008
Messages
1,043
this is very fast to show you how its done you of course need to remove unit group leaks and point leaks

  • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game
      • Unit - Create 1 Wisp for (Triggering player) at ((Center of HeroSpawnRegion <gen>) facing Default building facing degrees
      • Camera - Pan camera for (Triggering player) to (Center of HeroSpawnRegion <gen>)) over 0.50 seconds
      • Selection - Select (Last created unit) for (Triggering player)
that will work assuming only 1 hero per player at start.

or you can do it this way as well
  • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game
  • Unit - Create 1 Wisp for (Triggering player) at ((Center of HeroSpawnRegion <gen>) facing Default building facing degrees
  • Camera - Pan camera for (Triggering player) to (Center of HeroSpawnRegion <gen>)) over 0.50 seconds
  • Selection - Select (Last created unit) for (Triggering player)
either way works

Hmmm, just tested something else with this. Whenever you type -repick, it'll still give you a wisp - even if you done have a hero. This way you can have like 10 heroes at once. How do you prevent that from happening? Also, I dont know what na array is :S
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Also, I dont know what na array is :S
Sigh...

An array is an area of mapped memory space allowing access to different elements via the use of an index integer. The domain of valid indicies (what numbers are supported by the index integer) runs from 0 to the maximum array size - 1 to provide a number of storage spaces equal to the maximum array size. Array interaction is potentially slower than normal variable interaction due to the required extra memory reads and should only be used with non static indicies (if an index is a static number, it will acts like a normal variable but slower).

You can think of an array as a cabnet with shelves. The index integer refers to which shelf you want to interact with when revering to an array. variable[0] could be thought of as the bottom shelf or ground level while variable[maximum - 1] is the far top shelf. To compare with, a normal variable is like a chest which is a single place to store an object. Each storage location can only have 1 object at a time and asigning a new object to that location will equivently throw out (imagine picking up and throwing over sholder) the item that was previously there. Where as with a normal variable you refer to it like "Place an object in chest X" or "Take an object from chest X", with arrays you refer to it like "Place an object on the [index]s shelf of cabnet X" or "Take an object from the [index]s shelf of cabnet X" where X is a variable and index is a number refering to a specific shelf.

Arrays in WarCraft III are all dynamic arrays with a hard coded maximum size of 2^13 = 8192 meaning that indicies in the domain (range) of 0 to 8191 are all valid. A dynamic array automatically alters it size as needed so when you allocate an array it will default to a much smaller array (I think with a size 16 in WC3) and get extended in powers of 2 (16, 32, 64 etc) to the maximum of 8192 as you exceede the currently allocated maximum (this mechanic is irrelevent for their proper use, this is just so you do not concern about heavy memory consumption). Arrays can not be assigned an innital value upon definition unlike normal variables.

It is important to note that GUI's array size is fake and mostly not nescescary. All it does is initialize all indicies to a value (you can specify) within the array size so avoid using it unless you really need the feature.

Ok as for your multiple respawn question. Simply set the hero varabile for that player to null when they repick and only allow repicks if the hero variable for that player is not null. When they pick a hero, logically you assign the hero variable for that player to the choosen hero so repick becomes enabled. Things like a repick limit are probably not nescescary although you should consider how abusable repicking could be as far as items and money goes (especially if you use a save system).
 
Level 13
Joined
Mar 24, 2010
Messages
950
yea Dr. that way is better ;) but based on the technicality of his question i figured he would not be up to something like that, so this is how to solve the wisp problem.

  • Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((((Matching unit) is A Hero) Equal to True) or ((Unit-type of (Matching unit)) Equal to Wisp))) and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game
  • Unit - Create 1 Wisp for (Triggering player) at ((Center of HeroSpawnRegion <gen>) facing Default building facing degrees
  • Camera - Pan camera for (Triggering player) to (Center of HeroSpawnRegion <gen>)) over 0.50 seconds
  • Selection - Select (Last created unit) for (Triggering player)
that way becuz u can use -repick more than once that will remove both in case they are there, dont forget to remove the leaks.
 
Hmmm, just tested something else with this. Whenever you type -repick, it'll still give you a wisp - even if you done have a hero. This way you can have like 10 heroes at once. How do you prevent that from happening? Also, I dont know what na array is :S

Use a Boolean to determine of the player has a hero.

  • Set PlayerhasHero[(Owner of (Triggering Unit)] = True
Use this when the wisp goes into the circle.

When you repick; use this:

  • Set PlayerhasHero[(Some function to detect the player that entered the string; too lazy to check WE :D)] = False
And add a condition to the repick trigger:

  • Conditions
    • PlayerhasHero[(Some function to detect the player that entered the string; too lazy to check WE :D)] = True
I think that should work...
 
Level 4
Joined
Apr 15, 2011
Messages
108
Use a Boolean to determine of the player has a hero.

  • Set PlayerhasHero[(Owner of (Triggering Unit)] = True
Use this when the wisp goes into the circle.

When you repick; use this:

  • Set PlayerhasHero[(Some function to detect the player that entered the string; too lazy to check WE :D)] = False
And add a condition to the repick trigger:

  • Conditions
    • PlayerhasHero[(Some function to detect the player that entered the string; too lazy to check WE :D)] = True
I think that should work...
You mena playerhashero[numberoftriggeringplayer]
 
Status
Not open for further replies.
Top