Login
User Name:

Password:



Register

Forgot your password?
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
SWRFUSS 1.4
Author: Various
Submitted by: Samson
Users Online
AhrefsBot, Bing

Members: 0
Guests: 39
Stats
Files
Topics
Posts
Members
Newest Member
488
3,789
19,632
596
Elwood

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » General » Building » Roomprog for random dice roll
Forum Rules | Mark all | Recent Posts

Roomprog for random dice roll
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Jun 10, 2011 1:54 pm   
Go to the top of the page
Go to the bottom of the page

pentair
Fledgling
GroupMembers
Posts19
JoinedMar 18, 2009

 
I'm building an area based off a board game and I'm trying to figure out how to make prog that rolls 2 dice, then transports the player that many spaces. I got a basic one that takes a random number between 2 and 12, but was trying to make one that rolls 2 dice and adds them telling the player what the dice rolled. Is there a way to do this or do I have to make a if check for every dice roll possible?

Post is unread #2 Jun 10, 2011 10:41 pm   
Go to the top of the page
Go to the bottom of the page

pentair
Fledgling
GroupMembers
Posts19
JoinedMar 18, 2009

 
this is the quick version but it reports 2 rolls instead of one. ie:
You say 'roll dice'
you rolled a 12
you rolled a 8

here is the program:
[code]
>speech_prog roll dice
if rand(9)
mpe you rolled a 3
else
if rand(10)
mpe you rolled a 4
else
if rand(11)
mpe you rolled a 5
else
if rand(13)
mpe you rolled a 6
else
if rand(14)
mpe you rolled a 7
else
if rand(17)
mpe you rolled a 8
else
if rand(20)
mpe you rolled a 9
else
if rand(25)
mpe you rolled a 10
else
if rand(33)
mpe you rolled a 11
else
if rand(50)
mpe you rolled a 12
else
mpe you rolled a 2
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
[code]

Post is unread #3 Jun 11, 2011 9:57 am   
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

 
actually, that prog will only show one response of "you rolled a #". If it's showing 2 responses for you, pentair, you may want to look into that as a bug.

Post is unread #4 Jun 11, 2011 10:28 am   
Go to the top of the page
Go to the bottom of the page

pentair
Fledgling
GroupMembers
Posts19
JoinedMar 18, 2009

 
Hmm. It is a dbna src, so its probly very buggy. I will have to look into it later when im not on an Ipad

Post is unread #5 Jun 11, 2011 10:45 am   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,914
JoinedJul 26, 2005

 
Well It has been a long time but I think it is doing it once for the word roll and once for the word dice. Try doing the speech_prog 'roll dice' instead of roll dice. A good way to test it is just say roll in the room if it does it once there you go.

Post is unread #6 Jun 11, 2011 11:41 am   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
Remcon is correct.

Post is unread #7 Jun 11, 2011 11:42 am   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
btw what mud is this?

Post is unread #8 Jun 11, 2011 12:14 pm   
Go to the top of the page
Go to the bottom of the page

Quixadhal
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005

 
It ought to show a somewhat random number of responses, since it calls rand() multiple times and makes decisions based off each, no?

I dunno... I never used mprogs or whatever you call them, but I'd have to believe each call to rand() would generate a new random number.

Post is unread #9 Jun 11, 2011 12:21 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,914
JoinedJul 26, 2005

 
Yea Quix, each call to rand will get a different number. But the basics of it are that it doesn't have variables you can set like
dice1 = rand();
dice2 = rand();
if dice1(1) && dice2(2)
 say you rolled a 3.
endif

Granted that would be the best way to have it work but it isn't set up like that lol.

Post is unread #10 Jun 11, 2011 1:06 pm   
Go to the top of the page
Go to the bottom of the page

pentair
Fledgling
GroupMembers
Posts19
JoinedMar 18, 2009

 
The code is just dbna from here. I compiled it to test progs before I tried them on the actual mud I am building on. I will try the 'roll dice' It didn't occur to me.

And the rand(#) is the only way I could think of to do it. If hernes calculations are correct they should all have roughly the same % chance to occur. Should be somewhere around 9%. But now that I see it Im pretty sure it's the missing ' '. I will try it out and letbu know. Thanks for the help.

Post is unread #11 Jun 12, 2011 12:37 am   
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

 
oh, that's right...forgot that without quotes it counts all the words. heh

Post is unread #12 Jun 13, 2011 7:56 am   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
Another opinion you could go for this is having the coder actually make a Dice command, and a dice program type and then have the area pick up on the echo of the command. It won't be that hard to make. If you needed I could make one for you. I am used to working with dbsaga so yeah.

Post is unread #13 Jun 13, 2011 1:48 pm   
Go to the top of the page
Go to the bottom of the page

Quixadhal
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005

 
Has anyone though of implementing a (limited) set of variables in the mprog system? I'm sure it wouldn't be all that difficult to have a fixed set (like a-z), and assignment via a function like store(a, 12).

If you don't want to deal with types, you could probably just make a handful of variables like i1 i2.. i9, and s1 s2... s9.

*shrug*

Post is unread #14 Jun 13, 2011 2:07 pm   
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

 
I have a variable system in my MUD and I think it was a Smaug snippet. "setvar" etc. Also I thought Smaug 1.8 had something like that?

Post is unread #15 Jun 13, 2011 7:08 pm   
Go to the top of the page
Go to the bottom of the page

pentair
Fledgling
GroupMembers
Posts19
JoinedMar 18, 2009

 
I got it working, it was the apostrophys (sp?). Apparently i could have used p too. Like rpedit add speech p roll dice
any ways heres what i came up with. and how do u get the codebox to work? it just puts codbox in quotes for me.

mpe &YTaking up your dice, you hope for a good roll and let them fly....&d
mpsleep 6
if rand(9)
mpe &Yyou rolled a &C3&d
mptransfer $n 220005
else
if rand(10)
mpe &Yyou rolled a &C4&d
mptransfer $n 220006
else
if rand(11)
mpe &Yyou rolled a &C5&d
mptransfer $n 220007
else
if rand(13)
mpe &Yyou rolled a &C6&d
mptransfer $n 220008
else
if rand(14)
mpe &Yyou rolled a &C7&d
mptransfer $n 220009
else
if rand(17)
mpe &Yyou rolled a &C8&d
mptransfer $n 220010
else
if rand(20)
mpe &Yyou rolled a &C9&d
mptransfer $n 220011
else
if rand(25)
mpe &Yyou rolled a &C10&S!&d
mptransfer $n 220012
else
if rand(33)
mpe &Yyou rolled a &C11&S!&d
mptransfer $n 220013
else
if rand(50)
mpe &Yyou rolled a &C12&S!&d
mptransfer $n 220014
else
mpe &Yyou rolled a &C2&d
mptransfer $n 220004
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif

Post is unread #16 Jun 14, 2011 12:26 pm   
Go to the top of the page
Go to the bottom of the page

InfiniteAxis
Off the Edge of the Map
GroupAdministrators
Posts1,200
JoinedMar 21, 2006

 
The latest version of SmaugFUSS has the variables code, Zeno mentioned in it.

Post is unread #17 Jun 15, 2011 2:28 am   
Go to the top of the page
Go to the bottom of the page

antram
Apprentice
GroupMembers
Posts58
JoinedNov 22, 2010

 
Hello:

I've seen the term "DBNA code" in some different places, but I've never looked for it. I think that it's a Dragon Ball code, but I've never find it to download. Can somebody tells me where is the code to download and look it?

Thanks for all,

Antram

Post is unread #18 Jun 15, 2011 2:36 am   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
Is on this website.

Pages:<< prev 1 next >>