-Roll Trigger

HitmanYesman

New Member
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!

You're living only because it's illegal killing.
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

~Choco Coronet~ Omnomnom
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 &lt;gen&gt; (ignoring conditions)
• Trigger - Run Roll P2 &lt;gen&gt; (ignoring conditions)
• Trigger - Turn off Roll P1 &lt;gen&gt;
• Trigger - Turn off Roll P2 &lt;gen&gt;

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)

You're living only because it's illegal killing.
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.

HitmanYesman

New Member
I don't understand hashtables really

Rushhour

New Member
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.
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?'

You're living only because it's illegal killing.
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.

~Choco Coronet~ Omnomnom
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:
Happy Saturday!!!
+1
• The Helper:
I reorganized the forums somewhat but I doubt anyone would notice
• The Helper:
Happy Friday!
+1
• The Helper:
Happy Saturday!
+1
• The Helper:
The forum software says we have 554 members online now. We did not have that many unique visitors the whole day today. Too many bots and the disconnect between the forum counts and the stats.
• Varine:
Currently it says 413 guests and 2 members
+1
• Varine:
Aww
• The Helper:
That is going to be mostly bots
• The Helper:
527 (members: 2, guests: 525)
• The Helper:
Happy Saturday!
+1
• V-SNES:
Happy Saturday!
+1
• The Helper:
622 (members: 2, guests: 620)
• The Helper:
666 (members: 4, guests: 662)
+1
• Varine:
609 (members: 4, guests: 605)
• The Helper:
I was posting that last one because the 666 users online
+1
• The Helper:
Happy Wednesday Night!
+1
• The Helper:
Happy Thursday!
+1
• The Helper:
Marathon watching The Expanse!
+1
• V-SNES:
Happy Friday!
+1
• The Helper:
leaving for the weekend in San Antonio will be gone until Sunday afternoon
+1
• The Helper:
and I am back
+1