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

[Spell] Ability Doesn't Work

Status
Not open for further replies.
Level 7
Joined
Oct 3, 2014
Messages
657
This ability doesn't work. Any reasons
  • Events:
    • Unit - A unit Starts the effect of an ability
  • Conditions:
    • (Ability being cast) Equal to Execute
  • Actions:
  • -------- Setting Variables --------
  • Set Ex_Caster = (Casting Unit)
  • Set Ex_Owner = (Owner of Ex_Caster)
  • Set Ex_Location = (Position of Ex_Caster)
  • Set Ex_Target_Unit = (Targeted unit)
  • -------- Can't target ally --------
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Ex_Target_Unit belongs to an ally of Ex_Owner) Equal to True
    • Then - Actions
      • Game - Display to (All players) the text: |c00FFFF00Can't Tar...
    • Else - Actions
  • -------- Can Target Enemy --------
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Ex_Target_Unit belongs to an enemy of Ex_Owner) Equal to True
    • Then - Actions
      • -------- Instant Kill --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Percentage life of Ex_Target_Unit) Less than or equal to 30.00
        • Then - Actions
          • Unit - Make Ex_Target_Unit Explode on death
          • Floating Text - Create floating text that reads EXECUTE!! Above Ex_Target_Unit with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change the age of (Last created floating text) to 1.00 seconds
          • Wait 0.05 seconds
          • Unit - Kill Ex_Target_Unit
        • Else - Actions
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Percentage life of Ex_Target_Unit) Greater than 30.00
        • Then - Actions
          • Unit - Cause Ex_Caster to damage Ex_Target_Unit, dealing 2600.00 damage of attack type Chaos and damage type Demolition
        • Else - Actions
It should be like this:
1. Can't target ally
2. If enemy's HP is Less or equal to 30% it will instantly kill that unit
3. If enemy's HP is Greater than 30% it will take (Value) damage
 
Level 25
Joined
Sep 26, 2009
Messages
2,377
First of all, were you manually writing here the whole trigger? Because I don't remember the option "Targeted unit". For casting events the target is:
  • Set Ex_Target_Unit = (Target unit of ability being cast)
Does the ability work correctly when used on ally? (Does it write game message?)
Does the unit take damage when it has more than 30% health? Or not?

---------
To copy trigger, simply right-click on the name of the trigger in the actions window (not in the trigger-tree window!) and click "copy as text". This way you copy the whole trigger. For example in the trigger below:
  • TriggerName
  • Events
    • some event
  • Conditions
    • some conditions
  • Actions
    • some actions
right-click the icon here:
  • TriggerName
and choose "copy as text". Nowhere else.
 
Level 7
Joined
May 11, 2010
Messages
278
1. You are leaking ExLocation. At the end of your trigger, use this script to remove the leak:
  • Custom script: call RemoveLocation(udg_Ex_Location)
2. "Target unit belongs to an enemy of player = true" - this will make it so that you only can target enemy player units, no neutral units. This might be the reason it "doesn't work". Use "belongs to an ally of player = false" instead. You will still be unable to target allies, but you will be able to target anything that is not allied.
3. You are using a wait. Please don't do that. What's even the point of waiting 0.05 seconds? It's such a small period of time that it won't be noticable.
4. Because of the wait, this spell is not MUI. If another unit casts the spell while the wait is active, the first cast of the spell will break.

Also, it would be great if you could tell us exactly what part of it doesn't work.
A great way to test what's wrong is to add "game - display message" at certain points in the trigger, like
  • Game - Display to (All players) the text: (Name of Ex_Caster)
  • Game - Display to (All players) the text: (Name of Ex_Target_Unit)
put this just above your "can't target allies" comment and check if it returns the correct units.
Use game messages that display different pieces of information to check different aspects of the trigger.
 
Level 7
Joined
Oct 3, 2014
Messages
657
Nichilus said:
First of all, were you manually writing here the whole trigger? Because I don't remember the option "Targeted unit".
There is the (Event Response: Targeted Unit)

Nichilus said:
1. Does the ability work correctly when used on ally? (Does it write game message?)
2. Does the unit take damage when it has more than 30% health? Or not?
1. It doesn't do anything and no Messages
2. No damages or floating texts

Nichilus said:
To copy trigger, simply right-click on the name of the trigger in the actions window (not in the trigger-tree window!) and click "copy as text".
Then what must I do?
 
Level 7
Joined
May 11, 2010
Messages
278
How to easily post triggers

I'm fairly sure you can't use "Event Response: Targeted Unit" in this case. Use "Event Response: Target unit of ability being cast" instead.
Also, add some test messages at different points in the trigger, see what parts of it doesn't run. I'd suggest putting messages by the following functions:

*At the very start of the trigger to make sure it fires at all.

*the ones i suggested earlier to make sure the units are set correctly.

*The "else" bracket of the "is target ally = true" conditional.

*The "else" bracekt of the suggested "is target ally = false" conditional. (change from "is target enemy =true" -> "is target ally = false" as i suggested before)

*one in both the "then" and "else" brackets of the "is hp below 30%" conditional.

*one in both the "then" and "else" brackets of the "is hp above 30%" conditional.

If you put messages at these points and look what is output you an fairly easily see exactly what part of the trigger doesn't work.
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,377
There is the (Event Response: Targeted Unit)
Can't access WE now, so I couldn't make sure. But I do think the response "target unit of ability being cast" is the only one correct here.

1. It doesn't do anything and no Messages
2. No damages or floating texts
This seems to prove my point about the event response even more, as the trigger should do one or the other. There's nothing complex about your trigger.

Then what must I do?
Once you have copied the trigger as text, simply paste it between [TRIGGER][/TRIGGER] tags.
You did copy and paste it in the [TRIGGER][/TRIGGER] already in the first post, but due to how the actions are ordered, it seems you've been copying and pasting only parts of the trigger instead of the whole trigger. It's just to make your life easier.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Sorry if what I said has already been said before but I am too lazy to read everything that other people posted :D No offense

First of all the targeting:
You should be able to filter enemy units in the object editor as targets allowed as much as you can (unless you choose not to do that for any reason)
But if you cannot or dont want to then make a trigger similar to this:
Event: A unit starts channeling an ability
Condition: Ability being cast equal to (...)
Action: If targeted unit of ability being cast is ally of player of casting unit equal to false
Then order casting unit to "stop" and display message to owner of casting unit.

(If you already register all data of spells in the trigger editor, you can as well put the condition in there and make a dynamic trigger that does the condition of the casting of the spell)

For the actual effect of the ability, you can always use starts casting or starts the effect
In this case you do something like this:
Event: A unit starts the effect of an ability
Condition: Ability being cast equal to (...)
Action:
If (health percentage of targeted unit is lower than 30) then
Deal damage (current life of targeted unit) to targeted unit of type universal (for the killing event)
Else
Deal damage (value) to targeted unit

Should do the trick
 
Status
Not open for further replies.
Top