Is there any way to have create a point targeted ability, shockwave for example, and then detect whether that ability was cast on a point or on a unit?
I am creating a system where you carry some kind of gun, and when you fire at a point you will fire a volley of 6 or so "shockwave" like projectiles with some amount of random scattering for recoil. However if possible I would like to implement so that if a unit was targeted with the original spell, that unit would be stored in a variable then as the casting unit could sort of track the target unit as they fired the volley. I was hoping that it would just work, but when I use the below point targeted spell on a unit, GetSpellTargetUnit() is returning null. I'm new to JASS so feel free to roast me on anything I'm doing poorly too.
I am creating a system where you carry some kind of gun, and when you fire at a point you will fire a volley of 6 or so "shockwave" like projectiles with some amount of random scattering for recoil. However if possible I would like to implement so that if a unit was targeted with the original spell, that unit would be stored in a variable then as the casting unit could sort of track the target unit as they fired the volley. I was hoping that it would just work, but when I use the below point targeted spell on a unit, GetSpellTargetUnit() is returning null. I'm new to JASS so feel free to roast me on anything I'm doing poorly too.
JASS:
library SpellSystem
globals
private integer SPELL_ID = 'A000'
endglobals
function SpellStart takes nothing returns integer
local integer spellId = GetSpellAbilityId()
local player castingPlayer = GetTriggerPlayer()
local unit casterUnit = GetTriggerUnit()
local unit targetUnit = GetSpellTargetUnit()
local real targetX = GetSpellTargetX()
local real targetY = GetSpellTargetY()
if (spellId == SPELL_ID) then
call BJDebugMsg("Player : " + I2S(GetPlayerId(castingPlayer)))
call BJDebugMsg("Spell fired: " + I2S(spellId))
call BJDebugMsg("Caster Unit: " + I2S(GetUnitTypeId(casterUnit)))
call BJDebugMsg("Target Unit: " + I2S(GetUnitTypeId(targetUnit))) //This outputs: "Target Unit: 0"
call BJDebugMsg("Target Loc: " + R2S(targetX) + ", " + R2S(targetY))
endif
return spellId
endfunction
function InitTrig_SpellSystem takes nothing returns nothing
local trigger SpellSystem = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(SpellSystem, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(SpellSystem, function SpellStart)
endfunction
endlibrary
Last edited: