Zalinian
New Member
- Reaction score
- 0
There's actually 2 problems with my code. 1) The first time the code is triggered, it doesn't execute the 3 ele_buff functions. 2) the two loop while unit has buff loops don't work correctly. It does the loop and its contents once, but doesn't continue to loop when the unit has the buff.
Just so you know, it compiles fine, it just doesn't work correctly.
Here's the code:
Just so you know, it compiles fine, it just doesn't work correctly.
Here's the code:
JASS:
function Trig_Elementalist_Buff_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 039;A01E039; ) ) then
return false
endif
return true
endfunction
//===========================================================================
globals
elementalist_buff elementalist_buff_temp_struct
endglobals
struct elementalist_buff
// Main Varaibles
unit caster
player owner
integer owner_id
integer orbs_f
integer orbs_i
integer orbs_l
integer ability_level
integer orb_level
real spell_power
real buff_radius
group buff_targets
location point
// Universal Methods
private static method enemy_check takes nothing returns boolean
local elementalist_buff this = elementalist_buff_temp_struct
return IsUnitEnemy(GetFilterUnit(),(.owner)) == true and IsUnitAliveBJ(GetFilterUnit()) == true
endmethod
static method ally_check takes nothing returns boolean
local elementalist_buff this = elementalist_buff_temp_struct
return IsUnitAlly(GetFilterUnit(),(.owner)) == true and IsUnitAliveBJ(GetFilterUnit()) == true
endmethod
// Fire
private static method flame_damage takes nothing returns nothing
local effect sfx
local unit caster
local elementalist_buff this = elementalist_buff_temp_struct
call AddSpecialEffectTargetUnitBJ("chest", GetEnumUnit(), "Abilities\\Spells\\Other\\BreathOfFire\\BreathOfFireDamage.mdl")
set sfx = GetLastCreatedEffectBJ()
call BJDebugMsg("damage tick" + R2S(.spell_power))
call UnitDamageTarget(.caster, GetEnumUnit(), .spell_power, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, null)
call TriggerSleepAction(1.0)
call DestroyEffect(sfx)
endmethod
private static method flame_aura takes nothing returns nothing
local unit f_caster
local unit target
local location point
local group damage_targets
local real check
local elementalist_buff this = elementalist_buff_temp_struct
set target = GetEnumUnit()
set point = GetUnitLoc(target)
call CreateNUnitsAtLoc(1, 039;h008039;, .owner, point, bj_UNIT_FACING)
set f_caster = GetLastCreatedUnit()
call UnitApplyTimedLifeBJ(0.5, 039;BTLF039;, f_caster)
call SetUnitAbilityLevel(f_caster, 039;A01D039;, .orbs_f)
call IssueTargetOrderById(f_caster, OrderId("innerfire"), target)
set point = null
loop // !PROBLEM: This loop only runs once even while true.
exitwhen (UnitHasBuffBJ(target, 039;B00M039;) == false)
set point = GetUnitLoc(target)
set damage_targets = GetUnitsInRangeOfLocMatching(300, point, Condition (function elementalist_buff.enemy_check))
set elementalist_buff_temp_struct = this
call ForGroup(damage_targets, function elementalist_buff.flame_damage)
call GroupClear(damage_targets)
set point = null
call TriggerSleepAction(1.0)
endloop
call RemoveLocation(point)
call DestroyGroup(damage_targets)
endmethod
method ele_buff_fire takes nothing returns nothing
if this.orbs_f > 0 then
set elementalist_buff_temp_struct = this
call ForGroup(this.buff_targets, function elementalist_buff.flame_aura)
endif
endmethod
// Ice
private static method frost_barrier takes nothing returns nothing
local unit target
local unit i_caster
local location point
local elementalist_buff this = elementalist_buff_temp_struct
set target = GetEnumUnit()
set point = GetUnitLoc(target)
call CreateNUnitsAtLoc(1, 039;h008039;, .owner, point, bj_UNIT_FACING)
set i_caster = GetLastCreatedUnit()
call UnitApplyTimedLifeBJ(0.5, 039;BTLF039;, i_caster)
call SetUnitAbilityLevel(i_caster, 039;A01B039;, .orbs_i)
call IssueTargetOrderById(i_caster, OrderId("frostarmor"), target)
set point = null
call TriggerSleepAction(3.0)
loop // !PROBLEM: This loop only runs once even while true.
exitwhen (UnitHasBuffBJ(target, 039;B00L039;) == false)
set point = GetUnitLoc(target)
call CreateNUnitsAtLoc(1, 039;h008039;, .owner, point, bj_UNIT_FACING)
set i_caster = GetLastCreatedUnit()
call UnitApplyTimedLifeBJ(0.5, 039;BTLF039;, i_caster)
call SetUnitAbilityLevel(i_caster, 039;A01C039;, .ability_level)
call IssueImmediateOrder( i_caster, "thunderclap" )
call TriggerSleepAction(1.0)
endloop
endmethod
method ele_buff_ice takes nothing returns nothing
if this.orbs_i > 0 then
set elementalist_buff_temp_struct = this
call ForGroup(this.buff_targets, function elementalist_buff.frost_barrier)
endif
endmethod
// Lightning
private static method static_burst takes nothing returns nothing
local unit target
local unit l_caster
local location point
local elementalist_buff this = elementalist_buff_temp_struct
set target = GetEnumUnit()
set point = GetUnitLoc(target)
call CreateNUnitsAtLoc(1, 039;h008039;, .owner, point, bj_UNIT_FACING)
set l_caster = GetLastCreatedUnit()
call UnitApplyTimedLifeBJ(0.5, 039;BTLF039;, l_caster)
call SetUnitAbilityLevel(l_caster, 039;A01A039;, .orbs_l)
call IssueTargetOrderById(l_caster, OrderId("bloodlust"), target)
call RemoveLocation(point)
endmethod
method ele_buff_lightning takes nothing returns nothing
if this.orbs_l > 0 then
set elementalist_buff_temp_struct = this
call ForGroup(this.buff_targets, function elementalist_buff.static_burst)
endif
endmethod
endstruct
// Main Function
function Trig_Elementalist_Buff_Actions takes nothing returns nothing
local elementalist_buff data = elementalist_buff.create()
set data.caster = GetTriggerUnit()
set data.owner = GetOwningPlayer(data.caster)
set data.owner_id = GetConvertedPlayerId(( data.owner ))
set data.ability_level = GetUnitAbilityLevelSwapped(039;A01E039; , ( data.caster ))
set data.orb_level = GetUnitAbilityLevelSwapped(039;A00F039; , ( data.caster ))
set data.buff_radius = 400 + (50 * data.ability_level)
set data.point = GetUnitLoc(data.caster)
set data.buff_targets = GetUnitsInRangeOfLocMatching(data.buff_radius , data.point, Condition (function elementalist_buff.ally_check))
set data.spell_power = ( 100.00 + ( ( 0.5 + ( 0.3 * I2R(data.ability_level) ) ) * ( 2.50 * I2R(GetHeroStatBJ(bj_HEROSTAT_INT , (data.caster) , true)) ) ) )
set data.orbs_f = tally_fire(data.owner_id, data.orb_level)
set data.orbs_i = tally_ice(data.owner_id, data.orb_level)
set data.orbs_l = tally_lightning(data.owner_id, data.orb_level)
//call elementalist_orb_clear(data.owner_id)
// These 3 execute functions don't run the first time the spell is triggered, only 2nd and on.
call data.ele_buff_lightning.execute()
call data.ele_buff_ice.execute()
call data.ele_buff_fire.execute()
call TriggerSleepAction( 35.00 )
call data.destroy()
endfunction
//===========================================================================
function InitTrig_Elementalist_Buff takes nothing returns nothing
set gg_trg_Elementalist_Buff = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Elementalist_Buff, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Elementalist_Buff, Condition( function Trig_Elementalist_Buff_Conditions ) )
call TriggerAddAction( gg_trg_Elementalist_Buff, function Trig_Elementalist_Buff_Actions )
endfunction