• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] The code does not work :S

Status
Not open for further replies.
Level 18
Joined
Oct 18, 2007
Messages
930
Ok im making a thingy that teleports you and ure target to the center and fires 2 shockwaves, but this dosent wor -.-

It moves, and sends shockwave but only 1 and in the wrong direction...

EDIT: !Found my silly bug :D it was clearly stuck out, found it after 3 min i posted this lol -.-!

Jass thingy
JASS:
function Double_Edge_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00P'
endfunction

function Double_Edge_Actions takes nothing returns nothing

//#######################################################################

    local unit cast = GetTriggerUnit()
    local unit targ = GetSpellTargetUnit()
    local unit dummy = null


    local player owner = GetOwningPlayer(cast)


    local real x = GetUnitX(cast)
    local real y = GetUnitY(cast)
    local real x2 = GetUnitX(targ)
    local real y2 = GetUnitY(targ)
    local real x3
    local real y3
    local location xy = Location(x,y)
    local location xy2 = Location(x2,y2)
    local location xy3


    local real Angle1 = AngleBetweenPoints(xy,xy2)
    local real Angle2 = AngleBetweenPoints(xy2,xy)


    local real Distance1 = DistanceBetweenPoints(xy,xy2) - 100.00
    local real Distance2 = DistanceBetweenPoints(xy2,xy) - 100.00


    local location loc1 = PolarProjectionBJ(xy, Distance1 / 2.00, Angle1)
    local location loc2 = PolarProjectionBJ(xy2, Distance2 / 2.00, Angle2)


    local location TempLoc


    local effect se = null

//#######################################################################

    call SetUnitPositionLocFacingLocBJ( targ, loc2, xy )
    call SetUnitPositionLocFacingLocBJ( cast, loc1, xy2 )

    set se = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl", cast, "origin")
    call DestroyEffect(se)
    set se = null
    set se = AddSpecialEffectTarget("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", targ, "origin")
    call DestroyEffect(se)
    set se = null

    set x3 = GetUnitX(cast)
    set y3 = GetUnitY(cast)
    set xy3 = Location(x,y)
    set dummy = CreateUnit(owner,'h000',x3,y3,90.00)
    call UnitApplyTimedLife(dummy,'BTLF', 1.5 )
    call UnitAddAbility(dummy,'A00Q')
    call SetUnitAbilityLevelSwapped( 'A00Q', dummy, GetUnitAbilityLevelSwapped('A00P', cast) )
    set TempLoc = PolarProjectionBJ(xy3, 300.00, ( Angle1 + 15.00 ))
    call IssuePointOrderLoc(dummy,"shockwave",TempLoc)
    call RemoveLocation(TempLoc)
    set TempLoc = null
    set dummy = null
    call UnitApplyTimedLife(dummy,'BTLF', 1.5 )
    call UnitAddAbility(dummy,'A00Q')
    call SetUnitAbilityLevelSwapped( 'A00Q', dummy, GetUnitAbilityLevelSwapped('A00P', cast) )
    set TempLoc = PolarProjectionBJ(xy3, 300.00, ( Angle1 - 15.00 ))
    call IssuePointOrderLoc(dummy,"shockwave",TempLoc)
    call RemoveLocation(TempLoc)
    set TempLoc = null
    set dummy = null
    call RemoveLocation(xy)
    call RemoveLocation(xy2)
    call RemoveLocation(xy3)
    set xy = null
    set xy2 = null
    set xy3 = null
    set cast = null
    set targ = null
    set owner = null
endfunction

//===========================================================================
function InitTrig_Double_Edge takes nothing returns nothing
    local trigger T = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( T, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( T, Condition( function Double_Edge_Conditions ) )
    call TriggerAddAction( T, function Double_Edge_Actions )
    set T = null
endfunction

Any ideas???
 
Level 5
Joined
Jan 6, 2006
Messages
106
JASS:
------------------------------------------------------------
    set TempLoc = null
    set dummy = null
    call UnitApplyTimedLife(dummy,'BTLF', 1.5 )

------------------------------------------------------------

Huh? You applied timed life to "dummy" immediately after you nullified it? XD
No worries. Just a small typo in the script.

Fix:
JASS:
-------------------------------------------------------------
    set TempLoc = null
    set dummy = null
    set dummy = CreateUnit(owner,'h000',x3,y3,90.00)
    call UnitApplyTimedLife(dummy,'BTLF', 1.5 )
-------------------------------------------------------------

Hope this fixes it.

And about the angle problem, if it still flies at the wrong direction, try using Abs(Angle1)
 
Status
Not open for further replies.
Top