• 🏆 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!

[Spell] Jass Locations

Status
Not open for further replies.
Level 6
Joined
Mar 2, 2013
Messages
127
-Sorry if this is the wrong place to post

I didn't make this, im kinda bad with jass...
This spell, is a single target, takes both units, throws them around in the air them slams them to the ground dealing damage to the target. The problem I have is that it sometimes puts the units down in the water/hills, where units get stuck.

Solution: Save locations of both units at the start of the spell, then at the end, move them to where it started. If only i knew how to do this :(
Please help! Thanks - Holybear


JASS:
function HPCheck_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A01V' and GetUnitStateSwap(UNIT_STATE_LIFE, GetSpellAbilityUnit()) <= 200.00 then
        return true
    endif
    return false
endfunction

function HPCheck_Actions takes nothing returns nothing
    call IssueImmediateOrder( GetSpellAbilityUnit(), "stop" )
    call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetSpellAbilityUnit())), "                                                                                          |cffffcc00Not enough HP.|r" )
endfunction

//===========================================================================
function InitTrig_HP_Check takes nothing returns nothing
    set gg_trg_HP_Check = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_HP_Check, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_HP_Check, Condition( function HPCheck_Conditions ) )
    call TriggerAddAction( gg_trg_HP_Check, function HPCheck_Actions )
endfunction

JASS:
globals
    integer PRIMARY_INTEGER = 0
    timer PRIMARY_TIMER = CreateTimer()
endglobals

function Primary_Lotus_Main_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A01V'
endfunction

function Primary_Lotus_Hits takes nothing returns nothing
        local unit u
        local effect e
        local location l = GetUnitLoc(udg_LotusTarget)
        set PRIMARY_INTEGER = PRIMARY_INTEGER + 1
        call SetUnitTimeScalePercent(udg_LotusCaster,200.0)
        call SetUnitVertexColor(udg_LotusCaster, PercentTo255(100), PercentTo255(100), PercentTo255(100), PercentTo255(100.0))
        call SetUnitPositionLocFacingLocBJ( udg_LotusCaster, PolarProjectionBJ(l, 10.00, ( udg_LotusAngle + 180.00 )), l )
        set udg_LotusHeight = GetRandomInt(100, 500)
        call SetUnitFlyHeight(udg_LotusCaster,I2R(udg_LotusHeight),1000000000.00)
        call SetUnitFlyHeight(udg_LotusTarget,I2R(udg_LotusHeight),1000000000.00)
        call SetUnitAnimation(udg_LotusCaster,"attack")
        call SetUnitAnimation(udg_LotusTarget,"death")
        if GetUnitAbilityLevel(udg_LotusCaster,'A01V') == 1 then
            call UnitDamageTarget(udg_LotusCaster,udg_LotusTarget,I2R(GetUnitAbilityLevel(udg_LotusCaster,'A01G')) * 10.0, true, false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        else
            if GetUnitAbilityLevel(udg_LotusCaster,'A01V') == 2 then
                call UnitDamageTarget(udg_LotusCaster,udg_LotusTarget,I2R(GetUnitAbilityLevel(udg_LotusCaster,'A01G')) * 12, true, false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            else
                if GetUnitAbilityLevel(udg_LotusCaster,'A01V') == 3 then
                    call UnitDamageTarget(udg_LotusCaster,udg_LotusTarget,I2R(GetUnitAbilityLevel(udg_LotusCaster,'A01G')) * 14, true, false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                endif
            endif
        endif
        set l = GetUnitLoc(udg_LotusTarget)
        set u = CreateUnitAtLoc(GetOwningPlayer(udg_LotusCaster),'h00X',l,GetUnitFacing(udg_LotusCaster))
        call UnitApplyTimedLife(u, 'BTLF', 1.0)
        set u = null
        if IsUnitType(udg_LotusCaster,UNIT_TYPE_DEAD) == true or IsUnitType(udg_LotusTarget,UNIT_TYPE_DEAD) == true then
            call CreateNUnitsAtLoc( 1, 'h00Q', Player(PLAYER_NEUTRAL_PASSIVE), l, bj_UNIT_FACING )
            call UnitAddAbility(GetLastCreatedUnit(),'A020')
            call SetUnitAbilityLevel(GetLastCreatedUnit(), 'A020', 2 )
            call IssueTargetOrder(GetLastCreatedUnit(), "cripple", udg_LotusCaster)
            call UnitApplyTimedLife(GetLastCreatedUnit(),'BTLF',1.0)
            call DisableTrigger(gg_trg_Primary_Lotus_Fade)
            call DisableTrigger(gg_trg_Primary_Lotus_TargetMove)
            call SetUnitFlyHeight(udg_LotusTarget,0.00,1000.0)
            call SetUnitFlyHeight(udg_LotusCaster,0.00,1000.0)
            call SetUnitVertexColor(udg_LotusCaster, PercentTo255(100), PercentTo255(100), PercentTo255(100), PercentTo255(100.0))
            call UnitRemoveAbility(udg_LotusCaster, 'Amrf')
            call UnitRemoveAbility(udg_LotusTarget, 'Amrf')
            call SafeUnPause(udg_LotusCaster)
            call SafeUnPause(udg_LotusTarget)
            call SetUnitPathing(udg_LotusTarget,true)
            call SetUnitPathing(udg_LotusCaster,true)
            call RemoveLocation(udg_LotusPoint)
            set udg_LotusCaster = null
            set udg_LotusTarget = null
            return
        endif
        set udg_LotusFade = 0.0
        set l = GetUnitLoc(udg_LotusTarget)
        call EnableTrigger(gg_trg_Primary_Lotus_Fade)
        if DistanceBetweenPoints(GetUnitLoc(udg_LotusTarget), l) >= 500.0 then
            set udg_LotusAngle = AngleBetweenPoints(l,l)
        else
            set udg_LotusAngle = GetRandomReal(0,360)
        endif
        call SetUnitFacingTimed(udg_LotusCaster,udg_LotusAngle,0)

        if PRIMARY_INTEGER > 12 then
            set PRIMARY_INTEGER = 0
            call PauseTimer(PRIMARY_TIMER)
        endif
endfunction

//-----------------------------------------------------------------------------------------

function Primary_Lotus_Main_Actions takes nothing returns nothing
    local unit u
    local effect e
    local location l
    set udg_LotusCaster = GetTriggerUnit()
    call SetUnitState(udg_LotusCaster,UNIT_STATE_LIFE,RMaxBJ(0,(GetUnitState(udg_LotusCaster,UNIT_STATE_LIFE) - 200.00)))
    set udg_LotusTarget = GetSpellTargetUnit()
    set l = GetUnitLoc(udg_LotusTarget)
    call SafePause(udg_LotusCaster)
    call SafePause(udg_LotusTarget)
    call UnitAddAbility(udg_LotusCaster, 'Amrf')
    call UnitAddAbility(udg_LotusTarget, 'Amrf')
    call SetUnitPathing( udg_LotusCaster, false )
    call SetUnitPathing( udg_LotusTarget, false )
    call SetUnitAnimationWithRarity( udg_LotusCaster, "spell power up", RARITY_RARE )
    call TriggerSleepAction(0.1)
    if GetUnitAbilityLevel(udg_LotusCaster,'A01V') == 1 then
        call UnitDamageTarget(udg_LotusCaster,udg_LotusTarget,I2R(GetUnitAbilityLevel(udg_LotusCaster,'A04M')) * 25.0, true, false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    else
        if GetUnitAbilityLevel(udg_LotusCaster,'A01V') == 2 then
            call UnitDamageTarget(udg_LotusCaster,udg_LotusTarget,I2R(GetUnitAbilityLevel(udg_LotusCaster,'A04M')) * 35.0, true, false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        else
            if GetUnitAbilityLevel(udg_LotusCaster,'A01V') == 3 then
                call UnitDamageTarget(udg_LotusCaster,udg_LotusTarget,I2R(GetUnitAbilityLevel(udg_LotusCaster,'A04M')) * 45.0, true, false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            endif
        endif
    endif
    set u = CreateUnitAtLoc(GetOwningPlayer(udg_LotusTarget),'h00X',GetUnitLoc(udg_LotusCaster),270.00)
    call UnitApplyTimedLife(u, 'BTLF', 1.00)
    call SetUnitFlyHeight(u, 200.0, 1000000000.0)
    call SetUnitFlyHeight(udg_LotusTarget,500.0,500.0)
    call SetUnitAnimation(udg_LotusTarget, "death")
    call TriggerSleepAction(0.5)
    set u = null
    set udg_LotusFade = 0.00
    call EnableTrigger(gg_trg_Primary_Lotus_Fade)
    set udg_LotusAngle = GetRandomReal(0, 360)
    call SetUnitFacingTimed(udg_LotusCaster,udg_LotusAngle,0)
    if IsUnitType(udg_LotusCaster,UNIT_TYPE_DEAD) == true or IsUnitType(udg_LotusTarget,UNIT_TYPE_DEAD) == true then
        call DisableTrigger(gg_trg_Primary_Lotus_Fade)
        call DisableTrigger(gg_trg_Primary_Lotus_TargetMove)            
        call TriggerSleepAction(0.1)
        call SetUnitFlyHeight(udg_LotusTarget, 0.00, 1000.00)
        call SetUnitFlyHeight(udg_LotusCaster, 0.00, 1000.00)
        call SetUnitVertexColor(udg_LotusCaster, PercentTo255(100), PercentTo255(100), PercentTo255(100), PercentTo255(100.0))
        call TriggerSleepAction(0.5)
        call UnitRemoveAbility(udg_LotusCaster, 'Amrf')
        call UnitRemoveAbility(udg_LotusTarget, 'Amrf')
        call SafeUnPause(udg_LotusCaster)
        call SafeUnPause(udg_LotusTarget)
        call SetUnitPathing( udg_LotusTarget, true )
        call SetUnitPathing( udg_LotusCaster, true )
        call RemoveLocation (udg_LotusPoint)
        set udg_LotusCaster = null
        set udg_LotusTarget = null
        return
    endif
    call TriggerSleepAction(0.4)
    call EnableTrigger( gg_trg_Primary_Lotus_TargetMove )
    call TimerStart(PRIMARY_TIMER,0.35, true, function Primary_Lotus_Hits)
    loop
        exitwhen PRIMARY_INTEGER == 12
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL,.1))
    endloop
            call DisableTrigger(gg_trg_Primary_Lotus_TargetMove)
            call ShowUnitHide(udg_LotusCaster)
            set l = GetUnitLoc(udg_LotusTarget)
            set udg_LotusDummy = CreateUnitAtLoc(Player(0),'h00X',l,bj_UNIT_FACING)
            call SetUnitFlyHeight(udg_LotusDummy, 650.0, 1000000000.0)
            call DisableTrigger(gg_trg_Primary_Lotus_Fade)
            call SetUnitAnimation(udg_LotusDummy,"morph")
            call TriggerSleepAction(0.2)
            call AddUnitAnimationProperties(udg_LotusCaster, "alternate", true)
            call SetUnitAnimation(udg_LotusTarget,"death")
            call SetUnitFlyHeight(GetLastCreatedUnit(),600.0,1000000000.0)
            call SetUnitFlyHeight(udg_LotusDummy,0.0,1000000000.00)
            call SetUnitFlyHeight(udg_LotusTarget,0.0,1000000000.00)
            set u = CreateUnitAtLoc(GetOwningPlayer(udg_LotusCaster),'h00X',l,bj_UNIT_FACING)
            call UnitApplyTimedLife(u, 'BTLF', 1.0)
            call SetUnitVertexColor(udg_LotusCaster, PercentTo255(100), PercentTo255(100), PercentTo255(100), PercentTo255(100.0))
            call TriggerSleepAction(0.3)
            call RemoveUnit(udg_LotusDummy)
            call UnitRemoveAbility(udg_LotusCaster,'Amrf')
            call UnitRemoveAbility(udg_LotusTarget,'Amrf')
            set e = AddSpecialEffectLoc("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl",l)
            call DestroyEffect(e)
            call ShowUnitShow(udg_LotusCaster)
            call SetUnitPositionLoc(udg_LotusCaster, GetUnitLoc(udg_LotusDummy))
            call SetUnitFacing(udg_LotusCaster, GetUnitFacing(udg_LotusDummy))
            call SetUnitFlyHeight(udg_LotusCaster,0.0,1000000000.00)
            call SetUnitFlyHeight(udg_LotusTarget,0.0,1000000000.00)
            call SetUnitVertexColor(udg_LotusCaster, PercentTo255(100), PercentTo255(100), PercentTo255(100), PercentTo255(100.0))
            if GetUnitAbilityLevel(udg_LotusCaster,'A01V') == 1 then
                call UnitDamageTarget(udg_LotusCaster,udg_LotusTarget,200, true, false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            else
                if GetUnitAbilityLevel(udg_LotusCaster,'A01V') == 2 then
                    call UnitDamageTarget(udg_LotusCaster,udg_LotusTarget,250, true, false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                else
                    if GetUnitAbilityLevel(udg_LotusCaster,'A01V') == 3 then
                        call UnitDamageTarget(udg_LotusCaster,udg_LotusTarget,300, true, false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                    endif
                endif
            endif
            if (GetLocalPlayer() == GetOwningPlayer(udg_LotusCaster)) then
                call ClearSelection()
                call SelectUnit(udg_LotusCaster, true)
            endif
            call AddUnitAnimationProperties(udg_LotusCaster, "alternate", false)
            call SelectUnitAddForPlayer(udg_LotusCaster,GetOwningPlayer(udg_LotusCaster))
            call SelectUnitAddForPlayer(udg_LotusTarget,GetOwningPlayer(udg_LotusTarget))
            call TriggerSleepAction(1.0)
            call SetUnitPathing( udg_LotusTarget, true )
            call SetUnitPathing( udg_LotusCaster, true )
            call SafeUnPause(udg_LotusCaster)
            call SafeUnPause(udg_LotusTarget)
            call RemoveLocation (l)
            set udg_LotusCaster = null
            set udg_LotusDummy = null
            set udg_LotusTarget = null
endfunction

//===========================================================================
function InitTrig_Primary_Lotus_Main takes nothing returns nothing
    set gg_trg_Primary_Lotus_Main = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Primary_Lotus_Main, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Primary_Lotus_Main, Condition( function Primary_Lotus_Main_Conditions ) )
    call TriggerAddAction( gg_trg_Primary_Lotus_Main, function Primary_Lotus_Main_Actions )
endfunction

JASS:
function Primary_Lotus_Fade_Actions takes nothing returns nothing
    set udg_LotusFade = udg_LotusFade + 3.0
    call SetUnitVertexColor(udg_LotusCaster, 255, 255, 255, PercentTo255(100.0-udg_LotusFade))
    if udg_LotusFade >= 100.0 then
        call DisableTrigger(GetTriggeringTrigger())
    endif
endfunction

//===========================================================================
function InitTrig_Primary_Lotus_Fade takes nothing returns nothing
    set gg_trg_Primary_Lotus_Fade = CreateTrigger(  )
    call DisableTrigger( gg_trg_Primary_Lotus_Fade )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Primary_Lotus_Fade, 0.01 )
    call TriggerAddAction( gg_trg_Primary_Lotus_Fade, function Primary_Lotus_Fade_Actions )
endfunction

JASS:
function Primary_Lotus_TargetMove_Actions takes nothing returns nothing
    local location l = GetUnitLoc(udg_LotusTarget)
    local real x = SafeX(GetLocationX(l) + 7.0 * Cos(udg_LotusAngle * bj_DEGTORAD))
    local real y = SafeY(GetLocationY(l) + 7.0 * Sin(udg_LotusAngle * bj_DEGTORAD))
    call SetUnitPositionLoc(udg_LotusTarget, Location(x,y))
    call RemoveLocation (l)
endfunction

//===========================================================================
function InitTrig_Primary_Lotus_TargetMove takes nothing returns nothing
    set gg_trg_Primary_Lotus_TargetMove = CreateTrigger(  )
    call DisableTrigger( gg_trg_Primary_Lotus_TargetMove )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Primary_Lotus_TargetMove, 0.01 )
    call TriggerAddAction( gg_trg_Primary_Lotus_TargetMove, function Primary_Lotus_TargetMove_Actions )
endfunction
 
Status
Not open for further replies.
Top