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

fixing stuff for 1.24

Status
Not open for further replies.
Level 8
Joined
Aug 4, 2006
Messages
357
If you need to make something compatible with patch 1.24, whether GUI, JASS, or vJASS, I will do it for you here. You can either post your code in hidden jass tags, or attach a map containing your system. I will not fix entire maps. Please help me help you, and don't post shit unless you know it fails in 1.24. Be warned that I cannot fix everything, and I cannot modify someone's code without their permission.

Current customer: <none>
 
Last edited:
Level 8
Joined
Aug 4, 2006
Messages
357
OMG I figured out the problem with only1player. It has a global called "level" that conflicts with the local integer "level" of addedAtkLib/function addedAtk. This causes wc3 to go to the main menu when you test the map, but idk why it would only cause problems in patch 1.24... I am absolutely sure this is what was causing the problem. It now goes to the loading screen if I rename that local var, and replace handle vars.
 
Level 6
Joined
Jan 27, 2007
Messages
208
I have Detect Damage System, and that system is not working in 1.24

Here is the code

JASS:
// ===========================
function H2I takes handle h returns integer
    return h
    return 0
endfunction

// ===========================
function LocalVars takes nothing returns gamecache
    return udg_LocalVars
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
    if value==false then
        call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes handle subject, string name returns boolean
    return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleLightning takes handle subject, string name returns lightning
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleWidget takes handle subject, string name returns widget
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTriggerAction takes handle subject, string name returns triggeraction
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction

// ===========================

Second code, a Trigger named 'Detect Damage Events'

JASS:
function AnyUnitTakesDamage takes nothing returns nothing
    call DisableTrigger(GetTriggeringTrigger())
    call ConditionalTriggerExecute( gg_trg_Damage_Register )
    call EnableTrigger(GetTriggeringTrigger())
endfunction

// part 1
function AddDamageTriggers takes nothing returns nothing
    local trigger takedamage = CreateTrigger()
    call TriggerRegisterUnitEvent(takedamage,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
    call SetHandleHandle(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
    call SetHandleHandle(GetTriggerUnit(),"TakeDamageTrigger",takedamage)
endfunction

// part 2
function RemoveDamageTriggers takes nothing returns nothing
    local trigger me = GetHandleTrigger(GetTriggerUnit(),"TakeDamageTrigger")
    // delete action and trigger
    call TriggerRemoveAction(me,GetHandleTriggerAction(me,"action"))
    call DestroyTrigger(me)
    call FlushHandleLocals(me)
    set me = null
endfunction

// part 3
function InitTrig_Detect_Damage_Events 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 SetHandleHandle(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
        call SetHandleHandle(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

And the third trigger named 'Damage Register', but its only contain an activation other trigger when i want the system works.

Thanks for your help.
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
Ok, I looked over it again. Now violent wave seems to work. You need to replace h2ilib with Faux HandleVars. The only1player trigger still doesn't work. I hope I helped.


Wow oops thanks! I don't even use H2I anymore, I completely forgot to delete it.

Edit: didn't mean to double post -.- sorry. And sorry poptart I can't rep u again
 
Level 8
Joined
Aug 4, 2006
Messages
357
I have Detect Damage System, and that system is not working in 1.24

Here is the code
That is one ugly damage detection system... Well, I made it compatible for 1.24. If it still doesn't work, there may be something wrong with 'Damage Register' (the trigger you didn't post). You need JNGP to use the first trigger in its current state, but if you're too lazy to get it, I guess I can convert the trigger to regular JASS.
JASS:
/*******************************************************************************************
 Faux Handle Vars
 ----------------
    Do not use these functions for new stuff, it is just not the right thing to do...

    The intention of Faux Handle Vars is to be a patch fix for a map's migration to
  patch 1.24 This library might not cover all uses of handle vars, some of them are just
  impossible with the new rules set in patches 1.23b and 1.24, but they should work for
  most of the cases....

    All of them but the SetHandle*** ones are inline friendly. I follow the interface
  in official Kattana's handle vars from wc3jass.com, if your handle vars functions
  look different, then you were not using handle vars but another thing...

*******************************************************************************************/

//==========================================================================================
library HandleVars initializer init

 globals
    private hashtable ht
 endglobals
 
    // too bad the Handle vars' old functionality forces me to make these things
    // inline-unfriendly
    function SetHandleHandle takes agent subject,  string label, agent value returns nothing
        if(value==null) then
            call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
        else
            call SaveAgentHandle( ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleInt takes agent subject, string label, integer value returns nothing
        if value==0 then
            call RemoveSavedInteger(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveInteger(ht, GetHandleId(subject), StringHash(label), value)
        endif        
    endfunction

    function SetHandleBoolean takes agent subject, string label, boolean value returns nothing
        if (value == false) then
            call RemoveSavedBoolean(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveBoolean(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleReal takes agent subject, string label, real value returns nothing
        if (value == 0.0) then
            call RemoveSavedReal(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveReal(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleString takes agent subject, string label, string value returns nothing
        if ((value=="") or (value==null)) then
            call RemoveSavedString(ht, GetHandleId(subject), StringHash(label)) 
        else
            call SaveStr(ht, GetHandleId(subject), StringHash(label), value) //yay for blizz' consistent naming scheme...
        endif
    endfunction

    function GetHandleHandle takes agent subject, string label returns agent
        debug call BJDebugMsg("[debug] What the heck? Why would you call HandleHandle I guess this was caused by a search and replace mistake")
        return null
    endfunction

    // these are inline friendly, ok, maybe they aren't because jasshelper does not recognize
    // GetHandleId as non-state changing. But they will be once I fix jasshelper...

    function GetHandleInt takes agent subject, string label returns integer
        return LoadInteger(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleBoolean takes agent subject, string label returns boolean
        return LoadBoolean(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleString takes agent subject, string label returns string
        return LoadStr(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleReal takes agent subject, string label returns real
        return LoadReal(ht, GetHandleId(subject), StringHash(label))
    endfunction

    // got bored so I now use a textmacro...
    //! textmacro FAUX_HANDLE_VARS_GetHandleHandle takes NAME, TYPE
         function SetHandle$NAME$ takes agent subject,  string label, $TYPE$ value returns nothing
             if(value==null) then
                call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
             else
                call Save$NAME$Handle( ht, GetHandleId(subject), StringHash(label), value)
             endif
         endfunction

         function GetHandle$NAME$ takes agent subject, string label returns $TYPE$
             return Load$NAME$Handle( ht, GetHandleId(subject), StringHash(label))
         endfunction
    //! endtextmacro
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Player","player")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Widget","widget")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Destructable","destructable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Item","item")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Unit","unit")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ability","ability")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Timer","timer")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trigger","trigger")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerCondition","triggercondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerAction","triggeraction")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerEvent","event")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Force","force")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Group","group")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Location","location")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Rect","rect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("BooleanExpr","boolexpr")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Sound","sound")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Effect","effect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("UnitPool","unitpool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("ItemPool","itempool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Quest","quest")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("QuestItem","questitem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("DefeatCondition","defeatcondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TimerDialog","timerdialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Leaderboard","leaderboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Multiboard","multiboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("MultiboardItem","multiboarditem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trackable","trackable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Dialog","dialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Button","button")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TextTag","texttag")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Lightning","lightning")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Image","image")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ubersplat","ubersplat")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Region","region")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogState","fogstate")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogModifier","fogmodifier")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Hashtable","hashtable")


    function FlushHandleVars takes agent subject returns nothing
        call FlushChildHashtable(ht, GetHandleId(subject))
    endfunction
    function FlushHandleLocals takes agent subject returns nothing
        call FlushHandleVars(subject)
    endfunction


    private function init takes nothing returns nothing
        set ht=InitHashtable()
    endfunction

endlibrary
This next trigger can be used with regular world editor.
JASS:
//modified by MaskedPoptart
function AnyUnitTakesDamage takes nothing returns nothing
    call DisableTrigger(GetTriggeringTrigger())
    call ConditionalTriggerExecute( gg_trg_Damage_Register )
call EnableTrigger(GetTriggeringTrigger())
endfunction

// part 1
function AddDamageTriggers takes nothing returns nothing
    local trigger takedamage = CreateTrigger()
    call TriggerRegisterUnitEvent(takedamage,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
    call SetHandleTriggerAction(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
    call SetHandleTrigger(GetTriggerUnit(),"TakeDamageTrigger",takedamage)
endfunction

// part 2
function RemoveDamageTriggers takes nothing returns nothing
    local trigger me = GetHandleTrigger(GetTriggerUnit(),"TakeDamageTrigger")
    // delete action and trigger
    call TriggerRemoveAction(me,GetHandleTriggerAction(me,"action"))
    call DestroyTrigger(me)
    call FlushHandleLocals(me)
    set me = null
endfunction

// part 3
function InitTrig_Detect_Damage_Events 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 SetHandleTriggerAction(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
        call SetHandleTrigger(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
Hope that helps.
 
Level 8
Joined
Aug 4, 2006
Messages
357
Well you don't need this part:
JASS:
    local group startingunits = CreateGroup()
    local unit u
    local trigger takedamage
    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 SetHandleHandle(takedamage,"action",TriggerAddAction(takedamage,function AnyUnitTakesDamage))
        call SetHandleHandle(u,"TakeDamageTrigger",takedamage)
        call GroupRemoveUnit(startingunits,u)
    endloop
    set takedamage = null
Preplaced units will be dealt with in the entermap trigger.
I don't have much experience making damage detection stuff, but maybe you can learn something from this system by Rising_Dusk: http://www.wc3c.net/showthread.php?t=100618&highlight=damage+detection
 
Status
Not open for further replies.
Top