- Joined
- Dec 6, 2009
- Messages
- 168
Hello! I recently uploaded my kamehameha spell in the spell section and I wanted to make a GUI and a VJass version. Tho I have a problem with the VJass one since there is always one unit left when the spell ends. And from my testing it's not the .dummy unit..
+rep to anyone trying to help and I appreciate it alot!
I added the test map using the VJass version if anyone wanna check it out
+rep to anyone trying to help and I appreciate it alot!
JASS:
scope Kamehameha
globals
private constant integer AID = 'A000' //Set AID = your ability id. To get a spells id go into the objekt editor and press ctrl+d.
private constant real aoe = 200 //How large area around the spell that will take damage.
private constant real Offset = 50. //How long infront of the caster the unit will spawn.
private constant integer DUMMY = 'h000' //Set this to the Unit it of your dummy. Press ctrl+d in the objekt editor to find it.
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
private constant real interval = 0.03
endglobals
//This is the formula for the damage. You can make your own formula if you want.
private constant function GetDamage takes integer lvl returns real
return 500.*lvl
endfunction
//This is the range of the spell.
private constant function GetRange takes integer lvl returns real
return 200.*lvl
endfunction
//This is how fast the spell will move.
private constant function GetSpeed takes integer lvl returns real
return 20. + 0*lvl
endfunction
//This checks if a unit is alive so we can deal damage to it or not.
native UnitAlive takes unit id returns boolean
//This is the formula that filters out which units that should take damage.
private function FilterUnits takes unit u, player p returns boolean
return (UnitAlive(u)) and (IsUnitEnemy(u, p)) and (not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE))
endfunction
//DON'T EDIT ANYTHING BELOW
private struct Spell extends array
unit caster
unit dummy
real damage
location cl
location sl
location point
real angle
player owner
real range
real inRange
real speed
integer lvl
group g
static integer array rn
static integer ic = 0
private static method line takes nothing returns nothing
local timer t = GetExpiredTimer()
local thistype this = GetTimerData(t)
local location l = GetUnitLoc(.dummy)
local unit u
local real x = GetUnitX(.dummy)
local real y = GetUnitY(.dummy)
local unit u2 = CreateUnit( .owner, DUMMY, x, y, .angle)
set .g = CreateGroup()
if (UnitAlive(.caster)) and (.inRange < .range) then
call GroupEnumUnitsInRange( .g, x, y, aoe, null)
loop
set u = FirstOfGroup(.g)
exitwhen u == null
call GroupRemoveUnit(.g, u)
if FilterUnits(u, .owner) then
call UnitDamageTarget(.caster, u, .damage, false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
endif
endloop
call SetUnitPositionLoc( .dummy, PolarProjectionBJ( l, .speed, .angle))
call UnitApplyTimedLife(u2, 'BTLF', 0.45)
set u2 = null
call BJDebugMsg("then")
set .inRange = .inRange + 5.
else
call BJDebugMsg("else")
call ReleaseTimer(t)
call KillUnit(.dummy)
call RemoveUnit(.dummy)
//Deindex the spell
set rn[this] = rn[0]
set rn[0] = this
//Null all the variables
set g = null
set u = null
set t = null
set owner = null
set caster = null
set l = null
set t = null
endif
endmethod
private static method run takes nothing returns nothing
local thistype this
//Index the spell
set this = rn[0]
if this == 0 then
set ic = ic + 1
set this = ic
else
set rn[0] = rn[this]
endif
set .owner = GetTriggerPlayer()
set .caster = GetTriggerUnit()
set .lvl = GetUnitAbilityLevel(.caster, AID)
set .damage = GetDamage(lvl)
set .range = GetRange(lvl)
set .cl = GetUnitLoc(.caster)
set .sl = GetSpellTargetLoc()
set .point = PolarProjectionBJ(.cl, Offset, .angle)
set .angle = AngleBetweenPoints(.cl, .sl)
set .dummy = CreateUnitAtLoc( .owner, DUMMY, .point, .angle)
set .inRange = 0
set .speed = GetSpeed(lvl)
call TimerStart(NewTimerEx(this), interval, true, function thistype.line)
set .point = null
set .sl = null
set .cl = null
endmethod
private static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(AID, function thistype.run)
endmethod
endstruct
endscope