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

a script to show damage

Status
Not open for further replies.
Level 2
Joined
Dec 28, 2010
Messages
21
Code:
globals
trigger  gg_trg_b =null
trigger  gg_trg_a = null
endglobals
function Trig_a_Func001A takes nothing returns nothing
 call TriggerRegisterUnitEvent( gg_trg_b, GetEnumUnit(),EVENT_UNIT_DAMAGED )
endfunction

function Trig_a_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsInRectAll(GetPlayableMapRect()), function Trig_a_Func001A )
endfunction
function InitTrig_a takes nothing returns nothing
    set gg_trg_a = CreateTrigger(  )              //map initialization
    call TriggerAddAction( gg_trg_a, function Trig_a_Actions )
endfunction

function Trig_b_Actions takes nothing returns nothing
    call DisplayTimedTextToForce( GetPlayersAll(), 10.00, ( GetUnitName(GetEventDamageSource()) + ( "Damage is" + R2S(GetEventDamage()) ) ) )
endfunction
function InitTrig_b takes nothing returns nothing
    set gg_trg_b = CreateTrigger(  )
    call TriggerAddAction( gg_trg_b, function Trig_b_Actions )
endfunction

function Trig_c_Actions takes nothing returns nothing
    call TriggerRegisterUnitEvent( gg_trg_b, GetEnteringUnit(), EVENT_UNIT_DAMAGED )
endfunction
function InitTrig_c takes nothing returns nothing
    local trigger  gg_trg_c =null
    set gg_trg_c = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_c, GetPlayableMapRect() )   //register    event for the   EnteringUnit
    call TriggerAddAction( gg_trg_c, function Trig_c_Actions )
    set  gg_trg_c =null
endfunction
maybe GetPlayableMapRect() can be in place of GetEntireMapRect()
,i wonder when a unit enters PlayableMapRect,it will be registered in the
trigger gg_trg_c ,if i have several thousand units, will it make a lag??
 
Last edited:
Level 2
Joined
Dec 28, 2010
Messages
21
i just want someone could find problems and correct it.maybe this time can be
better.
JASS:
globals
trigger  gg_trg_b =null
trigger  gg_trg_a = null
endglobals
function Trig_a_Func001A takes nothing returns nothing
 call TriggerRegisterUnitEvent( gg_trg_b, GetEnumUnit(),EVENT_UNIT_DAMAGED )
endfunction

function Trig_a_Actions takes nothing returns nothing
    local group g = CreateGroup()
    call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea, null)
    call ForGroup( g, function Trig_a_Func001A )
    set g=null
endfunction
function InitTrig_a takes nothing returns nothing
    set gg_trg_a = CreateTrigger(  )              //map initialization
    call TriggerAddAction( gg_trg_a, function Trig_a_Actions )
endfunction

function Trig_b_Actions takes nothing returns nothing
    call DisplayTimedTextToPlayer( GetLocalPlayer(), 0.00,0.00,10.00, ( GetUnitName(GetEventDamageSource()) + ( "Damage is" + R2S(GetEventDamage()) ) ) )
endfunction
function InitTrig_b takes nothing returns nothing
    set gg_trg_b = CreateTrigger(  )
    call TriggerAddAction( gg_trg_b, function Trig_b_Actions )
endfunction

function Trig_c_Actions takes nothing returns nothing
    call TriggerRegisterUnitEvent( gg_trg_b, GetEnteringUnit(), EVENT_UNIT_DAMAGED )
endfunction
function InitTrig_c takes nothing returns nothing
    local trigger  gg_trg_c =null
    local region rectRegion = CreateRegion()
    set gg_trg_c = CreateTrigger(  )
    call RegionAddRect(rectRegion,bj_mapInitialPlayableArea )
    call TriggerRegisterEnterRegion(gg_trg_c, rectRegion, null)    //register    event for the   EnteringUnit
    call TriggerAddAction( gg_trg_c, function Trig_c_Actions )
    set  gg_trg_c =null
    set  rectRegion =null
endfunction
 
you can combine this set gg_trg_b = CreateTrigger( ) with the creation of the global

JASS:
globals
   trigger gg_trg_b = CreateTrigger(  )
endglobals

also remove InitTrig_a and b... just merge it with the InitTrig_c

JASS:
function InitTrig_c takes nothing returns nothing
    local trigger  gg_trg_c = CreateTrigger(  )
    local region rectRegion = CreateRegion()
    call RegionAddRect(rectRegion,bj_mapInitialPlayableArea )
    call TriggerRegisterEnterRegion(gg_trg_c,rectRegion, null)    
    call TriggerAddAction( gg_trg_c, function Trig_c_Actions )
    call TriggerAddAction( gg_trg_a, function Trig_a_Actions )
    call TriggerAddAction( gg_trg_b, function Trig_b_Actions )
    set  gg_trg_c =null
    set  rectRegion =null
endfunction
 
Level 2
Joined
Dec 28, 2010
Messages
21
it is said that triggeraction will leak .is that right?
for example
JASS:
native TriggerAddAction     takes trigger whichTrigger, code actionFunc returns triggeraction
we could clear it through TriggerRemoveAction
 
Level 2
Joined
Dec 28, 2010
Messages
21
trigger gg_trg_c is to be set null,so i think Trig_c_Actions should be deleted
before that trigger gg_trg_c be set null
 
trigger gg_trg_c is to be set null,so i think Trig_c_Actions should be deleted
before that trigger gg_trg_c be set null

NO!!! your trigger will not run if you delete the action... plus you didn't destroy the real gg_trg_c, you just nulled the variable pertaining to it...

you need to learn the difference between a variable and an object...
 
Status
Not open for further replies.
Top