What would cause code that works in one map, to not work in another?

MasterRofl

New Member
Reaction score
8
EDIT: Whatever, I switched to ABC and it works fine... heheh...

I have this:
JASS:
library ThrowKnife initializer ThrowKnife uses HSAS

globals
    private constant integer SPELLID = 'A01U'
    private constant string SLOWSTRING = "slow"
    private constant integer DUMMYID = 'n00N'
    private constant integer DUMMYSPELLID = 'A026'
endglobals

struct Dagger
    unit u
    unit t
    unit d
    real x
    real y
    real damage
        method onDestroy takes nothing returns nothing
            set.u = null
            set.t = null
            set.d = null
        endmethod
endstruct

private function AngleBetweenXY takes real x, real y, real xy, real yx returns real
    return bj_RADTODEG * (Atan2(y - yx, x - xy))
endfunction

private function DistanceBetweenXY takes real x, real y, real xy, real yx returns real
    local real dx = xy - x
    local real dy = yx - y
    return SquareRoot((dx * dx) + (dy * dy))
endfunction

//! runtextmacro HSAS_Static("d", "6", "private")

private function Callback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local Dagger d = GetAttachedStructd(t)
    local real x
    local real y 
    local real xy
    local real yx
    set x = GetUnitX(d.d)
    set y = GetUnitY(d.d)
    set xy = GetUnitX(d.t)
    set yx = GetUnitX(d.t)
    call SetUnitPositionLocFacingLocBJ( d.d, PolarProjectionBJ(GetUnitLoc(d.d), 25., AngleBetweenPoints(GetUnitLoc(d.d), GetUnitLoc(d.t))), GetUnitLoc(d.t))
    if  DistanceBetweenPoints(GetUnitLoc(d.d), GetUnitLoc(d.t)) < 12. then
        call SetUnitAbilityLevel(d.d, DUMMYSPELLID, GetUnitAbilityLevel(d.u, SPELLID))
        call IssueTargetOrder( d.d, SLOWSTRING, d.t)
        call UnitDamageTarget(d.d, d.t, d.damage, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
        call RemoveUnit(d.d)
        call d.destroy()
        call PauseTimer(t)
        call DestroyTimer(t)
    endif
endfunction

private function Actions takes nothing returns nothing
    local Dagger d = Dagger.create()
    local timer t = CreateTimer()
    set d.u = GetTriggerUnit()
    set d.t = GetSpellTargetUnit()
    set d.x = GetUnitX(d.u)
    set d.y = GetUnitY(d.u)
    set d.damage = GetUnitAbilityLevel(d.u, SPELLID) * 100.
    set d.d = CreateUnit( GetOwningPlayer(d.u), DUMMYID, d.x, d.y, AngleBetweenPoints(GetUnitLoc(d.u), GetUnitLoc(d.t)))
    call AttachStructd(t, d)
    call TimerStart(t, 0.03, true, function Callback)
    set t = null
endfunction

private function Conds takes nothing returns boolean
    return GetSpellAbilityId() == SPELLID
endfunction

private function ThrowKnife takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition( function Conds ))
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

endlibrary
and if I put it into a new map (/w HSAS), it works as intended. However, when I put it into a map that my friend and I have worked on for a while, it stops working (specifically the timer calling the function Callback).

What can possibly be preventing the code from working properly?
 

MasterRofl

New Member
Reaction score
8
The objects and HSAS in the two maps are the same. The new map has ONLY the above posted trigger, and HSAS, and the main map I'm working on has HSAS, and a whole bunch of other triggers. The main map also has a sh*t-ton of global variables (since I just started learning JASS), and GUI triggers.

EDIT: Whatever, I switched to ABC and it works fine... heheh...
 
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