-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.
  • Varine Varine:
    I have a bunch of community service I have to do, and I have a feeling there will be a lot of snow shoveling involved now
  • The Helper The Helper:
    don't know why people choose to live in that kind of weather :)
  • Varine Varine:
    Well
  • Varine Varine:
    My job is here
  • Varine Varine:
    I was born here man I didn't choose shit
  • Varine Varine:
    And also, I keep moving away and it doesn't get any better. I moved to San Antonio and shit froze there AND we had blackouts
  • tom_mai78101 tom_mai78101:
    I'm back, suffering from severe jet lag.
  • The Helper The Helper:
    Cold is following your ass around Varine - I just dont think I could handle a snowy winter.
  • The Helper The Helper:
    Welcome Back Tom!
  • The Helper The Helper:
    I hear that taking a Melatonin around your normal bedtime can really fix jet lag
  • tom_mai78101 tom_mai78101:
    Yeah, I also heard about that as well. I think I'm good. I'm just lucky it's the weekend so I have some time to readjust.
    +1
  • Varine Varine:
    It was a fucking blizzard today, shoveling was an effort in futility.
  • Varine Varine:
    Melatonin gives me nightmares
  • Varine Varine:
    They had me shoveling out the parking lot for the jail. Fucking pointless, they need a blow.
  • Varine Varine:
    Well they gave me a snow blower but it was too wet to do much with with other than compact everything. Oh well, the cop cars can get into there now when they arrest people I guess
    +1
  • The Helper The Helper:
    I shit you not we are Number one on Google for Banana Bread Recipe
  • jonas jonas:
    xD
    +1
  • The Helper The Helper:
    Need Web Design Contractor that knows Word Press, Woocommerce and Elementor to help with the company that sponsors this site
  • The Helper The Helper:
  • The Helper The Helper:
    I am going to be AFK most of this weekend has I have a friend coming into town for his company christmas party and I am going to be busy with that this weekend.
    +1
  • The Helper The Helper:
    541 Active Users and this number has been pretty steady give or take some. The bots are hammering us.
  • The Helper The Helper:
    I have been posting a bunch of recipes and Google is loving them. I mean OK my shit is good but how does google know LOL!

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top