Im making this spell that creates 3/4/5 illusions of the caster and positions them around the target and then each illusion attacks the target 1 after the other 1 at a time and after each one makes an attack it is removed and after all the illusions have attacked the caster takes the position where the last standing illusion was at... so it gets pretty messy.
i have the first trigger, the main trigger that goes off when the spell is cast. that trigger creates a local trigger that positions the illusions around the target when the illusions get summoned. after all of the illusions have been summoned and positioned that trigger creates another local trigger that goes off every time the target takes damage, if the damage source was one of the illusions that illusion is removed and the next illusion attacks. when all the illusions are gone the caster is reappeared where the last illusion was standing.
but because the spell works in this way there are a few conditions i need to take care of, like what if the caster dies before all of the illusions have attacked? i have that taken care of in the trigger but it just looks so messy. can anyone help make this trigger better?
oh yea and some times, rarely, the triggers dont even work. the caster gets hidden and the illusions are created, but the illusions do not get positioned around the caster and they dont get paused and they just attack whatever is closest to them inside their acquisition range. i have not figured out why that happens because its not an easily replicated bug. there is no apparent reason why it happens - most of the time it works perfectly though.
sorry its not in JESP and there are no comments, this wasn't meant for anyone to see but myself...
and i don't understand how to use scopes and structs and shit so thats why im using game cache
i have the first trigger, the main trigger that goes off when the spell is cast. that trigger creates a local trigger that positions the illusions around the target when the illusions get summoned. after all of the illusions have been summoned and positioned that trigger creates another local trigger that goes off every time the target takes damage, if the damage source was one of the illusions that illusion is removed and the next illusion attacks. when all the illusions are gone the caster is reappeared where the last illusion was standing.
but because the spell works in this way there are a few conditions i need to take care of, like what if the caster dies before all of the illusions have attacked? i have that taken care of in the trigger but it just looks so messy. can anyone help make this trigger better?
JASS:
constant function Shadow_Stab_SpellId takes nothing returns integer
return 'A01Y'
endfunction
constant function Shadow_Stab_BuffId takes nothing returns integer
return 'B00H'
endfunction
constant function Shadow_Stab_Create_Illusion_SpellId takes nothing returns integer
return 'A01Z'
endfunction
constant function Shadow_Stab_Illusion_BuffId takes nothing returns integer
return 'B00G'
endfunction
constant function Shadow_Stab_Illusion_Count takes integer L returns integer
return L+2
endfunction
constant function Create_Illusion_Order takes nothing returns integer
return 852274
endfunction
function Trig_Shadow_Stab_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Shadow_Stab_SpellId()
endfunction
function Shadow_Stab_Illusion_Has_Buff takes nothing returns boolean
return GetUnitAbilityLevel(GetSummonedUnit(), Shadow_Stab_Illusion_BuffId()) > 0
endfunction
//function Shadow_Stab_Damage_Condition takes nothing returns boolean
// local trigger Trig = GetTriggeringTrigger()
// local group G = H2G(GetHandleHandle(Trig, "G"))
// local unit I = GetEventDamageSource()
// local boolean B = IsUnitInGroup(I, G)
// set Trig = null
// set G = null
// set I = null
// return B
//endfunction
function Shadow_Stab_Damage_Action takes nothing returns nothing
local trigger Trig = GetTriggeringTrigger()
local unit I = GetEventDamageSource()
local unit C = H2U(GetHandleHandle(Trig, "C"))
local unit T = H2U(GetHandleHandle(Trig, "T"))
local group G = H2G(GetHandleHandle(Trig, "G"))
local real X = GetUnitX(I)
local real Y = GetUnitY(I)
if GetUnitState(T, UNIT_STATE_LIFE)-GetEventDamage() < 0.5 then
set I = FirstOfGroup(G)
loop
exitwhen I == null
call GroupRemoveUnit(G, I)
set X = GetUnitX(I)
set Y = GetUnitY(I)
call RemoveUnit(I)
set I = FirstOfGroup(G)
endloop
call SetUnitX(C, X)
call SetUnitY(C, Y)
call PauseUnit(T, false)
call ShowUnit(C, true)
call SelectUnitAddForPlayer(C, GetOwningPlayer(C))
call FlushHandleLocals(Trig)
call DestroyTrigger(Trig)
call DestroyGroup(G)
elseif IsUnitInGroup(I, G) then
call TriggerSleepAction(0.4)
call GroupRemoveUnit(G, I)
call RemoveUnit(I)
if CountUnitsInGroup(G) > 0 then
set I = GroupPickRandomUnit(G)
call PauseUnit(I, false)
call IssueTargetOrder(I, "attack", T)
else
call ShowUnit(C, true)
call SetUnitX(C, X)
call SetUnitY(C, Y)
call SelectUnitAddForPlayer(C, GetOwningPlayer(C))
call IssueTargetOrder(C, "attack", T)
call FlushHandleLocals(Trig)
call DestroyTrigger(Trig)
call DestroyGroup(G)
call PauseUnit(T, false)
call UnitRemoveAbility(T, Shadow_Stab_BuffId())
endif
if CountUnitsInGroup(G) == 1 then
set I = FirstOfGroup(G)
call SetUnitFacing(C, GetUnitFacing(I))
endif
endif
set Trig = null
set I = null
set C = null
set T = null
set G = null
endfunction
function Summon_Illusion_Function takes nothing returns nothing
local trigger Trig = GetTriggeringTrigger()
local unit C = H2U(GetHandleHandle(Trig, "C"))
local unit T = H2U(GetHandleHandle(Trig, "T"))
local integer L = GetHandleInt(Trig, "L")
local group G = H2G(GetHandleHandle(Trig, "G"))
local unit I = GetSummonedUnit()
local integer N = Shadow_Stab_Illusion_Count(L)
local integer InG
local real D = 150.0
local real A = 360.0/N
local real X = GetUnitX(T)
local real Y = GetUnitY(T)
local real X2
local real Y2
local trigger Trig2
if G == null then
set G = CreateGroup()
call SetHandleHandle(Trig, "G", G)
endif
call GroupAddUnit(G, I)
set InG = CountUnitsInGroup(G)
call SetUnitPathing(I, false)
set X2 = X + D * Cos(A*InG * bj_DEGTORAD)
set Y2 = Y + D * Sin(A*InG * bj_DEGTORAD)
call SetUnitX(I, X2)
call SetUnitY(I, Y2)
call SetUnitFacing(I, A*InG+180)
call PauseUnit(I, true)
if InG == N then
call FlushHandleLocals( Trig )
call DestroyTrigger( Trig )
call ShowUnit(C, false)
set Trig2 = CreateTrigger()
call SetHandleHandle(Trig2, "C", C)
call SetHandleHandle(Trig2, "T", T)
call SetHandleHandle(Trig2, "G", G)
call TriggerRegisterUnitEvent(Trig2, T, EVENT_UNIT_DAMAGED)
// call TriggerAddCondition(Trig2, Condition( function Shadow_Stab_Damage_Condition ))
call TriggerAddAction(Trig2, function Shadow_Stab_Damage_Action)
set I = GroupPickRandomUnit(G)
call PauseUnit(I, false)
call IssueTargetOrder(I, "attack", T)
else
call DisplayTextToForce( GetPlayersAll(), "Units in group = "+I2S(InG) )
endif
set Trig = null
set Trig2 = null
set C = null
set T = null
set G = null
endfunction
function Trig_Shadow_Stab_Actions takes nothing returns nothing
local unit C = GetSpellAbilityUnit()
local unit T = GetSpellTargetUnit()
local trigger Trig = CreateTrigger()
local unit Temp
local real X = GetUnitX(C)
local real Y = GetUnitY(C)
local player P = GetOwningPlayer(C)
local integer N = 0
local integer L = GetUnitAbilityLevel(C, Shadow_Stab_SpellId())
call PauseUnit(T, true)
call TriggerSleepAction(0.0)
loop
set N = N+1
set Temp = CreateUnit(P, Dummy_Unit_TypeId(), X, Y, 0)
call SetUnitPathing(Temp, false)
call UnitAddAbility(Temp, Shadow_Stab_Create_Illusion_SpellId())
call IssueTargetOrderById(Temp, Create_Illusion_Order(), C)
call UnitApplyTimedLife(Temp, 'BTLF', 2.0)
exitwhen N >= Shadow_Stab_Illusion_Count(L)
endloop
call TriggerRegisterPlayerUnitEvent( Trig, P, EVENT_PLAYER_UNIT_SUMMON, null )
call TriggerAddCondition( Trig, Condition( function Shadow_Stab_Illusion_Has_Buff ) )
call TriggerAddAction( Trig, function Summon_Illusion_Function )
call SetHandleInt( Trig, "L", L )
call SetHandleHandle( Trig, "C", C )
call SetHandleHandle( Trig, "T", T )
set C = null
set T = null
set Trig = null
set Temp = null
set P = null
endfunction
//===========================================================================
function InitTrig_Shadow_Stab takes nothing returns nothing
set gg_trg_Shadow_Stab = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Shadow_Stab, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Shadow_Stab, Condition( function Trig_Shadow_Stab_Conditions ) )
call TriggerAddAction( gg_trg_Shadow_Stab, function Trig_Shadow_Stab_Actions )
endfunction
oh yea and some times, rarely, the triggers dont even work. the caster gets hidden and the illusions are created, but the illusions do not get positioned around the caster and they dont get paused and they just attack whatever is closest to them inside their acquisition range. i have not figured out why that happens because its not an easily replicated bug. there is no apparent reason why it happens - most of the time it works perfectly though.
sorry its not in JESP and there are no comments, this wasn't meant for anyone to see but myself...
and i don't understand how to use scopes and structs and shit so thats why im using game cache