HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Game crashes when dealing damage

06-28-2008, 04:06 PM#1
Castlemaster
I've done some testing using Rising Dusk's damage detection, and in my map calling the following trigger causes a crash when it is in a trigger registered to the event TriggerRegisterDamageEvent()
Collapse JASS:
call UnitDamageTargetEx(GetTriggerDamageSource(), GetTriggerDamageTarget(), AGI2OffensiveStance(), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ATTACK, true)
when I remove UnitDamageTargetEx(), the map doesn't crash. This trigger is very similar to the critical strike example in the map, but the critical strike trigger obviously doesn't crash.

Any ideas on what is causing it?
06-28-2008, 05:26 PM#2
the-thingy
Perhaps an infinite loop? Try DisableTrigger (damage detection trigger) before dealing damage, then EnableTrigger (damage detection trigger) afterwards.

That's the only thing that springs to mind with damage detection and a damage function, but I've never looked at Rising_Dusk's system so I can't be sure
06-28-2008, 05:26 PM#3
moyack
Spell code please....
06-28-2008, 05:54 PM#4
Castlemaster
In full:
Collapse JASS:
private function OnDamageStanceEffect takes nothing returns nothing
    local unit u = GetTriggerDamageSource()
    local unit t = GetTriggerDamageTarget()
    if udg_DefensiveStanceOn == true and t== udg_Battlemaster then
    //Defensive Stance Effects
        
    elseif udg_DefensiveStanceOn == false and u== udg_Battlemaster then
     //  call CustomDamage(u,t,AGI2OffensiveStance(),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_ATTACK,true)
     call UnitDamageTargetEx(u,t,1,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_ATTACK,true)
    endif
endfunction

//Triggers
    local trigger OnDamageStance = CreateTrigger()
    call TriggerRegisterDamageEvent(OnDamageStance)
    call TriggerAddAction(OnDamageStance,function OnDamageStanceEffect)

I'm trying to figure out if my other code is causing an infinite loop somehow.
06-28-2008, 05:57 PM#5
the-thingy
From the looks of it, 90% sure that's it's an infinite loop

Collapse JASS:
private function OnDamageStanceEffect takes nothing returns nothing
    local unit u = GetTriggerDamageSource()
    local unit t = GetTriggerDamageTarget()
    if udg_DefensiveStanceOn == true and t== udg_Battlemaster then
    //Defensive Stance Effects
        
    elseif udg_DefensiveStanceOn == false and u== udg_Battlemaster then
//Add this line:
call DisableTrigger (GetTriggeringTrigger ())
     //  call CustomDamage(u,t,AGI2OffensiveStance(),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_ATTACK,true)
     call UnitDamageTargetEx(u,t,1,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_ATTACK,true)
//And this:
call EnableTrigger (GetTriggeringTrigger ())
    endif
endfunction

unless call TriggerRegisterDamageEvent () doesn't register a 'Takes Damage' event
06-28-2008, 06:08 PM#6
Castlemaster
OK, that worked perfectly. Now to make sure I understand how the infinite loop came about is this the progression: Unit deals damage-->extra damage is dealt--> extra damage retriggers the same trigger-->extra damage is dealt...

Is that how it happened?

+rep btw.
06-28-2008, 06:24 PM#7
the-thingy
Quote:
Originally Posted by Castlemaster
OK, that worked perfectly. Now to make sure I understand how the infinite loop came about is this the progression: Unit deals damage-->extra damage is dealt--> extra damage retriggers the same trigger-->extra damage is dealt...

Is that how it happened?

+rep btw.
Ye, pretty much :)
06-28-2008, 11:43 PM#8
Anitarf
Obvious infinite loop. I'll edit the thread title since it appears very FUD prone.