Help using Kattanas Handle variables.

phyrex1an

Staff Member and irregular helper
Reaction score
447
This is just about using the right thing for the job. If you really wanted then you could make a whole map using only string variables together with S2I/I2S and type casting functions.
IMO using the gamecache for global storage is pretty much the same thing with the difference that the string method is faster (I think).

It's true that the gamecache isn't evil when we are talking about storing information to objects, in that case it's a blessing.
In the end, it's your choose. As long as you don't make statments as "My way is better" (it isn't) or promoting it above globals then it's ok for me :)
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Can anyone tell me, what I am doing wrong? It says a ") is expected". But I think there is none missing...

Code:
function guardian_unitcode takes nothing returns integer
    return 'n003' //Rawcode of the 'Guardian Sheep' unit.
endfunction

function guardian_rawcode takes nothing returns integer
    return 'A001' //Rawcode of the 'Guardian Sheep' spell
endfunction

function Trig_Rounding_Sheep_Modified_Conditions takes nothing returns boolean
    return (GetLearnedSkill() == guardian_rawcode()) And [B]( GetUnitAbilityLevel(GetTriggerUnit(), guardian_rawcode()) == 1 )[/B]
endfunction
 

SFilip

Gone but not forgotten
Reaction score
634
Try and instead of And. Yes, there is a difference, and is a keyword and And is a native.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
It worked.

...But now other things bug out. I'll paste the whole script, can you see what needs fixing?

Right now it says "Invalid argument type (void)". Line 283.

Code:
function guardian_unitcode takes nothing returns integer
    return 'n003' //Rawcode of the 'Guardian Sheep' unit.
endfunction

function guardian_rawcode takes nothing returns integer
    return 'A001' //Rawcode of the 'Guardian Sheep' spell
endfunction

function guardian_radius takes nothing returns real
    return 100.00 //Radius, which the 'Guardian Sheep' revolves around.
endfunction

function guardian_move takes nothing returns nothing
    local timer t = GetExpiredTimer( )
    local unit a = GetHandleUnit( t,"a" )
    local unit b = GetHandleUnit( t,"b" )
    local integer h = GetUnitAbilityLevel( a, guardian_rawcode( ) )
    local real x = GetUnitX( a )
    local real y = GetUnitY( a )
    local real c = I2R( GetUnitUserData(b) )     
    local real x2 = ( x + guardian_radius( ) * Cos(c * bj_DEGTORAD) )
    local real y2 = ( y + guardian_radius( ) * Sin(c * bj_DEGTORAD) )
    
    call SetUnitPosition( b, x2, y2 )     
    call SetUnitFacingToFaceUnitTimed( b, a, 0 )      
    call SetUnitUserData( b, (GetUnitUserData(b) + 2) )
    call UnitAddAbility( b, udg_SheepAbility[h] )
[B]    call DestroyTimer ( t )[/B]
    
    set a = null
    set b = null
    set t = null
endfunction

function Trig_Rounding_Sheep_Modified_Conditions takes nothing returns boolean
    return ( GetLearnedSkill( ) == guardian_rawcode() ) and ( GetUnitAbilityLevel( GetTriggerUnit( ), guardian_rawcode( ) ) == 1 )
endfunction

function Trig_Rounding_Sheep_Modified_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit( )
    local unit b = CreateUnit( GetOwningPlayer(a), guardian_unitcode( ), GetUnitX(a), GetUnitY(a), 0 )
    local timer t = CreateTimer( )
    
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "a",H2I(a) )
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "b",H2I(b) )
    
    call TimerStart( t, 0.03, true, guardian_move() )
    call DestroyTimer ( t )
    
    set a = null
    set b = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Rounding_Sheep_Modified takes nothing returns nothing
    local integer h = 0
    set gg_trg_Rounding_Sheep_Modified = CreateTrigger()
    loop
        call TriggerRegisterPlayerUnitEvent( gg_trg_Rounding_Sheep_Modified, Player(h), EVENT_PLAYER_HERO_SKILL, null )
        set h = h + 1
        exitwhen h == bj_MAX_PLAYER_SLOTS
    endloop   
    call TriggerAddCondition( gg_trg_Rounding_Sheep_Modified, Condition( function Trig_Rounding_Sheep_Modified_Conditions ) )
    call TriggerAddAction( gg_trg_Rounding_Sheep_Modified, function Trig_Rounding_Sheep_Modified_Actions )
endfunction
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Nice, it got worse. Warcraft crashed.:eek:

EDIT:

The trigger is supposed to make the unit 'b' revolve around the unit 'a'.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Does not help. Still get the void thing. After I remove both of the DestroyTimer() functions I get a void action there.

Code:
function Trig_Rounding_Sheep_Modified_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit( )
    local unit b = CreateUnit( GetOwningPlayer(a), guardian_unitcode( ), GetUnitX(a), GetUnitY(a), 0 )
    local timer t = CreateTimer( )
    
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "a",H2I(a) )
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "b",H2I(b) )
    
    call TimerStart( t, 0.03, true, guardian_move() )
    
[B]    set a = null[/B]
    set b = null
    set t = null
endfunction

If I remove 'set a = null', the I get a void action on the 'set b = null' line. And ect.
 

Chocobo

White-Flower
Reaction score
409
Does not help. Still get the void thing. After I remove both of the DestroyTimer() functions I get a void action there.

Code:
function Trig_Rounding_Sheep_Modified_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit( )
    local unit b = CreateUnit( GetOwningPlayer(a), guardian_unitcode( ), GetUnitX(a), GetUnitY(a), 0 )
    local timer t = CreateTimer( )
    
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "a",H2I(a) )
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "b",H2I(b) )
    
    call TimerStart( t, 0.03, true, guardian_move() )
    
[B]    set a = null[/B]
    set b = null
    set t = null
endfunction

If I remove 'set a = null', the I get a void action on the 'set b = null' line. And ect.

Remove the useless space you made then.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
The spaces between the lines does not matter. I think the fault lies somewhere else, I just do not know where exactly.:p
 

SFilip

Gone but not forgotten
Reaction score
634
Its the line above :rolleyes:
call TimerStart( t, 0.03, true, guardian_move() )
Not a legal call, you mustn't use () here...and it needs a function prefix.
call TimerStart( t, 0.03, true, function guardian_move )

Oh and it also might not be wise to null local timers that have something "attached" to them. The best solution is to CSSafety (a part of CSCache/Caster System), but since you use handle variables instead this is probably not an option.
But a nulling leak can probably be lived with so...
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Hehe..." Expected '(' "

Code:
function Trig_Rounding_Sheep_Modified_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit( )
    local unit b = CreateUnit( GetOwningPlayer(a), guardian_unitcode( ), GetUnitX(a), GetUnitY(a), 0 )
    local timer t = CreateTimer( )
    
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "a",H2I(a) )
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "b",H2I(b) )
    [B]
    call TimerStart(t, 0.03, true, guardian_move)[/B]
    call DestroyTimer(t)
    
    set a = null
    set b = null
endfunction
 

SFilip

Gone but not forgotten
Reaction score
634
WE's errors can be so misguiding... :p
Anyway it has to have a "function" before the actual name...like this
call TimerStart(t, 0.03, true, function guardian_move)
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Thanks for the patience, finally got it saved without any errors. But the unit 'b' is not moved...I think I somehow "fixed" wrongly the polarprojection bj.

Code:
function guardian_unitcode takes nothing returns integer
    return 'n003' //Rawcode of the 'Guardian Sheep' unit.
endfunction

function guardian_rawcode takes nothing returns integer
    return 'A001' //Rawcode of the 'Guardian Sheep' spell
endfunction

function guardian_radius takes nothing returns real
    return 100.00 //Radius, which the 'Guardian Sheep' revolves around.
endfunction

function guardian_move takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit a = GetHandleUnit( t,"a" )
    local unit b = GetHandleUnit( t,"b" )
    local integer h = GetUnitAbilityLevel( a, guardian_rawcode( ) )
    local real x = GetUnitX( a )
    local real y = GetUnitY( a )
[B]    local real c = I2R( GetUnitUserData(b) )     
    local real x2 = ( x + guardian_radius( ) * Cos(c * bj_DEGTORAD) )
    local real y2 = ( y + guardian_radius( ) * Sin(c * bj_DEGTORAD) )
       
    call SetUnitPosition( b, x2, y2 ) [/B]    
    call SetUnitFacingToFaceUnitTimed( b, a, 0 )      
    call SetUnitUserData( b, (GetUnitUserData(b) + 2) )
    call UnitAddAbility( b, udg_SheepAbility[h] )
    call DestroyTimer(t)
    
    set a = null
    set b = null
endfunction

function Trig_Rounding_Sheep_Modified_Conditions takes nothing returns boolean
    return ( GetLearnedSkill( ) == guardian_rawcode() ) and ( GetUnitAbilityLevel( GetTriggerUnit( ), guardian_rawcode( ) ) == 1 )
endfunction

function Trig_Rounding_Sheep_Modified_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit( )
    local unit b = CreateUnit( GetOwningPlayer(a), guardian_unitcode( ), GetUnitX(a), GetUnitY(a), 0 )
    local timer t = CreateTimer( )
    
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "a",H2I(a) )
    call StoreInteger( LocalVars( ), I2S( H2I(t) ), "b",H2I(b) )
    
    call TimerStart(t, 0.03, true, function guardian_move)
    call DestroyTimer(t)
    
    set a = null
    set b = null
endfunction

//===========================================================================
function InitTrig_Rounding_Sheep_Modified takes nothing returns nothing
    local integer h = 0
    set gg_trg_Rounding_Sheep_Modified = CreateTrigger()
    loop
        call TriggerRegisterPlayerUnitEvent( gg_trg_Rounding_Sheep_Modified, Player(h), EVENT_PLAYER_HERO_SKILL, null )
        set h = h + 1
        exitwhen h == bj_MAX_PLAYER_SLOTS
    endloop   
    call TriggerAddCondition( gg_trg_Rounding_Sheep_Modified, Condition( function Trig_Rounding_Sheep_Modified_Conditions ) )
    call TriggerAddAction( gg_trg_Rounding_Sheep_Modified, function Trig_Rounding_Sheep_Modified_Actions )
endfunction
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Took a break and while watching tv, I realised, the timer needs to run through the entire game, so I don't need to destroy it. Now it works, yay.:p
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Code:
native AddSpecialEffectTarget       takes string modelName, widget targetWidget, string attachPointName returns effect

Right?

Code:
local effect e = AddSpecialEffectTarget("Abilities\Spells\Human\Polymorph\PolyMorphFallingSheepArt.mdl", a, "origin")

Right?

Well, I get an "Expected valid argument list" error from that line. Does anyone know, what I am doing wrong?

Code:
function Effect_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit()
    local effect e = AddSpecialEffectTarget("Abilities\Spells\Undead\VampiricAura\VampiricAura.mdl", a, "origin")
...
...
endfunction
 

Chocobo

White-Flower
Reaction score
409
Code:
function Effect_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit()
    local effect e = AddSpecialEffectTarget("Abilities\Spells\Undead\VampiricAura\VampiricAura.mdl", a, "origin")


Try this :

Code:
function Effect_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit()
    local effect e = AddSpecialEffectTarget("Abilities\\Spells\\Undead\\VampiricAura\\VampiricAura.mdl", a, "origin")
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top