- Joined
- Jul 22, 2015
- Messages
- 3,484
Well I've been stuck on this problem for over a week. I've bugged enough people through messages and just figured to let everyone know what's going on... for whatever reason in the SP Loop, CurrentIndex is being set to 0 even though MaxIndex is still at 1 (I know this through the messages I have it displaying). Anyone know whats going on? There are 2 other triggers that I felt were irrelevant to this (Config & Death), if you need them, please let me know and I'll update my post.
EDIT: It seems its not the index, its SP_Group[CurrentIndex] thats causing problems. If I run 2 instances of the spell these are the messages I get.
EDIT2: Problem was this.
-
SP Init
-

Events
-


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

Conditions
-


(Ability being cast) Equal to SP_Ability
-
-

Actions
-


Set SP_Target = (Target unit of ability being cast)
-


-------- ---------------------------------------------------- --------
-


-------- checking if target is already infected --------
-


-------- if so, do not continue spell --------
-


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



If - Conditions
-




(SP_Target is in SP_InfectedGroup) Equal to False
-
-



Then - Actions
-




-------- ---------------------------------------------------------------------- --------
-




-------- setting the current instance of spell variables --------
-




Set SP_MaxIndex = (SP_MaxIndex + 1)
-




Set SP_Caster[SP_MaxIndex] = (Triggering unit)
-




Set SP_TargetTest[SP_MaxIndex] = (Target unit of ability being cast)
-




Set SP_Player[SP_MaxIndex] = (Owner of SP_Caster[SP_MaxIndex])
-




Set SP_AbilityLevel[SP_MaxIndex] = (Level of SP_Ability for SP_Caster[SP_MaxIndex])
-




Set SP_Counter[SP_MaxIndex] = 0.00
-




-------- ---------------------------------------------------------------------------------------------------------------------------- --------
-




-------- adding unit to global infection group --------
-




-------- SP_Infected ensures that a unit cannot have more than 1 infection on at a time --------
-




-------- ------------------------------------------------------------------------------------------------------------ --------
-




-------- creating local group variables and adding targeted unit to SP_Group --------
-




-------- SP_Group are units infected by the target of the current instance --------
-




Custom script: if udg_SP_Group[udg_SP_MaxIndex] == null then
-




Custom script: set udg_SP_Group[udg_SP_MaxIndex] = CreateGroup()
-




Custom script: endif
-




Unit Group - Add SP_TargetTest[SP_MaxIndex] to SP_Group[SP_MaxIndex]
-




Unit Group - Add SP_TargetTest[SP_MaxIndex] to SP_InfectedGroup
-




-------- ------------------------------------------------- --------
-




-------- showing infect SFX --------
-




-------- adding movement speed ability --------
-




Special Effect - Create a special effect attached to the SP_InfectSFX_AP of SP_TargetTest[SP_MaxIndex] using SP_InfectSFX
-




Special Effect - Destroy (Last created special effect)
-




Unit - Add SP_AbilityMSFactor to SP_TargetTest[SP_MaxIndex]
-




-------- ------------------------------------------------------------------------ --------
-




-------- checking if user wants to change color of units --------
-




-------- if not, skip this nest --------
-




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





If - Conditions
-






SP_ChangeColor Equal to True
-
-





Then - Actions
-






Animation - Change SP_TargetTest[SP_MaxIndex]'s vertex coloring to (SP_Red%, SP_Green%, SP_Blue%) with 0.00% transparency
-
-





Else - Actions
-






-------- //////////////////// --------
-
-
-




-------- --------------------------------------------------------- --------
-




-------- check if there is an instance running --------
-




-------- if so, turning on loop --------
-




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





If - Conditions
-






SP_MaxIndex Equal to 1
-
-





Then - Actions
-






Trigger - Turn on SP Loop <gen>
-
-





Else - Actions
-






-------- //////////////////// --------
-
-
-
-



Else - Actions
-




-------- ------------------------------------------------------------------------------------------------------------------------ --------
-




-------- simulates an ingame error message if caster is trying to infect an infected unit --------
-




Custom script: call SimError(GetTriggerPlayer(), "That unit is already infected.")
-
-
-
-
-
SP Loop
-

Events
-


Time - Every 0.50 seconds of game time
-
-

Conditions
-

Actions
-


For each (Integer SP_CurrentIndex) from 1 to SP_MaxIndex, do (Actions)
-



Loop - Actions
-




-------- ------------------------------------------------------------------------- --------
-




-------- counting number of units in the group instance --------
-




Set SP_GroupCount[SP_CurrentIndex] = (Number of units in SP_Group[SP_CurrentIndex])
-




Unit Group - Pick every unit in SP_Group[SP_CurrentIndex] and do (Actions)
-





Loop - Actions
-






Set SP_PickedUnitG = (Picked unit)
-






Set SP_PickedUnitGLoc = (Position of SP_PickedUnitG)
-






-------- ----------------------------------------------------- --------
-






-------- looking for potential units to infect --------
-






Set SP_CheckGroup = (Units within SP_InfectRange of SP_PickedUnitGLoc)
-






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







Loop - Actions
-








Set SP_PickedUnitCG = (Picked unit)
-








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









If - Conditions
-










(SP_PickedUnitCG is alive) Equal to True
-










(SP_PickedUnitCG is in SP_InfectedGroup) Equal to False
-










(SP_PickedUnitCG belongs to an enemy of SP_Player[SP_CurrentIndex]) Equal to True
-










(SP_PickedUnitCG is Magic Immune) Equal to False
-










(SP_PickedUnitCG is A structure) Equal to False
-










(SP_PickedUnitCG is Mechanical) Equal to False
-
-









Then - Actions
-










-------- -------------------------------------------------------------------------------------------- --------
-










-------- checking if user wants to set a max infected unit limit or not --------
-










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











If - Conditions
-












Or - Any (Conditions) are true
-













Conditions
-














SP_InfectionLimit Equal to False
-














And - All (Conditions) are true
-















Conditions
-
















SP_InfectionLimit Equal to True
-
















SP_GroupCount[SP_CurrentIndex] Less than SP_MaxInfect[SP_AbilityLevel[SP_CurrentIndex]]
-
-
-
-
-
-











Then - Actions
-












Unit Group - Add SP_PickedUnitCG to SP_Group[SP_CurrentIndex]
-












Unit Group - Add SP_PickedUnitCG to SP_InfectedGroup
-












Unit - Add SP_AbilityMSFactor to SP_PickedUnitCG
-












Special Effect - Create a special effect attached to the SP_InfectSFX_AP of SP_PickedUnitCG using SP_InfectSFX
-












Special Effect - Destroy (Last created special effect)
-












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













If - Conditions
-














SP_ChangeColor Equal to True
-
-













Then - Actions
-














Animation - Change SP_PickedUnitCG's vertex coloring to (SP_Red%, SP_Green%, SP_Blue%) with 0.00% transparency
-
-













Else - Actions
-














-------- //////////////////// --------
-
-
-
-











Else - Actions
-












-------- //////////////////// --------
-
-
-
-









Else - Actions
-










-------- //////////////////// --------
-
-
-
-
-
-
-




-------- ----------------------- --------
-




-------- removing leaks --------
-




Custom script: call RemoveLocation (udg_SP_PickedUnitGLoc)
-




Custom script: call DestroyGroup (udg_SP_CheckGroup)
-




-------- ----------------------------------------------------------------------------------------------------------- --------
-




-------- adding 0.50 seconds to the duration of the spell until it hits max duration --------
-




Set SP_Counter[SP_CurrentIndex] = (SP_Counter[SP_CurrentIndex] + 0.50)
-




-------- ------------------------------------------------------------------------------ --------
-




-------- checking if duration of debuff has finished --------
-




-------- if not, continue to search for more targets to infect --------
-




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





If - Conditions
-






SP_Counter[SP_CurrentIndex] Equal to SP_Duration[SP_AbilityLevel[SP_CurrentIndex]]
-
-





Then - Actions
-






-------- ------------------------------------------------------------------------------------------------------------------------------------------- --------
-






-------- spell duration has ended, dealing damage and removing MS ability --------
-






Unit Group - Pick every unit in SP_Group[SP_CurrentIndex] and do (Actions)
-







Loop - Actions
-








Set SP_PickedUnitG = (Picked unit)
-








Unit - Remove SP_AbilityMSFactor from SP_PickedUnitG
-








Set SP_DamageCalculate[SP_CurrentIndex] = ((Max life of SP_PickedUnitG) / (100.00 / SP_Damage[SP_AbilityLevel[SP_CurrentIndex]]))
-








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









If - Conditions
-










SP_ChangeColor Equal to True
-
-









Then - Actions
-










Animation - Change SP_PickedUnitG's vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
-
-









Else - Actions
-










-------- //////////////////// --------
-
-
-








Special Effect - Create a special effect attached to the SP_DamageSFX_AP of SP_PickedUnitG using SP_DamageSFX
-








Special Effect - Destroy (Last created special effect)
-








Unit - Cause SP_Caster[SP_CurrentIndex] to damage SP_PickedUnitG, dealing SP_DamageCalculate[SP_CurrentIndex] damage of attack type SP_AttackType and damage type SP_DamageType
-








Unit Group - Remove SP_PickedUnitG from SP_Group[SP_CurrentIndex]
-








Unit Group - Remove SP_PickedUnitG from SP_InfectedGroup
-
-
-






-------- -------------------------- --------
-






-------- recycling variables --------
-






Set SP_Caster[SP_CurrentIndex] = SP_Caster[SP_MaxIndex]
-






Set SP_Player[SP_CurrentIndex] = SP_Player[SP_MaxIndex]
-






Set SP_Group[SP_CurrentIndex] = SP_Group[SP_MaxIndex]
-






Set SP_AbilityLevel[SP_CurrentIndex] = SP_AbilityLevel[SP_MaxIndex]
-






Set SP_Counter[SP_CurrentIndex] = SP_Counter[SP_MaxIndex]
-






Set SP_MaxIndex = (SP_MaxIndex - 1)
-






Set SP_CurrentIndex = (SP_CurrentIndex - 1)
-






Game - Display to (All players) the text: (Max Index Count: + (String(SP_MaxIndex)))
-






Game - Display to (All players) the text: (Number of Units in Group: + (String((Number of units in SP_Group[SP_CurrentIndex]))))
-






-------- ----------------------- --------
-






-------- removing leaks --------
-






Custom script: call DestroyGroup (udg_SP_Group[udg_SP_MaxIndex + 1])
-






Custom script: set udg_SP_Group[udg_SP_MaxIndex + 1] = null
-






-------- -------------------------------------------------------------------------------- --------
-






-------- checking if there are any instances of spell running --------
-






-------- if not, removing remaining leak and turning off loop --------
-






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







If - Conditions
-








SP_MaxIndex Equal to 0
-
-







Then - Actions
-








Trigger - Turn off (This trigger)
-
-







Else - Actions
-








-------- //////////////////// --------
-
-
-
-





Else - Actions
-






-------- //////////////////// --------
-
-
-
-
-
-
- Max Index: 1
- Max Index: 2
(Instance 1 finishes) - Max Index: 1
- Number of Units in Group: 0
(Instance 2 finishes) - Max Index: 0
- Number of Units in Group: 0
EDIT2: Problem was this.
-
Set SP_Group[SP_CurrentIndex] = SP_Group[SP_MaxIndex]
-
Unit Group - Add all units of SP_Group[SP_MaxIndex] to SP_Group[SP_CurrentIndex]
Last edited:







