Moderator
M
Moderator
Aerial Strike v1.1 | Reviewed by Maker | 12th Oct 2013 | ||||||
APPROVED | ||||||
|
16:56, 30th Jun 2013 Magtheridon96: Comments
|
scope AerialStrike
/*********************************************************************************/
/* */
/* Aerial Strike v1.1 */
/* by: msongyyy */
/* */
/* HOW TO IMPORT: */
/* 1. Import everything in the Import Manager to the correct paths */
/* 2. Import the Aerial Strike - Missile, Plane units and ability */
/* 3. Set the rawcode ID's below to the correct ones */
/* */
/* ENJOY ^^ */
/* */
/* THANKS TO: */
/* 1. Cohadar for TT */
/* 2. Nestharus for WorldBounds */
/* 3. Adikutz for MapBounds */
/* 3. Mechanical Man & Crusad3r91 for the Fireprism model(bombship) */
/* 4. zboc for BTNExplosion used */
/* 5. Fingolfin for Marauder missile(bombs) */
/* */
/*********************************************************************************/
globals
private constant integer ABIL_ID = 'A000' // Rawcode ID of Aerial Strike Spell
private constant integer MISS_ID = 'h003' // Rawcode ID of Aerial Strike - Missiles unit
private constant integer PLANE_ID = 'h002' // Rawcode ID of Aerial Strike - Plane unit
private constant string FX = "Abilities\\Weapons\\Mortar\\MortarMissile.mdl" // Effect created when a bomb explodes
private constant timer SPEED_TIMER = CreateTimer()
private constant real DEPLOY_PERIOD = .1 // How often the bombship drops bombs
private constant real SPEED_PERIOD = .0312500 // How often the bombship, and bombs move
private constant real PLANE_SPEED = 700.00 * SPEED_PERIOD // Speed of the bombship
private constant real MISSILE_SPEED = 300.00 * SPEED_PERIOD // Speed of the bombs
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_MAGIC
private constant weapontype WEAPON_TYPE = null
private group g = CreateGroup()
private unit fog
endglobals
// How many bombs dropped per DEPLOY_PERIOD
private constant function MISSILE_COUNT takes integer i returns integer
return 5
endfunction
// Distance travelled by plane
private constant function DIST takes integer i returns real
return i * 300. + 500.
endfunction
// Damage dealt by bombs
private constant function DMG takes integer i returns real
return i * 25. + 30.
endfunction
// Damage aoe of bombs
private constant function DMG_AOE takes integer i returns real
return 135.
endfunction
private function FILTER takes nothing returns boolean
if IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) then
return false
endif
return true
endfunction
/*********************************************************************************/
/* END OF CONFIGURABLES */
/*********************************************************************************/
private struct Bombs extends array
private unit caster
private player play
private unit missile
private real ex
private real ey
private real ang
private real dmg
private real aoe
private real hinc
private static integer array prev
private static integer array next
private static integer array rn
private static integer ic = 0
static method Drop takes nothing returns nothing
local thistype this = next[0]
local real x
local real y
loop
exitwhen this == 0
if GetUnitFlyHeight(.missile) <= 15 then
call DestroyEffect(AddSpecialEffect(FX, .ex, .ey))
call GroupEnumUnitsInRange(g, .ex, .ey, .aoe, null)
loop
set fog = FirstOfGroup(g)
exitwhen fog == null
if IsUnitEnemy(fog, .play) then
call UnitDamageTarget(.caster, fog, .dmg, false, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
endif
call GroupRemoveUnit(g, fog)
endloop
call RemoveUnit(.missile)
set .missile = null
set .caster = null
set .play = null
set prev[next[this]] = prev[this]
set next[prev[this]] = next[this]
set rn[this] = rn[0]
set rn[0] = this
else
set x = GetUnitX(.missile) + MISSILE_SPEED * Cos(.ang)
set y = GetUnitY(.missile) + MISSILE_SPEED * Sin(.ang)
set x = GetBoundedX(x)
set y = GetBoundedY(y)
call SetUnitX(.missile, x)
call SetUnitY(.missile, y)
call SetUnitFlyHeight(.missile, GetUnitFlyHeight(.missile) - .hinc, 0)
endif
set this = next[this]
if next[0] == 0 then
call PauseTimer(SPEED_TIMER)
endif
endloop
endmethod
static method Start takes unit caster, unit plane, player play returns nothing
local thistype this = rn[0]
local real sx = GetUnitX(plane)
local real sy = GetUnitY(plane)
local real rang = GetRandomReal(-90,90)
if this == 0 then
set ic = ic + 1
set this = ic
else
set rn[0] = rn[this]
endif
set .caster = caster
set .play = play
set .ex = sx + 300.00 * Cos((GetUnitFacing(plane) + rang) * bj_DEGTORAD)
set .ey = sy + 300.00 * Sin((GetUnitFacing(plane) + rang) * bj_DEGTORAD)
set .ang = Atan2(.ey-sy, .ex- sx)
set .hinc = 300/(SquareRoot((.ex-sx)*(.ex-sx) + (.ey-sy)*(.ey-sy))/MISSILE_SPEED)
set .missile = CreateUnit(.play, MISS_ID, sx, sy, .ang * bj_RADTODEG)
set .dmg = DMG(GetUnitAbilityLevel(.caster, ABIL_ID))
set .aoe = DMG_AOE(GetUnitAbilityLevel(.caster, ABIL_ID))
set .ex = GetBoundedX(.ex)
set .ey = GetBoundedY(.ey)
call UnitAddAbility(.missile, 'Amrf')
call UnitRemoveAbility(.missile, 'Amrf')
set prev[this] = prev[0]
set next[this] = 0
set next[prev[0]] = this
set prev[0] = this
if prev[this] == 0 then
call TimerStart(SPEED_TIMER, SPEED_PERIOD, true, function thistype.Drop)
endif
endmethod
endstruct
private struct Aerial extends array
private unit caster
private unit plane
private player play
private real ang
private real sx
private real sy
private real dist
private real tdist
private integer maxCount
private static integer array rn
private static integer ic = 0
static method Strike takes nothing returns boolean
local thistype this = TT_GetData()
local real tempx
local real tempy
if .dist > .tdist then
call RemoveUnit(.plane)
set .play = null
set .plane = null
set .caster = null
set rn[this] = rn[0]
set rn[0] = this
return true
else
set tempx = GetUnitX(.plane) + PLANE_SPEED * Cos(.ang)
set tempy = GetUnitY(.plane) + PLANE_SPEED * Sin(.ang)
set tempx = GetBoundedX(tempx)
set tempy = GetBoundedY(tempy)
call SetUnitX(.plane, tempx)
call SetUnitY(.plane, tempy)
set .dist = .dist + PLANE_SPEED
endif
return false
endmethod
static method Deploy takes nothing returns boolean
local thistype this = TT_GetData()
local integer i = 0
if .plane == null then
return true
endif
loop
exitwhen i == maxCount
call Bombs.Start(.caster, .plane, .play)
set i = i + 1
endloop
return false
endmethod
static method Start takes unit caster, real radians returns nothing
local thistype this = rn[0]
if this == 0 then
set ic = ic + 1
set this = ic
else
set rn[0] = rn[this]
endif
set .caster = caster
set .play = GetTriggerPlayer()
set .ang = radians
set .sx = GetUnitX(.caster) - 300 * Cos(.ang)
set .sy = GetUnitY(.caster) - 300 * Sin(.ang)
set .plane = CreateUnit(.play, PLANE_ID, .sx, .sy, .ang * bj_RADTODEG)
set .dist = 0
set .tdist = DIST(GetUnitAbilityLevel(.caster, ABIL_ID))
set .maxCount = MISSILE_COUNT(GetUnitAbilityLevel(.caster, ABIL_ID))
call TT_StartEx(function thistype.Strike, this, SPEED_PERIOD)
call TT_StartEx(function thistype.Deploy, this, DEPLOY_PERIOD)
endmethod
static method Cond takes nothing returns boolean
local unit lvCaster
if GetSpellAbilityId() == ABIL_ID then
set lvCaster = GetTriggerUnit()
call Aerial.Start(lvCaster, Atan2(GetSpellTargetY() - GetUnitY(lvCaster), GetSpellTargetX() - GetUnitX(lvCaster)))
set lvCaster = null
endif
return false
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function thistype.Cond))
set t = null
endmethod
endstruct
endscope