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

Hashtable messing up

Status
Not open for further replies.
Level 5
Joined
Dec 18, 2007
Messages
205
Hi guys
I was just starting to trigger once again with the new patch where i directly discovered the new handle problem. I know that there are hashtables now, but I just don't know whether some things aren't working or are working correct.

At first I'll post you here the trigger how I am scripting a spell at the moment at which i get stuck by an error. If you want, first read the problems below and afterwards look at the script.

JASS:
//My hash trigger is defined in the map header btw like this:

globals
    hashtable hash = InitHashtable()
endglobals

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

scope EnchantTotem initializer Init

    private function Conditions takes nothing returns boolean
        return GetUnitAbilityLevel(GetAttacker(), 'B005')>0 //Buff
    endfunction
    
    private function Timer_Effects takes nothing returns nothing
        if LoadBoolean(hash, 1, 1) and GetUnitCurrentOrder(LoadUnitHandle(hash, 1, 0)) != String2OrderIdBJ("attack") then
            SaveBoolean(hash, 1, 1, false)
        endif
    endfunction

    private function Actions takes nothing returns nothing
        local unit attacker = GetAttacker()
        local timer t = CreateTimer()
        call SaveUnitHandle(hash, 1, 0, attacker)
        call SaveBoolean(hash, 1, 1, true)
        call TimerStart(t, 0.03, true, function Timer_Effects)
        call TriggerSleepAction(0.4)
        call PauseTimer(t)
        call DestroyTimer(t)
        if LoadBoolean(hash, 1, 1) then
            call UnitRemoveAbility(attacker, 'B005')
        endif
        
        set attacker = null
    endfunction

    //=========================================================================
    private function Init takes nothing returns nothing
        local trigger Enchant_Totem = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(Enchant_Totem, EVENT_PLAYER_UNIT_ATTACKED )
        call TriggerAddCondition(Enchant_Totem, Condition( function Conditions ) )
        call TriggerAddAction(Enchant_Totem, function Actions )
        set Enchant_Totem = null
    endfunction

endscope

First Question:

Is the trigger still MUI? I mean with HandleVars there was the flush trigger (which i never understood, but which worked for MUI i think). now in the hashtable i found those 2 flush functions, but how do i have to use them to let the trigger work properly and when? With handle vars i used the flush trigger after destroying the timer.

Second Question:

If i create some spells, do i have to use different parent and child keys?
actualy i use for each spell another parent key and for each stored variable a different child key of the parent key.
so spell 1 uses parent key 0 and child keys 0-2
spell 2 uses parent key 1 and child key 0 and 1
is that correct?

Last Question that deals with the trigger itself:

I cannot save the map because the error in the Timer_Effects trigger says this line has an syntax error.
JASS:
SaveBoolean(hash, 1, 1, false)
why can't i save the boolean? i know that i could store the value as an integer (0 and 1), but why can't i save it?


Thank you for reading and helping in advance!

grertings, bReathl3sS
 
Level 5
Joined
Dec 18, 2007
Messages
205
no-one can help me out?
or should i have posted this in WE help zone?

EDIT: Solved my problem.
Just recognized that i missed a "call", thus resulting in an error.
I also recognized how to make the spells MUI using hashtables combined with timers.

greetings
 
Last edited:
Status
Not open for further replies.
Top