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
Function FamiliarGroup is the one that's malfunctioning =/
[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 =/
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
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() == 039;A01Y039; and GetUnitAbilityLevel(GetTriggerUnit(), 039;A01S039;) > 0
return GetSpellAbilityId() == 039;A01Y039; and GetUnitAbilityLevel(GetTriggerUnit(), 039;A01P039;) > 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(), 039;A01S039;) > 0 then
BJDebugMsg("First If")
set NapalmLevel = GetUnitAbilityLevel(GetTriggerUnit(), 039;A01S039;)
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(), 039;A01P039;) > 0
BJDebugMsg("First If")
set NapalmLevel = GetUnitAbilityLevel(GetTriggerUnit(), 039;A01P039;)
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(), 039;A01P039;) > 0 then
BJDebugMsg("Second If")
call DestroyEffect(AddSpecialEffectTarget("Environment\\UndeadBuildingFire\\UndeadLargeBuildingFire2.mdl", GetEnumUnit(), "chest"))
call UnitAddAbility(GetEnumUnit(), 039;Aroa039;)
call IssueImmediateOrder(GetEnumUnit(), "roar")
call UnitRemoveAbility(GetEnumUnit(), 039;Aroa039;)
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()), 039;h01O039;, x, y, bj_UNIT_FACING)
call UnitAddAbility(u, 039;ANab039;)
call SetUnitAbilityLevel(u, 039;ANab039;, NapalmLevel)
call IssueTargetOrder(u, "acidbomb", GetEnumUnit())
call UnitApplyTimedLife(u, 039;BTLF039;, 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, 039;A01P039;) > 0 then
set fv.u = CreateUnit(GetOwningPlayer(fv.h), 039;h004039;, fv.x, fv.y, (GetUnitFacing(fv.h)+90.00))
else
set fv.u = CreateUnit(GetOwningPlayer(fv.h), 039;h005039;, 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() == 039;A01Y039; and GetUnitAbilityLevel(GetTriggerUnit(), 039;A01S039;) > 0
return GetSpellAbilityId() == 039;A01Y039; and GetUnitAbilityLevel(GetTriggerUnit(), 039;A01P039;) > 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, 039;A01S039;) > 0 then
BJDebugMsg("First If")
set NapalmLevel = GetUnitAbilityLevel(fv.h, 039;A01S039;)
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, 039;A01P039;) > 0
BJDebugMsg("First If")
set NapalmLevel = GetUnitAbilityLevel(fv.h, 039;A01P039;)
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(), 039;A01P039;) > 0 then
BJDebugMsg("Second If")
call DestroyEffect(AddSpecialEffectTarget("Environment\\UndeadBuildingFire\\UndeadLargeBuildingFire2.mdl", GetEnumUnit(), "chest"))
call UnitAddAbility(GetEnumUnit(), 039;Aroa039;)
call IssueImmediateOrder(GetEnumUnit(), "roar")
call UnitRemoveAbility(GetEnumUnit(), 039;Aroa039;)
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), 039;h01O039;, x, y, bj_UNIT_FACING)
call UnitAddAbility(u, 039;ANab039;)
call SetUnitAbilityLevel(u, 039;ANab039;, NapalmLevel)
call IssueTargetOrder(u, "acidbomb", GetEnumUnit())
call UnitApplyTimedLife(u, 039;BTLF039;, 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, 039;A01P039;) > 0 then
set fv.u = CreateUnit(GetOwningPlayer(fv.h), 039;h004039;, fv.x, fv.y, (GetUnitFacing(fv.h)+90.00))
else
set fv.u = CreateUnit(GetOwningPlayer(fv.h), 039;h005039;, 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