HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Special Delivery

04-04-2006, 05:25 PM#1
Zoxc
Got a problem with this spell. The plane goes by target, but it drops no delivery. It's very nice to watch the plane fly by, but the spell is kinda useless without the damage part.

It stopped working with Caster System 13.3. I belive it worked with 13.2 (checking...)

Collapse JASS:
//**********************************************************************************************
//*
//* Air Strike
//* ¯¯¯¯¯¯¯¯¯¯
//* Requires:
//*          - The Caster System ( [url]http://vexorian.wc3campaigns.com/[/url] )
//*          - The Special Delivery Ability
//*          - The Special Delivery Missile Ability
//*          - This Trigger (make sure it points to the right ability rawcodes in your map)
//* Notes:
//*       - The Ability's 1st special art field determines the Zeppeling's model
//*       - The Ability's 2nd special art field determines the Zeppeling's Height
//*       - The Ability's 3rd special art field determines the Zeppeling's scale
//*       - The Ability's missile art determines
//*       - The Missile Ability determines the missile effects
//*
//**********************************************************************************************

//==============================================================================================
// Air Strike Configuration:
//
constant function SpecialDelivery_SpellId takes nothing returns integer
    return 'A07W' // Rawcode of the SpecialDelivery ability
endfunction

constant function SpecialDelivery_MissileSpellId takes nothing returns integer
    return 'A07X' // The special delivery missile ability Rawcode
endfunction

constant function SpecialDelivery_Area takes real level returns real
    return 250+level*0 // The main area of effect
endfunction

constant function SpecialDelivery_Duration takes real level returns real
    return 45+0*level // Spawned unit duration formula
endfunction

constant function SpecialDelivery_ReleaseDistance takes real level returns real
    return 400.0 
endfunction

constant function SpecialDelivery_BombCount takes integer level returns integer
    return 4 // Total number of spawned units.
endfunction

constant function SpecialDelivery_Speed takes real level returns real
    return 522+0*level //Must match the speed of the missile ability
endfunction

constant function SpecialDelivery_DamageArea takes real level returns real
    return 125+level*0 // The area of effect for each explosion
endfunction

constant function SpecialDelivery_Damage takes real level returns real
    return 45+level*45 // The damage of each explosion
endfunction

function SpecialDelivery_DamageOptions takes integer level returns integer
    return DamageTypes(ATTACK_TYPE_SIEGE,DAMAGE_TYPE_FORCE)+DamageTrees()
 // Damage options for the damage
 // See Caster System readme for more information
endfunction


//==============================================================================================
function Trig_SpecialDelivery_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == SpecialDelivery_SpellId()
endfunction

function SpecialDelivery_DoDamageC takes nothing returns boolean
    return GetSpellAbilityId()==SpecialDelivery_MissileSpellId()
endfunction

function SpecialDelivery_DoDamage takes nothing returns nothing
 local unit c=GetTriggerUnit()
 local unit u=GetAttachedUnit(c,"u")
 local integer l=GetAttachedInt(c,"l")
 local location loc=GetSpellTargetLoc()
 local real d
    call AttachObject(c,"u",null)
    call AttachInt(c,"l",0)
    
    set d=SquareRoot(Pow(GetUnitX(c)-GetLocationX(loc),2)+Pow(GetUnitY(c)-GetLocationY(loc),2))
    set d=d/SpecialDelivery_Speed(l)
    call PolledWait(d)
    call DamageUnitsInAOEExLoc(u,SpecialDelivery_Damage(l),loc,SpecialDelivery_DamageArea(l),true, SpecialDelivery_DamageOptions(l))
 call RemoveLocation(loc)
 set loc=null
 set c=null
 set u=null
endfunction

function SpecialDelivery_SetCoords takes real x, real y, real tx, real ty returns boolean
//Me and my ideas, thought that it wasn't a good idea to always use a horizontal line like it was
//before, and thought it was better to use lines that depended on the unit and the target point
//this costed me some time besides I had to remember geometry I didn't use for ages, it had some
//issues. you would note the damn checks I had to use. I placed  //*! where all the damn checks
//were placed so it is easier for you to note them.
//
//Oh yes, I made it return false just so it could be placed in the local declaration before the
//declaration of the vars that should have the results of this, it returns false because that
//variable had false as result value.
//
 local rect r=bj_mapInitialPlayableArea
 local real x1=GetRectMinX(r)
 local real x2=GetRectMaxX(r)
 local real y1=GetRectMinY(r)
 local real y2=GetRectMaxY(r)
 local real x3
 local real y3
 local real x4
 local real y4
 local real m

    if (x==tx) then
        set x=x+0.001
    endif
    if (y==ty) then
        set y=y+0.001
    endif
    set m=(x-tx)/(y-ty)
    set y3=y1
    set x3=m*(y3-y)+x
    if (x3>x2) or (x3<x1) then //*!
        set x3=x1
        set y3=(1/m)*(x3-x)+y
        if (y3>y2) or (y3<y1) then //*!
            set x3=x2
            set y3=(1/m)*(x3-x)+y
        endif
    endif
    set y4=y2
    set x4=m*(y4-y)+x
    if (x4>x2) or (x4<x1) then //*!
        set x4=x2
        set y4=(1/m)*(x4-x)+y
        if (y4>y2) or (y4<y1) then //*!
            set x4=x1
            set y4=(1/m)*(x4-x)+y
        endif
    endif
    if (SquareRoot(Pow(x4-x,2)+Pow(y4-y,2)) < SquareRoot(Pow(x3-x,2)+Pow(y3-y,2))) then
        set x2=x3
        set y2=y3
        set x3=x4
        set y3=y4
        set x4=x2
        set y4=y2
    endif
    set udg_castervars[0]=x3
    set udg_castervars[1]=y3
    set udg_castervars[2]=x4
    set udg_castervars[3]=y4
 set r=null
 return false
endfunction

constant function SpecialDelivery_Cycle takes nothing returns real
    return 0.06
endfunction

function SpecialDelivery_Move takes timer t returns nothing
 local unit m=GetAttachedUnit(t,"m")
 local real x=GetUnitX(m)
 local real y=GetUnitY(m)
 local real x2=GetAttachedReal(t,"x")
 local real y2=GetAttachedReal(t,"y")
 local real a=Atan2(y2-y,x2-x)
 local real d= SpecialDelivery_Cycle() * SpecialDelivery_Speed(GetAttachedInt(t,"l"))
 local real x3=x+d*Cos(a)
 local real y3=y+d*Sin(a)

    call SetUnitPosition(m,x3,y3)
    call SetUnitFacing(m,a*bj_RADTODEG)
    if (SquareRoot(Pow(x3-x2,2)+Pow(y3-y2,2))<20) then
        call AttachBoolean(t,"done",true)
    endif
 set m=null
endfunction

function SpecialDelivery_Timer takes nothing returns nothing
 local timer t=GetExpiredTimer()
    if not(GetAttachedBoolean(t,"done")) then
        call SpecialDelivery_Move(t)
    endif
 set t=null
endfunction


function Trig_SpecialDelivery_Actions takes nothing returns nothing
 local unit u=GetTriggerUnit()
 local unit ca
 local timer t
 local integer s=GetSpellAbilityId()
 local integer l=GetUnitAbilityLevel(u,s)
 local location loc=GetSpellTargetLoc()
 local real v
 local real x=GetLocationX(loc)
 local real y=GetLocationY(loc)
 local effect fx
 local integer c=SpecialDelivery_BombCount(l)
 local boolean bol=SpecialDelivery_SetCoords(GetUnitX(u),GetUnitY(u),x,y)
 local real x1=udg_castervars[0]
 local real y1=udg_castervars[1]
 local real x2=udg_castervars[2]
 local real y2=udg_castervars[3]
 local unit b=AddCasterFacing(Atan2BJ(y2-y1,x2-x1))
 local real d

    set t=CreateTimer()
    call AttachObject(t,"m",b)
    call AttachReal(t,"x",x2)
    call AttachReal(t,"y",y2)
    call AttachInt(t,"l",l)
    call SetUnitPosition(b,x1,y1)
    call SetUnitFlyHeight(b,S2R(GetAbilityEffectById(s,EFFECT_TYPE_SPECIAL,1)),0)
    call TimerStart(t,SpecialDelivery_Cycle(),true,function SpecialDelivery_Timer)
    set fx= AddSpellEffectTargetById(s,EFFECT_TYPE_SPECIAL,b,"origin")
    call SetUnitOwner(b,GetOwningPlayer(u),true)
    set v=S2R(GetAbilityEffectById(s,EFFECT_TYPE_SPECIAL,2))
    call SetUnitScale(b,v,v,v)


    loop
        exitwhen (GetAttachedBoolean(t,"done"))
        set x1=GetUnitX(b)
        set y1=GetUnitY(b)
        set d=SquareRoot(Pow(x1-x,2)+Pow(y1-y,2))
        if (c>0) and (bol or ((d<=SpecialDelivery_Area(l)+SpecialDelivery_ReleaseDistance(l)) and (d>=SpecialDelivery_Area(l)-SpecialDelivery_ReleaseDistance(l)))) then
            set c=c-1
            set bol=true
            set udg_sourcehack=GetUnitLoc(b)
            set d=Atan2(y2-y1,x2-x1)
            set udg_delayhack=5
            set ca= CasterCastAbilityPoint(GetOwningPlayer(u),SpecialDelivery_MissileSpellId(),"clusterrockets",x1+SpecialDelivery_ReleaseDistance(l)*Cos(d),y1+SpecialDelivery_ReleaseDistance(l)*Sin(d),false)
            call UnitAddAbility(ca,'Amrf')
            call UnitRemoveAbility(ca,'Amrf')
            call SetUnitFlyHeight(ca,GetUnitFlyHeight(b),0)
            call AttachInt(ca,"l",l)
            call AttachObject(ca,"u",u)
            call RemoveLocation(udg_sourcehack)
            set udg_delayhack=0
            set udg_sourcehack=null
        endif
        call TriggerSleepAction(0)
    endloop
    call CleanAttachedVars(t)
    call DestroyTimer(t)
    call RemoveUnit(b)
    call DestroyEffect(fx)
 set u=null
 set t=null
 set b=null
 set ca=null
 set fx=null
 call RemoveLocation(loc)
 set loc=null
endfunction

//===========================================================================
function InitTrig_Air_Strike takes nothing returns nothing
    set gg_trg_Air_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Air_Strike, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Air_Strike, Condition( function SpecialDelivery_DoDamageC ) )
    call TriggerAddAction( gg_trg_Air_Strike, function SpecialDelivery_DoDamage )
    set gg_trg_Air_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Air_Strike, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Air_Strike, Condition( function Trig_SpecialDelivery_Conditions ) )
    call TriggerAddAction( gg_trg_Air_Strike, function Trig_SpecialDelivery_Actions )
endfunction
04-14-2006, 10:44 PM#2
IPEONRUSH-SHIP
It worked for me. msg me and i'll tell ya what you're missing.