- Joined
- Aug 6, 2009
- Messages
- 697
I have a problem with the trigger below, it works as long as one person is casting it, but breaks if two people cast at the same time. From what I can tell, the Indexing seems to get mixed up somewhere but I have no clue to where. I used dynamic indexing before and it broke. Then, I changed to Linked Lists, and that worked, for a time. After copying and pasting about 5 functions at a time in the trigger, everything melted down and returned to being broken. Also, I am using Jass NewGen v2.09.
JASS:
function PSStart takes unit u, unit u2, real a, real b, real c, real d, real e, real f, integer i returns nothing
set udg_PS_SpellCount = udg_PS_SpellCount + 1
if udg_PS_SpellCount == 1 then
call EnableTrigger( gg_trg_ProjectileSystem2 )
endif
if udg_PS_RecycleSize == 0 then
set udg_PS_MaxIndex = udg_PS_MaxIndex + 1
set udg_TempSpellID = udg_PS_MaxIndex
else
set udg_PS_RecycleSize = udg_PS_RecycleSize - 1
set udg_TempSpellID = udg_PS_RecycleStack[udg_PS_RecycleSize]
endif
set udg_PS_SpellNext[udg_TempSpellID] = 0
set udg_PS_SpellNext[udg_PS_SpellLast] = udg_TempSpellID
set udg_PS_SpellPrev[udg_TempSpellID] = udg_PS_SpellLast
set udg_PS_SpellLast = udg_TempSpellID
set udg_PS_Caster[udg_TempSpellID] = u
set udg_PS_Unit[udg_TempSpellID] = u2
set udg_PS_Timer[udg_TempSpellID] = a
set udg_PS_Angle[udg_TempSpellID] = b
set udg_PS_Offset[udg_TempSpellID] = c
set udg_PS_Damage[udg_TempSpellID] = d
set udg_PS_MaxDistance[udg_TempSpellID] = e
set udg_PS_Number2[udg_TempSpellID] = i
set udg_PS_Detect[udg_TempSpellID] = f
endfunction
-
Custom script: call PSStart(udg_SKHA_Caster[udg_SKHA_Loop], udg_DR_Units[udg_DR_Number], udg_SKHA_Timer2[udg_SKHA_Loop],udg_DR_Angle, 80, udg_SKHA_Damage[udg_SKHA_Loop], 3000, 150, udg_DR_Number)
-
SuperKamehameha2
-

Events
-


Unit - A unit Starts the effect of an ability
-
-

Conditions
-


(Ability being cast) Equal to (|cff00ffffR|r)|cff3399ffSuper Kamehameha|r
-
-

Actions
-


Set TempInt = (Player number of (Owner of (Triggering unit)))
-


Set SKHA_MaxIndex = (SKHA_MaxIndex + 1)
-


Set SKHA_Caster[SKHA_MaxIndex] = (Triggering unit)
-


Set SKHA_Timer[SKHA_MaxIndex] = 5.35
-


Set SKHA_Timer2[SKHA_MaxIndex] = 4.10
-


Set SKHA_Damage[SKHA_MaxIndex] = (((2.00 x (((Real((Strength of SKHA_Caster[SKHA_MaxIndex] (Include bonuses)))) + (Real((Intelligence of SKHA_Caster[SKHA_MaxIndex] (Include bonuses))))) x (Real((Level of (|cff00ffffR|r)|cff3399ffSuper Kamehameha|r for SKHA_Caster[SKHA_MaxIndex]))))) / SKHA_
-


Set SKHA_Boolean[SKHA_MaxIndex] = False
-


Set SKHA_Casting[SKHA_MaxIndex] = True
-


Set TempPoint = (Position of SKHA_Caster[SKHA_MaxIndex])
-


Set TempPoint2 = (Target point of ability being cast)
-


Set SKHA_Angle[SKHA_MaxIndex] = (Angle from TempPoint to TempPoint2)
-


Custom script: call RemoveLocation(udg_TempPoint2)
-


Set TempPoint2 = (TempPoint offset by 20.00 towards ((Facing of SKHA_Caster[SKHA_MaxIndex]) - 90.00) degrees)
-


Unit - Create 1 KHADummy3 for (Owner of SKHA_Caster[SKHA_MaxIndex]) at TempPoint2 facing TempReal degrees
-


Set SKHA_Dummy[SKHA_MaxIndex] = (Last created unit)
-


Set SKHA_Size[SKHA_MaxIndex] = 15.00
-


Special Effect - Create a special effect attached to the origin of SKHA_Caster[SKHA_MaxIndex] using DustWave.mdx
-


Special Effect - Destroy (Last created special effect)
-


Special Effect - Create a special effect attached to the origin of SKHA_Caster[SKHA_MaxIndex] using Abilities\Spells\Other\Charm\CharmTarget.mdl
-


Special Effect - Destroy (Last created special effect)
-


Custom script: call StartSound(udg_SKHA_Sound1[udg_TempInt])
-


Custom script: call RemoveLocation(udg_TempPoint)
-


Custom script: call RemoveLocation(udg_TempPoint2)
-


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-



If - Conditions
-




SKHA_MaxIndex Equal to 1
-
-



Then - Actions
-




Trigger - Turn on SuperKamehamehaLoop2 <gen>
-
-



Else - Actions
-
-
-
-
SuperKamehamehaLoop2
-

Events
-


Time - Every 0.03 seconds of game time
-
-

Conditions
-

Actions
-


For each (Integer SKHA_Loop) from 1 to SKHA_MaxIndex, do (Actions)
-



Loop - Actions
-




If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-





If - Conditions
-






SKHA_Casting[SKHA_Loop] Equal to True
-
-





Then - Actions
-






If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-







If - Conditions
-








SKHA_Timer[SKHA_Loop] Greater than 0.00
-
-







Then - Actions
-








Animation - Play SKHA_Caster[SKHA_Loop]'s Spell Channel animation
-








Set SKHA_Timer[SKHA_Loop] = (SKHA_Timer[SKHA_Loop] - 0.03)
-








Set SKHA_Size[SKHA_Loop] = (SKHA_Size[SKHA_Loop] + 2.00)
-








Animation - Change SKHA_Dummy[SKHA_Loop]'s size to (SKHA_Size[SKHA_Loop]%, 15.00%, 15.00%) of its original size
-
-







Else - Actions
-








If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-









If - Conditions
-










SKHA_Timer2[SKHA_Loop] Greater than 0.00
-
-









Then - Actions
-










If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-











If - Conditions
-












SKHA_Boolean[SKHA_Loop] Equal to False
-
-











Then - Actions
-












Set TempInt = (Player number of (Owner of SKHA_Caster[SKHA_Loop]))
-












Animation - Play SKHA_Caster[SKHA_Loop]'s Spell Throw animation
-












Unit - Remove SKHA_Dummy[SKHA_Loop] from the game
-












Custom script: call StartSound(udg_SKHA_Sound2[udg_TempInt])
-












Set SKHA_Boolean[SKHA_Loop] = True
-












Set TempPoint = (Position of SKHA_Caster[SKHA_Loop])
-












Set DR_Point = (TempPoint offset by 80.00 towards SKHA_Angle[SKHA_Loop] degrees)
-












Custom script: set udg_DR_UnitType = 'h00G'
-












Set DR_Player = (Owner of SKHA_Caster[SKHA_Loop])
-












Set DR_Angle = SKHA_Angle[SKHA_Loop]
-












Trigger - Run DummyRecycler <gen> (checking conditions)
-












Custom script: call PSStart(udg_SKHA_Caster[udg_SKHA_Loop], udg_DR_Units[udg_DR_Number], udg_SKHA_Timer2[udg_SKHA_Loop],udg_DR_Angle, 80, udg_SKHA_Damage[udg_SKHA_Loop], 3000, 150, udg_DR_Number)
-












Custom script: call RemoveLocation(udg_DR_Point)
-












Custom script: call RemoveLocation(udg_TempPoint)
-
-











Else - Actions
-
-










Set SKHA_Timer2[SKHA_Loop] = (SKHA_Timer2[SKHA_Loop] - 0.03)
-
-









Else - Actions
-










Set SKHA_Casting[SKHA_Loop] = False
-










Set SKHA_Angle[SKHA_Loop] = SKHA_Angle[SKHA_MaxIndex]
-










Set SKHA_Boolean[SKHA_Loop] = SKHA_Boolean[SKHA_MaxIndex]
-










Set SKHA_Caster[SKHA_Loop] = SKHA_Caster[SKHA_MaxIndex]
-










Set SKHA_Caster[SKHA_MaxIndex] = No unit
-










Set SKHA_Casting[SKHA_Loop] = SKHA_Casting[SKHA_MaxIndex]
-










Set SKHA_Damage[SKHA_Loop] = SKHA_Damage[SKHA_MaxIndex]
-










Set SKHA_Dummy[SKHA_Loop] = SKHA_Dummy[SKHA_MaxIndex]
-










Set SKHA_Dummy[SKHA_MaxIndex] = No unit
-










Set SKHA_Size[SKHA_Loop] = SKHA_Size[SKHA_MaxIndex]
-










Set SKHA_Timer[SKHA_Loop] = SKHA_Timer[SKHA_MaxIndex]
-










Set SKHA_Timer2[SKHA_Loop] = SKHA_Timer2[SKHA_MaxIndex]
-










Set SKHA_MaxIndex = (SKHA_MaxIndex - 1)
-










Set SKHA_Loop = (SKHA_Loop - 1)
-
-
-
-
-
-





Else - Actions
-






Set SKHA_Casting[SKHA_Loop] = False
-






Set SKHA_Angle[SKHA_Loop] = SKHA_Angle[SKHA_MaxIndex]
-






Set SKHA_Boolean[SKHA_Loop] = SKHA_Boolean[SKHA_MaxIndex]
-






Set SKHA_Caster[SKHA_Loop] = SKHA_Caster[SKHA_MaxIndex]
-






Set SKHA_Caster[SKHA_MaxIndex] = No unit
-






Set SKHA_Casting[SKHA_Loop] = SKHA_Casting[SKHA_MaxIndex]
-






Set SKHA_Damage[SKHA_Loop] = SKHA_Damage[SKHA_MaxIndex]
-






Set SKHA_Dummy[SKHA_Loop] = SKHA_Dummy[SKHA_MaxIndex]
-






Set SKHA_Dummy[SKHA_MaxIndex] = No unit
-






Set SKHA_Size[SKHA_Loop] = SKHA_Size[SKHA_MaxIndex]
-






Set SKHA_Timer[SKHA_Loop] = SKHA_Timer[SKHA_MaxIndex]
-






Set SKHA_Timer2[SKHA_Loop] = SKHA_Timer2[SKHA_MaxIndex]
-






Set SKHA_MaxIndex = (SKHA_MaxIndex - 1)
-






Set SKHA_Loop = (SKHA_Loop - 1)
-
-
-




If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-





If - Conditions
-






SKHA_MaxIndex Equal to 0
-
-





Then - Actions
-






Trigger - Turn off (This trigger)
-






Skip remaining actions
-
-





Else - Actions
-
-
-
-
-
-
Actions
-

Custom script: local real x
-

Custom script: local real y
-

Set TempSpellID = 0
-

For each (Integer PS_Loop) from 1 to PS_SpellCount, do (Actions)
-


Loop - Actions
-



Set TempSpellID = PS_SpellNext[TempSpellID]
-



Set PS_Timer[TempSpellID] = (PS_Timer[TempSpellID] - 0.03)
-



If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-




If - Conditions
-





PS_Timer[TempSpellID] Greater than or equal to 0.00
-
-




Then - Actions
-





Set TempPoint = (Position of PS_Caster[TempSpellID])
-





Set DR_Point = (Position of PS_Unit[TempSpellID])
-





If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-






If - Conditions
-







PS_MaxDistance[TempSpellID] Greater than (Distance between TempPoint and DR_Point)
-
-






Then - Actions
-







Set DR_Player = (Owner of PS_Unit[TempSpellID])
-







Set DR_Angle = PS_Angle[TempSpellID]
-







Custom script: set udg_DR_UnitType = GetUnitTypeId(udg_PS_Unit[udg_TempSpellID])
-







Trigger - Run DummyRecycler <gen> (checking conditions)
-







Set PS_Counter[TempSpellID] = (PS_Counter[TempSpellID] + 1)
-







Set PS_Number[PS_Counter[TempSpellID]] = DR_Number
-







Custom script: set x = GetUnitX(udg_PS_Unit[udg_TempSpellID]) + udg_PS_Offset[udg_TempSpellID] * Cos(udg_PS_Angle[udg_TempSpellID] * bj_DEGTORAD)
-







Custom script: set y = GetUnitY(udg_PS_Unit[udg_TempSpellID]) + udg_PS_Offset[udg_TempSpellID] * Sin(udg_PS_Angle[udg_TempSpellID] * bj_DEGTORAD)
-







Custom script: call SetUnitX(udg_PS_Unit[udg_TempSpellID],x)
-







Custom script: call SetUnitY(udg_PS_Unit[udg_TempSpellID],y)
-
-






Else - Actions
-
-





Set PS_Counter2[TempSpellID] = 0
-





For each (Integer PS_Loop2[0]) from 1 to PS_Counter[TempSpellID], do (Actions)
-






Loop - Actions
-







Set PS_Counter2[TempSpellID] = (PS_Counter2[TempSpellID] + 1)
-







Set TempPoint2 = (Position of DR_Units[PS_Counter2[TempSpellID]])
-







Set TempGroup = (Units within PS_Detect[TempSpellID] of TempPoint2 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an ally of (Owner of PS_Unit[TempSpellID])) Equal to False) and (((Matching unit) is alive) Equal to True))))
-







Unit Group - Pick every unit in TempGroup and do (Actions)
-








Loop - Actions
-









If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-










If - Conditions
-











((Picked unit) is in TempGroup2) Equal to False
-
-










Then - Actions
-











Unit - Cause PS_Caster[TempSpellID] to damage (Picked unit), dealing PS_Damage[TempSpellID] damage of attack type Hero and damage type Normal
-











Unit Group - Add (Picked unit) to TempGroup2
-











Unit Group - Remove (Picked unit) from TempGroup
-
-










Else - Actions
-
-
-
-







Custom script: call RemoveLocation(udg_TempPoint2)
-







Custom script: call DestroyGroup(udg_TempGroup)
-







Custom script: set udg_TempGroup = CreateGroup()
-
-
-





Unit Group - Remove all units of TempGroup2 from TempGroup2
-





Custom script: call RemoveLocation(udg_TempPoint)
-





Custom script: call RemoveLocation(udg_DR_Point)
-
-




Else - Actions
-





Set PS_Counter2[TempSpellID] = 0
-





For each (Integer PS_Loop2[1]) from 1 to PS_Counter[TempSpellID], do (Actions)
-






Loop - Actions
-







Set PS_Counter2[TempSpellID] = (PS_Counter2[TempSpellID] + 1)
-







Set TempInt = PS_Counter2[TempSpellID]
-







Custom script: call DREnd(udg_PS_Number[udg_TempInt])
-
-
-





Custom script: call DREnd(udg_PS_Number2[udg_TempSpellID])
-





If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-






If - Conditions
-







PS_SpellLast Equal to TempSpellID
-
-






Then - Actions
-







Set PS_SpellLast = PS_SpellPrev[TempSpellID]
-
-






Else - Actions
-
-





Set PS_RecycleStack[PS_RecycleSize] = TempSpellID
-





Set PS_RecycleSize = (PS_RecycleSize + 1)
-





Set PS_SpellNext[PS_SpellPrev[TempSpellID]] = PS_SpellNext[TempSpellID]
-





Set PS_SpellPrev[PS_SpellNext[TempSpellID]] = PS_SpellPrev[TempSpellID]
-





Set PS_SpellCount = (PS_SpellCount - 1)
-





If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-






If - Conditions
-







PS_SpellCount Equal to 0
-
-






Then - Actions
-







Trigger - Turn off (This trigger)
-
-






Else - Actions
-
-
-
-
-
-
Last edited:








