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

[Solved] Research unlocked after killing an unity

Status
Not open for further replies.
Level 7
Joined
Jan 11, 2022
Messages
108
I was wondering how to do, that the research unlocks after killing certain unity. My idea is to unlock the damage boost research after killing a boss. I just don't know how to set it. If it's a trigger, would anyone mind showing me how to do it? I'm in the dark with triggers. Cheers!
 
Level 29
Joined
Sep 26, 2009
Messages
2,596
It's 'unit', not 'unity' :D
What I would do is use dummy units as research requirements.
In object editor find the research in the Research tab and check its 'Techtree - Requirements' - a requirement here can also be a unit (i.e. the existence of a unit allows you to run the research).
The basic idea is that we would have a special (dummy) unit which represents one of the research requirements. At the start of the game the player does not have that unit and has no way to train that unit. When you kill the boss unit, you create the special/dummy unit for each player via triggers.

As an example, I have created a dummy unit called 'Boss unit killed'. This unit cannot attack, move, does not have model, does not cost food, has no sight range, etc.
I have set up that unit as part of research requirements.
When the unit is NOT created in game, the tooltip looks like in the attached picture.

Finally, when boss dies (in this example, a blood mage), the dummy unit will be created
  • Untitled Trigger 001 Copy
    • Events
      • Unit - Blood Mage 0002 <gen> Dies
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Create 1 Boss unit killed (dummy) for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
 

Attachments

  • wc3_tooltip.png
    wc3_tooltip.png
    123.8 KB · Views: 13
Level 7
Joined
Jan 11, 2022
Messages
108
Thank you so much! Explained so simply that even a noobie like me understands :D Thanks
And yeah idk why I typed "unity" instead of "unit" lmao
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Using a unit type as a techtree requirement is a fine way to do this is fine and has the benefit of being reversible (remove the unit and the player no longer has access to that research), but it's not necessary. If you do not need this research gate to be reversible (since upgrades can be set back to 0 now apparently) you can just use another upgrade as a techtree requirement instead, then set the level of that upgrade for the player to 1 when the gated research should become available. No need to create an invisible useless enemy for each player if you do it that way.
 
Last edited:
Level 7
Joined
Jan 11, 2022
Messages
108
So that second way, if I don't need it to be reversible, I can just somehow set a requirement as an unit kill? or still need a trigger for that?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
You can freely increase and decrease research levels of upgrades. Just type in the "Search For Text" box when creating a new Action and look for "research" or "tech" or some keyword. The Action will be self-explanatory.

The exact Actions can be found here:
 
Level 7
Joined
Jan 11, 2022
Messages
108
It's 'unit', not 'unity' :D
What I would do is use dummy units as research requirements.
In object editor find the research in the Research tab and check its 'Techtree - Requirements' - a requirement here can also be a unit (i.e. the existence of a unit allows you to run the research).
The basic idea is that we would have a special (dummy) unit which represents one of the research requirements. At the start of the game the player does not have that unit and has no way to train that unit. When you kill the boss unit, you create the special/dummy unit for each player via triggers.

As an example, I have created a dummy unit called 'Boss unit killed'. This unit cannot attack, move, does not have model, does not cost food, has no sight range, etc.
I have set up that unit as part of research requirements.
When the unit is NOT created in game, the tooltip looks like in the attached picture.

Finally, when boss dies (in this example, a blood mage), the dummy unit will be created
  • Untitled Trigger 001 Copy
    • Events
      • Unit - Blood Mage 0002 <gen> Dies
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Create 1 Boss unit killed (dummy) for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
I found it as the easiest method for me. I've just got one more question. Is there a way to put it as to couple players? My map is 5v5 and If one player kills him it gives only to Player 1. On the other side I dont want to give it to ALL players, because it would mean It would give dummy to enemies
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
This is as simple as it gets. No need for a Dummy unit or anything weird like that.
  • Events
    • Unit - YourUnit Dies
  • Conditions
  • Actions
    • Trigger - Turn off (This trigger)
    • Player - Set the current research level of Damage Boost to 1 for (Owner of (Killing unit))
When editing an Event/Condition/Action, you can see certain words/numbers will be underlined and colored blue. These are values that you can modify.

So in the case of Player 1 (Red), you can see that it's blue + underlined, meaning you can modify it. So click it, and you'll see 3 types of options:

Preset: Choose one of the Players from 1 to 24 or one of the Neutral players.

Variable: Choose a Player variable, if you've created any.

Function: Choose from a list of functions that pertain to different things in the game that are related to Players. This is what you're looking for, specifically Owner of Unit is what you want since it allows us to get the Player who owns the killer of the unit that died.

example.png
 
Last edited:
Level 7
Joined
Jan 11, 2022
Messages
108
Will that also work if 5 players kill that enemy? Or just the player with the last hit will get the research?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
Will that also work if 5 players kill that enemy? Or just the player with the last hit will get the research?
The trigger will run whenever the Event happens. So if the unit can die multiple times, then yes, it could very well work for 5 different players.

HOWEVER, in this case you're turning the trigger off:
  • Trigger - Turn off (This trigger)
So the trigger turns itself off the first time it runs, preventing it from running again.
 
Level 7
Joined
Jan 11, 2022
Messages
108
I'll make sure to disable turning off, because wanna make it run again. So there's no actual way to set it, that in ONE kill 5 CERTAIN players get the research right? Only one by one after multiple kills if I understood right
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
I'll make sure to disable turning off, because wanna make it run again. So there's no actual way to set it, that in ONE kill 5 CERTAIN players get the research right? Only one by one after multiple kills if I understood right
You can do just about anything you can think of.

If you want the killing player's team to get the upgrade then you would use what's called a Player Group:
  • Events
    • Unit - YourUnit Dies
  • Conditions
  • Actions
    • Trigger - Turn off (This trigger)
    • Player Group - Pick every player in (All allies of (Owner of (Killing unit)).) and do (Actions)
      • Loop - Actions
        • Player - Set the current research level of Damage Boost to 1 for (Picked player)
This runs all of the Actions in the Loop - Actions section ONCE for each player in your Player Group.
In this case your Player Group is --> All allies of (Owner of (Killing unit)).

To reference these Players you use the (Picked player) function.

So in your case, assuming Player 1 killed the unit and his allies are Players 2, 3, 4, and 5, this would happen:

Player 1 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
Player 2 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
Player 3 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
Player 4 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
Player 5 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
 
Last edited:
Level 7
Joined
Jan 11, 2022
Messages
108
You can do just about anything you can think of.

If you want the killing player's team to get the upgrade then you would use what's called a Player Group:
  • Events
    • Unit - YourUnit Dies
  • Conditions
  • Actions
    • Trigger - Turn off (This trigger)
    • Player Group - Pick every player in (All allies of (Owner of (Killing unit)).) and do (Actions)
      • Loop - Actions
        • Player - Set the current research level of Damage Boost to 1 for (Picked player)
This runs all of the Actions in the Loop - Actions section ONCE for each player in your Player Group.
In this case your Player Group is --> All allies of (Owner of (Killing unit)).

To reference these Players you use the (Picked player) function.

So in your case, assuming Player 1 killed the unit and his allies are Players 2, 3, 4, and 5, this would happen:

Player 1 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
Player 2 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
Player 3 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
Player 4 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
Player 5 gets set to the (Picked player) and then their Damage Boost upgrade gets set to level 1.
Where do you pick "(picked player)" function? Because I only have options to pick players from 1 to 12 and neutral (hostile) and neutral (passive). Was wondering if that may be a missing option because of 1.27 version or rather me being not smart enough?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
If you're on version 1.27 then you may want to use the Dummy method instead. As others have stated in earlier posts, you can't set Research back to level 0 on older versions, it doesn't work properly. However, if you don't need to reset the Research then you can keep using my method.

(Picked player) is under the Function category when you click on the Player value (same way you found Owner of Unit):
exaaa.png


If each Player's upgrade depends on their Race then you can check their Race using an If Then Else statement:
ite.png

You would check their Race and then give them the correct upgrade for that Race:
  • Actions
    • Player Group - Pick every player in (All allies of (Owner of (Killing unit)).) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Race of (Picked player)) Equal to Human
          • Then - Actions
            • Player - Set the current research level of Iron Forged Swords to 1 for (Picked player)
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Race of (Picked player)) Equal to Orc
              • Then - Actions
                • Player - Set the current research level of Steel Melee Weapons to 1 for (Picked player)
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Race of (Picked player)) Equal to Undead
                  • Then - Actions
                    • Player - Set the current research level of Unholy Strength to 1 for (Picked player)
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (Race of (Picked player)) Equal to Night Elf
                      • Then - Actions
                        • Player - Set the current research level of Strength of the Moon to 1 for (Picked player)
                      • Else - Actions
Here I'm using multiple If Then Else statements, one for each of the four Races.

If that trigger looks confusing then maybe it'll be easier to read like this:
  • Actions
    • Player Group - Pick every player in (All allies of (Owner of (Killing unit)).) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Race of (Picked player)) Equal to Human
          • Then - Actions
            • Player - Set the current research level of Iron Forged Swords to 1 for (Picked player)
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Race of (Picked player)) Equal to Orc
          • Then - Actions
            • Player - Set the current research level of Steel Melee Weapons to 1 for (Picked player)
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Race of (Picked player)) Equal to Undead
          • Then - Actions
            • Player - Set the current research level of Unholy Strength to 1 for (Picked player)
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Race of (Picked player)) Equal to Night Elf
          • Then - Actions
            • Player - Set the current research level of Strength of the Moon to 1 for (Picked player)
          • Else - Actions
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
Technically the created player group (All allies of (Owner of (Killing unit)).) is a memory leak. I know Uncle knows this and probably ignored it because it's effectively inconsequential (how many times could this trigger possibly run, lol)... but for completeness this is how you'd fix it.
  • Set TempPG = (All allies of (Owner of (Killing unit)).)
  • Player Group - Pick every player in TempPG and do (Actions)
    • Loop - Actions
      • -------- do all the stuff --------
  • Custom script: call DestroyForce(udg_TempPG) //name here must match variable name, but keep udg_ prefix
 
Status
Not open for further replies.
Top