d is not of a type that allows .syntax

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Okay, I get this Jasshelper error (yes I got it almost fully working).
Basicly, the only one that gives me this error is d.offsetWTH?
I'm new to vJass (btw)
_I want this spell MUI so I use struct data.

JASS:

scope HookShot initializer Init
    globals
        private constant integer SPELL_ID = 'H00K'
        private constant integer DUMMY_ID = 'dumy'
    endglobals

private struct data
    unit caster
    real offset
    real angle
    real lenght
    location cpoint
    player p
endstruct

function Cond takes nothing returns boolean
    return GetSpellAbilityId() == SPELL_ID
endfunction

function Callback takes nothing returns nothing
    local location spawnpoint
    local unit c
    set d.offset = d.offset + 20.00
    set d.lengh = d.lenght - 0.05
    
    set spawnpoint = PolarProjectionBJ( d.cpoint, d.offset, d.angle )
    set c = CreateUnitAtLoc( p, DUMMY_ID, spawnpoint, d.angle )
    call UnitApplyTimedLife( c, 'BTLF', d.lenght )
        
    call RemoveLocation( spawnpoint)
    set spawnpoint = null
endfunction

function Main takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local timer t
    local location tloc = GetSpellTargetLoc()
    local location uloc = GetUnitLoc( u)
    
    set d.cpoint = uloc
    set d.offset = 0.00
    set d.lengh = 2.00
    set d.angle = AngleBetweenPoints( uloc, tloc)
    set d.p = GetOwningPlayer( u)
    call TimerStart( t, 0.05, true, function Callback)
    
    call RemoveLocation( tloc)
    call RemoveLocation( uloc)
    call RemoveLocation( d.cpoint)
    set u = null
    set t = null
    set tloc = null
    set uloc = null
endfunction

//===========================================================================
function Init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Cond))
    call TriggerAddAction( t, function Main )
endfunction

endscope
 

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
Shouldn't it be 'data' instead of 'd'?
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Well, I don't know, I'm new of about 2 days to vJass.
Oh and, in the call TimerStart, what does the boolean means?
 

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
I don't know any vJass. Try it.
 

cleeezzz

The Undead Ranger.
Reaction score
268
JASS:
scope HookShot initializer Init
    globals
        private constant integer SPELL_ID = 'H00K'
        private constant integer DUMMY_ID = 'dumy'
    endglobals

private struct data
    unit caster
    real offset
    real angle
    real lenght
    location cpoint
    player p
endstruct

function Cond takes nothing returns boolean
    return GetSpellAbilityId() == SPELL_ID
endfunction

function Callback takes nothing returns nothing
    local data d = GetCSData(GetExpiredTimer())
    local location spawnpoint
    local unit c
    set d.offset = d.offset + 20.00
    set d.lengh = d.lenght - 0.05
    
    set spawnpoint = PolarProjectionBJ( d.cpoint, d.offset, d.angle )
    set c = CreateUnitAtLoc( p, DUMMY_ID, spawnpoint, d.angle )
    call UnitApplyTimedLife( c, 'BTLF', d.lenght )
        
    call RemoveLocation( spawnpoint)
    set spawnpoint = null
endfunction

function Main takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local timer t
    local location tloc = GetSpellTargetLoc()
    local location uloc = GetUnitLoc( u)
    local data d = data.create()

    set d.cpoint = uloc
    set d.offset = 0.00
    set d.lengh = 2.00
    set d.angle = AngleBetweenPoints( uloc, tloc)
    set d.p = GetOwningPlayer( u)
    call TimerStart( t, 0.05, true, function Callback)
    call SetCSData(t,d)
    call RemoveLocation( tloc)
    call RemoveLocation( uloc)
    call RemoveLocation( d.cpoint)
    set u = null
    set t = null
    set tloc = null
    set uloc = null
endfunction

//===========================================================================
function Init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Cond))
    call TriggerAddAction( t, function Main )
endfunction

endscope

you didn't use any attachment system so the struct would not be carried over to the callback function
the code now requires CSData

(and btw, you never created the struct, you must create it by doing (struct name).create(), in your case, data.create()

and you must set it to a variable in order to use it

local (struct name) (variable)
set (variable) = (struct name).create()

in your case

local data d
set d = data.create()

or you could skip a step like i did in the code

local data d = data.create()
 

cleeezzz

The Undead Ranger.
Reaction score
268
http://www.wc3c.net/showthread.php?t=80534

16.0 for 1.23b patch
15.3 for current


>>>>Oh and, in the call TimerStart, what does the boolean means?
periodic or not

if true, the timer will restart when it expires. so

call TimerStart(t,1,true,function hi)
would run function hi every second

call TimerStart(t,1,false,function hi)
would run function hi only once
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
>>>>Oh and, in the call TimerStart, what does the boolean means?
periodic or not

if true, the timer will restart when it expires. so

call TimerStart(t,1,true,function hi)
would run function hi every second

call TimerStart(t,1,false,function hi)
would run function hi only once

Do I need a special system for CSData?

and, how can I stop the function to be ran?
 

cleeezzz

The Undead Ranger.
Reaction score
268
>Do I need a special system for CSData?
not that i know of, unless you dont have newgen?

>and, how can I stop the function to be ran?
stop the timer?
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Ty
Just another, where can I call it, in which function?
Edit:
In the Callback ,I add this after, lets say 50 excution?
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
Sure. Just remember to pause the timer before destroying it, or else it will bug up and continue to run, after what I've heard.

Something like this perhaps?

JASS:
// Structs and such

private function CB takes nothing returns nothing
    local data d = GetCSData(GetExpiredTimer())
    set d.counter = d.counter + 1
    if d.counter < 50 then
       // Do your things, including nulling of handles within this block
    
    else
        call PauseTimer(GetExpiredTimer())
        call DestroyTimer(GetExpiredTimer())
        call d.destroy()
        return
     endif
endfunction

private function Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local data d = data.create()
    set d.counter = 0
    call TimerStart(t, 0.035, true, function CB)
    // Your other actions go here, of course.
    set t = null
endfunction
 

Romek

Super Moderator
Reaction score
963
Use TimerUtils instead of CSData.
 

Romek

Super Moderator
Reaction score
963
TimerUtils has timer recycling.
 

Romek

Super Moderator
Reaction score
963
Obviously CSData won't leak; It's a system which doesn't even create handles... :confused:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top