-Roll Trigger

HitmanYesman

New Member
Reaction score
0
I'm making a simple game, turn based game, in which two units, controlled by 2 people, take turns either attacking, casting spell, or use an item. Now in order to see who goes first, I want both players to type -roll. The highest number wins, of course if they don't do it in 10 seconds it will be rolled automatically. I just don't know how to start the action part of the -roll trigger.

Any helps would be great, Thanks!
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Event
Map initialization
Condition
Action
Create hashtable
Set hashtable variable = last created hashtable
Set real variable = (number of players)
Save real variable as 1 of 1 for hashtable variable
For loop integer A 1 to (number of players)
Set integer[for loop integer A] = 0

Event
Player chat message entered was -roll as an exact match (For all your players)
Condition
Action
Set integer variable[Player number of triggering player] = random number from 1 to 100
Set real variable = Load 1 of 1 for hashtable variable
Save real variable - 1.00 as 1 of 1 for hashtable variable

(For 2 players, include more if neccessary)
Event
Real variable becomes 0.00
Condition
Action
If/then/else
If
Integer[1] is greater than Integer[2]
Then
-----Do action for player 1 to start first-----
Else
-----Do action for player 2 to start first-----


Edit:

If you want to auto roll After 10 seconds, then in between trigger 2 and 3, add this:

(For 2 players, add more if neccessary)
Event
Game time elasped is 10 seconds
Condition
Action
For loop integer A 1 to (number of players)
If/then/else
If
Integer[Integer A] = 0
Then
Set integer variable[integer A] = random number from 1 to 100
Set real variable = Load 1 of 1 for hashtable variable
Save real variable - 1.00 as 1 of 1 for hashtable variable
Else
 

Nenad

~Choco Coronet~ Omnomnom
Reaction score
137
The same answer if you can't use, or are confused by Hashtables:

Trigger:
  • Roll P1
    • Events
      • Player - Player 1 (Red) types a chat message containing -roll as An exact match
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Set Int[(Player number of (Triggering player))] = (Random integer number between 1 and 100)
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Has Rolled + (String(Int[(Player number of (Triggering player))]))))

Trigger:
  • Roll P2
    • Events
      • Player - Player 2 (Blue) types a chat message containing -roll as An exact match
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Set Int[(Player number of (Triggering player))] = (Random integer number between 1 and 100)
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Has Rolled + (String(Int[(Player number of (Triggering player))]))))

Trigger:
  • Autoroll
    • Events
      • Time - Elapsed game time is 10.00 seconds
    • Conditions
    • Actions
      • Trigger - Run Roll P1 <gen> (ignoring conditions)
      • Trigger - Run Roll P2 <gen> (ignoring conditions)
      • Trigger - Turn off Roll P1 <gen>
      • Trigger - Turn off Roll P2 <gen>


If you have multiple players it will get messier and i would advise you to use a hashtable, but this is the simplest way to -roll x)
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
But if you don't use hashtables, you won't find out whether all players have rolled already. And also, you have to compare the results.
 

Rushhour

New Member
Reaction score
46
Hashtables, multiple triggers? Why ?
Just create one global boolean array variable. When the player rolled set it to false, and before the trigger does its actions check if the specific boolean is true.
Index all arrays with the playernumber.
 

Joccaren

You can change this now in User CP.
Reaction score
54
But if you don't use hashtables, you won't find out whether all players have rolled already. And also, you have to compare the results.

So incredibly false. As has been said, a simple global boolean array can check if a player has rolled or not. And two simple global Integer arrays can save what they rolled. From there, its basically a matter of 'Which integer is larger?'
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Well what I meant was, the solution that he gave didn't have hashtables and couldn't check if all the players have rolled, so without hesitating i used hashtables instead. Didn't consider any other points. So actually what I meant was, you had to use something boolean, hashtable, or whatever, just that at that moment the boolean idea didn't came to me. :eek:
 

Nenad

~Choco Coronet~ Omnomnom
Reaction score
137
My mistake, i forgot to add the check for if the player had rolled or not, but i assumed that Comparing Int[Player Number] values was an easy method of discerning who rolled the highest xD
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top