• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Food Max system

Status
Not open for further replies.
Level 18
Joined
Jan 12, 2011
Messages
1,513
No. If your trigger fires only when you write "-ally red" then you know that the triggering player wants to ally red player! There is no need to get substring to find out if "-ally red" contains substring red, because they way you set it up, if the entered chat message didn't contain exactly "-ally red", then the trigger would not even fire.

If you want for this whole (un)alliance system only 1 trigger, you need to do it my way (similarly to what I posted in the test map a few posts before).
If you do it your way - 12 ally and 12 unally triggers, then each trigger has different event.

So just merge the important parts of my trigger into your trigger - like this:
  • Ally Red
    • Events
      • Player - Player 2 (Blue) types a chat message containing -ally red as An exact match
      • Player - Player 3 (Teal) types a chat message containing -ally red as An exact match
      • Player - Player 4 (Purple) types a chat message containing -ally red as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -ally red as An exact match
      • Player - Player 6 (Orange) types a chat message containing -ally red as An exact match
      • Player - Player 7 (Green) types a chat message containing -ally red as An exact match
      • Player - Player 8 (Pink) types a chat message containing -ally red as An exact match
      • Player - Player 9 (Gray) types a chat message containing -ally red as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -ally red as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -ally red as An exact match
      • Player - Player 12 (Brown) types a chat message containing -ally red as An exact match
    • Conditions
      • ((Triggering player) is an ally of Player 1 (Red)) Equal to False
    • Actions
      • Player - Make (Triggering player) treat Player 1 (Red) as an Ally with shared vision
      • Player - Make Player 1 (Red) treat (Triggering player) as an Ally with shared vision
      • Set allies = (All allies of (Triggering player))
      • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
      • Player Group - Pick every player in allies and do (Actions)
        • Loop - Actions
          • Player - Set (Picked player) Food max to int
          • Player - Set (Picked player) Food used to (((Picked player) Food used) + 1)
          • Player - Set (Picked player) Food used to (((Picked player) Food used) - 1)
      • Custom script: call DestroyForce(udg_allies)
      • -------- --------------------------------------------------------------- --------
      • -------- Here is the part where you update your multiboard --------
For -unally red the trigger is same, except the event (you have to change which command fires that trigger to -unally red), condition (now you check that they are allies instead of checking that they are not allies) and that you set their alliance as enemy.

Then you just copy it 11 times for other players.

ooooh nice :D (with the exception of the forced alliance)
 
Level 18
Joined
Jan 12, 2011
Messages
1,513
Well, yeah, it makes more sense that way.

I would not agree to be with someone in alliance anyway, if he were to remain hostile to me, while I would be friendly to him and lower my food max.

Yeah but if someone types -ally blue (a noob for example) and you don't want and start killing him he will unally after anyways, but you wouldn't want your enemy type -ally red to see all your base and then unallying
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
Well, from that point of view it makes sense, but for that you will need to change the trigger above a little bit.

  • Actions
    • Player - Make (Triggering player) treat Player 1 (Red) as an Ally with shared vision
    • Set allies = (All allies of (Triggering player))
    • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
    • Player - Set (Triggering player) Food max to int
    • Player - Set (Triggering player) Food used to (((Triggering player) Food used) + 1)
    • Player - Set (Triggering player) Food used to (((Triggering player) Food used) - 1)
    • Custom script: call DestroyForce(udg_allies)
    • -------- --------------------------------------------------------------- --------
    • -------- Here is the part where you update your multiboard --------
Now this makes the triggering player treat another player as his ally, but it will change Food Max only for the triggering player instead of his allies, else it would not make sense.
 
Level 18
Joined
Jan 12, 2011
Messages
1,513
Well, from that point of view it makes sense, but for that you will need to change the trigger above a little bit.

  • Actions
    • Player - Make (Triggering player) treat Player 1 (Red) as an Ally with shared vision
    • Set allies = (All allies of (Triggering player))
    • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
    • Player - Set (Triggering player) Food max to int
    • Player - Set (Triggering player) Food used to (((Triggering player) Food used) + 1)
    • Player - Set (Triggering player) Food used to (((Triggering player) Food used) - 1)
    • Custom script: call DestroyForce(udg_allies)
    • -------- --------------------------------------------------------------- --------
    • -------- Here is the part where you update your multiboard --------
Now this makes the triggering player treat another player as his ally, but it will change Food Max only for the triggering player instead of his allies, else it would not make sense.

hmm k
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
You will need to create 2 player groups.

  • Actions
    • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
    • Player - Make Player 1 (Red) treat (Triggering player) as an Enemy
    • -------- --------------------------------------------------------------- --------
    • Set allies = (All allies of (Triggering player))
    • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
    • Custom script: call DestroyForce(udg_allies)
    • Player - Set (Triggering player) Food max to int
    • Player - Set (Triggering player) Food used to (((Triggering player) Food used) + 1)
    • Player - Set (Triggering player) Food used to (((Triggering player) Food used) - 1)
    • -------- --------------------------------------------------------------- --------
    • -------- Picks Player 1 --------
    • Set allies = (All allies of Player 1 (Red))
    • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
    • Custom script: call DestroyForce(udg_allies)
    • Player - Set Player 1 (Red) Food max to int
    • Player - Set Player 1 (Red) Food used to ((Player 1 (Red) Food used) + 1)
    • Player - Set Player 1 (Red) Food used to ((Player 1 (Red) Food used) - 1)
    • -------- --------------------------------------------------------------- --------
    • -------- Here is the part where you update your multiboard --------
Basically I get the number of allies of triggering player to set his food max and then I pick allies of Player 1 and set his food max
 
Level 18
Joined
Jan 12, 2011
Messages
1,513
You will need to create 2 player groups.

  • Actions
    • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
    • Player - Make Player 1 (Red) treat (Triggering player) as an Enemy
    • -------- --------------------------------------------------------------- --------
    • Set allies = (All allies of (Triggering player))
    • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
    • Custom script: call DestroyForce(udg_allies)
    • Player - Set (Triggering player) Food max to int
    • Player - Set (Triggering player) Food used to (((Triggering player) Food used) + 1)
    • Player - Set (Triggering player) Food used to (((Triggering player) Food used) - 1)
    • -------- --------------------------------------------------------------- --------
    • -------- Picks Player 1 --------
    • Set allies = (All allies of Player 1 (Red))
    • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
    • Custom script: call DestroyForce(udg_allies)
    • Player - Set Player 1 (Red) Food max to int
    • Player - Set Player 1 (Red) Food used to ((Player 1 (Red) Food used) + 1)
    • Player - Set Player 1 (Red) Food used to ((Player 1 (Red) Food used) - 1)
    • -------- --------------------------------------------------------------- --------
    • -------- Here is the part where you update your multiboard --------
Basically I get the number of allies of triggering player to set his food max and then I pick allies of Player 1 and set his food max

wooja :D, but it will work normally if i destroy the variable allies 2 times in the same trigger?
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
You don't destroy the variable, you destroy the group that variable points to :)
Creating groups and then destroying them will cause no problems.
(in other words, in this trigger you can consider "allies" a temporal player group variable)
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
No, you need int in each trigger, because everytime that trigger fires, int may be different.

Int = 300 / number of allies
Everytime trigger fires, "number of allies" has different value, because one time you have 2 allies, other 3, etc.
 
Level 18
Joined
Jan 12, 2011
Messages
1,513
weird it only works once =/

Ally triggers i used:
  • Ally Red
    • Events
      • Player - Player 2 (Blue) types a chat message containing -ally red as An exact match
      • Player - Player 3 (Teal) types a chat message containing -ally red as An exact match
      • Player - Player 4 (Purple) types a chat message containing -ally red as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -ally red as An exact match
      • Player - Player 6 (Orange) types a chat message containing -ally red as An exact match
      • Player - Player 7 (Green) types a chat message containing -ally red as An exact match
      • Player - Player 8 (Pink) types a chat message containing -ally red as An exact match
      • Player - Player 9 (Gray) types a chat message containing -ally red as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -ally red as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -ally red as An exact match
      • Player - Player 12 (Brown) types a chat message containing -ally red as An exact match
    • Conditions
      • ((Triggering player) is an ally of Player 1 (Red)) Equal to (==) False
    • Actions
      • Player - Make (Triggering player) treat Player 1 (Red) as an Ally with shared vision
      • Set allies = (All allies of (Triggering player))
      • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
      • Player - Set (Triggering player) Food max to int
      • Player - Set (Triggering player) Food used to (((Triggering player) Food used) + 1)
      • Player - Set (Triggering player) Food used to (((Triggering player) Food used) - 1)
      • Custom script: call DestroyForce(udg_allies)
      • Set PlayerAllies[(Player number of (Triggering player))] = (PlayerAllies[(Player number of (Triggering player))] + 1)
      • Wait 0.01 seconds
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 2 to (String(PlayerAllies[1]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 3 to (String(PlayerAllies[2]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 4 to (String(PlayerAllies[3]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 5 to (String(PlayerAllies[4]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 6 to (String(PlayerAllies[5]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 7 to (String(PlayerAllies[6]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 8 to (String(PlayerAllies[7]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 9 to (String(PlayerAllies[8]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 10 to (String(PlayerAllies[9]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 11 to (String(PlayerAllies[10]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 12 to (String(PlayerAllies[11]))
      • Multiboard - Set the text for (Last created multiboard) item in column 3, row 13 to (String(PlayerAllies[12]))
Unally:
  • Unally Red
    • Events
      • Player - Player 2 (Blue) types a chat message containing -unally red as An exact match
      • Player - Player 3 (Teal) types a chat message containing -unally red as An exact match
      • Player - Player 4 (Purple) types a chat message containing -unally red as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -unally red as An exact match
      • Player - Player 6 (Orange) types a chat message containing -unally red as An exact match
      • Player - Player 7 (Green) types a chat message containing -unally red as An exact match
      • Player - Player 8 (Pink) types a chat message containing -unally red as An exact match
      • Player - Player 9 (Gray) types a chat message containing -unally red as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -unally red as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -unally red as An exact match
      • Player - Player 12 (Brown) types a chat message containing -unally red as An exact match
    • Conditions
      • ((Triggering player) is an ally of Player 1 (Red)) Equal to (==) True
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) is an ally of (Triggering player)) Equal to (==) True
        • Then - Actions
          • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
          • Player - Make Player 1 (Red) treat (Triggering player) as an Enemy
          • Set allies = (All allies of (Triggering player))
          • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
          • Player - Set (Triggering player) Food max to int
          • Player - Set (Triggering player) Food used to (((Triggering player) Food used) + 1)
          • Player - Set (Triggering player) Food used to (((Triggering player) Food used) - 1)
          • Custom script: call DestroyForce(udg_allies)
          • Set allies = (All allies of Player 1 (Red))
          • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
          • Player - Set Player 1 (Red) Food max to int
          • Player - Set Player 1 (Red) Food used to ((Player 1 (Red) Food used) + 1)
          • Player - Set Player 1 (Red) Food used to ((Player 1 (Red) Food used) - 1)
          • Custom script: call DestroyForce(udg_allies)
          • Set PlayerAllies[(Player number of (Triggering player))] = (PlayerAllies[(Player number of (Triggering player))] - 1)
          • Set PlayerAllies[1] = (PlayerAllies[1] - 1)
          • Wait 0.01 seconds
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 2 to (String(PlayerAllies[1]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 3 to (String(PlayerAllies[2]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 4 to (String(PlayerAllies[3]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 5 to (String(PlayerAllies[4]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 6 to (String(PlayerAllies[5]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 7 to (String(PlayerAllies[6]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 8 to (String(PlayerAllies[7]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 9 to (String(PlayerAllies[8]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 10 to (String(PlayerAllies[9]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 11 to (String(PlayerAllies[10]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 12 to (String(PlayerAllies[11]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 13 to (String(PlayerAllies[12]))
        • Else - Actions
          • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
          • Player - Make Player 1 (Red) treat (Triggering player) as an Enemy
          • Set allies = (All allies of (Triggering player))
          • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
          • Player - Set (Triggering player) Food max to int
          • Player - Set (Triggering player) Food used to (((Triggering player) Food used) + 1)
          • Player - Set (Triggering player) Food used to (((Triggering player) Food used) - 1)
          • Custom script: call DestroyForce(udg_allies)
          • Set allies = (All allies of Player 1 (Red))
          • Set int = (Integer((300.00 / (Real((Number of players in allies))))))
          • Player - Set Player 1 (Red) Food max to int
          • Player - Set Player 1 (Red) Food used to ((Player 1 (Red) Food used) + 1)
          • Player - Set Player 1 (Red) Food used to ((Player 1 (Red) Food used) - 1)
          • Custom script: call DestroyForce(udg_allies)
          • Set PlayerAllies[(Player number of (Triggering player))] = (PlayerAllies[(Player number of (Triggering player))] - 1)
          • Wait 0.01 seconds
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 2 to (String(PlayerAllies[1]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 3 to (String(PlayerAllies[2]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 4 to (String(PlayerAllies[3]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 5 to (String(PlayerAllies[4]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 6 to (String(PlayerAllies[5]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 7 to (String(PlayerAllies[6]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 8 to (String(PlayerAllies[7]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 9 to (String(PlayerAllies[8]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 10 to (String(PlayerAllies[9]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 11 to (String(PlayerAllies[10]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 12 to (String(PlayerAllies[11]))
          • Multiboard - Set the text for (Last created multiboard) item in column 3, row 13 to (String(PlayerAllies[12]))
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) slot status) Equal to (==) Has left the game
        • Then - Actions
          • Wait 0.01 seconds
          • Multiboard - Hide (Last created multiboard)
          • Multiboard - Show MultiBoard
        • Else - Actions
          • Do nothing
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) slot status) Equal to (==) Is unused
        • Then - Actions
          • Wait 0.01 seconds
          • Multiboard - Hide (Last created multiboard)
          • Multiboard - Show MultiBoard
        • Else - Actions
          • Do nothing
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
Seems I find out the problem - it is in the player group itself.

This line:
  • Set allies = (All allies of (Triggering player))
picks all players who consider Triggering player to be his ally...
However we have this situation:
I write -ally blue, so trigger sets allies = all allies of me (player 1 red)... while I consider player 2 blue to by my friend, player 2 blue still considers me an enemy, which is why he will not be picked into "allies" player group :D

To fix this, change every line where you pick allies of (triggering player), to this:
  • Set allies = (All players matching (((Triggering player) is an ally of (Matching player)) Equal to True))
In your -unally triggers, change the line where you picked allies of specific player (like allies = all allies of Player 1 (red) ) to this line:
  • Set allies = (All players matching ((Player 3 (Teal) is an ally of (Matching player)) Equal to True))
Change Player 3 (Teal) to the player you unallied with.


------------
An offtopic note:
Is it necessary to wait 0,01 second before changing the multiboard? Wait 0,01 is not accurate and can range from 0,1 to 0,3 seconds - that time is further prolonged by player's ping.
 
Level 18
Joined
Jan 12, 2011
Messages
1,513
Seems I find out the problem - it is in the player group itself.

This line:
  • Set allies = (All allies of (Triggering player))
picks all players who consider Triggering player to be his ally...
However we have this situation:
I write -ally blue, so trigger sets allies = all allies of me (player 1 red)... while I consider player 2 blue to by my friend, player 2 blue still considers me an enemy, which is why he will not be picked into "allies" player group :D

To fix this, change every line where you pick allies of (triggering player), to this:
  • Set allies = (All players matching (((Triggering player) is an ally of (Matching player)) Equal to True))
In your -unally triggers, change the line where you picked allies of specific player (like allies = all allies of Player 1 (red) ) to this line:
  • Set allies = (All players matching ((Player 3 (Teal) is an ally of (Matching player)) Equal to True))
Change Player 3 (Teal) to the player you unallied with.


------------
An offtopic note:
Is it necessary to wait 0,01 second before changing the multiboard? Wait 0,01 is not accurate and can range from 0,1 to 0,3 seconds - that time is further prolonged by player's ping.



i just remove wait 0.01?
 
Status
Not open for further replies.
Top