Moderator
M
Moderator
18 Feb 2012
Bribe: Thanks for making the changes. Approved 3.5/5.
Bribe: Thanks for making the changes. Approved 3.5/5.
/*
=====Spell Name: Bombardment v1.4a
=====Created by: Mckill2009
REQUIRES:
- JassNewGenPack by Vexorian
REQUIRED LIBRARIES:
- DestructableLib by PitzerMike (http://www.wc3c.net/showthread.php?t=103927)
- T32 by Jesus4Lyf (http://www.thehelper.net/forums/showthread.php/132538-Timer32)
- RegisterSpellEffectEvent by Bribe (http://www.hiveworkshop.com/forums/jass-resources-412/snippet-spelleffectevent-187193/)
- RegisterPlayerUnitEvent by Magtheridon96 (http://www.hiveworkshop.com/forums/jass-resources-412/snippet-registerplayerunitevent-203338/)
OPTIONAL LIBRARIES:
- BoundSentinel by Vexorian (http://www.wc3c.net/showthread.php?t=102576)
HOW TO USE:
- Make a new trigger and convert to custom text via EDIT >>> CONVERT CUSTOM TEXT
- Copy ALL that is written here (overwrite the existing texts in the trigger)
- Copy ALL the required libraries stated above
- Copy the Dummy unit and the custom ability OR make your own
- You MUST input or change the correct raw ID's (see below)
- To view raw ID, press CTRL+D in the object editor
*/
scope Bombardment
globals
//NOTE: The custom ability should be 'Rain of Fire', or change it if you like
//but the ability order should be equal to CHANNEL_ORDER_ID
private constant integer SPELL_ID = 'A001' //raw code (rain of fire)
private constant integer COPTER_ID = 'h001' //raw code
private constant integer BOMB_ID = 'h000' //raw code
private constant integer CHANNEL_ORDER_ID = 852238 //rain of fire
private constant real FALL_SPEED = 10. //fall speed of the bomb
private constant real MOVE_SPEED = 15. //copter move speed
private constant real COPTER_HEIGHT = 300. //copter default height at creation time
private constant real CREATION_INTERVAL = 1.5 //interval for copter creation
private constant real COPTER_LIFE = 5.0 //life of copter after bomb is released
private constant real AOE = 300.//area of effect for damage
private constant attacktype ATK = ATTACK_TYPE_CHAOS
private constant damagetype DMG = DAMAGE_TYPE_NORMAL
private constant string SFX = "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl"
private rect Rct
endglobals
private function GetDamage takes integer i returns real
return 25 + i * 25.
endfunction
private function GetDuration takes integer i returns real
return 5 + i * 5.
endfunction
private function UnitAlive takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_DEAD)
endfunction
private interface Bomb
unit caster
unit copter
real damage
real distance
real xSpell
real ySpell
endinterface
//===Bombs Explode
private struct BombExplode extends Bomb
unit bomb
real height
static method getDestructables takes nothing returns boolean
local destructable d = GetFilterDestructable()
if IsDestructableTree(d) then
call KillDestructable(d)
endif
set d = null
return false
endmethod
method periodic takes nothing returns nothing
local real x
local real y
local unit first
if .height > 0 then
set .height = .height - FALL_SPEED
call SetUnitFlyHeight(.bomb, .height, 0)
else
set x = GetUnitX(.bomb)
set y = GetUnitY(.bomb)
call DestroyEffect(AddSpecialEffect(SFX, x, y))
call MoveRectTo(Rct, x, y)
call EnumDestructablesInRect(Rct, function thistype.getDestructables, null)
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, AOE, null)
loop
set first = FirstOfGroup(bj_lastCreatedGroup)
exitwhen first==null
if UnitAlive(first) and IsUnitEnemy(first, GetOwningPlayer(.bomb)) or IsUnitType(first, UNIT_TYPE_STRUCTURE) then
call UnitDamageTarget(.bomb, first, .damage, false, false, ATK, DMG, null)
endif
call GroupRemoveUnit(bj_lastCreatedGroup, first)
endloop
call KillUnit(.bomb)
call .stopPeriodic()
call .destroy()
endif
endmethod
implement T32x
static method create takes unit b, real d, real h returns thistype
local thistype this = thistype.allocate()
set .bomb = b
set .damage = d
set .height = h
call .startPeriodic()
return this
endmethod
endstruct
//Copters Appear
private struct Copter extends Bomb
real angle
integer chk
method periodic takes nothing returns nothing
local unit bomb
if UnitAlive(.copter) then
call SetUnitPosition(.copter, GetUnitX(.copter)+MOVE_SPEED*Cos(.angle), GetUnitY(.copter)+MOVE_SPEED*Sin(.angle))
if .distance > 0 then
set .distance = .distance - MOVE_SPEED
elseif .chk==1 then
set .chk = 0
set bomb = CreateUnit(GetOwningPlayer(.copter), BOMB_ID, .xSpell, .ySpell, GetUnitFacing(.copter))
call SetUnitFlyHeight(bomb, COPTER_HEIGHT, 0)
call BombExplode.create(bomb, .damage, COPTER_HEIGHT)
call UnitApplyTimedLife(.copter, 'BTLF', COPTER_LIFE)
endif
else
call .stopPeriodic()
call .destroy()
endif
endmethod
implement T32x
static method create takes unit copter, real damage, real distance, real x, real y returns thistype
local thistype this = thistype.allocate()
set .copter = copter
set .damage = damage
set .angle = Atan2(y-GetUnitY(copter), x-GetUnitX(copter))
set .distance = distance
set .chk = 1
set .xSpell = x
set .ySpell = y
call .startPeriodic()
return this
endmethod
endstruct
//===Cast
private struct Bombardment extends Bomb
real xUnit
real yUnit
real duration
real creationgap
method periodic takes nothing returns nothing
local unit copter
if .duration > 0 and GetUnitCurrentOrder(.caster)==CHANNEL_ORDER_ID and UnitAlive(.caster) then
set .duration = .duration - T32_PERIOD
set .creationgap = .creationgap + T32_PERIOD
if .creationgap >= CREATION_INTERVAL then
set .creationgap = 0
set copter = CreateUnit(GetOwningPlayer(.caster), COPTER_ID, .xUnit, .yUnit, GetUnitFacing(.caster))
call SetUnitFlyHeight(copter, COPTER_HEIGHT, 0)
call Copter.create(copter, .damage, .distance, .xSpell, .ySpell)
set copter = null
endif
else
call IssueImmediateOrder(.caster, "stop")
call .stopPeriodic()
call .destroy()
endif
endmethod
implement T32x
private static method create takes nothing returns thistype
local thistype this = thistype.allocate()
local integer level
set .caster = GetTriggerUnit()
set level = GetUnitAbilityLevel(.caster, SPELL_ID)
set .xUnit = GetUnitX(.caster)
set .yUnit = GetUnitY(.caster)
set .xSpell = GetSpellTargetX()
set .ySpell = GetSpellTargetY()
set .duration = GetDuration(level)
set .damage = GetDamage(level)
set .distance = SquareRoot((.xSpell-.xUnit) * (.xSpell-.xUnit) + (.ySpell-.yUnit) * (.ySpell-.yUnit))
set .creationgap = CREATION_INTERVAL
call .startPeriodic()
return this
endmethod
private static method onInit takes nothing returns nothing
set Rct = Rect(-AOE, -AOE, AOE, AOE)
call RegisterSpellEffectEvent(SPELL_ID, function thistype.create)
call Preload(SFX)
endmethod
endstruct
endscope