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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top