/*
=====Ignition v1.4
=====Made by: Mckill2009
REQUIRES:
- Jass New Gen Pack (JNGP) by Vexorian
- T32 by Jesus4Lyf
- RegisterPlayerUnitEvent by Magtheridon96
HOW TO USE:
- Make a trigger and convert to custom text via EDIT >>> CONVERT CUSTOM TEXT
- Copy ALL that is written here and overwrite the existing texts in the custom text
- Copy the necessary libraries (T32 and RegisterPlayerUnitEvent)
- Replace the raw code as stated below if necessary...
- You can view the raw codes by pressing CTRL+B in the object editor
*/
library Ignition uses T32, RegisterPlayerUnitEvent
globals
private constant integer SPELL_ID = 'A000' //spell raw code
//Configurables
private constant real AOE = 90 //highly recommended
private constant real GAP_DIST = 9 //the bigger this, the longer the line
private constant real SFX_SPEED = 0.1 //lower value will cause lag, this is recommended
private constant attacktype ATK = ATTACK_TYPE_PIERCE
private constant damagetype DMG = DAMAGE_TYPE_FIRE
private constant string SFX = "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl"
private constant string LIG = "DRAL"
//Not configurable
private location LOC = Location(0,0)
endglobals
//Configurables:
private constant function GetDamage takes integer i returns real
return 10 + i * 15.
endfunction
private constant function GetDuration takes integer i returns real
return 2 + i * 2.
endfunction
//End of Configurables:
//Never touch the code below unless you know what you're doing
private constant function UnitAlive takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_DEAD)
endfunction
private function GetUnitZ takes unit u returns real
call MoveLocation(LOC, GetUnitX(u), GetUnitY(u))
return GetLocationZ(LOC) + GetUnitFlyHeight(u)
endfunction
private struct IG
unit caster
real effectgap
real duration
real damage
real maxdist
lightning lig
method periodic takes nothing returns nothing
local unit u
local real x
local real y
local real angle
local real dist = 0
if .duration > 0 and UnitAlive(.caster) then
set angle = GetUnitFacing(.caster) * bj_DEGTORAD
set .duration = .duration - T32_PERIOD
loop
set dist = dist + AOE
set x = GetUnitX(.caster) + dist * Cos(angle)
set y = GetUnitY(.caster) + dist * Sin(angle)
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, AOE, null)
loop
set u = FirstOfGroup(bj_lastCreatedGroup)
exitwhen u==null
if UnitAlive(u) and not IsUnitType(u, UNIT_TYPE_FLYING) and IsUnitEnemy(.caster, GetOwningPlayer(u)) then
call UnitDamageTarget(.caster, u, .damage, false, false, ATK, DMG, null)
endif
call GroupRemoveUnit(bj_lastCreatedGroup, u)
endloop
exitwhen dist >= .maxdist
endloop
call MoveLightningEx(.lig, true, GetUnitX(.caster), GetUnitY(.caster), GetUnitZ(.caster)+100, x, y, GetUnitZ(.caster)+100)
//To avoid lag
set .effectgap = .effectgap + T32_PERIOD
if .effectgap >= SFX_SPEED then
set .effectgap = 0
call DestroyEffect(AddSpecialEffect(SFX, x, y))
endif
else
call DestroyLightning(.lig)
call .stopPeriodic()
call .destroy()
endif
endmethod
implement T32x
private static method create takes unit u returns thistype
local thistype this = thistype.allocate()
local integer level = GetUnitAbilityLevel(u, SPELL_ID)
set .caster = u
set .duration = GetDuration(level)
set .damage = GetDamage(level) * T32_PERIOD
set .lig = AddLightning(LIG, true, 0, 0, 0, 0)
set .maxdist = AOE * GAP_DIST
set .effectgap = 0
call .startPeriodic()
return this
endmethod
private static method cond takes nothing returns boolean
if GetSpellAbilityId()==SPELL_ID then
call IG.create(GetTriggerUnit())
endif
return false
endmethod
private static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, function thistype.cond)
endmethod
endstruct
endlibrary