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

[Trigger] Round System

Status
Not open for further replies.
Level 6
Joined
Aug 1, 2009
Messages
159
Hi, I learned how to make nova spells from watermelon_1234, and tml616, thank you very much.

Now, I need someone to explain to me how to make Round Systems and how they work. Like in Warlock (if you don't know what map is this you don't need to know). at the start of the game. The host via Player 1 sets the rounds needed to win.

e.g
-r "x" (without quotes [""].)

the X is the value or the rounds set by red, can someone show me an example trigger here?

Greets,
X3n0nX
 
Level 9
Joined
Oct 11, 2009
Messages
477
By the way, you can do the trigger by yourself. All you need to do is to compare the dialog/text command or value what method you used to an integer one and set and equality between the two, next is to create a timer for the next round to begin, as the round passes, increase an integer, if the increasing integer's value is now equal to the round specified which is the first integer, end the game or add any actions you want before the game ends.

Got it? I hope it helps!!!:grin:
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
It would look something like this. There's a debug message there to show that it works (and it does).

  • SelectRounds
    • Events
      • Player - Player 1 (Red) types a chat message containing -r as A substring
      • Player - Player 2 (Blue) types a chat message containing -r as A substring
      • Player - Player 3 (Teal) types a chat message containing -r as A substring
      • Player - Player 4 (Purple) types a chat message containing -r as A substring
      • Player - Player 5 (Yellow) types a chat message containing -r as A substring
      • Player - Player 6 (Orange) types a chat message containing -r as A substring
      • Player - Player 7 (Green) types a chat message containing -r as A substring
      • Player - Player 8 (Pink) types a chat message containing -r as A substring
      • Player - Player 9 (Gray) types a chat message containing -r as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -r as A substring
      • Player - Player 11 (Dark Green) types a chat message containing -r as A substring
      • Player - Player 12 (Brown) types a chat message containing -r as A substring
    • Conditions
    • Actions
      • Set Command = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (String((Substring(Command, 1, 3))) as Lower case) Equal to -r
        • Then - Actions
          • Set Rounds = (Integer((Substring(Command, 4, (Length of Command)))))
        • Else - Actions
      • Game - Display to (All players) the text: (# User has selected + ((String(Rounds)) + rounds.))
 
Level 6
Joined
Aug 1, 2009
Messages
159
Thank you very much, +rep after I go home, will try to make them.

How can I set this to the host? for example, blue is host, I just followed the tutorial that ragingspeedhorn provide me, how can I set this to only him can set the rounds?
 
If you have JASS NewGen pack, use [Snippet] GetHost 2.0 (requires [Snippet] Event)

If you use the normal WE, I think this is the function you are looking for (however, it is not always accurate because sometimes the host lags more than the other players, eg: when alt-tabbing): GetHost.

First, copy and paste this (assuming you are using the normal world editor) into your header (the header is found by opening the trigger editor and clicking on your map name, it should say Custom Script Code somewhere):
JASS:
function Host_GameCache takes nothing returns gamecache
    return udg_HostGameCache
endfunction
//This function takes nothing and returns the host of the game.
function GetHost takes nothing returns player
    //This stores the Id + 1 for each player.
    call StoreInteger(Host_GameCache(), "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1)
    //Setup the TriggerSyncReady call.
    call TriggerSyncStart()
    //Sync the value of the entry for each player.
    //Each value will sync to the value of the host.
    call SyncStoredInteger(Host_GameCache(), "missionKey", "key")
    //Wait until the Game Cache syncs the key for everyone.
    call TriggerSyncReady()
    //Return the synced value as a player.
    return Player(GetStoredInteger(Host_GameCache(), "missionKey", "key") - 1)
endfunction

Press CTRL+B to open the variables editor, and create a gamecache variable named HostGameCache. Now create a player variable named HostIndex. Then use this:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game Cache - Create a game cache from InsertYourMapName.w3v
      • Set HostGameCache = (Last created game cache)
      • Custom script: set udg_HostIndex = GetPlayerId(GetHost())+1
  • Rounds
    • Events
      • Player - (Player(HostIndex)) types a chat message containing -r as A substring
    • Conditions
    • Actions
      • Set Command = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (String((Substring(Command, 1, 3))) as Lower case) Equal to -r
        • Then - Actions
          • Set Rounds = (Integer((Substring(Command, 4, (Length of Command)))))
        • Else - Actions
      • Game - Display to (All players) the text: (# User has selected + ((String(Rounds)) + rounds.))
I dunno why it doesn't let me use a player variable directly into the event. It is weird. But anyway, that is probably something like what you are looking for. It is untested, though. (But the host detection was tested a lot, it works most of the time)
 
Level 6
Joined
Aug 1, 2009
Messages
159
Thank you, but I cant do the (Player(HostIndex)) part the (Player(1) is conversion part, but the HostIndex I cant find it.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
HostIndex refers to an integer variable that is defined in PurgeandFire111's "Init" trigger. It points to the index of the player that is returned from the GetHost() function that he posted above.
 
Level 6
Joined
Aug 1, 2009
Messages
159
How can I set the Conversion - Convert Player Index to player part? Since I cant see an HostIndex variable.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
That's because you have to make it yourself. Please, read this post.

PurgeandFire111 said:
Press CTRL+B to open the variables editor, and create a gamecache variable named HostGameCache. Now create a player variable named HostIndex.

Though he does say it's a Player variable here (even though it's an integer) it is still mentioned in ample detail. Did you even read what he had to say or did you just look at the pictures?

PurgeandFire111 said:
I dunno why it doesn't let me use a player variable directly into the event.

And then he clarifies that you can't use the player variable, and that you need to use an integer index.

Nothing I hate more than people who don't even thoroughly read the posts to their own threads.
 
Level 6
Joined
Aug 1, 2009
Messages
159
Yes, I didn't just take a look at the pictures. What I mean is I cant set the HostIndex variable, I tried setting it to Player Variable it doesn't, and I tried setting it to an Integer it doesn't. I'm just going to give an screenshot.

This time it was set to a Integer Type Variable via HostIndex variable. Function is Conversion - Convert Player Index To Player. I also did tried setting it to a Player Variable, same results.

Picture:

Sorry I don't know how to attach pictures.
51px7l.jpg
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Notice how he's using custom script. The reason you can't use the GUI to set the variable is because custom script functions are not programmed in.

Oh, on the event...

So, you'd want to do this:

  • Example
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Trigger - Add to Example <gen> the event (Player - (Player(HostIndex)) types a chat message containing -r as A substring)
Sorry, I don't really use GUI at all.
 
Status
Not open for further replies.
Top