• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Problem with event (Unit takes damage)

Status
Not open for further replies.
Level 1
Joined
Dec 3, 2012
Messages
2
Hi, I'm trying to make a spell that you use in a unit and mark that unit. Every time you attack that unit you receive a bonus damage.
Those are my triggers.
  • Mark of Death
  • Events
    • Unit - A unit begins casting an ability
  • Conditions
    • (Ability being cast) Equal to Mark of Death
  • Actions
    • Set MarkofDeath_caster = (Triggering unit)
    • Set MarkofDeath_unit = (Target unit of ability being cast)
    • Trigger - Add to Mark of Death attack <gen> the event (Unit - MarkofDeath_unit Takes damage)
    • Wait 6.00 seconds
    • Set MarkofDeath_caster = No unit
    • Set MarkofDeath_unit = No unit
  • Mark of Death attack
  • Events
  • Conditions
    • (Damage source) Equal to MarkofDeath_caster
  • Actions
    • Unit - Create 1 Dummie for (Owner of MarkofDeath_caster) at (Position of MarkofDeath_unit) facing Default building facing degrees
    • Unit - Add 1 second Generic expiration timer to (Last created unit)
    • Unit - Cause (Last created unit) to damage MarkofDeath_unit dealing 70.00 damage of attack type Hero and damage type Normal
The problem is: every time I use the spell it adds another event to the second trigger and when I attack the unit, it runs the trigger twice, then 3 times and so on.
If someone knows how to fix it please help me.
sorry my English is not very good.
 

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
U should import the Damage Detection system or the Damage Engine system to detect when the damage is dealed by u or any other source. Also, I think u should add the caster into the unit group, when the target takes damage (which will be detected by the above system), u can check whether the damage source is ur unit or not.
Edit: Rule!!! Why can u be faster than me >.<?
 
Although you say the trigger works fine already, I still have a suggestion.

Since what triggers the second trigger is the MarkofDeath_unit taking damage, then an action in the trigger deals damage to the MarkofDeath_unit, it will create an infinite loop of actions. What you could do is turn the trigger off at the start of the trigger, then turn it on again; like this:
  • Mark of Death attack
    • Events
    • Conditions
      • (Damage source) equal to MarkofDeath_caster
    • Events
      • Trigger - Turn off (this trigger)
      • Set MarkofDeath_Point = (Position of MarkofDeath_unit)
      • Unit - Create 1 Dummie for (Owner of MarkofDeath_caster) at MarkofDeath_Point facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_MarkofDeath_Point)
      • Unit - Add 1 second Generic expiration timer to (Last created unit)
      • Unit - Cause (Last created unit) to damage MarkofDeath_unit dealing 70.00 damage of attack type Hero and damage type Normal
      • Trigger - Turn on (this trigger)
Also, you have a leak; but the trigger I showed you fixes the leak, and hopefully any other problems.
 
Status
Not open for further replies.
Top