LearningCode
New Member
- Reaction score
- 24
I made a trigger where the spell goes like this:
1)Unit casts spell at point
2)All units within a certain AoE of the point are paused and hidden
3)Casting unit is healed based on some formula
4)After some time, enemy units are un-paused and un-hidden
5)Enemy units receive damage based on some formula
The problem is, when I target this spell at a point and it hides 12 Units..
Exactly 1 unit returns..
When I target a point and it hides 1 unit...
No units return ..
There's something screwy =/
BJDebugMsg(I2S(a.numberOfUnit)) shows the correct values =(
1)Unit casts spell at point
2)All units within a certain AoE of the point are paused and hidden
3)Casting unit is healed based on some formula
4)After some time, enemy units are un-paused and un-hidden
5)Enemy units receive damage based on some formula
The problem is, when I target this spell at a point and it hides 12 Units..
Exactly 1 unit returns..
When I target a point and it hides 1 unit...
No units return ..
There's something screwy =/
BJDebugMsg(I2S(a.numberOfUnit)) shows the correct values =(
JASS:
scope Astral initializer AstralTrig
struct Astral
private static Astral data = 0
unit caster
timer t
integer INT
integer A029Level
group g = CreateGroup()
real damage
real x
real y
real range
group hidden
integer numberOfUnit = 0
effect AI
real hp
static method AstralGroup2 takes nothing returns nothing
local Astral a = Astral.data
local unit u = GetEnumUnit()
call PauseUnit(u, false)
call ShowUnit(u, true)
call UnitDamageTarget(a.caster, u, a.damage, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
set u = null
endmethod
static method AstralShow takes nothing returns nothing
local Astral a = Astral.data
call ForGroup(a.hidden, function Astral.AstralGroup2)
call TriggerSleepAction(0.5)
call a.destroy()
endmethod
static method ActGroup takes nothing returns boolean
local Astral a = Astral.data
local unit u = GetFilterUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
set a.hidden = CreateGroup()
if IsUnitEnemy(u, GetOwningPlayer(a.caster)) == true and IsUnitInGroup(u, a.hidden) == false then
call PauseUnit(u, true)
call ShowUnit(u, false)
set a.AI = AddSpecialEffect("Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCasterOverhead.mdl", x, y)
set a.numberOfUnit = a.numberOfUnit+1
call GroupAddUnit(a.hidden, u)
endif
set u = null
return false
endmethod
static method AstralAct takes nothing returns nothing
local Astral a = Astral.allocate()
set a.caster = GetTriggerUnit()
set a.INT = GetHeroInt(a.caster, true)
set a.A029Level = GetUnitAbilityLevel(a.caster, 039;A029039;)
set a.g = CreateGroup()
set a.x = GetSpellTargetX()
set a.y = GetSpellTargetY()
set a.range = a.A029Level * 100.00
set a.t = CreateTimer()
set a.hp = GetUnitState(a.caster, UNIT_STATE_LIFE)
set Astral.data = a
call GroupEnumUnitsInRange(a.g, a.x, a.y, a.range, function Astral.ActGroup)
set a.damage = (a.A029Level * 0.1) * a.numberOfUnit
call SetUnitState(a.caster, UNIT_STATE_LIFE, a.hp+a.damage)
call TimerStart(a.t, 4.00, false, function Astral.AstralShow)
endmethod
method onDestroy takes nothing returns nothing
set .caster = null
call PauseTimer(.t)
call DestroyTimer(.t)
set .t = null
call GroupClear(.hidden)
set .numberOfUnit = 0
call DestroyEffect(.AI)
set .AI = null
endmethod
endstruct
private function AstralCond takes nothing returns boolean
return GetSpellAbilityId() == 039;A029039;
endfunction
//===========================================================================
private function AstralTrig 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 AstralCond))
call TriggerAddAction( t, function Astral.AstralAct )
endfunction
endscope