• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How do I check if Player Red is the only Human player to run Actions?

Level 4
Joined
Dec 23, 2023
Messages
47
TLTR: What condition checks if there is only 1 human player.

Hello,
I am new to Triggers and try to get better. I am currently creating a Hero Defence Map, and I want to create Cheats I can use, for testing my Map. Furthermore, I want to make it, that the Cheats get disabled, when there are more than 1 Human player.

I am sure, I need to check this with a Condition, but I can't find a condition, that checks if there is only 1 human.
I hope someone can help me.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
Hello, I think these two triggers should get the job done:

This trigger fires a singleplayer-only cheat code that will give Player 1 a lot of Gold/Lumber:
  • Detect Singleplayer
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Custom script: call Cheat("greedisgood 99999")
      • Wait 0.20 game-time seconds
      • Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) Current gold) Greater than or equal to 99000
              • ((Picked player) Current lumber) Greater than or equal to 99000
            • Then - Actions
              • Set VariableSet Is_Singleplayer = True
            • Else - Actions
      • Trigger - Run Handle Singleplayer <gen> (checking conditions)
Then after a short Wait - to give it time to go through, it checks to see if any Users have a lot of resources. If one does, we know that the cheat was successful and since cheats can only be used in singleplayer then we know that it must be singleplayer.

Lastly, this trigger runs and checks the state of our Is_Singleplayer boolean. If it is True, you can proceed to setting up everything necessary for cheats/debugging:
  • Handle Singleplayer
    • Events
    • Conditions
      • Is_Singleplayer Equal to True
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: Singleplayer cheats enabled!
      • Unit - Create 1 Paladin for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Archmage for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Mountain King for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create 1 Blood Mage for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Is_Singleplayer is a Boolean variable. You can use it throughout your triggers to control what should happen differently when it's Singleplayer or Multiplayer.

Note that this means that you need to control the order of Events in your map in an intelligent way. Avoid using the Elapsed Game Time and Periodic Interval event whenever possible and instead always rely on Timer variables since you can choose WHEN and IF they Start.
 

Attachments

  • Singleplayer Detection 1.w3m
    17.6 KB · Views: 0
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
oh damm i didn't expect it would be so difficult... But really thanks for this. I found a workaround now, but I download what you send me, maybe that'll come in handy for another case.
It's not difficult, but I suppose that depends on how familiar you are with the World Editor. You really only need the first trigger which takes about a minute to make. Remember to use Search For Text when looking for an Action and look under the correct categories for the Conditions/Functions. The Trigger Editor organizes everything in alphabetical order and you can see which category something falls under by looking at the Prefix in it's name.

You can also copy the trigger from my map, open your map, and paste it. The editor will remember what you've copied when switching between different maps - just don't close the editor.
 
Level 4
Joined
Dec 23, 2023
Messages
47
It's not difficult, but I suppose that depends on how familiar you are with the World Editor.
I used it much as a kid, but when it comes to trigger I am wuiet new, and Variables are something I never used. So it is difficult to me. I just tsartet to learn more complex stuff.
 
There is
  • Custom Script - if bj_isSinglePlayer == true then
  • Action - Put action here
  • Custom Script - endif
iirc.

EDIT:

  • Events
    • Time - Elapsed game time is 1.00 seconds
  • Conditions
  • Actions
    • Custom script: if bj_isSinglePlayer then
    • Player Group - Pick every player in (All Players) and do (Actions)
      • Loop - Actions
        • Set Variable,Set Temp_Player = (Picked Player)
        • Trigger - Add to TestVision the event (Temp_Player types a chat message containing -vision as An exact match)
        • Trigger - Add to TestLevel the event (Temp_Player types a chat message containing -lvl as An exact match)
        • Trigger - Add to TestRestore the event (Temp_Player types a chat message containing -heal as An exact match)
        • Trigger - Add to TestMoney the event (Temp_Player types a chat message containing -kaya as An exact match)
        • Trigger - Add to Developer Mode the event (Temp_Player types a chat message containing daffa here as An exact match)
        • Trigger - Add to Kill Hero the event (Temp_Player types a chat message containing kill as An exact match)
    • Custom script: endif
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
There is
  • Custom Script - if bj_isSinglePlayer == true then
  • Action - Put action here
  • Custom Script - endif
iirc.

EDIT:

  • Events
    • Time - Elapsed game time is 1.00 seconds
  • Conditions
  • Actions
    • Custom script: if bj_isSinglePlayer then
    • Player Group - Pick every player in (All Players) and do (Actions)
      • Loop - Actions
        • Set Variable,Set Temp_Player = (Picked Player)
        • Trigger - Add to TestVision the event (Temp_Player types a chat message containing -vision as An exact match)
        • Trigger - Add to TestLevel the event (Temp_Player types a chat message containing -lvl as An exact match)
        • Trigger - Add to TestRestore the event (Temp_Player types a chat message containing -heal as An exact match)
        • Trigger - Add to TestMoney the event (Temp_Player types a chat message containing -kaya as An exact match)
        • Trigger - Add to Developer Mode the event (Temp_Player types a chat message containing daffa here as An exact match)
        • Trigger - Add to Kill Hero the event (Temp_Player types a chat message containing kill as An exact match)
    • Custom script: endif
Note that bj_isSingleplayer is true as long as there was only one User playing at the start of the game. It doesn't care if you're online, offline, LAN, etc. I imagine it doesn't actually matter for OP and he'd probably prefer your solution, but if you have a Save & Load system then you're going to want to use something more reliable like I suggested.
 
Level 4
Joined
Dec 23, 2023
Messages
47
yeah its my first Map were I don't depend on the Basic Melee Triggers. The Map is mostly for 2 friends and me.
My biggest Problem is, that I find Overviews like the one from Daffa, but can't find wich trigger it is exactly. Even with the Text search.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
yeah its my first Map were I don't depend on the Basic Melee Triggers. The Map is mostly for 2 friends and me.
My biggest Problem is, that I find Overviews like the one from Daffa, but can't find wich trigger it is exactly. Even with the Text search.
You're talking about finding the Events, Conditions, and Actions - not the Trigger itself.

A Trigger is a container of those things which you already know how to create.

Then inside of the Events/Conditions/Actions you will find Presets/Variables/Functions which allow you to do all sorts of cool things. Most of the time you'll be using a Function since that's where most of the logic is found.

In the case of an Action like Custom Script it's even more simple since it goes straight to setting a value.

This might sound confusing but you can see the terms I'm mentioning labeled throughout the Trigger Editor. Here's a simple breakdown.

Create a Trigger:
1703452622939.png

Add an Action to the Trigger:
1703452691656.png

Edit the Action to have the value you want:
1703452748258.png

Click OK and you're finished:
  • Actions
    • Custom script: if bj_isSinglePlayer then
Try to understand these terms better and use the hints and tips that the Trigger Editor provides. Plus check out tutorials like the one linked in my signature.

Also, try different combinations of words with Search For Text. Usually searching for one word is enough. Be careful because if you add an extra letter or too many words it can fail to work - the Search For Text is very specific.
 
Last edited:
Top