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

damage source is the unit being attacked?

Status
Not open for further replies.
Level 5
Joined
Aug 19, 2015
Messages
68
Hey guys,
I have this trigger to give lumber on attack.
But it also gives lumber when the "damage source" is being attacked.
  • onhit vamps
    • Events
    • Conditions
    • Actions
      • Set aantileak_unit = (Damage source)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • aantileak_unit Equal to Heiress 0015 <gen>
        • Then - Actions
          • Player - Add (Integer((150.00 + ((Damage taken) / 50.00)))) to valwinner Current lumber
          • Hero - Add (Integer((25.00 + ((Damage taken) / 34.00)))) experience to Heiress 0015 <gen>, Show level-up graphics
        • Else - Actions
      • Custom script: set udg_aantileak_unit = null

  • init enemies
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Set aantileak_unittype = (Unit-type of (Entering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • aantileak_unittype Equal to Gold supplier
        • Then - Actions
          • Set gsupp = (Entering unit)
          • Trigger - Add to onhit goldsupplier <gen> the event (Unit - (Entering unit) Takes damage)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • aantileak_unittype Equal to Vampire
              • aantileak_unittype Equal to Vampire Minion
        • Then - Actions
          • Trigger - Add to onhit vamps <gen> the event (Unit - (Entering unit) Takes damage)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • aantileak_unittype Equal to Vampiric Stun Tower
        • Then - Actions
          • Trigger - Add to onhit vamptowers <gen> the event (Unit - (Entering unit) Takes damage)
        • Else - Actions

How to do it properly?
Thanks.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
First of all, making a DDS that way is bad because it leaks a Trigger Event meaning after the unit dies/removed, the event is still there. Second, units initially on the map are not added if they have a 'Vampire' unit type. This won't matter if your map has no units initially.
Now to fix your DDS, you need to periodically (i.e
every 60 sec) 'refresh' the onhitvamps. By 'refresh' I meant destroying and re-creating the onhitvamps trigger to remove all its Events. When re-creating, pick all units in the map and if the condition is true, add them to the Event via
'Trigger - Add to onhit ... the event a (Picked Unit) takes damage'

Now for your problem, you didn't set the valwinner variable.
 
Status
Not open for further replies.
Top