Hello,
I'm quite new in the JASS universe, and I'm trying to convert my projectile system to it. However, when I cast the spells, they do not appear at all. I think it's the CreateUnitAtLoc function, because I can't even create a Footman (which is modeled and I should see if the bug was with the special effect). What's even stranger, I got no compiler error in JassNewGen.
Here's the whole trigger. Thanks in advance for the help.
Notice that ProjectileData is a global. (A structure too)
I'm quite new in the JASS universe, and I'm trying to convert my projectile system to it. However, when I cast the spells, they do not appear at all. I think it's the CreateUnitAtLoc function, because I can't even create a Footman (which is modeled and I should see if the bug was with the special effect). What's even stranger, I got no compiler error in JassNewGen.
Here's the whole trigger. Thanks in advance for the help.
Notice that ProjectileData is a global. (A structure too)
JASS:
function Trig_ProjectileCreation_Conditions takes nothing returns boolean
// Returns true if the Caster Unit is a Sorcerer, else returns false
if(IsUnitInGroup(GetSpellAbilityUnit(), SorcererGroup) == true) then
return true
endif
return false
endfunction
function Trig_ProjectileCreation_Actions takes nothing returns nothing
local location SorcererPosition = GetUnitLoc(GetSpellAbilityUnit()) // Sorcerer's actual position
local location TargetPoint = GetSpellTargetLoc() // Spell target point
local unit Dummy // Projectile
// Creation of the projectile - PROBLEM THERE
set Dummy = CreateUnitAtLoc(GetOwningPlayer(GetSpellAbilityUnit()), 'h000', SorcererPosition, AngleBetweenPoints(SorcererPosition, TargetPoint))
if(GetSpellAbilityId() == 'A004') then // Fireball
call SetUnitUserData(Dummy, 1)
elseif(GetSpellAbilityId() == 'A006') then // Water Bolt
call SetUnitUserData(Dummy, 2)
elseif(GetSpellAbilityId() == 'A005') then // Earth Strike
call SetUnitUserData(Dummy, 3)
elseif(GetSpellAbilityId() == 'A000') then // Wind Blast
call SetUnitUserData(Dummy, 4)
elseif(GetSpellAbilityId() == 'A003') then // Lightning Bolt
call SetUnitUserData(Dummy, 5)
endif
call AddSpecialEffectTargetUnitBJ("chest", Dummy, ProjectileData[GetUnitUserData(Dummy)].Model) // Adding appropriate model to the unit
call GroupAddUnit(SpellGroup, Dummy) // Adding Dummy to the spellgroup
// Delete locations
set SorcererPosition = null
set TargetPoint = null
endfunction
function InitTrig_ProjectileCreation takes nothing returns nothing
set gg_trg_ProjectileCreation = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_ProjectileCreation, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_ProjectileCreation, Condition(function Trig_ProjectileCreation_Conditions))
call TriggerAddAction(gg_trg_ProjectileCreation, function Trig_ProjectileCreation_Actions)
endfunction