- Joined
- Jul 28, 2008
- Messages
- 211
Well as the title suggests, I'm back and I need your help yet again. I decided to start making spells and, as usuall, I got stuck. I've beed looking at the code for about 15 minutes now and I fixed a few things, but it still won't work as it should. Here's the code:
Now, for the spell. It should create a dummy at a unit (works). The dummy makes explosions every on 1/4 and 3/4 of its durration (works). Units in the radius of the explosion start to burn, taking damage over time (doesn't work), emmiting an explosion of their own at 1/2 of the burn durration (works). I don't understand why won't they burn. It's like the burn effect doesn't appear and they don't take damage over time, but they still explode. Oh and I think that it deals more damage than it should (just isn't logical that 3 or 4 explosions of 20 damage get a 300 hp unit to red) so maybe the burning damage happens all at once.
If you find anything let me know, please. Thanks in advance.
JASS:
//Made by Destroyer95
scope Spell initializer Initt
globals
//***********************************************\\
//********************SPELL**********************\\
//***********************************************\\
private timer T = CreateTimer()
private group G
private constant integer DUMMY_ID = 'h000'
private constant integer SPELL_ID = 'A000'
private constant real DURRATION = 16.00
private constant real PERIOD = 0.04
private constant real RADIUS = 400
private constant string SFX = "Abilities\\Spells\\Orc\\Bloodlust\\BloodlustTarget.mdl"
private constant string ATTACH = "overhead"
private constant string EXPLODE = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl"
private constant string EATTACH = "overhead"
//***********************************************\\
//***********************************************\\
//*********************BURN**********************\\
//***********************************************\\
private timer BT = CreateTimer()
private group BG
private constant real BDURRATION = 6.00
private constant real BPERIOD = 0.25
private constant real BDMG_MIN = 3.00
private constant real BDMG_MAX = 6.00
private constant real BEXPLODE_DMG = 20.00
private constant real BRADIUS = 200
private constant string BSFX = "Environment\\LargeBuildingFire\\LargeBuildingFire1.mdl"
private constant string BATTACH = "origin"
private constant string BEXPLODE_SFX = "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl"
//***********************************************\\
private boolexpr bool
endglobals
private function Filt takes nothing returns boolean
return (IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE ) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE ) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL ) == false) and (GetWidgetLife(GetFilterUnit()) > 0.405)
endfunction
private struct burn
unit caster
unit target
effect eff
real durr
static integer Total = 0
static burn array arr
static method Loop takes nothing returns nothing
local integer i = 0
local burn b
local unit temp
loop
exitwhen i >= burn.Total
set b = burn.arr[i]
if b.durr >= 0 and GetWidgetLife(b.target) > 0.405 then
call UnitDamageTarget(b.caster, b.target, GetRandomReal(BDMG_MIN, BDMG_MAX), false, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
if b.durr == BDURRATION / 2 then
call GroupEnumUnitsInRange(BG, GetUnitX(b.target), GetUnitY(b.target), BRADIUS, bool)
call DestroyEffect(AddSpecialEffect(BEXPLODE_SFX, GetUnitX(b.target), GetUnitY(b.target)))
loop
set temp = FirstOfGroup(BG)
exitwhen temp == null
if IsUnitEnemy(temp, GetOwningPlayer(b.caster)) then
call UnitDamageTarget(b.caster, temp, BEXPLODE_DMG, false, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(BG, temp)
endloop
endif
set b.durr = b.durr - BPERIOD
else
call GroupEnumUnitsInRange(BG, GetUnitX(b.target), GetUnitY(b.target), BRADIUS, bool)
call DestroyEffect(AddSpecialEffect(BEXPLODE_SFX, GetUnitX(b.target), GetUnitY(b.target)))
loop
set temp = FirstOfGroup(BG)
exitwhen temp == null
if IsUnitEnemy(temp, GetOwningPlayer(b.caster)) then
call UnitDamageTarget(b.caster, temp, BEXPLODE_DMG, false, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(BG, temp)
endloop
call DestroyEffect(b.eff)
set b.eff = null
set b.caster = null
set b.target = null
call b.destroy()
set burn.Total = burn.Total - 1
set burn.arr[i] = burn.arr[burn.Total]
set i = i - 1
endif
set i = i + 1
endloop
if burn.Total == 0 then
call PauseTimer(BT)
endif
endmethod
static method Start takes unit caster, unit target returns nothing
local burn b = burn.allocate()
set b.target = target
set b.caster = caster
set b.eff = AddSpecialEffectTarget(BSFX, b.target, BATTACH)
if burn.Total == 0 then
call TimerStart(BT, BPERIOD, true, function burn.Loop)
endif
set burn.arr[burn.Total] = b
set burn.Total = burn.Total + 1
endmethod
endstruct
private struct data
unit target
unit caster
unit dummy
real durr = DURRATION
effect eff
static integer Total = 0
static data array arr
static method onLoop takes nothing returns nothing
local integer i = 0
local data d
local real x
local real y
local unit temp
loop
exitwhen i >= data.Total
set d = data.arr[i]
if d.durr >= 0 and GetWidgetLife(d.target) > 0.405 then
set x = GetUnitX(d.target)
set y = GetUnitY(d.target)
call SetUnitX(d.dummy, x)
call SetUnitY(d.dummy, y)
if d.durr == DURRATION / 4 or d.durr == DURRATION * 3 / 4 then
call DestroyEffect(AddSpecialEffectTarget(EXPLODE, d.target, EATTACH))
call GroupEnumUnitsInRange(G, x, y, RADIUS, bool)
loop
set temp = FirstOfGroup(G)
exitwhen temp == null
if IsUnitEnemy(temp, GetOwningPlayer(d.caster)) then
call burn.Start(d.caster, d.target)
endif
call GroupRemoveUnit(G, temp)
endloop
endif
set d.durr = d.durr - PERIOD
else
call DestroyEffect(d.eff)
call RemoveUnit(d.dummy)
set d.dummy = null
set d.target = null
set d.caster = null
set d.eff = null
call d.destroy()
set data.Total = data.Total - 1
set data.arr[i] = data.arr[data.Total]
set i = i - 1
endif
set i = i + 1
endloop
if data.Total == 0 then
call PauseTimer(T)
endif
endmethod
static method Start takes unit cast, unit targ returns nothing
local data d = data.allocate()
set d.target = targ
set d.caster = cast
set d.dummy = CreateUnit(GetOwningPlayer(cast), DUMMY_ID, GetUnitX(targ), GetUnitY(targ), 0.00)
set d.eff = AddSpecialEffectTarget(SFX, targ, ATTACH)
if data.Total == 0 then
call TimerStart(T, PERIOD, true, function data.onLoop)
endif
set data.arr[data.Total] = d
set data.Total = data.Total + 1
endmethod
endstruct
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Act takes nothing returns nothing
call data.Start(GetTriggerUnit(), GetSpellTargetUnit())
endfunction
private function Initt takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Cond))
call TriggerAddAction(t, function Act)
set G = CreateGroup()
set BG = CreateGroup()
set bool = Condition(function Filt)
endfunction
endscope
//Made by Destroyer95
Now, for the spell. It should create a dummy at a unit (works). The dummy makes explosions every on 1/4 and 3/4 of its durration (works). Units in the radius of the explosion start to burn, taking damage over time (doesn't work), emmiting an explosion of their own at 1/2 of the burn durration (works). I don't understand why won't they burn. It's like the burn effect doesn't appear and they don't take damage over time, but they still explode. Oh and I think that it deals more damage than it should (just isn't logical that 3 or 4 explosions of 20 damage get a 300 hp unit to red) so maybe the burning damage happens all at once.
If you find anything let me know, please. Thanks in advance.