Spell flaws, looking for sharp eyes to pin-point error =/

LearningCode

New Member
Reaction score
24
The spell is supposed to create One of Two possible dummy units:
h004 (Fire)
h005 (Ice)

Depending on which element the hero has activated:
A01P (Fire)
A01S (Ice)

Problem is, it creates the dummy, but deals no damage, even when an enemy unit is in range.

It displays only one Debug Message out of 3 I have placed
Works Without If (Displays)
First If (Does Not Display)
Second If (Does Not Display)

Here is the trigger :confused:
Function FamiliarGroup is the one that's malfunctioning =/

JASS:
struct FamiliarVar
   unit u
   real x
   real y
   real rad
   real xC
   real yC
   timer t
   group g
   real r=400.00
   integer i = 0
   unit h
endstruct

function FamiliarCond takes nothing returns boolean
   return GetSpellAbilityId() == 'A01Y' and GetUnitAbilityLevel(GetTriggerUnit(), 'A01S') > 0
   return GetSpellAbilityId() == 'A01Y' and GetUnitAbilityLevel(GetTriggerUnit(), 'A01P') > 0
endfunction

function FamiliarGroup takes nothing returns nothing
   local integer Agility = GetHeroAgi(GetTriggerUnit(), true)
   local integer NapalmLevel
   local real NapalmDmg
   local real x = GetUnitX(GetEnumUnit())
   local real y = GetUnitY(GetEnumUnit())
   local location l = GetUnitLoc(GetEnumUnit())
   local unit u
   BJDebugMsg("Works Without If")
    
    if GetUnitAbilityLevel(GetTriggerUnit(), 'A01S') > 0 then
        BJDebugMsg("First If")
        set NapalmLevel = GetUnitAbilityLevel(GetTriggerUnit(), 'A01S')
        if ModuloInteger(NapalmLevel, 2) == 0 then
            set NapalmDmg = I2R(R2I((((NapalmLevel * 0.5) * Agility))))
        else
            set NapalmDmg = I2R(R2I(((((NapalmLevel+1) * 0.5) * Agility))))
        endif
    elseif GetUnitAbilityLevel(GetTriggerUnit(), 'A01P') > 0
        BJDebugMsg("First If")
        set NapalmLevel = GetUnitAbilityLevel(GetTriggerUnit(), 'A01P')
        set NapalmDmg = I2R(R2I(((((NapalmLevel * 0.11)+0.11) * Agility)))) + (NapalmLevel * 5)
    endif   
    
    
    if IsPlayerAlly(GetOwningPlayer(GetEnumUnit()), GetOwningPlayer(GetTriggerUnit())) == false then
        call UnitDamageTarget(GetTriggerUnit(), GetEnumUnit(), NapalmDmg, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
        if GetUnitAbilityLevel(GetTriggerUnit(), 'A01P') > 0 then
            BJDebugMsg("Second If")
            call DestroyEffect(AddSpecialEffectTarget("Environment\\UndeadBuildingFire\\UndeadLargeBuildingFire2.mdl", GetEnumUnit(), "chest"))
            call UnitAddAbility(GetEnumUnit(), 'Aroa')
            call IssueImmediateOrder(GetEnumUnit(), "roar")
            call UnitRemoveAbility(GetEnumUnit(), 'Aroa')
            call CreateTextTagLocBJ( I2S(R2I(NapalmDmg))+"!", l, 0, 10, 100, 0,0, 0 )
        else
            BJDebugMsg("Second If")
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorDamage.mdl", GetEnumUnit(), "chest"))
            set u = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 'h01O', x, y, bj_UNIT_FACING)
            call UnitAddAbility(u, 'ANab')
            call SetUnitAbilityLevel(u, 'ANab', NapalmLevel)
            call IssueTargetOrder(u, "acidbomb", GetEnumUnit())
            call UnitApplyTimedLife(u, 'BTLF', 1.00)
            set u = null
            call CreateTextTagLocBJ( I2S(R2I(NapalmDmg))+"!", l, 0, 10, 0, 0, 100, 0 )
        endif
        call SetTextTagLifespanBJ( bj_lastCreatedTextTag, 1.00 )
        call SetTextTagPermanentBJ( bj_lastCreatedTextTag, false )
    endif
    
    call RemoveLocation(l)
    set l = null

endfunction

function FamiliarMove takes nothing returns nothing
   local FamiliarVar fv = GetTimerData(GetExpiredTimer())
   set fv.g = CreateGroup()
   call GroupEnumUnitsInRange(fv.g,fv.x, fv.y, 200.00, null) 
   call ForGroup(fv.g, function FamiliarGroup)
   set fv.rad = fv.rad+0.175
   set fv.xC = GetUnitX(fv.h)
   set fv.yC = GetUnitY(fv.h)
   set fv.x = fv.xC + fv.r * Cos(fv.rad)
   set fv.y = fv.yC + fv.r * Sin(fv.rad)
   call IssuePointOrder(fv.u, "move", fv.x, fv.y)
   set fv.i = fv.i + 1
   if fv.i == 100
      call fv.destroy()
      call PauseTimer(fv.t)
      call DestroyTimer(fv.t)
      call KillUnit(fv.u)
      call RemoveUnit(fv.u)
      set fv.u = null
   endif
   call GroupClear(fv.g)
   call DestroyGroup(fv.g)
   set fv.g = null
endfunction

function FamiliarAct takes nothing returns nothing
   local FamiliarVar fv = FamiliarVar.create()
   set fv.t = NewTimer()
   set fv.h = GetTriggerUnit()
   call SetTimerData(fv.t,fv)
   set fv.xC = GetUnitX(fv.h)
   set fv.yC = GetUnitY(fv.h)
   set fv.rad = (GetUnitFacing(fv.h) * bj_DEGTORAD)
   set fv.x = fv.xC + fv.r * Cos(fv.rad)
   set fv.y = fv.yC + fv.r * Sin(fv.rad)
   if GetUnitAbilityLevel(fv.h, 'A01P') > 0 then
      set fv.u = CreateUnit(GetOwningPlayer(fv.h), 'h004', fv.x, fv.y, (GetUnitFacing(fv.h)+90.00))
   else
      set fv.u = CreateUnit(GetOwningPlayer(fv.h), 'h005', fv.x, fv.y, (GetUnitFacing(fv.h)+90.00))
   endif
   call TimerStart(fv.t, 0.13, true, function FamiliarMove)
endfunction

//===========================================================================
function InitTrig_Familiar_Copy takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    local integer i = 0
    loop
    exitwhen i == 8
    call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
    set i = i+1
    endloop
    call TriggerAddCondition(t, Condition(function FamiliarCond))
    call TriggerAddAction( t, function FamiliarAct )
endfunction


[EDIT]
Apparently, using [lJASS]GetTriggerUnit()[/lJASS] is wrong.
[lJASS]BJDebugMsg(I2S(Agility))[/lJASS] Returned [lJASS]0[/lJASS], meaning, it couldn't get the Agility of [lJASS]GetTriggerUnit()[/lJASS]
But I tried using structs and JASSHelper told me that I'm using the wrong syntax=/

How would I use structs in this case.. ?
But even if [lJASS]GetTriggerUnit()[/lJASS] was the problem..
It should have displayed the floating text or created the dummies to cast spells on the affected units..

Right?


[EDIT=2]
Okay, I now can use the structs without JASSHelper giving me errors =x
But It still only shows me One Debug message, and it's the same one =/

JASS:
struct FamiliarVar
   unit u
   real x
   real y
   real rad
   real xC
   real yC
   timer t
   group g
   real r=400.00
   integer i = 0
   unit h
endstruct

function FamiliarCond takes nothing returns boolean
   return GetSpellAbilityId() == 'A01Y' and GetUnitAbilityLevel(GetTriggerUnit(), 'A01S') > 0
   return GetSpellAbilityId() == 'A01Y' and GetUnitAbilityLevel(GetTriggerUnit(), 'A01P') > 0
endfunction

function FamiliarGroup takes nothing returns nothing
   local FamiliarVar fv = FamiliarVar.create()
   local integer Agility = GetHeroAgi(fv.h, true)
   local integer NapalmLevel
   local real NapalmDmg
   local real x = GetUnitX(GetEnumUnit())
   local real y = GetUnitY(GetEnumUnit())
   local location l = GetUnitLoc(GetEnumUnit())
   local unit u
   BJDebugMsg("Works Without If"+I2S(Agility))
    
    if GetUnitAbilityLevel(fv.h, 'A01S') > 0 then
        BJDebugMsg("First If")
        set NapalmLevel = GetUnitAbilityLevel(fv.h, 'A01S')
        if ModuloInteger(NapalmLevel, 2) == 0 then
            set NapalmDmg = I2R(R2I((((NapalmLevel * 0.5) * Agility))))
        else
            set NapalmDmg = I2R(R2I(((((NapalmLevel+1) * 0.5) * Agility))))
        endif
    elseif GetUnitAbilityLevel(fv.h, 'A01P') > 0
        BJDebugMsg("First If")
        set NapalmLevel = GetUnitAbilityLevel(fv.h, 'A01P')
        set NapalmDmg = I2R(R2I(((((NapalmLevel * 0.11)+0.11) * Agility)))) + (NapalmLevel * 5)
    endif   
    
    
    if IsPlayerAlly(GetOwningPlayer(GetEnumUnit()), GetOwningPlayer(fv.h)) == false then
        call UnitDamageTarget(GetTriggerUnit(), GetEnumUnit(), NapalmDmg, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
        if GetUnitAbilityLevel(GetTriggerUnit(), 'A01P') > 0 then
            BJDebugMsg("Second If")
            call DestroyEffect(AddSpecialEffectTarget("Environment\\UndeadBuildingFire\\UndeadLargeBuildingFire2.mdl", GetEnumUnit(), "chest"))
            call UnitAddAbility(GetEnumUnit(), 'Aroa')
            call IssueImmediateOrder(GetEnumUnit(), "roar")
            call UnitRemoveAbility(GetEnumUnit(), 'Aroa')
            call CreateTextTagLocBJ( I2S(R2I(NapalmDmg))+"!", l, 0, 10, 100, 0,0, 0 )
        else
            BJDebugMsg("Second If")
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorDamage.mdl", GetEnumUnit(), "chest"))
            set u = CreateUnit(GetOwningPlayer(fv.h), 'h01O', x, y, bj_UNIT_FACING)
            call UnitAddAbility(u, 'ANab')
            call SetUnitAbilityLevel(u, 'ANab', NapalmLevel)
            call IssueTargetOrder(u, "acidbomb", GetEnumUnit())
            call UnitApplyTimedLife(u, 'BTLF', 1.00)
            set u = null
            call CreateTextTagLocBJ( I2S(R2I(NapalmDmg))+"!", l, 0, 10, 0, 0, 100, 0 )
        endif
        call SetTextTagLifespanBJ( bj_lastCreatedTextTag, 1.00 )
        call SetTextTagPermanentBJ( bj_lastCreatedTextTag, false )
    endif
    
    call RemoveLocation(l)
    set l = null

endfunction

function FamiliarMove takes nothing returns nothing
   local FamiliarVar fv = GetTimerData(GetExpiredTimer())
   set fv.g = CreateGroup()
   call GroupEnumUnitsInRange(fv.g,fv.x, fv.y, 200.00, null) 
   call ForGroup(fv.g, function FamiliarGroup)
   set fv.rad = fv.rad+0.175
   set fv.xC = GetUnitX(fv.h)
   set fv.yC = GetUnitY(fv.h)
   set fv.x = fv.xC + fv.r * Cos(fv.rad)
   set fv.y = fv.yC + fv.r * Sin(fv.rad)
   call IssuePointOrder(fv.u, "move", fv.x, fv.y)
   set fv.i = fv.i + 1
   if fv.i == 100
      call fv.destroy()
      call PauseTimer(fv.t)
      call DestroyTimer(fv.t)
      call KillUnit(fv.u)
      call RemoveUnit(fv.u)
      set fv.u = null
   endif
   call GroupClear(fv.g)
   call DestroyGroup(fv.g)
   set fv.g = null
endfunction

function FamiliarAct takes nothing returns nothing
   local FamiliarVar fv = FamiliarVar.create()
   set fv.t = NewTimer()
   set fv.h = GetTriggerUnit()
   call SetTimerData(fv.t,fv)
   set fv.xC = GetUnitX(fv.h)
   set fv.yC = GetUnitY(fv.h)
   set fv.rad = (GetUnitFacing(fv.h) * bj_DEGTORAD)
   set fv.x = fv.xC + fv.r * Cos(fv.rad)
   set fv.y = fv.yC + fv.r * Sin(fv.rad)
   if GetUnitAbilityLevel(fv.h, 'A01P') > 0 then
      set fv.u = CreateUnit(GetOwningPlayer(fv.h), 'h004', fv.x, fv.y, (GetUnitFacing(fv.h)+90.00))
   else
      set fv.u = CreateUnit(GetOwningPlayer(fv.h), 'h005', fv.x, fv.y, (GetUnitFacing(fv.h)+90.00))
   endif
   call TimerStart(fv.t, 0.13, true, function FamiliarMove)
endfunction

//===========================================================================
function InitTrig_Familiar_Copy takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    local integer i = 0
    loop
    exitwhen i == 8
    call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
    set i = i+1
    endloop
    call TriggerAddCondition(t, Condition(function FamiliarCond))
    call TriggerAddAction( t, function FamiliarAct )
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top