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

Is there possible to make a trigger that creates unit after dying from spell?

Status
Not open for further replies.
Level 1
Joined
Oct 6, 2017
Messages
3
Hello, I want to make a trigger that creates unit when he dies from spell. I tried to make something like this, but it didn't work.
base.gif
Save soul
  • joinminus.gif
    events.gif
    Events
    • line.gif
      joinbottom.gif
      unit.gif
      Unit - A unit Dies
  • joinminus.gif
    cond.gif
    Conditions
    • line.gif
      joinbottom.gif
      if.gif
      (Dying unit) Equal to (Target unit of ability being cast)
    • line.gif
      joinbottom.gif
      if.gif
      (Ability being cast) Equal to Save soul
  • joinbottomminus.gif
    actions.gif
    Actions
    • line.gif
      joinbottom.gif
      unit.gif
      Unit - Create 1 (Unit-type of (Dying unit)) for Neutral Passive at (Center of Region 000 <gen>) facing Default building facing degrees
    • line.gif
      joinbottom.gif
      unitgroup.gif
      Unit Group - Add (Last created unit) to Souls
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
In that case no because "Target unit of ability being cast" and "Ability being cast" only responds for spell events, your option is use a Damage Engine (you have to search it, I don't know what is your version) that detect if the unit is damaged for that spell, but the problem is that not difference the spell, just the damage, so you also have to create another trigger to detect if the cause is that spell, so it would be like this:
  • Events
    • Unit - A unit begins the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Save soul
  • Actions
    • Set "Your boolean" = True
  • Events
    • Game - DamageEvent becomes equal to 1.00
  • Conditions
    • DamageType Equal to Spell
    • "Your boolean" Equal to True
  • Actions
    • Set "Your boolean" = False
    • If all (Conditions) are true then do (Actions) else do (Actions)
      • If - Conditions
        • DamageAmount Greater than (Current live of DamageTarget)
      • Then - Actions
        • Set Temp_Loc = (Center of Region 000 <gen>)
        • Unit - Create 1 (Unit-type of (Dying unit)) for Neutral Passive at Temp_Loc facing Default building facing degrees
        • Custom script: call RemoveLocation(udg_Temp_Loc) This is to prevent memory leak
        • Unit Group - Add (Last created unit) to Souls
      • Else - Actions
 
Here's a spell I made recently for an ability that kills a target unit and creates a temporary copy. This ability one shots the target, so I don't know if that's what you want.

  • Spectre
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spectre
    • Actions
      • Set VariableSet Temp_loc = (Position of (Target unit of ability being cast))
      • Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing 99999.00 damage of attack type Spells and damage type Magic
      • Unit - Create 1 (Unit-type of (Target unit of ability being cast)) for (Owner of (Casting unit)) at Temp_loc facing (Facing of (Target unit of ability being cast)) degrees
      • Unit - Disable supply usage for (Last created unit).
      • Unit - Add a 45.00 second Generic expiration timer to (Last created unit)
      • Unit - Add classification of Summoned to (Last created unit)
      • Animation - Change (Last created unit)'s vertex coloring to (50.00%, 50.00%, 100.00%) with 70.00% transparency
      • Special Effect - Create a special effect attached to the chest of (Last created unit) using Abilities\Spells\Items\AIil\AIilTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_Temp_loc)
 
@Footman16 that will depend if he wanna kill that unit with 1 shot or not and the unit not necessarly dies.

This ability one shots the target, so I don't know if that's what you want.

I know, until he says exactly what it is he wants I thought I'd give him an example. Another way to do it without a DDS would be using buffs I think.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,534
In that case no because "Target unit of ability being cast" and "Ability being cast" only responds for spell events, your option is use a Damage Engine (you have to search it, I don't know what is your version) that detect if the unit is damaged for that spell, but the problem is that not difference the spell, just the damage, so you also have to create another trigger to detect if the cause is that spell, so it would be like this:
  • Events
    • Unit - A unit begins the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Save soul
  • Actions
    • Set "Your boolean" = True
  • Events
    • Game - DamageEvent becomes equal to 1.00
  • Conditions
    • DamageType Equal to Spell
    • "Your boolean" Equal to True
  • Actions
    • Set "Your boolean" = False
    • If all (Conditions) are true then do (Actions) else do (Actions)
      • If - Conditions
        • DamageAmount Greater than (Current live of DamageTarget)
      • Then - Actions
        • Set Temp_Loc = (Center of Region 000 <gen>)
        • Unit - Create 1 (Unit-type of (Dying unit)) for Neutral Passive at Temp_Loc facing Default building facing degrees
        • Custom script: call RemoveLocation(udg_Temp_Loc) This is to prevent memory leak
        • Unit Group - Add (Last created unit) to Souls
      • Else - Actions
The issue with this design is the fact that ANY unit/spell could deal spell damage while "Your boolean" is True. I suppose if you use the Event "A unit STARTS the effect of an ability" and the spell is instant like Frost Nova then this would work without issues since there'd be no gap between setting the Boolean to True and dealing the damage. Otherwise, you're leaving room for error.

A decent solution to this is to create a unique Dummy unit that's used exclusively for this spell. Then you replace the Hero's "Save Soul" ability with a "fake" version of it that has no effects besides mana cost/cooldown/tooltip/etc... Then whenever the Hero casts the "Fake Save Soul" ability you create the new Dummy unit and order it to cast the REAL Save Soul ability on the target. Finally, in your DamageEvent trigger you check to see if "Unit-type of DamageEventSource Equal to Save Soul Dummy", and since this Dummy is used exclusively for this effect you'll know for a fact that you've detected the correct source of damage. The only issue here is that the Killing Unit will be equal to the Dummy unit instead of the casting Hero, but there's solutions to that such as linking the Dummy to the Caster and then designing your On Kill triggers around this.
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
The issue with this design is the fact that ANY unit/spell could deal spell damage while "Your boolean" is True. I suppose if you use the Event "A unit STARTS the effect of an ability" and the spell is instant like Frost Nova then this would work without issues since there'd be no gap between setting the Boolean to True and dealing the damage. Otherwise, you're leaving room for error.
I know that, I admit I was too reductionist but I don't wanna do that too complicated if this guy wanna solve his problem, so I am sorry.
A decent solution to this is to create a unique Dummy unit that's used exclusively for this spell. Then you replace the Hero's "Save Soul" ability with a "fake" version of it that has no effects besides mana cost/cooldown/tooltip/etc... Then whenever the Hero casts the "Fake Save Soul" ability you create the new Dummy unit and order it to cast the REAL Save Soul ability on the target. Finally, in your DamageEvent trigger you check to see if "Unit-type of DamageEventSource Equal to Save Soul Dummy", and since this Dummy is used exclusively for this effect you'll know for a fact that you've detected the correct source of damage. The only issue here is that the Killing Unit will be equal to the Dummy unit instead of the casting Hero, but there's solutions to that such as linking the Dummy to the Caster and then designing your On Kill triggers around this.
This is a better solution and he doesn't need use the damage event, so the trigger would be (you must have the dummy done):
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to "Fake Save soul"
  • Actions
    • Set Temp_Loc = (Position of (Casting unit))
    • Unit - Create 1 "Dummy Unit" for (Owner of (Casting unit)) at Temp_Loc facing (Facing of (Target unit of ability being cast)) degrees
    • Custom script: call RemoveLocation(udg_Temp_Loc)
    • Unit - Add a "The necessary time" second Generic expiration timer to (Last created unit)
    • Unit - Hide (Last created unit)
    • Unit - Order (Last created unit) "Base ID of the Save soul" to (Target unit of ability being cast)
  • Events
    • Unit - A unit dies
  • Conditions
    • (Unit-Type of (Killing Unit)) Equal to "Dummy Unit"
  • Actions
    • Set Temp_Loc = (Center of Region 000 <gen>)
    • Unit - Create 1 (Unit-type of (Dying unit)) for Neutral Passive at Temp_Loc facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_Temp_Loc)
    • Unit Group - Add (Last created unit) to Souls
Just don't use that Dummy Unit for anything else.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,534
Good point, I overlooked the fact that the Dummy made the Damage Engine unnecessary.

Some minor things though and you're probably aware of this but I figured I'd mention it anyway. I don't think Hiding the Dummy does anything. Also, you can change Owner of Casting unit to Triggering Player (minor optimization) and just to clarify again you want to use "A unit STARTS the effect of an ability" as the Event, not Begins.
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
Good point, I overlooked the fact that the Dummy made the Damage Engine unnecessary.

Some minor things though and you're probably aware of this but I figured I'd mention it anyway. I don't think Hiding the Dummy does anything. Also, you can change Owner of Casting unit to Triggering Player (minor optimization) and just to clarify again you want to use "A unit STARTS the effect of an ability" as the Event, not Begins.
Ok I see, just I don't know how it is writen in english, and hide the dummy makes look the principal caster is who cast the ability.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,534
I never heard about that, what is that?
The Locust units that are created by the Crypt Lord's ultimate have an ability called Locust which makes them unselectable/uncommandable. However, you can still issue orders to them through triggers.

So to create a Dummy unit, you want to copy and paste a Locust unit and modify some unit settings:

1) Set their model to an empty custom path, like "none" for example (you can write anything that isn't a real model path) then the unit will have no Model. You can also use a custom Dummy model like Vexorians (I attached the file below) which has Attachment points and is recommended if you want everything to work properly.

2) Turn off their Shadow, disable their Attack, set their Movement Type to None, and Speed Base to 0.

From there you should be good to go.
 

Attachments

  • dummy.mdx
    34.2 KB · Views: 45
Level 24
Joined
Jun 26, 2020
Messages
1,852
The Locust units that are created by the Crypt Lord's ultimate have an ability called Locust which makes them unselectable/uncommandable. However, you can still issue orders to them through triggers.

So to create a Dummy unit, you want to copy and paste a Locust unit and modify some unit settings:

1) Set their model to an empty custom path, like "none" for example (you can write anything that isn't a real model path) then the unit will have no Model. You can also use a custom Dummy model like Vexorians (I attached the file below) which has Attachment points and is recommended if you want everything to work properly.

2) Turn off their Shadow, disable their Attack, set their Movement Type to None, and Speed Base to 0.

From there you should be good to go.
I see.
 
Level 1
Joined
Oct 6, 2017
Messages
3
Sorry for asking, how is this trigger called
unit.gif
Unit - Order (Last created unit) "Base ID of the Save soul" to (Target unit of ability being cast)? Issue an order targeting a unit? If true then Base ID of the Save soul is effect or what?
 
Status
Not open for further replies.
Top