• 🏆 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] How to make the correct emergence of unit(1) at the place of death of unit(2)?

Status
Not open for further replies.
Level 2
Joined
Apr 27, 2022
Messages
6
I want to make a unit(1) in a given rect. If you kill him, then a unit (2) with a certain animation appears in his place.
The appearance of unit (1) works, but for some reason the conditions for the appearance of unit (2) do not want to work in case of the death of unit (1).
I tried different ways, but nothing comes out.
Help me figure out how to do this?
  • Spawn boss
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Unit - Create 1 TEST_UNIT for Neutral Extra at (Center of Boss spawn <gen>) facing Default building facing (270.0) degrees
      • Animation - Play (Last created unit)'s stand channel animation
        • Do Multiple ActionsFor each (Integer A) from 1 to 10, do (Actions)
          • Loop - Actions
            • Custom script: (exitwhen (TEST_UNIT_INTEGER Equal to (==) 0))
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Last created unit) Equal to (==) (Dying unit)
                • Then - Actions
                  • Set TEST_UNIT_INTEGER = 0
                • Else - Actions
                  • Set TEST_UNIT_INTEGER = 1
        • Do Multiple ActionsFor each (Integer A) from 1 to 10, do (Actions)
          • Loop - Actions
            • Custom script: (exitwhen (TEST_UNIT_INTEGER Equal to (==) 1))
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TEST_UNIT_INTEGER Equal to (==) 0
                • Then - Actions
                  • Unit - Create 1 Lootbox for Neutral Passive at (Position of (Dying unit)) facing Default building facing (270.0) degrees
                  • Animation - Play (Last created unit)'s Birth animation
                  • Set TEST_UNIT_INTEGER = 1
                • Else - Actions
                  • Set TEST_UNIT_INTEGER = 2
 
From the trigger event itself, I doubt that it will run when a unit dies. Even if the right event is used, there's no way normally for TEST_UNIT_INTEGER to be 0 (unless bj_lastCreatedUnit is used explicitly and assigned to the dying unit).

First, you'll have to change the event to a generic unit event (A unit dies). Then, you filter out the type of your dying unit (you can use triggering unit as well) in your trigger conditions tab and proceed with the following:
  • Assign the position of the dying unit to a location variable
  • Create the secondary unit.
  • (Optional: Use custom script and copy-paste the following lines:
JASS:
call SetUnitX(<your_unit>, GetLocationX(<your_loc>))
call SetUnitY(<your_unit>, GetLocationY(<your_loc>))
- Clean up the generated location handle by using the following script:
call RemoveLocation(<your_loc>)
 
Level 2
Joined
Apr 27, 2022
Messages
6
Thanks. Now everything works. I created a separate trigger with the event (A unit dies) and specified the condition (Unit-type of (Dying unit)) Equal to (==) TEST_UNIT). In the action, I indicated the creation of a unit in the position of a dying unit, which is TEST_UNIT.
 
Status
Not open for further replies.
Top