Building Unit, depend to other Players unit

Status
Not open for further replies.
Level 1
Joined
Aug 6, 2021
Messages
3
Hallo,


i am working on a TD Map especially for our LAN group.
Every member of our group is represented as an own race you can choose from.
A big focus is teamplay. So here is my idea:
Player 1 with race A want to build the tower "pizza" but he should not be able until another Player with race B build the tower "oven".
There is an option in the object Editor "tech-tree requirement" but thats just for the player. It does not check the whole map for any "oven"
I can track if someone build it and set a variable to true/false but how can i activate the ability to build the "pizza" tower?

I hope you can understand me and my problem :vw_unimpressed:
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Create a new "Oven" upgrade that acts as the requirement to build the "Pizza".
Add this upgrade as a Requirement to build the "Pizza" tower so that in-game it will say "Requires Oven".
Then using triggers, detect when a Player builds an "Oven" and Pick through every player in the map, setting the level of the "Oven" upgrade to 1 for them.
As a result the players will all have access to the "Pizza" tower because they all have the "Oven Upgrade" researched.

If players can sell towers/lose towers then you'll want to account for this. When a player loses an "Oven", count the number of "Ovens" owned by you and your allies and if it's Equal to 0 then Pick through every player and set their "Oven" upgrade back to 0, reversing the process.

  • Build Oven
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Oven
    • Actions
      • Player Group - Pick every player in Users and do (Actions)
        • Loop - Actions
          • Player - Set the current research level of Oven (Upgrade) to 1 for (Picked player)
  • Lose Oven
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Oven
    • Actions
      • Set Variable OvenGroup = (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Oven)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in OvenGroup) Equal to 0
        • Then - Actions
          • Player Group - Pick every player in Users and do (Actions)
            • Loop - Actions
              • Player - Set the current research level of Oven (Upgrade) to 0 for (Picked player)
        • Else - Actions
      • Custom script: call DestroyGroup (udg_OvenGroup)

If the Lose Oven trigger is even necessary than make sure that the Ovens actually die. For example, if you REMOVE them from the game then they won't trigger the "A unit Dies" event.
 
Last edited:
Status
Not open for further replies.
Top