An artist's depiction of an Extended Unit Death
Alright, let me just say that this would be much, much better handled in the Data Editor (especially enabling/disabling the ability). However, my experience in the Data Editor is limited.
Here is how you would implement the revive system using triggers only:
Trigger Revive System
Initialization
Events
Game - Map initialization
Local Variables
Conditions
Actions
Unit Group - Pick each unit in ((Unit type of My_Revive_Building) units in (Entire map) owned by player (Owner of (Triggering unit)) matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Unit - Disable the My_Custom_Ability ability for (Picked unit)
Variable - Set PlayerHero[1] = Player1_Hero_Unit
Variable - Set PlayerHero[2] = Player2_Hero_Unit
Variable - Set PlayerHero[3] = Player3_Hero_Unit
Adds all heroes to a Unit array global variable. The array size should be the number of players that have units.
HeroDies
Events
Unit - Any Unit dies
Local Variables
Conditions
(Unit type of (Triggering unit)) == My_Hero_Unit
Actions
Unit Group - Pick each unit in ((Unit type of My_Revive_Building) units in (Entire map) owned by player (Owner of (Triggering unit)) matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Unit - Enable the My_Custom_Ability ability for (Picked unit)
When a hero dies, it enables the ability for all revive buildings for that player.
ReviveHero
Events
Unit - Any Unit uses My_Custom_Ability at Generic1 - Any stage (Ignore shared abilities)
Local Variables
ReviveCost = ((Experience level of PlayerHero[(Owner of (Triggering unit))]) * 250) <Integer>
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Player 1 has at least ReviveCost and at least 0) == true
Then
Player - Modify player (Owner of (Triggering unit)) Minerals: Subtract ReviveCost
Unit Group - Pick each unit in ((Unit type of My_Revive_Building) units in (Entire map) owned by player (Owner of (Triggering unit)) matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Unit - Disable the My_Custom_Ability ability for (Picked unit)
Unit - Revive PlayerHero[(Owner of (Triggering unit))]
Unit - Move PlayerHero[(Owner of (Triggering unit))] instantly to (Start location of player (Owner of (Triggering unit))) (No Blend)
Else
------- Cannot Afford Revive; maybe display an error here
The player casts the ability to revive the hero. If the player can afford it, it will revive the hero and position the hero at the player's start location. The ability will also become disabled. If the player cannot afford the revive, nothing will happen.
As you can see, it's a little hacked together and it's possible for some of it to become out-of-sync from other triggers or game events. There is no way (that I know) to change the cost of an ability through triggers.
The ability's enable/disable would be much better handled using a requirement through the Data Editor. I discuss how to create a requirement for an upgrade in
this thread.
Making Requirement, Applying it to an Ability
Part 3: Adding RequirementsOpen the Requirements tab in the Data Editor.
1. Right-click anywhere in the list. Select "Add Requirement..."
2. Name the requirement to what you want. Select the Race you want and Tech Type "Upgrade."
3. Double-click "Requirement - Node Link." A dialog will appear.
4. Insert conditions for making the upgrade display.
- The "Use" is the conditions to be met when the player is allowed to start researching the upgrade (ex. Tech-Tree requirement like "Owns a Barracks").
- The "Show" is the conditions to be met when a player can see the upgrade (ex. Show "Protoss Shields Level 2" if "Protoss Shields Level 1" is queued or better and "Protoss Shields Level 2" is not queued or better).
Part 4: Adding the Upgrade to an AbilityJust going into a quick example for this.
1. Look for the ability to which you want to apply the upgrade (ex. "Engineering Bay - Research") (You can make your own ability if you want).
2. Click on it and find "Ability - Info - Upgrade." Double-click to open a dialog.
3. Choose an empty research space and double-click it. Another dialog will open.
4. At the top, you can choose a default button.
5. If you have a requirement, set the button state to restricted. Find your requirement in the "Info - Button - Requirements" and select it.
6. Scroll down in the dialog until you reach the bottom. Select your upgrade in the "Info - Upgrade" section.
Your requirement would want to have a use condition to check if the player owns 0 of his hero unit. It would look like this:
My_Custom_Requirement
Use
And
Count Unit Hero_Unit In Progress or Better
Constant 0
Show
That would handle the graying out for you, and you wouldn't have to trigger it.
The cost could probably be handled better in the Data Editor as well. Maybe instead of basing the revive on an ability, you should base it off of constructing a unit. Hopefully Cardinal or one of the other Data Editor gurus will provide more information as to how to implement this entire system through the Data Editor, because my personal knowledge is insufficient.
Post has been edited 1 time(s), last time on Feb 20 2011, 6:47 pm by Roy.