• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Please help me with this mathematic.

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,142
Let me tell you what happens. I had a twelve special abilities within my map. Then i have removed 4 of them and it is 8 now. Player 1 and Player 7 are computer slot. Player 1-6 team against player 7-12.

Players 2,3,4,5,6 and 8 can select abilites between 1-8 but this is not working when it comes players 9,10,11,12.

This is one of my friends trigger and my math is terrible. I cannot solve this issue. Can you help me about that? Probably it will work if i will create empty ability and connect them between GOD_Dialog 9,10,11,12.

Why this trigger not works for players 9,10,11 and 12?
Note: Dialog buttons still visible and can be selected by anyone. But not works for players 9,10,11 and 12. I know probably i was already solved this if i was good at math...

  • Dialog Button
    • Events
      • Dialog - A dialog button is clicked for GOD_Dialog[1]
      • Dialog - A dialog button is clicked for GOD_Dialog[2]
      • Dialog - A dialog button is clicked for GOD_Dialog[3]
      • Dialog - A dialog button is clicked for GOD_Dialog[4]
      • Dialog - A dialog button is clicked for GOD_Dialog[5]
      • Dialog - A dialog button is clicked for GOD_Dialog[6]
      • Dialog - A dialog button is clicked for GOD_Dialog[7]
      • Dialog - A dialog button is clicked for GOD_Dialog[8]
    • Conditions
    • Actions
      • For each (Integer GOD_A) from 1 to 64, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to GOD_DialogButton[GOD_A]
            • Then - Actions
              • Set GOD_TempInteger[1] = GOD_A
              • Set GOD_TempInteger[2] = (Player number of (Triggering player))
              • Set GOD_TempInteger[3] = (GOD_TempInteger[2] - 1)
              • Set GOD_TempInteger[4] = (GOD_TempInteger[3] x 8)
              • Set GOD_TempInteger[5] = (GOD_TempInteger[1] - GOD_TempInteger[4])
              • Game - Display to (Player group((Triggering player))) the text: (|cffb4b4b4Seçtigin özellik |r + (GOD_Buton_Name[GOD_TempInteger[5]] + |cffb4b4b4 Basarılar...|r))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of GOD_Hero[(Player number of (Triggering player))]) Equal to Dark Ranger Lady Sylvanas
                • Then - Actions
                  • Game - Display to (Player group((Triggering player))) the text: Hero suan test sür...
                • Else - Actions
              • Unit - Add GOD_Ability[GOD_TempInteger[5]] to GOD_Hero[(Player number of (Triggering player))]
              • -------- --------
              • Custom script: call UnitMakeAbilityPermanent(udg_GOD_Hero[GetConvertedPlayerId(GetTriggerPlayer())], true, udg_GOD_Ability[udg_GOD_TempInteger[5]])
              • Custom script: call UnitMakeAbilityPermanent(udg_GOD_Hero[GetConvertedPlayerId(GetTriggerPlayer())], true, 'A03Y')
              • For each (Integer B) from 1 to 12, do (Actions)
                • Loop - Actions
                  • Custom script: call UnitMakeAbilityPermanent(udg_GOD_Hero[GetPlayerId(GetTriggerPlayer()) + 1], true, udg_GOD_Sub_Ability[bj_forLoopBIndex])
              • -------- --------
              • Multiboard - Set the text for (Last created multiboard) item in column 8, row Table_PlayerLine[(Player number of (Triggering player))] to GOD_Nick[GOD_TempInteger[5]]
              • Set StartingAbility[(Player number of (Triggering player))] = GOD_Ability[GOD_TempInteger[5]]
              • Player - Disable GOD_Ability[GOD_TempInteger[5]] for (Triggering player)
            • Else - Actions
      • Dialog - Clear GOD_Dialog[(Player number of (Triggering player))]
 
Level 25
Joined
Sep 26, 2009
Messages
2,383
If the trigger above works, then I believe this is not the full trigger... or rather I think there is at least one other trigger that affects your trigger that you did not post - the trigger you posted will simply not work alone, because the math does not make any sense otherwise.

My guess is that there is actually 64 GOD_Dialog buttons, ranging under indices 1-64.
Since adding manually 64 events is waste of time, I believe the events are added via another trigger using loop and the action "Trigger - Add new event".

Why do I think so? Because the GOD_A loop iterates 64 times, but with only 8 buttons in the events, the condition
  • (Clicked dialog button) Equal to GOD_DialogButton[GOD_A]
would never be true for iterations 9-64.
... And the math would make no sense.

So my guess is that each player has his own 8 unique instances of the GOD_Dialog buttons and the trigger attempts to calculate which ability out of 8 possible abilities should be added based on button clicked.
The trigger was originally made with 8 players in mind and each player should see 8 dialog buttons, so 8*8 = 64, hence why loop iterates 64 times.
The GOD_TempInteger just calculates which ability should be added to the hero, based on the index of clicked button.

So in your case, you need to update:
  • whatever trigger creates dialog buttons for players (I guess that is done since you wrote players 9+ see the buttons)
  • whatever trigger adds the "Dialog - A dialog button is clicked" events to also include buttons for player 9-12, so buttons with indices 65-96
  • Update the loop in your trigger to iterate 8*12 = 96 times

As an example of why the math would make no sense otherwise, imagine right now that the buttons are shared by all players and player 9 clicked the "GOD_Dialog[1]" dialog button.
Then the temp integers would have these values:
  • GOD_TempInteger[1] = 1 (this is the index of clicked GOD_Dialog button)
  • GOD_TempInteger[2] = 9 (number of player 9)
  • GOD_TempInteger[3] = 9 - 1 = 8
  • GOD_TempInteger[4] = 8 * 8 = 64
  • GOD_TempInteger[5] = 1 - 64 = -63
You would be searching for ability in GOD_Ability array under index -63... which makes no sense.
But if player 9 could only ever click GOD_Dialog with indices 65-72, then it would suddenly make sense:
  • GOD_TempInteger[1] = 65
  • ...
  • GOD_TempInteger[5] = 65 - 64 = 1
So player 9 would get the ability under index 1.
 
Level 17
Joined
Jun 2, 2009
Messages
1,142
If the trigger above works, then I believe this is not the full trigger... or rather I think there is at least one other trigger that affects your trigger that you did not post - the trigger you posted will simply not work alone, because the math does not make any sense otherwise.

My guess is that there is actually 64 GOD_Dialog buttons, ranging under indices 1-64.
Since adding manually 64 events is waste of time, I believe the events are added via another trigger using loop and the action "Trigger - Add new event".

Why do I think so? Because the GOD_A loop iterates 64 times, but with only 8 buttons in the events, the condition
  • (Clicked dialog button) Equal to GOD_DialogButton[GOD_A]
would never be true for iterations 9-64.
... And the math would make no sense.

So my guess is that each player has his own 8 unique instances of the GOD_Dialog buttons and the trigger attempts to calculate which ability out of 8 possible abilities should be added based on button clicked.
The trigger was originally made with 8 players in mind and each player should see 8 dialog buttons, so 8*8 = 64, hence why loop iterates 64 times.
The GOD_TempInteger just calculates which ability should be added to the hero, based on the index of clicked button.

So in your case, you need to update:
  • whatever trigger creates dialog buttons for players (I guess that is done since you wrote players 9+ see the buttons)
  • whatever trigger adds the "Dialog - A dialog button is clicked" events to also include buttons for player 9-12, so buttons with indices 65-96
  • Update the loop in your trigger to iterate 8*12 = 96 times

As an example of why the math would make no sense otherwise, imagine right now that the buttons are shared by all players and player 9 clicked the "GOD_Dialog[1]" dialog button.
Then the temp integers would have these values:
  • GOD_TempInteger[1] = 1 (this is the index of clicked GOD_Dialog button)
  • GOD_TempInteger[2] = 9 (number of player 9)
  • GOD_TempInteger[3] = 9 - 1 = 8
  • GOD_TempInteger[4] = 8 * 8 = 64
  • GOD_TempInteger[5] = 1 - 64 = -63
You would be searching for ability in GOD_Ability array under index -63... which makes no sense.
But if player 9 could only ever click GOD_Dialog with indices 65-72, then it would suddenly make sense:
  • GOD_TempInteger[1] = 65
  • ...
  • GOD_TempInteger[5] = 65 - 64 = 1
So player 9 would get the ability under index 1.
Oh sorry. Here is the another one

  • Ability Setup 2
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is A Hero) Equal to True
          • (Level of (Triggering unit)) Equal to 1
          • (Unit-type of (Triggering unit)) Not equal to Flash Swift Strike Dummy
    • Actions
      • Set MB_Bool[(Player number of (Owner of (Triggering unit)))] = True
      • Set GOD_PlayerNumber = (Player number of (Owner of (Triggering unit)))
      • Set GOD_Hero[GOD_PlayerNumber] = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • mod_test Equal to False
        • Then - Actions
          • Player - Limit training of Heroes to 0 for (Owner of (Triggering unit))
        • Else - Actions
      • For each (Integer GOD_B) from 1 to GOD_ButtonNumber, do (Actions)
        • Loop - Actions
          • Dialog - Change the title of GOD_Dialog[GOD_PlayerNumber] to |cffff8c00Bonus yet...
          • Dialog - Create a dialog button for GOD_Dialog[GOD_PlayerNumber] labelled GOD_Buton_Name[GOD_B]
          • Set GOD_DialogButton[(((GOD_PlayerNumber - 1) x 8) + GOD_B)] = (Last created dialog Button)
      • Dialog - Show GOD_Dialog[GOD_PlayerNumber] for (Player(GOD_PlayerNumber))
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
Unrelated notes because I can't help myself:

AND - All conditions are true is not necessary in the last trigger you posted. By default, ALL conditions need to be met.

You'll rarely use AND. Here is an example of when it would be used:
If Condition A is true OR Condition B AND C are true then proceed...

Also, in the future I recommend designing your Player Slots so that Users and Computers are separated like so:
Team 1 Users = Players 1 to 6
Team 2 Users = Players 7 to 12
Team 1 Computers = Player 13
Team 2 Computers = Player 14

This helps when using For Loops and managing things in general, because often times you want to do thing for Users but not Computers. If Player Color is the deciding factor in which Player Slot you use, remember that you can change Player Colors with triggers.

That being said, you can use Player Groups to break the players up and organize them in any way you'd like, so in that case Player Slot isn't important.
 
Level 17
Joined
Jun 2, 2009
Messages
1,142
My problem is, it was not my trigger. My friend was created it. I really don't know how to fix this issue.

GOD_Dialog[9] - GOD_Dialog[12] have no registered events.

@Nichilus @icemanb How can i solve this issue? One of my friends was created it.

@Uncle Yes i know but it is a bit of late for that. This is trigger from my moba map and it is 20 years old map.
 
1645482889656.png

here are the events, you can add more events for index 9-12
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
All of the math is designed around 8 abilities and 8 players. So now that there's 12 players this needs to be accounted for.
For example, the number 64 becomes 96 because there's 8 buttons * 12 players. Before there was 8 buttons * 8 players (64).
 
Level 17
Joined
Jun 2, 2009
Messages
1,142
All of the math is designed around 8 abilities and 8 players. So now that there's 12 players this needs to be accounted for.
For example, the number 64 becomes 96 because there's 8 buttons * 12 players. Before there was 8 buttons * 8 players (64).
10 Actually
Team 1: 2, 3, 4, 5, 6
Team 2: 8, 9, 10, 11, 12

But still i don't get it. All i need to do add GOD_Dialog[9] to 12 right?
View attachment 395659
here are the events, you can add more events for index 9-12
Tomorrow i will try it but still i don't think it won't work even if i change this to 1-96
  • For each (Integer GOD_A) from 1 to 64, do (Actions)
I will inform in here tomorrow.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
10 Actually
Team 1: 2, 3, 4, 5, 6
Team 2: 8, 9, 10, 11, 12

But still i don't get it. All i need to do add GOD_Dialog[9] to 12 right?

Tomorrow i will try it but still i don't think it won't work even if i change this to 1-96
  • For each (Integer GOD_A) from 1 to 64, do (Actions)
I will inform in here tomorrow.
My mistake, but the concept should still remain the same:
X = number of players
Y = number of buttons
X * Y = the length of the Loop

Variables[1 to 8] are set for the first player
Variables[9 to 16] are set for the second player
etc...

These triggers were designed in a way that makes it very easy to add/remove players and buttons, but your friend made the mistake of not using Variables to define Player Count and Ability Count. Ideally, there'd be variables for these 2 things which you could adjust in an Initialize trigger. Then the rest of the triggers would reference these 2 variables when doing their calculations.
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,142
Here is the update.

  • Dialog Button
    • Events
      • Dialog - A dialog button is clicked for GOD_Dialog[1]
      • Dialog - A dialog button is clicked for GOD_Dialog[2]
      • Dialog - A dialog button is clicked for GOD_Dialog[3]
      • Dialog - A dialog button is clicked for GOD_Dialog[4]
      • Dialog - A dialog button is clicked for GOD_Dialog[5]
      • Dialog - A dialog button is clicked for GOD_Dialog[6]
      • Dialog - A dialog button is clicked for GOD_Dialog[7]
      • Dialog - A dialog button is clicked for GOD_Dialog[8]
      • Dialog - A dialog button is clicked for GOD_Dialog[9]
      • Dialog - A dialog button is clicked for GOD_Dialog[10]
      • Dialog - A dialog button is clicked for GOD_Dialog[11]
      • Dialog - A dialog button is clicked for GOD_Dialog[12]
I have added GOD_Dialog from 9 to 12. Then i have changed this x 8 to x12
  • Set GOD_TempInteger[4] = (GOD_TempInteger[3] x 12)
And changed this from 64 to 96
  • For each (Integer GOD_A) from 1 to 96, do (Actions)
Still slot 9 cannot get any abilities but this time i am able to get this message
Game - Display to (Player group((Triggering player))) the text: (|cffb4b4b4Sectigin Ozellik |r + (GOD_Buton_Name[GOD_TempInteger[5]] + |cffb4b4b4 Basarilar..|r)) but still i cannot get name of the ability and ability itself.

And there are other things changed. I have tested it on Player 2 (first human slot) when i click the dialog 1-2-3-4 nothing happens but when i click 5, it gives me the 1. When i click 6, it gives me the 2 and it goes on like this (3-7, 4-8)
I really don't know what can i do. By the way this is from map initialization.

  • Set GOD_ButtonNumber = 8
  • Set GOD_Buton_Name[1] = |cff00ff00Ormanci|r
  • Set GOD_Buton_Name[2] = |cff87cefaDestek|r
  • Set GOD_Buton_Name[3] = |cffff8c00+%20 vurus hizi|r
  • Set GOD_Buton_Name[4] = |cffff8c00+5 zirh|r
  • Set GOD_Buton_Name[5] = |cffff8c00+12 hasar|r
  • Set GOD_Buton_Name[6] = |cffff8c00+6 strength|r
  • Set GOD_Buton_Name[7] = |cffff8c00+6 intelligence|r
  • Set GOD_Buton_Name[8] = |cffff8c00+6 agility|r
  • -------- Spellbooklar --------
  • Set GOD_Ability[1] = GOD Orman
  • Set GOD_Ability[2] = GOD Destek
  • Set GOD_Ability[3] = God 3 // AS
  • Set GOD_Ability[4] = God 4 // ARMOR
  • Set GOD_Ability[5] = God 5 // DAMAGE
  • Set GOD_Ability[6] = God 6 // str
  • Set GOD_Ability[7] = God 7 // int
  • Set GOD_Ability[8] = God 8 // agi
  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Player - Disable GOD_Ability[(Integer A)] for (Picked player)
  • -------- Spellbooklarin icinlerindekiler --------
  • Set GOD_Sub_Ability[1] = GOD ORMAN REAL
  • Set GOD_Sub_Ability[2] = GOD DESTEK REAL
  • Set GOD_Sub_Ability[3] = GOD AS (20%)
  • Set GOD_Sub_Ability[4] = GOD ARMOR (+5)
  • Set GOD_Sub_Ability[5] = GOD DAMAGE (+12)
  • Set GOD_Sub_Ability[6] = stat str 6//
  • Set GOD_Sub_Ability[7] = stat int 6//
  • Set GOD_Sub_Ability[8] = stat agi 6//
  • Set GOD_Sub_Ability[9] = stat int 8//
  • Set GOD_Sub_Ability[10] = stat agi 8//
  • Set GOD_Nick[1] = |cff87cefaOrmanci|n
  • Set GOD_Nick[2] = |cff87cefaDestek|r|n
  • Set GOD_Nick[3] = |cff87cefaAS|r|n
  • Set GOD_Nick[4] = |cff87cefaArmor|r|n
  • Set GOD_Nick[5] = |cff87cefaDamage|r|n
  • Set GOD_Nick[6] = |cff87cefaSTR|r|n
  • Set GOD_Nick[7] = |cff87cefaINT|r|n
  • Set GOD_Nick[8] = |cff87cefaAGI|r|n
I really don't know what should i do. Still thinking on it.

Edit: Wow it seems it's worked when i changed this to x8 instead of x12. I will test it on every slot and let you know the final result.
  • Set GOD_TempInteger[4] = (GOD_TempInteger[3] x 8)
I have tested it on player 2, 8 and 9 and it seems everything is ok now. Still i don't understand how it works but i don't care actually. I suck at math..
Again i wanted to thank all of you.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
Not that it matters since you've got it working, but here's my best explanation as to how it all works:

When a player's Hero first enters the map (so when it's first created), 8 Dialog Buttons are created for that Player which represent their 8 Abilities to choose from. These buttons are added to that player's Dialog menu.

Each player has their own Dialog which these Dialog Buttons belong to:
GOD_Dialog[1] = Player 1's Dialog
GOD_Dialog[2] = Player 2's Dialog
GOD_Dialog[3] = Player 3's Dialog
etc...

This method takes advantage of each Player's Number to keep track of their Dialog/Dialog Buttons.

You can see this method in action here:
  • Dialog - Show GOD_Dialog[GOD_PlayerNumber] for (Player(GOD_PlayerNumber))

Then these 8 Dialog Buttons are tracked inside of a Dialog Button Variable Array so you can reference them later on:
  • Set GOD_DialogButton[(((GOD_PlayerNumber - 1) x 8) + GOD_B)] = (Last created dialog Button)
The math here may look confusing but all it's doing is this:
If you're Player 1, it's storing these new Buttons in GOD_DialogButton using the [Indexes] 1 through 8. So the first button is [1] and the last is [8].
If you're Player 2, it's storing these new Buttons in GOD_DialogButton using the [Indexes] 9 through 16. So the first button is [9] and the last is [16].
If you're Player 3, it's storing these new Buttons in GOD_DialogButton using the [Indexes] 17 through 24. So the first button is [17] and the last is [24].

This pattern continues for each Player, all the way up to what used to be 64 but is now 96. (64 old buttons + 32 new buttons = 96 total buttons)
No two player's Buttons will ever share the same GOD_DialogButton [Index].
This is important since it allows these triggers to work for everyone at the same time without any conflicts.

Finally, when a player clicks a Dialog Button inside of one of the 12 (what used to be 8) Dialogs:
  • Dialog - A dialog button is clicked for GOD_Dialog[1]
  • Dialog - A dialog button is clicked for GOD_Dialog[2]
  • Dialog - A dialog button is clicked for GOD_Dialog[3]
  • Dialog - A dialog button is clicked for GOD_Dialog[4]
  • Dialog - A dialog button is clicked for GOD_Dialog[5]
  • Dialog - A dialog button is clicked for GOD_Dialog[6]
  • Dialog - A dialog button is clicked for GOD_Dialog[7]
  • Dialog - A dialog button is clicked for GOD_Dialog[8]
  • Dialog - A dialog button is clicked for GOD_Dialog[9]
  • Dialog - A dialog button is clicked for GOD_Dialog[10]
  • Dialog - A dialog button is clicked for GOD_Dialog[11]
  • Dialog - A dialog button is clicked for GOD_Dialog[12]
A For Loop runs which figures out which of the 96 Dialog Buttons was pressed and which Ability should be added to the Hero.

This is done using confusing math again but it's honestly not that confusing once it all clicks. It'd be easier to understand if the variables were named accordingly instead of TempInteger.

For example, if it was GOD_DialogButton[10] that was pressed it would know that this is Player 2's second Dialog Button. This is because Player 2's Dialog Button index range goes from 9 to 16. So 9 = 1st button, 10 = 2nd button, 11 = 3rd button, etc...

Lastly, the Ability associated with that [Index] is added to the Hero. So since GOD_DialogButton[10] is Player 2's 2nd Dialog Button, we know to add GOD_Ability[2] to their Hero. If GOD_DialogButton[11] was clicked we'd add GOD_Ability[3] to their Hero instead since it's their 3rd Dialog Button.
 
Last edited:
Status
Not open for further replies.
Top