• 🏆 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!

Need help with a trigger

Status
Not open for further replies.
Level 1
Joined
Feb 28, 2016
Messages
3
In my map it's possible to ally a player and also to give gold to him via a custom command. But i want to make a limitation, if a player recieves more than 150 gold from his ally, he can't make another ally afterwards (after his original ally died, left or he wared him). I've tried to make a variable that tracks the gold recieved and then put it's value limit into the allying trigger, but it doesnn't work for some reason. Could anyone tell me what's wrong, or how can i do such a limitation? I'm also not too good with trigger, so might not understand something. My triggers:

Ally trigger:
  • Actual Trigger
    • Events
    • Conditions
      • hasGiveBase[(Player number of (Triggering player))] Equal to False
      • GoldRecieved Less than 150
    • Actions
      • Set playergroups[0] = (All players matching (((Matching player) slot status) Equal to Is playing))
      • Set playergroups[1] = (All players matching (((Triggering player) is an ally of (Matching player)) Equal to True))
      • Set playergroups[2] = (All players matching ((((Matching player) is in playergroups[0]) Equal to True) and (((Matching player) is in playergroups[1]) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in playergroups[2]) Less than alliancesize
        • Then - Actions
          • For each (Integer A) from 1 to 12, do (Actions)
            • Loop - Actions
              • Set playergroups[1] = (All allies of (Player((Integer A))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Substring((Entered chat string), 7, (Length of (Entered chat string)))) Equal to AllyStringColor[(Integer A)]
                • Then - Actions
                  • Player - Make (Triggering player) treat (Player((Integer A))) as an Ally with shared vision
                  • Custom script: call MMD_UpdateValueInt("ally", ConvertedPlayer(GetForLoopIndexA()), MMD_OP_SET, 1)
                • Else - Actions
              • Custom script: call DestroyForce( udg_playergroups[1] )
        • Else - Actions
          • Set playergroups[3] = (Player group((Triggering player)))
          • Game - Display to playergroups[3] the text: You already have al...
          • Custom script: call DestroyForce( udg_playergroups[3] )
      • Custom script: call DestroyForce( udg_playergroups[0] )
      • Custom script: call DestroyForce( udg_playergroups[1] )
      • Custom script: call DestroyForce( udg_playergroups[2] )
Gold giving trigger:
  • give gold
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Substring((Entered chat string), 2, ((Length of AllyStringColor[(Integer A)]) + 1))) Equal to AllyStringColor[(Integer A)]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer((Substring((Entered chat string), ((Length of AllyStringColor[(Integer A)]) + 2), (Length of (Entered chat string)))))) Less than or equal to ((Triggering player) Current gold)
                  • (Integer((Substring((Entered chat string), ((Length of AllyStringColor[(Integer A)]) + 2), (Length of (Entered chat string)))))) Greater than 0
                  • alliancesize Not equal to 0
                  • ((Player((Integer A))) is an ally of (Triggering player)) Equal to True
                  • ((Triggering player) is an ally of (Player((Integer A)))) Equal to True
                • Then - Actions
                  • Player - Add (Integer((Substring((Entered chat string), (2 + (Length of AllyStringColor[(Integer A)])), (Length of (Entered chat string)))))) to (Player((Integer A))) Current gold
                  • Player - Add ((Integer((Substring((Entered chat string), ((Length of AllyStringColor[(Integer A)]) + 2), (Length of (Entered chat string)))))) x -1) to (Triggering player) Current gold
                  • Player Group - Pick every player in (All allies of (Triggering player)) and do (Actions)
                    • Loop - Actions
                      • Set GoldRecieved = (GoldRecieved + ((Integer((Substring((Entered chat string), ((Length of AllyStringColor[(Integer A)]) + 2), (Length of (Entered chat string)))))) x -1))
                • Else - Actions
            • Else - Actions
 
Last edited by a moderator:
Level 14
Joined
Jul 1, 2008
Messages
1,314
Looks quite confusing to me, I dont really understand why you are setting these playergroups. Plus, what is "aliancesize" ?

But most important, do these triggers have events at all? Are they called by another trigger?
 
Level 1
Joined
Feb 28, 2016
Messages
3
Looks quite confusing to me, I dont really understand why you are setting these playergroups. Plus, what is "aliancesize" ?

But most important, do these triggers have events at all? Are they called by another trigger?

They do have events, but they're set up and called in other triggers. The ally system works perfectly. What doesn't work is this limitation, that i'm trying to add:

The condition for re-allying:

  • GoldRecieved Less than 150
Trying to track the gold given:

  • Player Group - Pick every player in (All allies of (Triggering player)) and do (Actions)
    • Loop - Actions
      • Set GoldRecieved = (GoldRecieved + ((Integer((Substring((Entered chat string), ((Length of AllyStringColor[(Integer A)]) + 2), (Length of (Entered chat string)))))) x -1))
Going to try and change the last part of setting the variable. Changing "-1" to "1".

I'm gonna try and simplify this. Is this possible for a variable to save up the additive value of recieved gold (gold is given with a chat command like "-red 100"). And when that value reaches, let's say 150 gold, limiting the ability of a player to ally?
 
Last edited by a moderator:
Level 14
Joined
Jul 1, 2008
Messages
1,314
I'm gonna try and simplify this. Is this possible for a variable to save up the additive value of recieved gold (gold is given with a chat command like "-red 100"). And when that value reaches, let's say 150 gold, limiting the ability of a player to ally?

actually you got the right Idea, but I think you write code in a very confusing manner (sry this is not meant to be rude).

Is it possible to ally more than one player? If it is not possible I would avoid these group things and just use a single player variable per player, so your code gets much more cleaner.

For the limit: I would just make an integer array, where you got one array "slot" for each player, and use it instead this variable "GoldReceived". From the code, you posted, it seems like this variable gets overwritten each time another player is handled.

Its kind of hard to judge without knowing the other triggers that are involved and your events so thats all I can say.

I would say, this

  • Set GoldRecieved = (GoldRecieved + ((Integer((Substring((Entered chat string), ((Length of AllyStringColor[(Integer A)]) + 2), (Length of (Entered chat string)))))) x -1))
could return a wrong value (apart from that it only works for one player as said above). please check for the amount that you get out of this by debug messages (just make a game message where you convert integer to string)

I strongly suggest to use debug-messages as they help very much.
 
Level 1
Joined
Feb 28, 2016
Messages
3
Well, these triggers were made by a previous editor, and they wll work fine, so i didnt really have a good enough reason to change them, cos i could mess something up.
Hm, i'm gonna look up how debug messages work and then try to test the numbers.

Actually this is what i was looking for. Didnt know how to make it separate for each players. Thanks a lot.
For the limit: I would just make an integer array, where you got one array "slot" for each player, and use it instead this variable "GoldReceived". From the code, you posted, it seems like this variable gets overwritten each time another player is handled.

Players already started complaining that it works for all of the players, no matter if they gave gold or not, and they can't ally anyone :goblin_cry:
 
Status
Not open for further replies.
Top