[JASS] Help implementing a spell

Status
Not open for further replies.
Level 12
Joined
Mar 23, 2008
Messages
942
Boomerang... lol

Edit: lol this is a WOP (Workaround-oriented programming)

Everything I want is to make a boomerang spell that throw two blades in in +45 and -45 angle and them they go forward the enemy and return to the caster... But when I throw the right blade goes to the right point but the left one start a infinite rush across the map...
I already tried many ways, this is the actual (poor) version of the trigger.
I already tried with move orders but the max movement speed is 500. that make the blade slow and if both target and caster have a good movement speed they can ruin the spell.

JASS:
function Trig_Kansho_and_Bakuya_Jass_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A01O' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Kansho_and_Bakuya_Jass_Actions takes nothing returns nothing
    local unit x1
    local unit x2
    local unit c1 = GetSpellAbilityUnit()
    local real f1 = GetUnitFacing(c1)
    local location point0 = GetUnitLoc(GetSpellAbilityUnit())
    local location point1 = GetUnitLoc(GetSpellTargetUnit())
    local location point2 = PolarProjectionBJ(GetUnitLoc(GetSpellAbilityUnit()), ( DistanceBetweenPoints(point0, point1) / 2.00 ), ( f1 + 45.00 ))
    local location point3 = PolarProjectionBJ(GetUnitLoc(GetSpellAbilityUnit()), ( DistanceBetweenPoints(point0, point1) / 2.00 ), ( f1 - 45.00 ))
    local real dx = GetLocationX(point0) - GetLocationX(point2)
    local real dy = GetLocationY(point0) - GetLocationY(point2)
    local real r1 = ( DistanceBetweenPoints(point0, point2) / 8 )
    local location px1
    local location px2
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h00H', GetOwningPlayer(GetSpellAbilityUnit()), point0, point1 )
    set x1 = (GetLastCreatedUnit())
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h00H', GetOwningPlayer(GetSpellAbilityUnit()), point0, point1 )
    set x2 = (GetLastCreatedUnit())
loop
    if ( ( DistanceBetweenPoints(GetUnitLoc(x1), point2) <= 50.00 ) ) then
      call SetUnitPositionLoc( x1, point2)
     else
      call SetUnitPositionLoc( x1, PolarProjectionBJ(GetUnitLoc(x1), 40 , ( f1 + 45.00 )) )
    endif
    if ( ( DistanceBetweenPoints(GetUnitLoc(x2), point3) <= 50.00 ) ) then
      call SetUnitPositionLoc( x2, point3)
     else
      call SetUnitPositionLoc( x2, PolarProjectionBJ(GetUnitLoc(x2), 40 , ( f1 - 45.00 )) )
    endif
    set px1 = GetUnitLoc(x1)
    set px2 = GetUnitLoc(x2)
    exitwhen px1 == point2 and px2 == point3
    call TriggerSleepAction(0.01)
endloop
loop
    if ( ( DistanceBetweenPoints(GetUnitLoc(x1), point1) <= 50.00 ) ) then
      call SetUnitPositionLoc(x1, point1)
     else
      call SetUnitPositionLoc( x1, PolarProjectionBJ(GetUnitLoc(x1), r1 , ( f1 - 45.00 )) )
    endif
    if ( ( DistanceBetweenPoints(px2, point1) <= 50.00 ) ) then
      call SetUnitPositionLoc(x2, point1)
     else
      call SetUnitPositionLoc( x2, PolarProjectionBJ(GetUnitLoc(x2), r1 , ( f1 + 45.00 )) )
    endif
    set px1 = GetUnitLoc(x1)
    set px2 = GetUnitLoc(x2)
    call TriggerSleepAction(0.02)
    exitwhen DistanceBetweenPoints(px1, point1) <= 50.00 and DistanceBetweenPoints(px2, point1) <= 50.00
endloop
loop
    set point0 = GetUnitLoc(c1)
    call IssuePointOrderLocBJ( x1, "move", point0 )
    call IssuePointOrderLocBJ( x2, "move", point0 )
    call TriggerSleepAction(0.05)
    exitwhen GetUnitCurrentOrder(x1) == (OrderId("idle")) and GetUnitCurrentOrder(x2) == (OrderId("idle"))
endloop
    call KillUnit(x1)
    call KillUnit(x2)
    set x1 = null
    set x2 = null
    set c1 = null
    call RemoveLocation (px1)
    call RemoveLocation (px2)
    call RemoveLocation (point0)
    call RemoveLocation (point1)
    call RemoveLocation (point2)
    call RemoveLocation (point3)
endfunction

//===========================================================================
function InitTrig_Kansho_and_Bakuya_Jass takes nothing returns nothing
    set gg_trg_Kansho_and_Bakuya_Jass = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Kansho_and_Bakuya_Jass, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Kansho_and_Bakuya_Jass, Condition( function Trig_Kansho_and_Bakuya_Jass_Conditions ) )
    call TriggerAddAction( gg_trg_Kansho_and_Bakuya_Jass, function Trig_Kansho_and_Bakuya_Jass_Actions )
endfunction
 
Last edited:
Status
Not open for further replies.
Top