• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Please help to convert this JASS

Status
Not open for further replies.
Level 6
Joined
Jan 27, 2007
Messages
208
Hi, can someone in here convert this JASS Code so i can use it in normal WE?

JASS:
library DD initializer InitTrig_Detect_Damage_Events

globals
    hashtable hash = InitHashtable()
endglobals

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 SaveTriggerActionHandle(hash,GetHandleId(takedamage),StringHash("action"),TriggerAddAction(takedamage,function AnyUnitTakesDamage))
    call SaveTriggerHandle(hash,GetHandleId(GetTriggerUnit()),StringHash("TakeDamageTrigger"),takedamage)
endfunction

// part 2
function RemoveDamageTriggers takes nothing returns nothing
    local trigger me = LoadTriggerHandle(hash,GetHandleId(GetTriggerUnit()),StringHash("TakeDamageTrigger"))
    // delete action and trigger
    call TriggerRemoveAction(me,LoadTriggerActionHandle(hash,GetHandleId(me),StringHash("action")))
    call FlushChildHashtable(hash,GetHandleId(me))
    call DestroyTrigger(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 SaveTriggerActionHandle(hash,GetHandleId(takedamage),StringHash("action"),TriggerAddAction(takedamage,function AnyUnitTakesDamage))
        call SaveTriggerHandle(hash,GetHandleId(u),StringHash("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

endlibrary

Its Detect Damage System that my friends made. I can use it after i activate my trigger that needs this system by Turn that it On in "Damage Register" Trigger. Like this

  • Damage Register
    • Events
    • Conditions
    • Actions
      • Trigger - Run Maximize Power Effect <gen> (checking conditions)
And in the Map Initialization, i put this action.

  • Custom script: call FlushGameCache( InitGameCache( "localvars.w3v" ) )
  • Custom script: set udg_LocalVars = InitGameCache( "localvars.w3v" )
Thanks for help (really).
 
Level 6
Joined
Jan 27, 2007
Messages
208
He quit mapping, and i can`t contact him again now...

I know I can take other DD System and maybe that system better than this, but many of them use JASS to use that system, which i dont know how to do it ;( . With this system i can use it with GUI.

Poor me.
 
Level 14
Joined
Nov 18, 2007
Messages
816
Okay, why do you need this system in pure JASS again?

Why are you afraid of looking at this piece of crap and figuring out what it does?
Okay, it might be overcomplicated, but JASS is so verbose that you can grasp it by reading out loud. Try it and youll see JASS is no magic.

If you need a starting point, check your GUI trigger that serves as a proxy to run all other trigger off that DD system. Then check the function "AnyUnitTakesDamage" in your script. After you figured out how this script works, try reading Captain_Griffens DD library over at wc3c.net. Im sure you can figure out how to use that one.
 
Level 6
Joined
Jan 27, 2007
Messages
208
Okay, why do you need this system in pure JASS again?
In JNGP, I cant use GetHandle from Hashtable in GUI. So im tired if i must quit JNGP to make some spell with Hashtable, and quit again to run JNGP, when i want to test that spell.....

If you need a starting point, check your GUI trigger that serves as a proxy to run all other trigger off that DD system. Then check the function "AnyUnitTakesDamage" in your script. After you figured out how this script works, try reading Captain_Griffens DD library over at wc3c.net. Im sure you can figure out how to use that one

Emm, do you mean this?
http://www.wc3c.net/showthread.php?t=101865

Sorry, I dont understand it...
 
Status
Not open for further replies.
Top