Need help with chat string

Level 5
Joined
Mar 18, 2023
Messages
52
Ima start by saying I had a different one that worked. But I decided to remake most of it as I wanted to change the condition for how the item works. Now the chat string doesn't work at all. This trigger is for each player to set a value so they can use certain abilities from an item that will then reference the set value.
  • Setting DT amount
    • Events
      • Player - Player 1 (Red) types a chat message containing DT as A substring
      • Player - Player 2 (Blue) types a chat message containing DT as A substring
      • Player - Player 3 (Teal) types a chat message containing DT as A substring
      • Player - Player 4 (Purple) types a chat message containing DT as A substring
      • Player - Player 5 (Yellow) types a chat message containing DT as A substring
      • Player - Player 6 (Orange) types a chat message containing DT as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 3)) Equal to DT
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Triggering player).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has an item of type |cffd45e19Black Diamond of Eclipso|r) Equal to True
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set VariableSet DTUnit[(Player number of (Triggering player))] = (Picked unit)
            • Else - Actions
              • Set VariableSet DTUnit[(Player number of (Triggering player))] = No unit
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DTUnit[(Player number of (Triggering player))] Not equal to No unit
        • Then - Actions
          • Set VariableSet DTAmount[(Player number of (Triggering player))] = (Real((Substring((Entered chat string), 4, (Length of (Entered chat string))))))
          • Set VariableSet TempPG[0] = (All players matching ((Matching player) Equal to (Triggering player)).)
          • Game - Display to TempPG[0] for 5.00 seconds the text: (Dark Tribute Cost: |cffff0000 + ((String(DTAmount[(Player number of (Triggering player))])) + |r))
          • Custom script: call DestroyForce( udg_TempPG[0])
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Remember that this line here can happen AFTER it has found a DTUnit, resetting it back to No unit.
  • Set VariableSet DTUnit[(Player number of (Triggering player))] = No unit
The most recent setting of the variable takes priority.

With that in mind, this design should work:
  • Setting DT amount
    • Events
      • Player - Player 1 (Red) types a chat message containing DT as A substring
      • Player - Player 2 (Blue) types a chat message containing DT as A substring
      • Player - Player 3 (Teal) types a chat message containing DT as A substring
      • Player - Player 4 (Purple) types a chat message containing DT as A substring
      • Player - Player 5 (Yellow) types a chat message containing DT as A substring
      • Player - Player 6 (Orange) types a chat message containing DT as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 3)) Equal to DT
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • Set VariableSet DT_Unit[PN] = No unit
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Triggering player).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has an item of type |cffd45e19Black Diamond of Eclipso|r) Equal to True
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set VariableSet DT_Unit[PN] = (Picked unit)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DT_Unit[PN] Not equal to No unit
        • Then - Actions
          • Set VariableSet DT_Amount[PN] = (Real((Substring((Entered chat string), 4, (Length of (Entered chat string))))))
          • Game - Display to Self_PG[PN] for 5.00 seconds the text: (Dark Tribute Cost: |cffff0000 + ((String(DT_Amount[PN])) + |r))
        • Else - Actions
  • Create Self Player Groups
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set Variable PN = (Player number of (Picked player))
          • Custom script: set udg_Self_PG[udg_PN] = CreateForce()
          • Player Group - Add (Picked player) to Self_PG[PN]
^ You can avoid the annoying memory leak stuff (TempPG) by giving each Player their own personal Player Group to use the entire game.
 
Last edited:
Level 5
Joined
Mar 18, 2023
Messages
52
Remember that this line here can happen AFTER it has found a DTUnit, resetting it back to No unit.
  • Set VariableSet DTUnit[(Player number of (Triggering player))] = No unit
The most recent setting of the variable takes priority.

With that in mind, this design should work:
  • Setting DT amount
    • Events
      • Player - Player 1 (Red) types a chat message containing DT as A substring
      • Player - Player 2 (Blue) types a chat message containing DT as A substring
      • Player - Player 3 (Teal) types a chat message containing DT as A substring
      • Player - Player 4 (Purple) types a chat message containing DT as A substring
      • Player - Player 5 (Yellow) types a chat message containing DT as A substring
      • Player - Player 6 (Orange) types a chat message containing DT as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 3)) Equal to DT
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • Set VariableSet DT_Unit[PN] = No unit
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Triggering player).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has an item of type |cffd45e19Black Diamond of Eclipso|r) Equal to True
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set VariableSet DT_Unit[PN] = (Picked unit)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DT_Unit[PN] Not equal to No unit
        • Then - Actions
          • Set VariableSet DT_Amount[PN] = (Real((Substring((Entered chat string), 4, (Length of (Entered chat string))))))
          • Game - Display to Self_PG[PN] for 5.00 seconds the text: (Dark Tribute Cost: |cffff0000 + ((String(DT_Amount[PN])) + |r))
        • Else - Actions
  • Create Self Player Groups
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set Variable PN = (Player number of (Picked player))
          • Custom script: set udg_Self_PG[udg_PN] = CreateForce()
          • Player Group - Add (Picked player) to Self_PG[PN]
^ You can avoid the annoying memory leak stuff (TempPG) by giving each Player their own personal Player Group to use the entire game.
OOoooh right about the unit group part haha. Thank you Uncle! I shall test this and see how it goes :thumbs_up:
 
Top