- Joined
- Apr 29, 2005
- Messages
- 999
I have a problem with my chain spell I am trying to make. Take a look at the code below.
//THE CONDITION USED BY THE EVENT
//==================================================================================================
function Trig_Chain_Spell_JASS_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A000' ) ) then
return false
endif
return true
endfunction
//==================================================================================================
function CV_Conditions takes nothing returns boolean
return (IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true)
return (IsUnitInGroup(GetEnumUnit(), udg_Hit)==false)
return (IsUnitAliveBJ(GetEnumUnit())== true)
endfunction
function Trig_Chain_Spell_JASS_Actions takes nothing returns nothing
local unit CV_Caster = GetSpellAbilityUnit()
local unit CV_Target = GetSpellTargetUnit()
local integer CV_Bounces = 5
local group CV_Hit
local player CV_Owner = GetOwningPlayer(CV_Caster)
loop
exitwhen (CV_Bounces == 0)
call UnitDamageTargetBJ(CV_Caster, CV_Target, 1000, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL)
call AddSpecialEffectTargetUnitBJ( "origin", CV_Target, "Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl" )
call DestroyEffectBJ(GetLastCreatedEffectBJ())
call GroupAddUnit(udg_Hit, CV_Target)
set CV_Target = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(250, GetUnitLoc(CV_Target), Condition(function CV_Conditions)))
call TriggerSleepAction(3)
set CV_Bounces = CV_Bounces-1
endloop
set udg_Hit = null
endfunction
//THE EVENT
//==================================================================================================
function InitTrig_Chain_Spell_JASS takes nothing returns nothing
set gg_trg_Chain_Spell_JASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Chain_Spell_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Chain_Spell_JASS, Condition( function Trig_Chain_Spell_JASS_Conditions ) )
call TriggerAddAction( gg_trg_Chain_Spell_JASS, function Trig_Chain_Spell_JASS_Actions )
endfunction
//==================================================================================================
The code works but not a it should do.
If you look at the loop you se that the unit to be stored in "CV_Target" must match the conditions in the function "CV_Conditions". The function tells that the unit must not be in the group "udg_Hit", it must be alive and it must be an enemy. After a unit is stored in "CV_Target" it is stored in "udg_Hit" so that it can not be stored in "CV_Target" again. When I try it in the game it seem to igorne the conditions. Both dead and already affected units is affected. Why is it so?
Can someone help me with this?
//THE CONDITION USED BY THE EVENT
//==================================================================================================
function Trig_Chain_Spell_JASS_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A000' ) ) then
return false
endif
return true
endfunction
//==================================================================================================
function CV_Conditions takes nothing returns boolean
return (IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true)
return (IsUnitInGroup(GetEnumUnit(), udg_Hit)==false)
return (IsUnitAliveBJ(GetEnumUnit())== true)
endfunction
function Trig_Chain_Spell_JASS_Actions takes nothing returns nothing
local unit CV_Caster = GetSpellAbilityUnit()
local unit CV_Target = GetSpellTargetUnit()
local integer CV_Bounces = 5
local group CV_Hit
local player CV_Owner = GetOwningPlayer(CV_Caster)
loop
exitwhen (CV_Bounces == 0)
call UnitDamageTargetBJ(CV_Caster, CV_Target, 1000, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL)
call AddSpecialEffectTargetUnitBJ( "origin", CV_Target, "Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl" )
call DestroyEffectBJ(GetLastCreatedEffectBJ())
call GroupAddUnit(udg_Hit, CV_Target)
set CV_Target = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(250, GetUnitLoc(CV_Target), Condition(function CV_Conditions)))
call TriggerSleepAction(3)
set CV_Bounces = CV_Bounces-1
endloop
set udg_Hit = null
endfunction
//THE EVENT
//==================================================================================================
function InitTrig_Chain_Spell_JASS takes nothing returns nothing
set gg_trg_Chain_Spell_JASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Chain_Spell_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Chain_Spell_JASS, Condition( function Trig_Chain_Spell_JASS_Conditions ) )
call TriggerAddAction( gg_trg_Chain_Spell_JASS, function Trig_Chain_Spell_JASS_Actions )
endfunction
//==================================================================================================
The code works but not a it should do.
If you look at the loop you se that the unit to be stored in "CV_Target" must match the conditions in the function "CV_Conditions". The function tells that the unit must not be in the group "udg_Hit", it must be alive and it must be an enemy. After a unit is stored in "CV_Target" it is stored in "udg_Hit" so that it can not be stored in "CV_Target" again. When I try it in the game it seem to igorne the conditions. Both dead and already affected units is affected. Why is it so?
Can someone help me with this?