• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Toss

Status
Not open for further replies.
Level 12
Joined
Nov 5, 2007
Messages
730
Im interested,how can i make an enemy unit get tossed in the air when its hit by a certain spell?
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
JASS:
function Trig_Toss_Conditions takes nothing returns boolean
    if(GetSpellAbilityId()!='A0BZ')then
        return false
    endif
    if GetUnitTypeId(GetSpellTargetUnit())=='n00I'or GetUnitTypeId(GetSpellTargetUnit())=='e01H'then
        return false
    endif
    if(GetOwningPlayer(GetSpellTargetUnit())==GetOwningPlayer(GetTriggerUnit()))then
        return false
    endif
    return true
endfunction

function TossFilter takes nothing returns boolean
    if(IsUnitType(GetFilterUnit(),UNIT_TYPE_ANCIENT))then
        return false
    endif
    if IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) then
        return false
    elseif IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING) then
        return false
    elseif GetFilterUnit()==GetSpellAbilityUnit()then
        return false
    elseif IsUnitDeadBJ(GetFilterUnit())then
        return false
    elseif IsUnitType(GetTriggerUnit(),UNIT_TYPE_ANCIENT) then
        return false
    elseif GetUnitTypeId(GetFilterUnit())=='n00L'then
        return false
    elseif IsUnitType(GetTriggerUnit(),UNIT_TYPE_GIANT) then
        return false
    elseif IsUnitVisible(GetFilterUnit(),GetOwningPlayer(GetSpellAbilityUnit()))==false then
        return false
    elseif GetUnitAbilityLevelSwapped('A04R',GetFilterUnit())!=0 then
        return false
    elseif(GetUnitTypeId(GetFilterUnit())=='H00F'or GetUnitTypeId(GetFilterUnit())=='H00E'or GetUnitTypeId(GetFilterUnit())=='H00G')then
        return false
    endif
    return true
endfunction

function TossDamage takes unit pWho,real pxx,real pyy,real pAOE,real pDamage,integer pSpellId returns nothing
    local group lVictims=CreateGroup()
    local unit lFirst
    local location lTMP
    call GroupEnumUnitsInRange(lVictims,pxx,pyy,pAOE,null)
    loop
        set lFirst=FirstOfGroup(lVictims)
        exitwhen lFirst==null
        if IsUnitEnemy(lFirst,GetOwningPlayer(pWho))and IsUnitDeadBJ(lFirst)==false and GetUnitAbilityLevel(lFirst,'A04R')==0 then
            if(IsUnitType(lFirst,UNIT_TYPE_STRUCTURE)==false)then
                call UnitDamageTargetBJ(pWho,lFirst,pDamage,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEMOLITION)
            else
                call UnitDamageTargetBJ(pWho,lFirst,pDamage/3,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEMOLITION)
            endif
            set lTMP=GetUnitLoc(lFirst)
            call DestroyEffect(AddSpellEffectByIdLoc(pSpellId,EFFECT_TYPE_CASTER,lTMP))
            call DestroyEffect(AddSpellEffectByIdLoc(pSpellId,EFFECT_TYPE_CASTER,lTMP))
            call DestroyEffect(AddSpellEffectByIdLoc(pSpellId,EFFECT_TYPE_CASTER,lTMP))
            call RemoveLocation(lTMP)
            call GroupRemoveUnit(lVictims,lFirst)
        else
            call GroupRemoveUnit(lVictims,lFirst)
        endif
    endloop
    call GroupClear(lVictims)
    call DestroyGroup(lVictims)
endfunction

function TossMain takes nothing returns nothing
    local timer lMoveTimer=GetExpiredTimer()
    local string lTable=H2Tx(lMoveTimer)
    local integer lCount=GetInteger(lTable,"TossCounter")
    local real lRange=GetReal(lTable,"TossDistance")
    local real lAngle=GetReal(lTable,"TossAngle")
    local location lTarget=GetLocation(lTable,"TossTargetLoc")
    local location lStart=GetLocation(lTable,"TossSourceLoc")
    local unit lCaster=GetUnit(lTable,"Tiny")
    local unit lVictim=GetUnit(lTable,"TossSource")
    local real lHeight=(lCount-25)*(lCount-25)
    local real lSpeedMod=lRange*lCount/50-lRange
    local location lDest=PolarProjectionBJ(lTarget,lSpeedMod,lAngle)
    if(lCount<51)then
        call SetUnitPositionLoc(lVictim,lDest)
        call SetUnitFlyHeight(lVictim,775-lHeight,0)
        set lCount=lCount+1
        if(GetRandomInt(1,4)==2)then
            call DestroyEffect(AddSpecialEffectTargetUnitBJ("origin",lVictim,"Abilities\\Spells\\Undead\\Cripple\\CrippleTarget.mdl"))
        endif
    endif
    if(lCount>50)then
        call SetUnitFlyHeight(lVictim,GetUnitDefaultFlyHeight(lVictim),0)
        call PauseUnit(lVictim,false)
        call SetUnitPathing(lVictim,true)
        call TerrainDeformationRippleBJ(.2,true,lTarget,1.,300.,96.,1,64.)
        if IsUnitAlly(lVictim,GetOwningPlayer(lCaster))then
            call UnitDamageTargetBJ(lCaster,lVictim,.2*75*GetUnitAbilityLevel(lCaster,'A0BZ'),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEMOLITION)
        else
            call UnitDamageTargetBJ(lCaster,lVictim,(.2+.15*GetUnitAbilityLevel(lCaster,'A0CY'))*75*GetUnitAbilityLevel(lCaster,'A0BZ'),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEMOLITION)
        endif
        call TossDamage(lCaster,GetLocationX(lTarget),GetLocationY(lTarget),300,75.*I2R(GetUnitAbilityLevelSwapped('A0BZ',lCaster)),'A0BZ')
        call EnumDestructablesInCircleBJ(300,lTarget,function KillDestructableEnum)
        call PauseTimer(GetExpiredTimer())
        call PolledWait(.01)
        call FastFlush(lTable)
        call DestroyTimer(GetExpiredTimer())
        call RemoveLocation(lTarget)
        call RemoveLocation(lStart)
    endif
    call SetInteger(lTable,"TossCounter",lCount)
    call RemoveLocation(lDest)
endfunction

function Trig_Toss_Actions takes nothing returns nothing
    local group lNearCaster=CreateGroup()
    local timer lMoveTimer
    local unit lCaster=GetTriggerUnit()
    local unit lVictim
    local location lTarget
    local location lStart
    local integer lCounter
    local real lRange
    local real lAngle
    local string lf5
    call GroupEnumUnitsInRange(lNearCaster,GetUnitX(lCaster),GetUnitY(lCaster),275,Condition(function TossFilter))
    set lVictim=GroupPickRandomUnit(lNearCaster)
    call DestroyGroup(lNearCaster)
    set lTarget=GetUnitLoc(GetSpellTargetUnit())
    set lStart=GetUnitLoc(lVictim)
    set lCounter=1
    set lRange=DistanceBetweenPoints(lStart,lTarget)
    set lAngle=AngleBetweenPoints(lStart,lTarget)
    if(lVictim!=null and GetUnitTypeId(lVictim)!='n00I'and GetUnitTypeId(lVictim)!='e01H'and GetOwningPlayer(GetSpellTargetUnit())!=GetOwningPlayer(lCaster))then
        call SetUnitAnimationByIndex(lCaster,4)
        call PauseUnit(lVictim,true)
        call SetUnitPathing(lVictim,false)
        call UnitAddAbility(lVictim,'AEme')
        call UnitRemoveAbility(lVictim,'AEme')
        set lMoveTimer=CreateTimer()
        set lf5=H2Tx(lMoveTimer)
        call SetHandle(lf5,"Tiny",lCaster)
        call SetHandle(lf5,"TossSource",lVictim)
        call SetHandle(lf5,"TossTargetLoc",lTarget)
        call SetHandle(lf5,"TossSourceLoc",lStart)
        call SetInteger(lf5,"TossCounter",lCounter)
        call SetReal(lf5,"TossDistance",lRange)
        call SetReal(lf5,"TossAngle",lAngle)
        call TimerStart(lMoveTimer,.02,true,function TossMain)
    endif
endfunction

function StartTrigger_Toss takes nothing returns nothing
    set gg_trg_Toss=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Toss,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Toss,Condition(function Trig_Toss_Conditions))
    call TriggerAddAction(gg_trg_Toss,function Trig_Toss_Actions)
endfunction
Credits to DotA for the code.
 
Last edited:
Level 12
Joined
Nov 5, 2007
Messages
730
Just up and down....BTW i suck at jass...which variables should i make for that code,and how should i use them in the trigger?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
I have reason to believe that that script is from DotA, is this true since if it is please say that creadits go to it.

Also please state what system needs to be imported for that script to work as there are noticable custom functions missing from that extract that are vital for it to work.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
  • Actions
    • Unit - Add Crow Form to (Triggering unit)
    • Unit - Remove Crow Form from (Triggering unit)
    • Animation - Change (Triggering unit) flying height to 250.00 at 250.00
    • Animation - Change (Triggering unit) flying height to 0.00 at 250.00

Im not sure if there is a automated wait between them.
If there isn't, just add a wait.

If you want a more specific trigger, write what the spell does.
 
Level 6
Joined
Jun 30, 2006
Messages
230
It came from DotA, what do you expect? Extract the war3map.j file from the map... you'll see that nearly all of it is poorly written...
 
Level 12
Joined
Nov 5, 2007
Messages
730
Im not sure if there is a automated wait between them.
If there isn't, just add a wait.

If you want a more specific trigger, write what the spell does.


I was looking through the Crypt Lord animations,and noticed a bunch of them blizzard didnt use in any map or campaign i know of yet.Theres this cool animation where he jumps in the air and extends his hook/claw/nose thingy like hes picking up something from the ground and tossing it into the air.

So the spell goes like this:
The Crypt Lord extends his massive claw to impale a target enemy unit,then toss it into the air,dealing X damage.(90,160,250,345)Upon landing the unit will be stunned for x seconds(1,1.5,2,2.5)

So basically,i copy/paste the script,and make the exact same trigger that youve showed to me?
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I was looking through the Crypt Lord animations,and noticed a bunch of them blizzard didnt use in any map or campaign i know of yet.Theres this cool animation where he jumps in the air and extends his hook/claw/nose thingy like hes picking up something from the ground and tossing it into the air.


Actually they use it in their "Worm War" map :xxd:

You just raise and lower and change the values each time untill you get them to the right timing.
 
Status
Not open for further replies.
Top