-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.
  • jonas jonas:
    That sounds like fun!
    +1
  • The Helper The Helper:
    it was a blast!
  • The Helper The Helper:
    I am going to post the Youtube of the investigation in the forums when it is ready
    +1
  • jonas jonas:
    cool!
  • vypur85 vypur85:
    Sounds cool TH.
  • tom_mai78101 tom_mai78101:
    I was on a Legend of Zelda marathon...
  • tom_mai78101 tom_mai78101:
    Am still doing it now
    +1
  • jonas jonas:
    which one(s) are you playing?
  • jonas jonas:
    I played a little bit of the switch title two weeks ago and found it quite boring
  • The Helper The Helper:
    just got back from San Antonio this weekend had the best Buffalo Chicken Cheesesteak sandwhich in Universal City, TX - place was called Yous Guys freaking awesome! Hope everyone had a fantastic weekend!
    +1
  • The Helper The Helper:
    Happy Tuesday!
  • The Helper The Helper:
    We have been getting crazy numbers reported by the forum of people online the bots are going crazy on us I think it is AI training bots going at it at least that is what it looks like to me.
  • The Helper The Helper:
    Most legit traffic is tracked on multiple Analytics and we have Cloud Flare setup to block a ton of stuff but still there is large amount of bots that seem to escape detection and show up in the user list of the forum. I have been watching this bullshit for a year and still cannot figure it out it is drving me crazy lol.
    +1
  • Ghan Ghan:
    Beep boop
    +1
  • The Helper The Helper:
    hears robot sounds while 250 bots are on the forum lol
  • The Helper The Helper:
    Happy Saturday!
    +1
  • The Helper The Helper:
    and then it was Thursday...
    +2
  • tom_mai78101 tom_mai78101:
    And then Monday
    +1
  • The Helper The Helper:
    I got the day off today!
    +1
  • tom_mai78101 tom_mai78101:
    How...? (T-T)
  • The Helper The Helper:
    I took the day off. I work for myself so I can do that.
    +1
  • Varine Varine:
    Well I'm already over summer
  • jonas jonas:
    varine! good to see you
  • jonas jonas:
    what's going on, what's got you going
  • The Helper The Helper:
    good to see you varine hope you are well my friend

    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