• 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.

[JASS] Checking Conditions

Status
Not open for further replies.
Level 10
Joined
Jan 21, 2007
Messages
576
Ok i got this code from... DK-Diablo i think, anways when it runs the trigger HEffect will HEffect still go through its conditions or will it automaticaly do the actions.

JASS:
function AnyUnitTakesDamage takes nothing returns nothing
call TriggerExecute(gg_trg_HEffect)
// Sample Damage display:
// call BJDebugMsg( "Damage: " + R2S(GetEventDamage()) )
endfunction
// part 1
function AddDamageTriggers takes nothing returns nothing
local trigger takedamage = CreateTrigger()
call TriggerRegisterUnitEvent(takedamage,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
call AttachObject(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
call AttachObject(GetTriggerUnit(),"TakeDamageTrigger",takedamage)
endfunction
// part 2
function RemoveDamageTriggers takes nothing returns nothing
local unit u = GetTriggerUnit()
local trigger me = GetAttachedTrigger(GetTriggerUnit(),"TakeDamageTrigger")
local string t = GetAttachmentTable(me)
local boolean revived = false
if not IsUnitType(u,UNIT_TYPE_HERO) then
loop
set revived = (GetWidgetLife(u)>0.405)
exitwhen revived or GetUnitTypeId(u)==0
call TriggerSleepAction(0)
endloop
endif
if not revived then
// delete action and trigger
call TriggerRemoveAction(me,GetTableTriggerAction(t,"action"))
call DestroyTable(t)
call DestroyTrigger(me)
endif
set me = null
set u = null
endfunction
// part 3
function InitTrig_AddDmg takes nothing returns nothing
local trigger entermap = CreateTrigger()
local group startingunits = CreateGroup()
local unit u
local trigger takedamage
local trigger upondeath = CreateTrigger()
call GroupEnumUnitsInRect(startingunits,bj_mapInitialPlayableArea,null)
loop
set u = FirstOfGroup(startingunits)
exitwhen u == null
set takedamage = CreateTrigger()
call TriggerRegisterUnitEvent(takedamage,u,EVENT_UNIT_DAMAGED)
call AttachObject(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
call AttachObject(u,"TakeDamageTrigger",takedamage)
call GroupRemoveUnit(startingunits,u)
endloop
set takedamage = null
// unit enters the map/revives
call TriggerRegisterAnyUnitEventBJ(entermap ,EVENT_PLAYER_HERO_REVIVE_FINISH)
call TriggerRegisterEnterRectSimple(entermap, bj_mapInitialPlayableArea)
call TriggerAddAction(entermap,function AddDamageTriggers)
// unit dies
call TriggerRegisterAnyUnitEventBJ(upondeath,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction(upondeath,function RemoveDamageTriggers)
endfunction
 
Level 10
Joined
Jan 21, 2007
Messages
576
I thought it should to, sec im going over all teh variables agian.
 
Status
Not open for further replies.
Top