HAIL - Cannot convert timer to integer error

Flare

Stops copies me!
Reaction score
662
Solved

For some reason, whenever I try to retrieve my struct data from a timer using HAIL, I get an error (cannot convert timer to integer). I also get a similar error when attaching the struct to a timer (cannot convert integer to timer)

Do I need to run the HAIL textmacro within the scope?

NOTE: This is my first time using HAIL, so if the problem is related to how I created the property or how I called the function, please explain exactly how I should fix it.

(I have marked the lines between a pair of comments. One error is in TimerActions, the other is in MeathookActions)
JASS:
//Meat Hook
//By Flare
//Constructed using vJASS and Strilanc's HAIL system
//Thanks to Strilanc for creating HAIL
//Thanks to DotA for the inspiration to make my own version of the spell

//REQUIRES NEWGEN WORLDEDITOR TO OPEN\\

//Importing instructions\\
///////////////////////////////////////////////////////
//Copy the HAIL trigger into your map
//Copy the Meathook trigger into your map
//Copy the Hook Dummy unit, Link Dummy unit and Meathook ability into your map
//Adjust the SPELLID, HOOKID and LINKID values in the global block.
//They MUST match the rawcodes shown in Object Editor (press Ctrl - D to view the rawcodes)
//Adjust the remainder of the constants to suit your needs
//Add the Meathook ability to a unit.
//Cast the ability, and enjoy.
///////////////////////////////////////////////////////
//End of importing instructions\\

//Initializing HAIL
//Do -NOT-, under ANY circumstances, change the following lines unless you know exactly what you are doing
    //! runtextmacro HAIL_CreateProperty("HookTimer", "timer", "")
    //! runtextmacro HAIL_CreateProperty("HookTrigger", "trigger", "")
    
scope Meathook
globals
    //This limits the number of links to the hook's chain.
//Setting it higher will limit the MUI capability (currently, 81 instances max)
//Setting it lower will potentially limit the maximum distance travelled
//^--Depends on how close the links will be spawned beside each other
    constant integer MAXLINKS = 100
    
    //Rawcodes\\
//Base ability (Meathook) rawcode
    private constant integer SPELLID = 'A000'
//Hook dummy rawcode
    private constant integer HOOKID = 'h000'
//Link dummy ID
    private constant integer LINKID = 'h001'
    
    //Other constants\\
//Timer interval
    private constant real TIMERINTERVAL = 0.03
    
//Distance travelled per second by hook
    private constant real SPEED = 800
    
//Distance moved per timer interval
//Also used for distance between hook links
    private constant real DISTANCE = SPEED*TIMERINTERVAL
//DISTANCE * MAXLINKS = Maximum possible distance. Increase SPEED, TIMERINTERVAL (not highly advised) or MAXLINKS to increase the maximum possible range.
//Currently, maximum range is 2400 (100 * (800*0.03) = 100 * 24 = 2400)

//-180 degrees in radians
//This is used for hook retraction
    private constant real REVERSEANGLE = Deg2Rad (-180)
    
//Collision range
    private constant real COLLIDERANGE = 100
    
//Hook size scale
    private constant real HOOKSCALE = 1.
    
//Link size scale
    private constant real LINKSCALE = 1.
    
//How far in front of the hero the hook will form
    private constant real SPAWNOFFSET = 100
    
//Effect created on hook hit
//NOTE: Make sure you replace a single \ with \\ if you change this i.e.
//Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl --> Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl
    private constant string FXSTRING = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
    
//Determines whether the above effect is created when an ally is hit
//By default, no SFX will be created when hitting an ally.
    private constant boolean ALLYHITSFX = false
endglobals



//DO NOT EDIT BELOW HERE
//--------------------------------------------------------------------------------\\

//Struct data for the hook
private struct Hookdata
    unit hookcaster = null //The unit who casts Meathook
    unit hooktarget = null //The target struck
    unit array hooklink[MAXLINKS] //The links/segments of the hook chain
    integer linkcounter //Used for creating/destroying the above units
    real hookangle //Angle at which the hook travels
    real currentdistance //Current distance travelled by the hook
    real maxdistance //Maximum distance travelled before the hook retracts
    real damage = 0//The damage, obviously
    unit hook = null//The hook itself
    real targetangle //Used to keep the angle between hook and victim correct on retract
    real targetdistance //Same as above, except relates to distance instead of angle
    boolean retracton = false
    boolean targethooked = false
    timer hooktimer //Timer used for extension/retraction
    trigger hittrig //Trigger used for detecting when a unit is hit
    method onDestroy takes nothing returns nothing //Cleaning up triggers/timers/HAIL
        call ResetHookTimer (.hooktimer)
        call DestroyTimer (.hooktimer)
        call ResetHookTrigger (.hittrig)
        call DestroyTrigger (.hittrig)
    endmethod
endstruct

private function TimerActions takes nothing returns nothing
    local timer t = GetExpiredTimer ()
//This line gives an error
    local Hookdata a = GetHookTimer (t)
//------------------------
    local real hx1 = GetUnitX (a.hook)
    local real hy1 = GetUnitY (a.hook)
    local real hx2
    local real hy2
    local real tx
    local real ty
    if a.retracton == false then
        set a.linkcounter = a.linkcounter + 1
        set a.hooklink[a.linkcounter] = CreateUnit (GetOwningPlayer (a.hookcaster), LINKID, hx1, hy1, Rad2Deg (a.hookangle))
        set hx2 = hx1 + Cos(a.hookangle)*DISTANCE
        set hy2 = hy1 + Sin (a.hookangle)*DISTANCE
    else
        set a.linkcounter = a.linkcounter - 1
        call RemoveUnit (a.hooklink[a.linkcounter])
        set hx2 = hx1 + Cos(a.hookangle + REVERSEANGLE)*DISTANCE
        set hy2 = hy1 + Sin (a.hookangle + REVERSEANGLE)*DISTANCE
    endif
    
    set a.currentdistance = a.currentdistance + DISTANCE
    call SetUnitPosition (a.hook, hx2, hy2)
    
    if a.currentdistance >= a.maxdistance then
        set a.retracton = true
    endif
    
    if a.targethooked == true then
        set tx = hx2 + Cos (a.targetangle) * a.targetdistance
        set ty = hy2 + Sin (a.targetangle) * a.targetdistance
        call SetUnitPosition (a.hooktarget, tx, ty)
    endif
endfunction

private function MeathookCond takes nothing returns boolean
    return GetSpellAbilityId () == SPELLID
endfunction
    
private function MeathookActions takes nothing returns nothing
    local Hookdata a = Hookdata.create ()
    local location targetloc
    local real cx
    local real cy
    local real tx
    local real ty
    local real sx
    local real sy
    set a.hookcaster = GetTriggerUnit ()
    set a.linkcounter = 0
    if GetSpellTargetUnit () == null then
        set targetloc = GetSpellTargetLoc ()
        set tx = GetLocationX (targetloc)
        set ty = GetLocationY (targetloc)
        call RemoveLocation (targetloc)
    else
        set tx = GetUnitX (GetSpellTargetUnit ())
        set ty = GetUnitY (GetSpellTargetUnit ())
    endif
    set cx = GetUnitX (a.hookcaster)
    set cy = GetUnitY (a.hookcaster)
    set a.hookangle = Atan2 (ty-cy, tx-cx)
    set sx = cx + Cos (a.hookangle)*SPAWNOFFSET
    set sy = cy + Sin (a.hookangle)*SPAWNOFFSET
    set a.hook = CreateUnit (GetOwningPlayer (a.hookcaster), HOOKID, sx, sy, Rad2Deg (a.hookangle))
    set a.hooklink[a.linkcounter] = CreateUnit (GetOwningPlayer (a.hookcaster), LINKID, sx, sy, Rad2Deg (a.hookangle))
    set a.hooktimer = CreateTimer ()
    set a.hittrig = CreateTrigger ()
//This line gives an error
    call SetHookTimer (a.hooktimer, a)
//------------------------
    call TimerStart (a.hooktimer, TIMERINTERVAL, true, function TimerActions)
endfunction
    
public function InitTrig takes nothing returns nothing
    local trigger Meathook = CreateTrigger ()
    call TriggerRegisterAnyUnitEventBJ (Meathook, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition (Meathook, Condition (function MeathookCond))
    call TriggerAddAction (Meathook, function MeathookActions)
endfunction
endscope


EDIT: oh... when I run the textmacro, the second argument is the type of the data BEING attached, not the handle type to which you are attaching the data...
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      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