Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
illyism
Wanderer


Joined: 09 Dec 2007
Posts: 58

PostPosted: Wed Apr 23, 2008 4:09 pm   

a dice game
 
This is a small and easy script I made.
this only supports one contender.
usage: host may type INTROBET, to introduce the dice system.
contender has to call a number.(trigger (Illyism calls 5))
contender has to give you gold after calling a number.(smiles and hands you (%w) gold coins.) (made for (firstage.net:23) you can adjust it to your own game.)
host has to type BETSIN.

wordtonumber script is needed.
Code:
#CLASS {wordtonum}
#VAR Ones {one|two|three|four|five|six|seven|eight|nine}
#VAR Tens {twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety}
#VAR WordToNum {%case( %numwords( %replace( "%1", "-", " ")), %case( %ismember( "%1", "one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety"), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90), %eval( %case( %ismember( %word( %replace( "%1", "-", " "), 1), @tens), 20, 30, 40, 50, 60, 70, 80, 90) + %case( %ismember( %word( %replace( "%1", "-", " "), 2), @ones), 1, 2, 3, 4, 5, 6, 7, 8, 9)), %eval( %if( %pos( "thousand", "%1"), %case( %ismember( %word( %replace( "%1", "-", " "), 1), @ones), 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000), %case( %ismember( %word( %replace( "%1", "-", " "), 1), @ones), 100, 200, 300, 400, 500, 600, 700, 800, 900)) + %case( %ismember( %word( %replace( "%1", "-", " "), 3), "one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety"), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90)), %eval( %if( %pos( "thousand", "%1"), %case( %ismember( %word( %replace( "%1", "-", " "), 1), @ones), 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000), %case( %ismember( %word( %replace( "%1", "-", " "), 1), @ones), 100, 200, 300, 400, 500, 600, 700, 800, 900)) + %case( %ismember( %word( %replace( "%1", "-", " "), 3), @tens), 20, 30, 40, 50, 60, 70, 80, 90) + %case( %ismember( %word( %replace( "%1", "-", " "), 4), @ones), 1, 2, 3, 4, 5, 6, 7, 8, 9)), %eval( %case( %ismember( %word( %replace( "%1", "-", " "), 1), @ones), 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000) + %case( %ismember( %word( %replace( "%1", "-", " "), 3), @ones), 100, 200, 300, 400, 500, 600, 700, 800, 900) + %case( %ismember( %word( %replace( "%1", "-", " "), 5), "one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety"), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90)), %eval( %case( %ismember( %word( %replace( "%1", "-", " "), 1), @ones), 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000) + %case( %ismember( %word( %replace( "%1", "-", " "), 3), @ones), 100, 200, 300, 400, 500, 600, 700, 800, 900) + %case( %ismember( %word( %replace( "%1", "-", " "), 5), @tens), 20, 30, 40, 50, 60, 70, 80, 90) + %case( %ismember( %word( %replace( "%1", "-", " "), 6), "one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety"), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90)))}
#CLASS 0


Code:
#CLASS {calculators|dicegame}
#ALIAS betsin {em screams, ~"bets in! ROLL IT!"~ across the room.}
#ALIAS introbet {say @quote1, holding a true ruby cut dice between finger and thumb, showing it to you. ~"@quote2"~, he continues smartly. ~"~Then just give me the gold you're paying and I'll roll the dice.}
#VAR conts {Black}
#VAR contscalls {4}
#VAR contspays {0}
#VAR diceget {4}
#VAR contspaid {0}
#VAR payment {0}
#VAR answerwin {say congratulations! you just won @payment gold!|say wow! you actually won something, @payment gold!|say not bad! @payment gold in your pocket!|say whoa! you make me really poor, now I don't have @payment gold!|say I lost @payment gold, oh my god!|say you won @payment gold, big wow...|say meh, it's just @payment gold less for me.|say I don't care about that @payment gold.|say feel free, enjoy my @payment gold.|say stop drooling on my foot, and put your @payment gold in your pocket.|say You're @payment gold higher.|say holy Wraith! I lost @payment gold!|say I should stop losing, How can I buy bread without that @payment gold.|say buy a palace with your @payment gold.|say enjoy your @payment gold, please.}
#VAR answerlose {say Sorry, no refunds|say excuse me, I'm going to spend that @contpays gold now.|em puts his @contpays gold in his pocket, grinning at you.|say host wins @contpays gold.|say you just lost @contpays gold, try again.|say you lose @contpays gold! muahahaha!|say that @contpays gold is mine, sucker|say my @contpays gold, finally!|say I got @contpays gold, and you fucking don't!|say take your hands off my @contpays gold! thief!|say where is the nearest tavern?|say sorry, you lost, would you like to play again for your @contpays gold coins?|em's eyes go ~"KA-CHING"~, when he sees the @contpays gold.|say losers always lose, and cheaters always win... I didn't say that.|say I said, NO REFUNDS.}
#VAR quote1 {who wants to play dice with me?"}
#VAR quote2 {"just SAY your NAME CALLS and the NUMBER you think will roll on the dice, it varies from 1 to 6."}
#TRIGGER {(%w) calls (%d)} {
  #class calculators|dicegame
  #var conts %1
  #var contscalls %2
  #var contspays 0
  #var contspaid 0
  #if (@contscalls>6) {
    sa can't go above 6 in a dice, fool
    #var contspays 0
    }
  #if (@contscalls<1) {
    sa can't go below 1 in a dice, fool!
    #var contspays 0
    }
  #var contspays %3
  #class 0
  }
#TRIGGER {bets in! ROLL IT!} {
  #class calculators|dicegame
  #var diceget ""
  emote throws a dice to the floor
  #alarm (+1) {
    #var diceget %dice( 1d6)
    say and it's @diceget people!
    #if (@contscalls=@diceget) {
      #math payment @contspays*6
      seo
      get @payment gold from pack
      sef
      give @payment coins to @conts
      %item( @answerwin, %random( 1, 15))
      #var contspaid 0
      }
    #if (@contscalls!=@diceget) {%item( @answerlose, %random( 1, 15))}
    }
  #class 0
  }
#TRIGGER {smiles and hands you (%w) gold coins.} {
  #class calculators|dicegame
  #var contspaid 1
  #var contspays @wordtonum(%1)
  #class 0
  }
#TRIGGER {Let's roll!} {betsin}
#CLASS 0
Reply with quote
groundzero2010
Novice


Joined: 30 Sep 2004
Posts: 47
Location: Arkansas

PostPosted: Wed Oct 15, 2008 4:06 pm   
 
I like the idea of this script. I changed a bit of it to work in my situation.

What I'd like to do is set this up so another player could come up to your character (the char with the script) and start playing without you even being there.

For this, you'd want to check and make sure they are actually paying you and not just switching your triggers.

I did a check and set a variable for my gold on hand from my prompt. @gold
Although I can't find a way to take the money they bet and add it to @gold to make @betgold (which is the gold you had before plus the gold that was bet)
Then you'd want to check the amount of @contspays (bet amount) + @gold (gold on hand before bet) to equal @betgold before it runs the rest of the game.
If this comes up to be negative don't run the game.
If its okay..run the game.

Also, you might want to set it up so they can't bet more than you could pay out.
Meaning...
If you have 550 gold on hand.
They bet 100.
If they win the payout would be 600, which you wouldn't have enough to pay.
So you'd want it to throw up something saying "I'm sorry, I can't afford to bet that amount of coins. Try a lower amount"

Could someone please help out with some sample code, that i may be able to do this.
I've tried and did some variable checks after the math and its not adding up correctly.

ALSO, the wordtonumber script I don't believe is working correctly on my side. What exactly is this suppose to do? I may have by-passed it to get it to work.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Oct 15, 2008 9:48 pm   
 
It's supposed to build a decimal number (ie, 100) from a numeric phrase (ie, one hundred). Some games don't use decimal numbers.
_________________
EDIT: I didn't like my old signature
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Nov 16, 2008 1:09 am   
 
Well, in RE: Your concerns about not having enough... if they bet 100 and you had 550 you would then have 650, which is enough to cover a 600 payout. But you would simply need to do:

#IF (%eval(@gold_on_hand + @bet_amnt) < calc_payout @bet_amnt) {blah blah message;#ABORT 1}

Thats of course not real code, just an example.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Zeiram20
Newbie


Joined: 08 Nov 2009
Posts: 3

PostPosted: Tue Feb 16, 2010 3:29 am   
 
hey there, ive been trying to get this game to work in Achaea. and the only real wall ive hit is that i cant get it to recognize the amount someone bets. I realize this is an old post, but im hoping a passer by may be able to spot the issue. Thanks for any input

#TRIGGER {gives (%w) gold sovereigns to you.} {
#class calculators|dicegame
#var contspaid 1
#var contspays @wordstonum(%1)
#class 0
}
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Tue Feb 16, 2010 6:54 pm   
 
Is #var contspays @wordstonum(%1) a typo here only or in your script? If you have that in your script change it to #var contspays @wordtonum(%1)
_________________
Taz :)
Reply with quote
Zeiram20
Newbie


Joined: 08 Nov 2009
Posts: 3

PostPosted: Wed Feb 17, 2010 3:04 am   
 
Taz wrote:
Is #var contspays @wordstonum(%1) a typo here only or in your script? If you have that in your script change it to #var contspays @wordtonum(%1)

it was indeed a typo in my script, but it didnt make any difference when i fixed it. Ive stared at this for hours and cant find the hole.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed Feb 17, 2010 12:58 pm   
 
Have you replaced the original gold trigger with your gold trigger and is the class calculators|dicegame enabled?
_________________
Taz :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net