HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Bomber plane !! ARRGH help remake!

07-22-2008, 06:59 PM#1
Flame_Phoenix
Hi guys, I was thinking in remaking my bomber system. I made a bombarding system, but is is old and uses many sleeps, which I know have to eradicate.
However The code is kinda complex, and I also want to add a realistic parabola effect to the falling bombs, but I don't even know where to start !! Can some bode help me ??
I will submit this to resources, give credits and rep+ if you guys help me ... please =S

Trigger 1, we call the bomber and make the bombs fall
Collapse JASS:
function Trig_InBomber_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//=============================================================
function Trig_InBomber_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location loc = GetSpellTargetLoc()
    local location lc = GetUnitLoc(caster)
    local real angle = (180.0 / 3.14159) * Atan2(GetLocationY(loc) - GetLocationY(lc), GetLocationX(loc) - GetLocationX(lc))
    local real X = GetLocationX(loc) 
    local real Y = GetLocationY(loc)
    local player p = GetOwningPlayer(caster)
    local unit bomb
    local integer fade = 0
    local real height 
    local integer bombcounter = 0
    local real heightbomb
    
    local unit bomber = CreateUnit(p, 'h002', X - 1400 * Cos(angle * (3.14159 / 180.0)), Y - 1400 * Sin(angle * (3.14159 / 180.0)), angle)
    
    call SetUnitVertexColor(bomber, 255, 255, 255, fade)
    set height = GetUnitFlyHeight(bomber)
    
    call IssuePointOrder( bomber, "move", X + 200 * Cos(angle * (3.14159 / 180.0)), Y + 200 * Sin(angle * (3.14159 / 180.0)))
    
    loop
        exitwhen(fade >= 255)
        call TriggerSleepAction(0.1)
        call IssuePointOrder( bomber, "move", X + 200 * Cos(angle * (3.14159 / 180.0)), Y + 200 * Sin(angle * (3.14159 / 180.0)))
        set fade = fade + 30
        call SetUnitVertexColor(bomber, 255, 255, 255, fade)
    endloop
    
    loop 
        exitwhen(height <= 450)
        set height = height - 50
        call SetUnitFlyHeight(bomber, height, 80)
        call TriggerSleepAction(0.3)
        call IssuePointOrder( bomber, "move", X + 200 * Cos(angle * (3.14159 / 180.0)), Y + 200 * Sin(angle * (3.14159 / 180.0)))
    endloop
    
        call TriggerSleepAction(0.6)
        call IssuePointOrder( bomber, "move", X + 200 * Cos(angle * (3.14159 / 180.0)), Y + 200 * Sin(angle * (3.14159 / 180.0)))    
    loop 
        exitwhen(bombcounter == 5)
        call IssuePointOrder( bomber, "move", X + 700 * Cos(angle * (3.14159 / 180.0)), Y + 700 * Sin(angle * (3.14159 / 180.0)))        
        set bomb = CreateUnit(p, 'h003', GetUnitX(bomber), GetUnitY(bomber), 270.0) 
        call SetUnitFlyHeight(bomb, height, 0)
        set heightbomb = height
        call UnitApplyTimedLife( bomb,'BHwe', 3)
        loop
            exitwhen(heightbomb <= 0)
            set heightbomb = heightbomb - 100
            call SetUnitFlyHeight(bomb, heightbomb, 140)
        endloop
        set bombcounter = bombcounter + 1
        call TriggerSleepAction(0.25)
    endloop
    
    call IssuePointOrder( bomber, "move", X + 2000 * Cos(angle * (3.14159 / 180.0)), Y + 2000 * Sin(angle * (3.14159 / 180.0)))
    call TriggerSleepAction(0.2)
        
    loop 
        exitwhen(height >= 600)       
        set height = height + 50
        call SetUnitFlyHeight(bomber, height, 100)     
        call TriggerSleepAction(0.2) 
    endloop
    
    loop
        exitwhen(fade <= 0)
        call TriggerSleepAction(0.1)
        
        set fade = fade - 30
        call SetUnitVertexColor(bomber, 255, 255, 255, fade)
    endloop
   
    call ShowUnit(bomber, false)
    call KillUnit(bomber)
    call RemoveLocation(loc)
    call RemoveLocation(lc)
    
    set lc = null
    set loc = null
    set bomber = null
    set bomb = null
    set caster = null
    set p = null
endfunction
//===========================================================================
function InitTrig_Incendiary_Bomber takes nothing returns nothing
    set gg_trg_Incendiary_Bomber = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Incendiary_Bomber, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Incendiary_Bomber, Condition( function Trig_InBomber_Conditions ) )
    call TriggerAddAction( gg_trg_Incendiary_Bomber, function Trig_InBomber_Actions )
endfunction

Trigger 2, when a bomb dies, we create it's effect.
Collapse JASS:
function Trig_InBombs_Actions takes nothing returns nothing
    local unit bomb = GetDyingUnit()
    local integer bombID = GetUnitTypeId(bomb)
    local player p = GetOwningPlayer(bomb)
    local unit dummy
    local unit fire
    if bombID == 'h003' then 
        set dummy = CreateUnit(p, 'h001', GetUnitX(bomb), GetUnitY(bomb), 0.0)
        call UnitAddAbility(dummy, 'A001')
        call IssuePointOrder(dummy, "attackground", GetUnitX(bomb), GetUnitY(bomb))
        call UnitApplyTimedLife( dummy,'BTLF', 1)
        set fire = CreateUnit(p, 'h005', GetUnitX(bomb), GetUnitY(bomb), 0.0) 
        call UnitApplyTimedLife( fire,'BTLF', 20)
    endif
    set bomb = null
    set p = null
    set dummy = null
    set fire = null          
endfunction
//===========================================================================
function InitTrig_Incendiary_Bombs takes nothing returns nothing
    set gg_trg_Incendiary_Bombs = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Incendiary_Bombs, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Incendiary_Bombs, function Trig_InBombs_Actions )
endfunction