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

"Gold on attack" trigger

Status
Not open for further replies.
Level 7
Joined
Jul 11, 2008
Messages
104
Hello, I currently have this trigger:

  • Events
    • Unit - A unit is attacked
  • Conditions
    • (Triggering Unit) Equal to Scout Tower 001 <Gen>
  • Action
    • Player - Add 1 to (Owner of (Attacking Unit)) Current Gold
My problem is, there is a bug in my map in which the player can press attack and then stop really quickly in order to get gold fast. How do I make it so that when the unit FINISHES attacking, it adds a gold?
 
You need a damage detection system:
  • One
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Custom script: set bj_wantDestoryGroup = true
    • Unit Group - Pick every unit in (Units in (Playable Map Area)) and do (Actions)
      • Loop - Actions
        • Trigger - Add to Three <gen> the event (Unit - (Picked unit) takes damage)
  • Two
  • Events
    • Unit - A unit enters (Playable Map Area)
  • Conditions
  • Actions
    • Trigger - Add to Three <gen> the event (Unit - (Triggering unit) takes damage)
  • Three
  • Events
  • Conditions
    • ((Triggering unit) Equal to Scout Tower 001 <gen>)
  • Actions
    • Player - Add 1 to (Owner of (Damage source)) Curren gold
 
Level 7
Joined
Jul 11, 2008
Messages
104
You need a damage detection system:
  • One
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Custom script: set bj_wantDestoryGroup = true
    • Unit Group - Pick every unit in (Units in (Playable Map Area)) and do (Actions)
      • Loop - Actions
        • Trigger - Add to Three <gen> the event (Unit - (Picked unit) takes damage)
  • Two
  • Events
    • Unit - A unit enters (Playable Map Area)
  • Conditions
  • Actions
    • Trigger - Add to Three <gen> the event (Unit - (Triggering unit) takes damage)
  • Three
  • Events
  • Conditions
    • ((Triggering unit) Equal to Scout Tower 001 <gen>)
  • Actions
    • Player - Add 1 to (Owner of (Damage source)) Curren gold

Say theres 4 scout towers, would it work if I just add them all into the conditions of the 3rd trigger?
 
Level 7
Joined
Jul 11, 2008
Messages
104
Something must be wrong with the script. I tried it out and it gave me an error, then this. Looks like JASS.

set i = i + 1
endloop

endfunction

function Trig_Gold_1_Func002A takes nothing returns nothing
call TriggerRegisterUnitEvent( GetTriggeringTrigger(), GetEnumUnit(), EVENT_UNIT_DAMAGED )
endfunction

function Trig_Gold_1_Actions takes nothing returns nothing
set bj_wantDestoryGroup = true
call ForGroupBJ( GetUnitsInRectAll(GetPlayableMapRect()), function Trig_Gold_1_Func002A )
endfunction

//===========================================================================
function InitTrig_Gold_1 takes nothing returns nothing
set gg_trg_Gold_1 = CreateTrigger( )
call TriggerAddAction( gg_trg_Gold_1, function Trig_Gold_1_Actions )
endfunction
 
Status
Not open for further replies.
Top