ability not dealing damage properly

Level 3
Joined
Apr 29, 2024
Messages
30
Hello, I have a problem with this ability not dealing any damage and I dont know how to make it deal damage properly, is the caster not set properly? Or is there a different issue causing this.

JASS:
function Trig_Kamikaze_Sound_Conditions takes nothing returns boolean
return((GetSpellAbilityId()=='A00I'))or((GetSpellAbilityId()=='A884'))
endfunction

function Trig_Kamikaze_Sound_Actions takes nothing returns nothing
call PlaySoundOnUnitBJ(udg_sound17, 100, GetTriggerUnit())
set udg_Caster[GetConvertedPlayerId(GetTriggerPlayer())] = GetTriggerUnit()
endfunction

function Trig_Kamikaze_Attack_Conditions takes nothing returns boolean
return((GetUnitTypeId(GetDyingUnit())=='h00B'))
endfunction

function Trig_Kamikaze_Attack_Func009002003 takes nothing returns boolean
return(IsPlayerAlly(GetOwningPlayer(GetFilterUnit()),GetOwningPlayer(GetTriggerUnit()))==false)
endfunction

function Trig_Kamikaze_Attack_Func010A takes nothing returns nothing
call UnitDamageTargetBJ(udg_Caster[GetConvertedPlayerId(GetTriggerPlayer())], GetEnumUnit(), udg_real02, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL)
endfunction

function Trig_Kamikaze_Attack_Func012Func001C takes nothing returns boolean
return((IsDestructableAliveBJ(GetEnumDestructable())))
endfunction

function Trig_Kamikaze_Attack_Func012A takes nothing returns nothing
if((IsDestructableAliveBJ(GetEnumDestructable())))then
call KillDestructable(GetEnumDestructable())
call TriggerExecute(udg_trigger623)
endif
endfunction

function Trig_Kamikaze_Attack_Actions takes nothing returns nothing
set udg_location08=GetUnitLoc(GetTriggerUnit())
call SetTerrainTypeBJ(udg_location08,'Kdtr',-1,3,0)
call SetTerrainTypeBJ(udg_location08,'Jdtr',-1,2,0)
call CreateNUnitsAtLoc(1,'h02N',GetTriggerPlayer(),udg_location08,bj_UNIT_FACING)
call SetUnitVertexColorBJ(bj_lastCreatedUnit,0.00,100.00,0.00,0)

if (GetSpellAbilityId()=='A00I') then
set udg_real02 = ((I2R(GetHeroStatBJ(2, udg_Caster[GetConvertedPlayerId(GetTriggerPlayer())], false)) * (I2R(GetUnitAbilityLevelSwapped('A00I', udg_Caster[GetConvertedPlayerId(GetTriggerPlayer())])) * 9.00)) + 100.00)
endif

if (GetSpellAbilityId()=='A884') then
set udg_real02 = ((I2R(GetHeroStatBJ(2, udg_Caster[GetConvertedPlayerId(GetTriggerPlayer())], false)) * (I2R(GetUnitAbilityLevelSwapped('A884', udg_Caster[GetConvertedPlayerId(GetTriggerPlayer())])) * 9.00)) + 100.00)
endif

call CreateNUnitsAtLoc(1,'h028',GetTriggerPlayer(),udg_location08,bj_UNIT_FACING)
set udg_group05=GetUnitsInRangeOfLocMatching(400.00,udg_location08,Condition(function Trig_Kamikaze_Attack_Func009002003))
call ForGroupBJ(udg_group05,function Trig_Kamikaze_Attack_Func010A)
call DestroyGroup(udg_group05)
call EnumDestructablesInCircleBJ(400.00,udg_location08,function Trig_Kamikaze_Attack_Func012A)
call RemoveLocation(udg_location08)
endfunction
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Did you convert your trigger to code? It's pretty messy and would be much easier to read in GUI.

Potential issues:
  • real02 is equal to 0.00 (wrong ability id)
  • group05 is empty (bad location or bad Conditions)
  • Other triggers are running which interfere with variables

If you're writing Jass then you should rely on local variables whenever possible.

Anyway, this is how you can damage units in a group:
  • Set Variable real02 = 100.00
  • Set Variable location08 = (Position of (Triggering unit))
  • Set Variable group05 = (Units within 400.00 range of location08)
  • Unit Group - Pick every unit in group05 and do (Actions)
    • Loop - Actions
      • Set Variable target = (Picked unit)
      • If all conditions are true then do (Actions)
        • If - Conditions
          • (target belongs to an enemy of (Owner of (Triggering unit))
        • Then - Actions
          • Unit - Cause (Triggering unit) to damage target, dealing real02 damage of attack type Spells and damage type Normal
        • Else - Actions
Add more If - Conditions as needed, like filtering out dead units, structures, invulnerable, magic immune, etc.
 
Level 3
Joined
Apr 29, 2024
Messages
30
Yeah the issue was udgreals02 being set to zero, because the event was only set to run for one character. I changed it now and it works thanks
 
Top