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.
  • 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