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

Unit Revival System

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
Hello, I am trying to make a unit revival system for each player. There is a shop which sells "companions" which each hero may have 1 of at a time. When the companion dies, it is revived after 5 seconds. However the text message and SPX is displayed, but no unit is created. Here is my trigger

  • Revive Companion
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to Forest Troll High Priest
          • (Unit-type of (Dying unit)) Equal to Red Dragon
          • (Unit-type of (Dying unit)) Equal to Goblin Shredder
          • (Unit-type of (Dying unit)) Equal to Goblin Zeppelin
          • (Unit-type of (Dying unit)) Equal to Bronze Dragon
    • Actions
      • Set Companion_Owner[(Player number of (Owner of (Dying unit)))] = (Owner of (Dying unit))
      • Game - Display to (All players matching ((Matching player) Equal to (Owner of (Dying unit)))) for 5.00 seconds the text: Your Companion will...
      • Wait 5.00 seconds
      • Unit - Create 1 (Unit-type of (Dying unit)) for Companion_Owner[(Player number of (Owner of (Dying unit)))] at Revive_Companion facing Default building facing degrees
      • Special Effect - Create a special effect at Revive_Companion using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
      • Special Effect - Destroy (Last created special effect)
I noticed if I didn't use a wait line of code, the trigger worked. I even used a countdown timer and used a wait condition action to wait for the countdown timer to reach 0. It still showed the same results as a normal wait action. Can somebody please tell me why the wait function is not working, and a work-around? Thanks.
 
Level 12
Joined
Aug 12, 2008
Messages
349
If you're going to apply the system to more than 1 player, definitely you need to eliminate the "Wait". Within the 5 seconds, any units that dies will consider the "dying unit" and that's why it will bug when another unit dies within the 5 seconds.
In order to make it works. I suggest storing it into variable and when the companion is dead, just like applying indexing on spells to make it MUI/MPI.
Here is the triggers that would work if only each player can only has one companion. I've tried it. :)

[trigger=Companion is dead]Companion is dead
Events
Unit - A unit Dies
Conditions
... Add your own conditions
Actions
Set companionDeadCount = (companionDeadCount + 1)
Set tempInteger = (Player number of (Owner of (Triggering unit)))
Set reviveTime[(Player number of (Owner of (Triggering unit)))] = 5
Set companionType[tempInteger] = (Unit-type of (Triggering unit))
Set isDead[tempInteger] = True
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
companionDeadCount Equal to 1
Then - Actions
Trigger - Turn on Revive a companion <gen>
Else - Actions
[/trigger]
[trigger=Revive Companion loop]Revive a companion loop
Events
Time - Every 1.00 seconds of game time
Conditions
Actions
For each (Integer tempInteger) from 1 to (...Your number of players), do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
isDead[tempInteger] Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
reviveTime[tempInteger] Equal to 0
Then - Actions
Set tempPoint = (Center of (Playable map area))
Unit - Create 1 companionType[tempInteger] for (Player(tempInteger)) at tempPoint facing Default building facing degrees
Special Effect - Create a special effect at tempPoint using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
Special Effect - Destroy (Last created special effect)
Custom script: call RemoveLocation (udg_tempPoint)
Set isDead[tempInteger] = False
Set companionDeadCount = (companionDeadCount - 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
companionDeadCount Equal to 0
Then - Actions
Trigger - Turn off (This trigger)
Else - Actions
Else - Actions
Set reviveTime[tempInteger] = (reviveTime[tempInteger] - 1)
Else - Actions
[/trigger]
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Use this trigger instead, short and simple.

  • Revive System
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Forest Troll High Priest
          • (Unit-type of (Triggering unit)) Equal to Red Dragon
          • (Unit-type of (Triggering unit)) Equal to Goblin Shredder
          • (Unit-type of (Triggering unit)) Equal to Goblin Zeppelin
          • (Unit-type of (Triggering unit)) Equal to Bronze Dragon
    • Actions
      • Custom script: local unit udg_DyingUnit
      • Set DyingUnit = (Triggering unit)
      • Wait 5.00 seconds
      • Unit - Create 1 (Unit-type of DyingUnit) for (Triggering player) at Revive_Companion facing Default building facing degrees
      • Custom script: set udg_DyingUnit = null
Make sure you create a variable of Unit named "DyingUnit"

The custom script you have to follow the exact detail of the writing, it is case sensitive.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I am using local variable, local variable works MUI as I set it at first (custom script)

Also, (Triggering Unit) works MUI if you do not set it as variable, it is native function so it will work for all units without bugging it.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Okay...I tried both of your methods. The first didnt actually wait at all, and the second only worked without the wait function.
My map is a hero defence game. I've decided to make the Companions spawn at the conclusion of each round. I've decided this suits my game better, and there will be no need for a wait function. Sorry to confuse you guys.

I've been working on this for over an hour an a half, getting frustrating :/ I've attached the map if anybody can solve it for me. There are lots of units to kill some dragons (companions) that I placed on the map for testing purposes. I would be highly appreciative if anyone could help.
 

Attachments

  • Mini Gunners Ultimate.w3x
    87.3 KB · Views: 35
Status
Not open for further replies.
Top