• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Respawn

Status
Not open for further replies.
Level 7
Joined
May 30, 2018
Messages
290
Hello guys :)

I want to implent a system into my map that should achieve the following: at the start of the game the players can chose a unit from a tavern/building. (that part shouldn't be that hard I believe)

The other thing is after the player's unit, he should be able to pick a new unit from the tavern/building like in the beginning . I want him only to be allowed to pick a new unit after his current unit died. (In other words: a player should only be allowed to own max. 1 unit at a time. (and preferably with a short "respawn cooldown" so he can't immediatly pick something and has to wait a few seconds before he can chose again)

I guess this isn't really hard to implement, but I would greatly appreciate some ideas, since I don't know how to do the part with the "after someone dies he can pick a new unit".

Thank you in advance :)
 
At the core you want a sort of state engine...

Choose a Hero -(hero choosen)> Play With Hero -(hero dies)> Wait Respawn Time -(timer expires)> Choose a Hero

When a hero is choosen you can hide the building, disable the tech for training the hero or remove the selector unit. The selected hero is tracked in a variable and multiple selection attempts are ignored. When the selected hero unit dies then it gets removed and a timer starts for the respawn time. When that respawn timer times out then the hero selector is restored and the player can select another hero.
 
I attached a map. I think it does everything you want.

How it works:
Instead of "Selling Units" I use the "Train Units" option on a Barracks that I made to look like a Tavern.
When you start training a unit I immediately cancel the unit being trained.
Then I check whether or not you already have a unit. If you don't have a unit yet then I create one for you based on what you attempted to train. If you do have a unit already then nothing happens.
Finally, when you unit dies I add it to a Unit Group and start it's "Respawn" timer. Once the unit has "Respawned" (it doesn't actually respawn) you can select a new unit again.

It's a simple Boolean really. If you have a unit then Boolean = True. If you don't then Boolean = False. When you attempt to train a unit it checks this boolean and responds accordingly. When your unit dies I start a respawn timer and after that timer expires I set the Boolean to false (allowing you to train again).
 

Attachments

Last edited:
I attached a map. I think it does everything you want.

How it works:
Instead of "Selling Units" I use the "Train Units" option on a Barracks that I made to look like a Tavern.
When you start training a unit I immediately cancel the unit being trained.
Then I check whether or not you already have a unit. If you don't have a unit yet then I create one for you based on what you attempted to train. If you do have a unit already then nothing happens.
Finally, when you unit dies I add it to a Unit Group and start it's "Respawn" timer. Once the unit has "Respawned" (it doesn't actually respawn) you can select a new unit again.

It's a simple Boolean really. If you have a unit then Boolean = True. If you don't then Boolean = False. When you attempt to train a unit it checks this boolean and responds accordingly. When your unit dies I start a respawn timer and after that timer expires I set the Boolean to false (allowing you to train again).

Thank you very much for your hard work. :) I will check it our immediatly.

Say, is there a way to set a limit for certain unit types? That for example only 3 of one type are allowed on the map at the same time ?
 
Last edited:
I attached a map. I think it does everything you want.

How it works:
Instead of "Selling Units" I use the "Train Units" option on a Barracks that I made to look like a Tavern.
When you start training a unit I immediately cancel the unit being trained.
Then I check whether or not you already have a unit. If you don't have a unit yet then I create one for you based on what you attempted to train. If you do have a unit already then nothing happens.
Finally, when you unit dies I add it to a Unit Group and start it's "Respawn" timer. Once the unit has "Respawned" (it doesn't actually respawn) you can select a new unit again.

It's a simple Boolean really. If you have a unit then Boolean = True. If you don't then Boolean = False. When you attempt to train a unit it checks this boolean and responds accordingly. When your unit dies I start a respawn timer and after that timer expires I set the Boolean to false (allowing you to train again).

Your trigger works great! Still, I decided on using a much simpler approach, which is enough for my needs: I just give every player a food supply limit of 1 and let the units cost 1 food supply, pretty self-explanatory I guess :) But Iam still in need of the respawn timer! Is it possible to apply the respawn timer you made to my method? Maybe a trigger that checks if a player has 0/1 or 1/1 food supply and then applies a respawn timer after death ?
 
Copy and paste the "Player Unit Dies" trigger and "Player Respawn Timer" triggers into your map. Inside the Player Unit Dies trigger do this:
  • Player - Set (Triggering player) Food used to 1
Then in the Player Respawn Timer trigger look for this action and delete it:
  • Set T_PlayerCanSelect[T_Player] = True
Replace it with a new action:
  • Player - Set (Triggering player) Food used to 0
This will make your food used 1/1 when your unit dies, then 0/1 when the respawn timer finishes.

Finally, make sure when you Select your units that you set them as
  • Set T_PlayerHero[Player number of triggering player] = (Triggering Unit)
 
Copy and paste the "Player Unit Dies" trigger and "Player Respawn Timer" triggers into your map. Inside the Player Unit Dies trigger do this:
  • Player - Set (Triggering player) Food used to 1
Then in the Player Respawn Timer trigger look for this action and delete it:
  • Set T_PlayerCanSelect[T_Player] = True
Replace it with a new action:
  • Player - Set (Triggering player) Food used to 0
This will make your food used 1/1 when your unit dies, then 0/1 when the respawn timer finishes.

Finally, make sure when you Select your units that you set them as
  • Set T_PlayerHero[Player number of triggering player] = (Triggering Unit)

Thank you :)
 
Hey, dunno if you used my last upload (v.2) but I found a new bug for it so I scrapped it entirely. (It's tough making multiplayer-compatible maps without actually being able to test them online with other people)

Anyway, I think I solved all of the issues with this latest version. In it I added the option to set a limit for specific unit-types AND it now only uses 1 Tavern/Marketplace instead of the weird setup I had before.

If you provide some more information I could fine tune it to your needs. For example, how many Taverns will you have in your map? Will multiple buildings have their own custom set of Units? For example, Goblin Merchant sells Undead units while the Mercenary Camp sells Orc units.

With the system I have on my current map I would have to modify it if you wanted different types of Taverns but it wouldn't be hard to do.
 

Attachments

Hey, dunno if you used my last upload (v.2) but I found a new bug for it so I scrapped it entirely. (It's tough making multiplayer-compatible maps without actually being able to test them online with other people)

Anyway, I think I solved all of the issues with this latest version. In it I added the option to set a limit for specific unit-types AND it now only uses 1 Tavern/Marketplace instead of the weird setup I had before.

If you provide some more information I could fine tune it to your needs. For example, how many Taverns will you have in your map? Will multiple buildings have their own custom set of Units? For example, Goblin Merchant sells Undead units while the Mercenary Camp sells Orc units.


I really appreciate your amazing support! My original plan was to actually have a building that is constructable by a worker. This building contains units for the players to train. Basically the building should be "clickable" by every player on the team and produce units for the respective player, who trains it.
 
Alright, that changes things up a lot then. My system only works for ALL Marketplaces at the moment, as in every single Tavern on the map will have the Units added to it.

Some more questions:
1) Would you have multiple buildings each with different trainable units?

2) Do you want to Train units or Sell units? Training them creates a queue that lets you train up to 7 units at a time (like a Barracks) but selling them is instant (like how the Mercenary Camps work).

3) Are these buildings invulnerable? Can they be destroyed? Should they be player-owned or can they be owned by a neutral player (For example, you build the building and when it finishes it gets changed ownership to neutral passive)
 
Alright, that changes things up a lot then. My system only works for ALL Marketplaces at the moment, as in every single Tavern on the map will have the Units added to it.

Some more questions:
1) Would you have multiple buildings each with different trainable units?

2) Do you want to Train units or Sell units? Training them creates a queue that lets you train up to 7 units at a time (like a Barracks) but selling them is instant (like how the Mercenary Camps work).

3) Are these buildings invulnerable? Can they be destroyed? Should they be player-owned or can they be owned by a neutral player (For example, you build the building and when it finishes it gets changed ownership to neutral passive)

1) yes, every of the playable faction should have their respective building for units (1 Building for each of the 2 factions)

2) eventhough the players can only own 1 unit , I'd still like them to train that unit

3) The buildings can be destroyed and are player-owned (the player who builds them is player 1 of each team)
 
For #2 when you say you'd like them to train that unit do you mean the unit will have a build time? Like how a footman takes 18 seconds to build.

Exactly, just not that long. I'd like it to vary with the unit type, but since I don't even created the concept of the units yet, it'll be eaiser to just give the units a global 5 second build time.
 
No worries about the specifics, it's more about the mechanics. I just wanted to know whether or not you were SELLING or BUILDING. Two very different things :p but I understand now.

I just remembered one important detail! It would be very helpful, if one player of each team gets locked out from using the building ( the one player who constructs the building, shouldn't be able to train units in it! So just the team of the player who builds it has access to the units, not the player who built it himself) Thank you for your help man, you're gods gift!

+ the respawn thing we talked about before. Can I still just use your "old" trigger you used with the taverns? So that after a player dies he need to wait a few seconds before he can train a new unit.
 
Last edited:
Quick question, who owns the trained units? As in, if Player 2 trains a footman but Player 1 was the one who built the Barracks, does Player 2 get the unit or does it belong to Player 1?

In this case Player 2! Always the player who trains it. :)
 
Going to be a bit difficult/impossible to do this without some weird workaround. Are you okay with one of these alternative options?

1) Units are built instantly.
2) Units have a build time but it doesn't show up in the normal 7 unit queue.

I have to do it like this because there's no way to detect which player issued the build order. As in, if a Barracks is owned by Player 1 but shared with Player 2, I can't detect when Player 2 uses the Barracks. The game will always think it was Player 1 that tried to build the unit and the unit will always be made for Player 1, even if Player 2 did it.
 
Last edited:
Going to be a bit difficult/impossible to do this without some weird workaround. Are you okay with one of these alternative options?

1) Units are built instantly.
2) Units have a build time but it doesn't show up in the normal 7 unit queue.


No problem. Both alternatives are completly fine! Both of these Features aren't essential for my map. So just use the alternative that's most fitting for you and eases your work the most. :)
 
@Uncle Hey I kept pondering about the problem aswell. Maybe it is solveable through changing the buildings ownership to the player who clicks it ? Question is how to restrict this mechanic to your team only...
Maybe the approach you are working on will be better anyways. Just wanted to tell you about my idea.
 
Alright, here it is.

How to get started:
Import the triggers into your map and then modify the "Setup Barracks Variables" trigger to suit your needs. That should be the only trigger you have to worry about.
Also, there are some important things your units need when using this system.
Make sure your purchased units have a Stock Maximum = 32, Stock Initial After Delay = 32, Stock Start Delay = 0, and Stock Replenish Interval = 0.
Also. make sure your Barracks structures don't actually Sell any units but do have the Sell Units ability.

How the system works:
Whenever a Player purchases a Unit from a Barracks I check a few things. 1) Who owns that Barracks. 2) Who owns the purchased unit. 3) Whether or not the purchasing player can purchase a unit yet.
After getting this information I can determine what to do with with the Purchased unit.
If the unit can be purchased then the unit is created as normal, however, if the unit cannot be purchased then I remove it. Removing it gives the illusion that the unit was never purchased in the first place but in reality I just remove it immediately after it's created. Then, after purchasing a unit, I adjust the Stock of the purchased unit for all of your team's Barracks. The Stock represents how many of those units are available, so if a unit has a Stock of 3 then that means your team may only have at most 3 of those units. When the Stock reaches 0 the unit is removed from the Barracks but will be added back after one of those units are killed.

Some other notes:
1) The Barracks (referring to it as a Barracks now and not a Tavern) can be "used" by the opposing team but it will not actually train that team any units. I couldn't get around this but it's a purely visual issue and doesn't actually cause any problems.
2) I added Gold/Lumber costs to the Units but you don't have to use this. You can delete everything Gold/Lumber related or simply set the values to 0 if you don't wish to use them. (You can delete the variables from the Setup trigger too, since the default Gold/Lumber values will be 0 anyway)
3) You can delete or change the Display Text Messages if you want. I display a message in the "Player Unit Dies" trigger and the "Player Respawn Timer" trigger.

Also, the map might seem weird when testing it out but that's because Player 1 (You) is set to be the Captain. Try setting the Captain to a player other than you (player 1), since Captain's can't purchase units. Also, you won't be able to build Orc Units unless you're an ally with Player 7 (Orc Captain).

EDIT: I found some minor bugs and fixed them. Use v.3 instead of v.2.
 

Attachments

Last edited:
Uploaded a new version just now. I found a bug last minute but fixed it.

Hopefully, fingers crossed, this will all work. From the testing I did it appears to work just fine but you never know when it comes to multiplayer and other weird interactions that weren't thought of.
 
Uploaded a new version just now. I found a bug last minute but fixed it.

Hopefully, fingers crossed, this will all work. From the testing I did it appears to work just fine but you never know when it comes to multiplayer and other weird interactions that weren't thought of.


I tested it out and it works magnificent ! Thank you, thank you, thank you for the great effort, you put in :D Take all my rep. points!
 
Status
Not open for further replies.
Back
Top