- Joined
- Feb 2, 2006
- Messages
- 1,621
Hi,
I use command button effects from Reforged to indicate which unit types are spawned. Whenever I play alone or 1 vs 1 it seems to work but as soon as multiple players play the wrong buttons have an effect.
This is my trigger to create/recreate the effect:
The custom JASS function Index2D looks like this:
It should calculate the 2-dimensional index using the unit type (integer a) as value 0 and the player number as value 1. There is only one barrack per player, so the player number should be enough. One barrack has buttons for every unit type. When a unit type is enabled, the command effect should appear.
It works perfectly when I play alone but as I wrote I get issues playing with other players. Maybe the player number causes problems?
I use command button effects from Reforged to indicate which unit types are spawned. Whenever I play alone or 1 vs 1 it seems to work but as soon as multiple players play the wrong buttons have an effect.
This is my trigger to create/recreate the effect:
-
Actions
-
Custom script: set udg_TmpHandle = udg_TmpUnit
-
Custom script: set udg_TmpInt2 = udg_TmpUnitType
-
For each (Integer A) from 0 to AllBarrackUnitTypesSize, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
TmpUnitType Equal to AllBarrackUnitTypes[(Integer A)]
-
-
Then - Actions
-
Custom script: set udg_TmpString2 = GetObjectName(udg_TmpInt2)
-
Hashtable - Save TmpInt as TmpInt2 of (Key TmpHandle.) in AllBarracksUnitTypes.
-
-------- Ability Command Effect --------
-
Custom script: set udg_TmpInt3 = Index2D(GetForLoopIndexA(), GetConvertedPlayerId(GetOwningPlayer(udg_TmpUnit)), 9)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
TmpInt Equal to 0
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
AllBarracksCommandEffectsB[TmpInt3] Equal to True
-
-
Then - Actions
-
Game - Destroy Button Effect AllBarracksCommandEffects[TmpInt3]
-
Set VariableSet AllBarracksCommandEffectsB[TmpInt3] = False
-
-
Else - Actions
-
Do nothing
-
-
-
-
Else - Actions
-
Custom script: call CreateCommandButtonEffectBJ(udg_AllBarrackUnitTypesAbilities[GetForLoopIndexA()], udg_AllBarrackUnitTypesOrders[GetForLoopIndexA()])
-
Set VariableSet AllBarracksCommandEffects[TmpInt3] = (Last created Button effect)
-
Set VariableSet AllBarracksCommandEffectsB[TmpInt3] = True
-
-
-
-
Else - Actions
-
Do nothing
-
-
-
-
-
Trigger - Run Update Unit Type Priority Floating Text <gen> (checking conditions)
-
The custom JASS function Index2D looks like this:
Code:
function Index2D takes integer value0, integer value1, integer maxValue1 returns integer
return (value0 * maxValue1) + value1
endfunction
It should calculate the 2-dimensional index using the unit type (integer a) as value 0 and the player number as value 1. There is only one barrack per player, so the player number should be enough. One barrack has buttons for every unit type. When a unit type is enabled, the command effect should appear.
It works perfectly when I play alone but as I wrote I get issues playing with other players. Maybe the player number causes problems?
Last edited: