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

Game cache damage engine problem

Status
Not open for further replies.
Level 14
Joined
Nov 17, 2010
Messages
1,266
This has been solved thanks to looking for help, if you want a good DDS that can still be used with GUI I would recommend his system it's simple and effective.
 
Last edited:
Level 14
Joined
Nov 17, 2010
Messages
1,266
No it only crashes when I have the DDS the rest works fine without it. And it's only in the map that I move to using a Game Cache. So I'm wondering if there is something I have to add to the Game Cache to make it work.
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Ok, replace the damage engine with this modified version of Bribes DDS.

JASS:
function Trig_Damage_Engine_Func015C takes nothing returns boolean
    return true
endfunction

function Trig_Damage_Engine_Func050C takes nothing returns boolean
    if ( not ( udg_DamageEventAmount == 0.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func055Func002Func003C takes nothing returns boolean
    if ( not ( udg_DamageEventExplodesUnit == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func055Func002Func008Func004C takes nothing returns boolean
    if ( not ( udg_DmgEvN == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func055Func002Func008C takes nothing returns boolean
    if ( not ( GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_DamageEventTarget) < udg_DmgEvLife ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func055Func002C takes nothing returns boolean
    if ( not ( udg_DamageEventAmount > udg_DamageEventPrevAmt ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func055C takes nothing returns boolean
    if ( not ( udg_DamageEventAmount != udg_DamageEventPrevAmt ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func091C takes nothing returns boolean
    if ( not ( udg_DamageEvent == 0.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func102Func006Func003Func007C takes nothing returns boolean
    if ( not ( udg_UnitDamageRegistered[udg_UDex] == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func102Func006Func003C takes nothing returns boolean
    if ( not ( udg_DamageEventsWasted == 15 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func102Func006C takes nothing returns boolean
    if ( not ( udg_UnitDamageRegistered[udg_UDex] == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Func102C takes nothing returns boolean
    if ( not ( udg_UnitIndexEvent == 1.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Damage_Engine_Actions takes nothing returns nothing
    // Copy the Cheat Death Ability from Object Editor into your map and set the following variable respectively:
    set udg_DamageBlockingAbility = 'A001'
    // -
    set udg_DamageTypeSpell = 1
    set udg_DamageTypeDOT = 2
    set udg_DamageTypeRanged = 3
    // -
        call ExecuteFunc("InitDamageEvent")
    endfunction
     
    function DmgEvFilter takes nothing returns boolean
    // -
    // The next conditions let you filter out unwanted units. By default, units with Locust will not pass the check.
    // -
    if ( Trig_Damage_Engine_Func015C() ) then
        return true
    else
    endif
        return false
    endfunction
     
    function DmgEvRemoveAbilities takes nothing returns nothing
        local real r
        loop
    set udg_DmgEvN = ( udg_DmgEvN - 1 )
            set r = GetWidgetLife(udg_DmgEvStack[udg_DmgEvN])
    call UnitRemoveAbilityBJ( udg_DamageBlockingAbility, udg_DmgEvStack[udg_DmgEvN] )
            call SetWidgetLife(udg_DmgEvStack[udg_DmgEvN], r)
    set udg_DmgEvStack[udg_DmgEvN] = null
            exitwhen udg_DmgEvN == 0
        endloop
    endfunction
     
    function DmgEvSetVars takes nothing returns nothing
    set udg_DamageEventAmount = GetEventDamage()
    set udg_DamageEventSource = GetEventDamageSource()
    set udg_DamageEventTarget = GetTriggerUnit()
    endfunction
     
    function FireDmgEv takes nothing returns nothing
        local boolean b = GetUnitAbilityLevel(udg_DamageEventTarget, udg_DamageBlockingAbility) > 0
        local real life = 0
        local real pain = 0
        if b then
            set life = GetWidgetLife(udg_DamageEventTarget)
    call UnitRemoveAbilityBJ( udg_DamageBlockingAbility, udg_DamageEventTarget )
            call SetWidgetLife(udg_DamageEventTarget, life)
            set pain = GetWidgetLife(udg_DamageEventTarget)
        endif
    set udg_DamageEventPrevAmt = udg_DamageEventAmount
    set udg_DamageEventExplodesUnit = false
    set udg_DamageEventOverride = false
    if ( Trig_Damage_Engine_Func050C() ) then
        set udg_DamageEvent = 2.00
    else
        set udg_DamageModifierEvent = 1.00
        set udg_DamageEvent = 1.00
    endif
        if b then
    call UnitAddAbilityBJ( udg_DamageBlockingAbility, udg_DamageEventTarget )
            call SetWidgetLife(udg_DamageEventTarget, life + GetWidgetLife(udg_DamageEventTarget) - pain)
        endif
    if ( Trig_Damage_Engine_Func055C() ) then
        set udg_DmgEvLife = ( GetUnitStateSwap(UNIT_STATE_LIFE, udg_DamageEventTarget) + ( udg_DamageEventPrevAmt - udg_DamageEventAmount ) )
        if ( Trig_Damage_Engine_Func055Func002C() ) then
            call SetUnitLifeBJ( udg_DamageEventTarget, RMaxBJ(0.41, udg_DmgEvLife) )
            if udg_DmgEvLife <= .405 then
            if ( Trig_Damage_Engine_Func055Func002Func003C() ) then
                call SetUnitExplodedBJ( udg_DamageEventTarget, true )
            else
            endif
            call DisableTrigger( udg_DamageEventTrigger )
                call UnitDamageTarget(udg_DamageEventSource, udg_DamageEventTarget, 999, false, false, null, null, null)
            call EnableTrigger( udg_DamageEventTrigger )
            endif
        else
            if ( Trig_Damage_Engine_Func055Func002Func008C() ) then
                call UnitAddAbilityBJ( udg_DamageBlockingAbility, udg_DamageEventTarget )
                set udg_DmgEvStack[udg_DmgEvN] = udg_DamageEventTarget
                set udg_DmgEvN = ( udg_DmgEvN + 1 )
                if ( Trig_Damage_Engine_Func055Func002Func008Func004C() ) then
                    call TimerStart(udg_DmgEvTimer, 0, false, function DmgEvRemoveAbilities)
                else
                endif
            else
            endif
            call SetUnitLifeBJ( udg_DamageEventTarget, udg_DmgEvLife )
        endif
    else
    endif
    endfunction
     
    function FireRecursiveDmgEv takes nothing returns nothing
        local real d = udg_DamageEventAmount
        local unit s = udg_DamageEventSource
        local unit t = udg_DamageEventTarget
        local integer ptype = udg_DmgTypPrev
        local boolean explode = udg_DamageEventExplodesUnit
        local boolean override = udg_DamageEventOverride
        local real prev = udg_DamageEventPrevAmt
        call DmgEvSetVars()
        if udg_DamageEventTarget != t or udg_DamageEventSource != s or udg_DamageEventAmount != d or udg_DamageEventType != ptype then
    set udg_DamageEvent = 0.00
    set udg_DamageModifierEvent = 0.00
            call FireDmgEv()
    // -
    // Delete the next three lines to disable the in-game recursion crash warnings
    // -
        else
    call ClearTextMessagesBJ( GetPlayersAll() )
    call DisplayTimedTextToForce( GetPlayersAll(), 999.00, "TRIGSTR_019" )
    // -
        endif
        set udg_DamageEventOverride = override
        set udg_DamageEventExplodesUnit = explode
        set udg_DamageEventPrevAmt = prev
        set udg_DmgTypPrev = ptype
        set udg_DamageEventAmount = d
        set udg_DamageEventSource = s
        set udg_DamageEventTarget = t
        set s = null
        set t = null
    endfunction
     
    function OnDmgEv takes nothing returns boolean
    if ( Trig_Damage_Engine_Func091C() ) then
        set udg_DmgTypPrev = udg_DamageEventType
        call DmgEvSetVars()
        call FireDmgEv()
        set udg_DamageModifierEvent = 0.00
        set udg_DamageEvent = 0.00
        set udg_DamageEventType = 0
    else
        call FireRecursiveDmgEv()
    endif
        return false
    endfunction
     
    function CreateDmgEv takes nothing returns nothing
        set udg_DamageEventTrigger = CreateTrigger()
        call TriggerAddCondition(udg_DamageEventTrigger, Filter(function OnDmgEv))
    endfunction
     
    function SetupDmgEv takes nothing returns boolean
        local integer pdex = udg_UDex
        
    if ( Trig_Damage_Engine_Func102C() ) then
        set udg_TempUnit = udg_UDexUnits[udg_UDex]
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.0, 0.0, 60000.0, GetUnitName(udg_TempUnit))
        if udg_TempUnit == null or GetUnitName(udg_TempUnit) == null or GetUnitTypeId(udg_TempUnit) == 0 or udg_UDex < 0 or udg_UDex > 8191 then
            call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.0, 0.0, 60000.0, "ERROR DETECTED!")
            call PauseGame(true)
            set udg_UDex = udg_UDex/0
        endif
        if GetUnitAbilityLevel(udg_TempUnit, 'Aloc') == 0 and DmgEvFilter() then
        set udg_UnitDamageRegistered[udg_UDex] = true
        call TriggerRegisterUnitEvent( udg_DamageEventTrigger, udg_TempUnit, EVENT_UNIT_DAMAGED )
        endif
    else
        if ( Trig_Damage_Engine_Func102Func006C() ) then
            set udg_UnitDamageRegistered[udg_UDex] = false
            set udg_DamageEventsWasted = ( udg_DamageEventsWasted + 1 )
            if ( Trig_Damage_Engine_Func102Func006Func003C() ) then
                set udg_DamageEventsWasted = 0
                call DestroyTrigger(udg_DamageEventTrigger)
                call CreateDmgEv()
                set udg_UDex = udg_UDexNext[0]
                loop
                    exitwhen udg_UDex == 0
                if ( Trig_Damage_Engine_Func102Func006Func003Func007C() ) then
                    call TriggerRegisterUnitEvent( udg_DamageEventTrigger, udg_UDexUnits[udg_UDex], EVENT_UNIT_DAMAGED )
                else
                endif
                set udg_UDex = udg_UDexNext[udg_UDex]
                endloop
                set udg_UDex = pdex
            else
            endif
        else
        endif
    endif
        return false
    endfunction
     
    function InitDamageEvent takes nothing returns nothing
        call CreateDmgEv()
        call TriggerAddCondition(GetTriggeringTrigger(), Filter(function SetupDmgEv))
    set udg_UnitIndexerEnabled = false
        //set udg_TempUnit = CreateUnit(Player(15), 'uloc', 0, 0, 0)
    set udg_UnitIndexerEnabled = true
    //call UnitAddAbilityBJ( udg_DamageBlockingAbility, udg_TempUnit )
    //call RemoveUnit( udg_TempUnit )
    call ConditionalTriggerExecute( GetTriggeringTrigger() )
endfunction

//===========================================================================
function InitTrig_Damage_Engine takes nothing returns nothing
    set gg_trg_Damage_Engine = CreateTrigger(  )
    call TriggerRegisterVariableEvent( gg_trg_Damage_Engine, "udg_UnitIndexEvent", EQUAL, 1.00 )
    call TriggerRegisterVariableEvent( gg_trg_Damage_Engine, "udg_UnitIndexEvent", EQUAL, 2.00 )
    call TriggerAddAction( gg_trg_Damage_Engine, function Trig_Damage_Engine_Actions )
endfunction

Does the game pause and display an error message when you switch the map or does it still crash?
 
Last edited:
Level 14
Joined
Nov 17, 2010
Messages
1,266
Does this need any knowledge of JASS to use, because unfortunately I have none. If not, I can implement it and try it out. If he had an updated version with GUI that would be ideal.

And the game just crashes right now, no error message. It just sends me back to the campaign screen instead of the map loading screen. I'll let you know if it still does it after I update it though.
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Hm, do you have tried it with all onDamage handler functions deactivated?

If yes, debug through the save and load triggers by displaying a debug message after one line, then crash the thread by dividing an integer by zero. If it shows you the debug message the trigger runs until that line, then you take the next line until it crashes. By doing so you can find the problematic line.
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Ok, I try it again ;)

1.) Do you use anywhere the events
Game - DamageEvent becomes Equal to 1.00
Game - DamageEvent becomes Equal to 2.00
Game - DamageModifierEvent becomes Equal to 1.00?
If so, deactivate all of them and try again if it crashes.

2.) If it still crashes, you should debug the save and load triggers. For this, create a new integer variable, for example "crash". Then do this for every line:

  • Load
    • Events
    • Conditions
    • Actions
      • Game Cache - Reload all game cache data from disk
      • -------- This is used to check if the line is reached --------
      • Custom script: call BJDebugMsg("Line reached!")
      • Custom script: call PauseGame(true)
      • set udg_crash = udg_crash/0
      • -------- Do it line for line --------
      • Set Cache_LeftFromMap = (Load LeftFromMap of Variables from Cache_LA_cache)
      • Set Cache_CallienthNewGame = (Load CallienthNewGame of Variables from Cache_LA_cache)
By doing so, you can check line by line whether the program reaches it or not. Repeat this until you find the critical line and post it then here.
 
Level 14
Joined
Nov 17, 2010
Messages
1,266
Oh ok I understand now. This will take some time but I'll get started. One question though, how is it supposed to show a message if it won't even try to load the map? It just goes right to the campaign screen again after i try to go to the next map.
 
Level 14
Joined
Nov 17, 2010
Messages
1,266
It is of course really hard to say what causes this problems. Did you already try to disable all your onDamage events?

Yes, I didn't have any on this map yet since the Damage Engine itself wasn't working. And it still crashes.

So should I have the damage engine disabled while I debug the load trigger?

Edit: i sent you a link to the campaign in a private message if you want to check for anything obvious that I just didn't see.
 
Last edited:
Status
Not open for further replies.
Top