Lightstalker
New Member
- Reaction score
- 55
Fire Geysers v1.5
My first spell...
Go nuts on the critique but also tell me what to change & improve this is my first vJASS spell...
vJASS, MUI, Leakless, & Lagless
''Technical' description'': creates X amount of fire special effects at random points around the caster, dealing Y damage to all units within range of any of those effects. Every Z seconds for A times, random fire effects will be created at random points around the caster, damaging all units within range.
X, Y, Z, A are all configurable variables.
Screenshots:
Could probably look a lot better with more fire effects, but now you can configure that, too.
Code:
Changelog:
FIRE GEYSERS
My first spell...
Go nuts on the critique but also tell me what to change & improve this is my first vJASS spell...
vJASS, MUI, Leakless, & Lagless
''Technical' description'': creates X amount of fire special effects at random points around the caster, dealing Y damage to all units within range of any of those effects. Every Z seconds for A times, random fire effects will be created at random points around the caster, damaging all units within range.
X, Y, Z, A are all configurable variables.
Screenshots:
Code:
JASS:
scope FireGeysers initializer Init
globals
private constant integer SPELLID = 039;A000039; //ABILITY RAWCODE
private constant string EFFECT = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl" //FIRE EFFECT
private constant integer EFFECTAMOUNT = 3 //HOW MANY FIRE GEYSERS ARE CREATED DURING A PERIOD
private constant integer AMOUNT = 3 //HOW MANY TIMES THE EFFECT OCCURS IN TOTAL. TO FIND OUT HOW LONG THE SPELL WILL LAST IN SECONDS: AMOUNT * PERIOD
private constant real PERIOD = 2.0 //HOW OFTEN THE EFFECT OCCURS
private constant real DAMAGE = 50.0 //DAMAGE DONE BY EACH FIRE GEYSER PER LEVEL
private constant real RNDMIN = 300.0 //MINIMUM DISTANCE THE EFFECT WILL OCCUR FROM THE CASTER
private constant real RNDMAX = 600.0 //MINIMUM DISTANCE THE EFFECT WILL OCCUR FROM THE CASTER
private constant attacktype ATTACKTYPE = ATTACK_TYPE_MAGIC //THE TYPE OF ATTACK (MAGIC, HERO, CHAOS, ETC.)
private constant damagetype DAMAGETYPE = DAMAGE_TYPE_FIRE //THE TYPE OF DAMAGE.
private constant weapontype WEAPONTYPE = WEAPON_TYPE_WHOKNOWS //FOR DIFFERENT TYPES OF WEAPONS. DON'T RECOMMAND YOU CHANGE IT.
//DON'T CHANGE ANYTHING AFTER THIS POINT UNLESS YOU KNOW WHAT YOU'RE DOING!
private group TEMPGROUP = CreateGroup()
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELLID
endfunction
private struct data
unit u = null
real ux = 0.0
real uy = 0.0
integer lvl = 0
integer count = 0
static method create takes unit u returns data
local data d = data.allocate()
set d.u = u
set d.ux = GetUnitX(u)
set d.uy = GetUnitY(u)
set d.lvl = GetUnitAbilityLevel(u, SPELLID)
return d
endmethod
endstruct
globals
private data TEMPSTRUCT
endglobals
private function Damage takes nothing returns boolean
call UnitDamageTarget(TEMPSTRUCT.u, GetFilterUnit(), DAMAGE * TEMPSTRUCT.lvl, false, false, ATTACKTYPE, DAMAGETYPE, WEAPONTYPE)
return false
endfunction
private function Periodic takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local real rndx = 0.0
local real rndy = 0.0
local real angle = 0.0
local integer i = 0
if d.count < AMOUNT then
loop
set rndx = d.ux + GetRandomReal(RNDMIN, RNDMAX) * Cos(GetRandomReal(0.00,57.29))
set rndy = d.uy + GetRandomReal(RNDMIN, RNDMAX) * Sin(GetRandomReal(0.00,57.29))
call DestroyEffect(AddSpecialEffect(EFFECT, rndx, rndy))
call GroupEnumUnitsInRange(TEMPGROUP, rndx, rndy, 200.0, Condition(function Damage))
set i = i + 1
exitwhen i == EFFECTAMOUNT
endloop
set d.count = d.count + 1
else
call ReleaseTimer(GetExpiredTimer())
call d.destroy()
endif
endfunction
private function Actions takes nothing returns nothing
local timer t = NewTimer()
call SetTimerData(t, data.create(GetTriggerUnit()))
call TimerStart(t, PERIOD, true, function Periodic)
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Actions)
endfunction
endscope
Changelog:
v1.5
- Fixed a bug where incorrect units would be damaged.
- Further randomized effects.
v1.4
- Added weapontype, damagetype, and attacktype configurables.
- Made code easier to read.
- Optimized code.
v1.3
- Inlined damage.
v1.2
- Further optimized code.
v1.1
- Optimized code.
- Damage, amount of fire effects, amount of times the spell will run for can now all be easily modified.
- Fixed a bug where incorrect units would be damaged.
- Further randomized effects.
v1.4
- Added weapontype, damagetype, and attacktype configurables.
- Made code easier to read.
- Optimized code.
v1.3
- Inlined damage.
v1.2
- Further optimized code.
v1.1
- Optimized code.
- Damage, amount of fire effects, amount of times the spell will run for can now all be easily modified.