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

trigger help needed

Status
Not open for further replies.
Level 20
Joined
Nov 20, 2005
Messages
1,178
I'd like to run a trigger when a unit is killed but it uses its reincarnation ability to resurrect(hence it's not truly killed), how to do it?
If i use as an event "a unit is killed" and/or as a condition "number of "this unit" owned by player is equal to 0" it will run after the unit is killed the second time(hence true death) but i want it to run the first time it's dead, so that it can get back to life while the trigger goes on. Any help on how to do it?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Instead of making a trigger for it why don't you add him the reincarnation ability?
He said he wants a trigger that runs when the Reincarnation ability is active.

The only way I know of to get this is to use Event to register the instant the unit's hit points drop below zero, because there is no Unit-Dies event for the Reincarnation ability.

A cheapshot way to do this is to give him an Ankh of Reincarnation... you can detect "unit - a unit uses an item" for the ankh...
 
Level 20
Joined
Nov 20, 2005
Messages
1,178
He said he wants a trigger that runs when the Reincarnation ability is active.

The only way I know of to get this is to use Event to register the instant the unit's hit points drop below zero, because there is no Unit-Dies event for the Reincarnation ability.

A cheapshot way to do this is to give him an Ankh of Reincarnation... you can detect "unit - a unit uses an item" for the ankh...

heeyyyyy you're right! :D i didn't think about the ankh. Maybe i'll try with that(i think i already tried the "if unit's life is below x do action" but without success)
 
Level 9
Joined
Nov 28, 2008
Messages
704
You could always manuually trigger the resurrection.

Failing that, does a "unit dies" event fire if something with res dies? If it does, just start waiting after it dies, and check every second or so if it has any life. At that point, you can say that res fired and then trigger something.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Failing that, does a "unit dies" event fire if something with res dies?
Not even the slightest. There's an event to detect when hp reaches a specified amount; problem is, this incredibly overcomplicates things that should have been a simple Unit Finishes Casting; Ability being cast == Reincarnation.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Add Event 1
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Temp_Group_1 = (Units in (Playable map area) matching ((Level of Reincarnation for (Matching unit)) Greater than 0))
      • Unit Group - Pick every unit in Temp_Group_1 and do (Actions)
        • Loop - Actions
          • Trigger - Add to Death Detection <gen> the event (Unit - (Picked unit)'s life becomes Less than (0.41 - 0.05))
      • Custom script: call DestroyGroup(udg_Temp_Group_1)
  • Add Event 2
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Reincarnation
    • Actions
      • Trigger - Add to Death Detection <gen> the event (Unit - (Triggering unit)'s life becomes Less than (0.41 - 0.05))
  • Death Detection
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: True
The first two triggers makes all units with Reincarnation to work with the third trigger. The third trigger fires when the unit dies, it will go off even if you have Reincarnation.

Then you can play around with booleans to check whether it is the first or second time. You may also need a timer to know whether the ability is on cooldown or not. If you need help with those things, post in this thread and I'll help.
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
If you want to use the item, yes. "Unit Uses Item" + "Item Being Manipulated == Ankh" will be one trigger and you just put the actions in this one trigger.

@Maker, you need World Editor Unlimited or Jass NewGen to add events to triggers like that. If you're doing that in World Editor, you'll need the custom script.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
@Maker, you need World Editor Unlimited or Jass NewGen to add events to triggers like that. If you're doing that in World Editor, you'll need the custom script.

I think it should be

  • Trigger - Add to Death Detection <gen> the event (Unit - (Triggering unit)'s life becomes Less than or equal to (0.41 - 0.05))
But what do you mean you need JNGP? Normal WE can add those event also.
 
Last edited:
  • Slow Debuff
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(slow))
    • Actions
      • Wait until (((Target unit of issued order) has buff Slow) Equal to True), checking every 0.50 seconds
      • Unit - Remove Slow buff from (Target unit of issued order)
This is inefficient, but it depends on what you want it for.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Yeah if you want a special effect you're going to have to do that yourself; I hate working with effects.

  • Slow Debuff
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(slow))
    • Actions
      • Wait for 2.00 seconds
      • Unit - Remove Slow buff from (Target unit of issued order)
This is inefficient, but it depends on what you want it for.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
^Not MUI, target unit of ability being cast isn't local.

I'd do it like this:


  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Slow_Hash = (Last created hashtable)
  • Cast Slow
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(slow))
    • Actions
      • Unit Group - Add (Target unit of issued order) to Slow_Cancel
      • Hashtable - Save 2.00 as (Key timer) of (Key (Target unit of issued order)) in Slow_Hash
      • Trigger - Turn on Remove Slow <gen>
  • Remove Slow
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Slow_Cancel and do (Actions)
        • Loop - Actions
          • Set Temp_Real_1 = (Load (Key timer) of (Key (Picked unit)) from Slow_Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Real_1 Greater than 0.00
              • (Temp_Unit_1 is alive) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Temp_Unit_1 has buff Slow) Equal to True
                • Then - Actions
                  • Hashtable - Save (Temp_Real_1 - 0.25) as (Key timer) of (Key (Picked unit)) in Slow_Hash
                • Else - Actions
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Slow_Hash
              • -------- ---------------------------------------- --------
              • Unit - Remove Slow buff from (Picked unit)
              • -------- ---------------------------------------- --------
              • Unit Group - Remove (Picked unit) from Slow_Cancel
              • -------- ---------------------------------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Slow_Cancel is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 

Attachments

  • Remove Slow [2 sec].w3x
    17.7 KB · Views: 22

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Erm, why use such complex Hashtables when you can just use

  • Slow Debuff
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability Being Cast) Equal to (Slow)
    • Actions
      • Custom script: local unit u = GetSpellTargetUnit()
      • Wait for 2.00 seconds
      • Custom script: call UnitRemoveAbility( u , 'Bslo' )
 
Last edited:
Status
Not open for further replies.
Top