News:

Pretty crazy that we're closer to 2030, than we are 2005. Where did the time go!

Main Menu

RPG Bot

Started by Newby, November 20, 2005, 05:50:27 PM

Previous topic - Next topic

0 Members and 5 Guests are viewing this topic.

iago

Quote from: Newby on November 21, 2005, 09:19:07 PM
Quote from: iago on November 21, 2005, 09:15:03 PM
But if you're feeling ambition, then do:
- x d y (x y-sided dice)
- 2d6 doubles-add-roll-over (I mentioned that somewhere else)
- xd6, doubles-add-roll-over (Required if we have a berserker)

Also, I'd like to be able to do a table look up.  Like, for example, I want a table of, say, 100 languages.  Then they could do:
.choose language
And it would return a random one.  But for other things besides languages, like, make sure I can easily expand it. 

Well, I can get most of that, but if you wanna do some of the work...

What do you want me to do with the result of the 3d6?

Display it out loud. 

And I don't WANT to do any work, but I WILL do it if I have to :P

Newby

I mean, do you want me to sum them up or just list the individual results (it seems like this one)?
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Sidoh

Quote from: Newby on November 21, 2005, 09:19:07 PM
Well, I can get most of that, but if you wanna do some of the work...

What do you want me to do with the result of the 3d6?

Something like this:

Quote
.roll 3d6
You rolled 3 6-sided die: 3, 6, 1

iago

Why not both?

Sum is the most important part, though. 

<me> .roll 3d6
<bot> 3 + 6 + 1 = 10

I'll also need you to allow adds and display the level of the 2d6DARO rolls (level 1 is 20, level 2 is 25, level 3 is 30, level 4 is 35, etc:

Let's see if this table looks ok:

   Lvl   Target   Lvl   Target   Lvl   Target   Lvl   Target
   1st   20   2nd   25   3rd   30   4th   35
   5th   40   6th   45   7th   50   8th   55
   9th   60   10th   65   11th   70   12th   75
   13th   80   14th   85   15th   90   16th   95
   17th   100   18th   105   19th   110   20th   115


The forumula for level is simple, though: floor((roll - 15) / 5)

The command should look like this:
.daro 12

It will roll 2 dice in the standard way, add 12 to it, and display the level achieved:

<me> .daro 12
<bot> rolled 2 2 + 3 4 + 12 = 23 = level 1
<me> .daro 23
<bot> rolled 1 5 + 23 = 29 = level 2
<me> .daro 17
<bot> rolled 2 2 + 4 4 + 3 3 + 12 = 30 = level 3


Finally, if 1 2 or 2 1 or 3 1 or 1 3 is rolled, it's an auto-fail:
<me> .daro 100
<bot> rolled 2 1 = autofail
<me> .daro 12
<bot> rolled 3 1 = autofail

auto-fail = botch

Newby

#19
I hate you. I just worked for a good 2-3 hours working on this fucking script, and you ask for something different?!?!?! >:(

Quote[21:02:51] <@newby_> Result of 4d6 roll: 5 5 5 3
[21:02:58] <+newby__> !roll 3d6
[21:02:58] <@newby_> Result of 3d6 roll: 1 1 3
[21:03:01] <+newby__> !roll 3d6
[21:03:01] <@newby_> Result of 3d6 roll: 1 4 4
[21:03:03] <+newby__> !roll 3d6
[21:03:03] <@newby_> Result of 3d6 roll: 5 6 1
[21:03:06] <+newby__> !roll 4d4
[21:03:06] <@newby_> Result of 4d4 roll: 3 3 2 2
[21:03:10] <+newby__> !roll 100d6
[21:03:10] <@newby_> Result of 100d6 roll: 6 4 1 3 4 5 5 3 5 1 2 4 6 6 1 5 1 4
                     1 3 3 1 6 3 4 1 2 6 2 1 5 2 6 1 1 5 1 4 5 4 6 3 4 3 2 6 3
                     2 5 6 3 6 3 1 6 2 1 4 3 4 3 3 1 6 5 2 5 4 5 3 1 6 6 1 3 5
                     4 6 4 1 3 6 3 6 3 5 2 4 4 1 5 2 5 2 6 2 6 5 4 1
[21:03:13] <+newby__> !roll 69d69
[21:03:14] <@newby_> Result of 69d69 roll: 66 11 52 57 61 50 47 4 27 7 67 57 12
                     6 34 29 69 52 32 58 39 16 37 40 12 21 13 12 59 34 17 63 69
                     50 18 28 17 31 8 45 34 4 52 18 58 40 66 69 39 14 6 61 4 67
                     28 57 26 54 59 13 1 57 52 63 26 13 52 11 51

I refuse to sum them up or do any further work. Blow me. :-*

x86-rpg-script.pl

#!/usr/bin/perl
# Perl script for tunnels and trolls online.
# Contains various script things.
# Written by newby (newbypwns@gmail.com) for iago (iago@valhallalegends.com)
# http://wwww.x86labs.org
# :)

# Register the plugin with X-Chat.

Xchat::register("x86-rpg-script", "0.1a", "RPG script for X-Chat", \&unload);
Xchat::print("3Loading x86-rpg-script... please wait.");

# Register the roll command to a variable.

my $rpghook = Xchat::hook_server("PRIVMSG", "parsetalking");

# Randomize the seed!

srand();

# This sub is called whenever the plugin is unloaded.

sub unload()
{
    Xchat::unhook($rpghook);
    Xchat::print("3Unloading x86-rpg-script... please wait.");
}

# sub rolldice(int times, int sides)
# Sides: number of sides on the dice
# Times: number of times to roll the dice.
sub rolldice()
{
($times,$sides) = @_;
undef @arrayofnumbers;
for (my $i = 0; $i < ($times); $i++)
{
@arrayofnumbers = (@arrayofnumbers,(int(rand($sides)+1)));;
}
return \@arrayofnumbers;
}

sub parsetalking()
{
my $data = shift(@_);
my $username = substr(shift(@$data), 1);
# Xchat::print("Username: $username");
shift(@$data); # Don't know better.
shift(@$data); # :(!
my $message = substr(join(" ", @$data), 1);
# Xchat::print("Message: $message");
# Xchat::command("say <$username> $message");

# Enter the command sub:
if (substr($message, 0, 1) eq "!")
{
if (lc(shift(@$data)) eq ":!roll") # If not, we lost it. I'll have to assign to a variable later!
{
my $diceroll = lc(shift(@$data));
if (index($diceroll, "d") == -1)
{
Xchat::command("say You didn't enter a real dice value!\n");
return 0;
}
my $times = substr($diceroll, 0, index($diceroll, "d"));
my $sides = substr($diceroll, index($diceroll, "d")+1);
my $resultofdiceroll = &rolldice($times, $sides);
Xchat::command("say Result of $times"."d"."$sides roll: @$resultofdiceroll\n");
}
}
return 0;
}
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Hitmen

Newby is just mad because he sucks at life and I kept making fun of him the whole time while he was screwing up.
Quote
(22:15:39) Newby: it hurts to swallow

Newby

Actually, most of my anger (my harsh comments in the above post are sarcasm) came out of Perl not having a switch statement?

(I couldn't get mine to work for love 'nor money.)
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Towelie

programing sounds like it could be a hassle and frustrating at times!

Sidoh

Quote from: Toweliex86] link=topic=3840.msg40113#msg40113 date=1132640362]
programing sounds like it could be a hassle and frustrating at times!

I think the entirety of programming is frustrating. -_-

Haha, just kidding.  Programming is great, it's an awesome way to learn how to approach/solve problems. :)

iago

Yeah, Newby just has an angry personality :-)

Thanks for writing that, I can look after anything else. 

Incidentally, how do I use that?

Newby

Put it in ~/.xchat2 and it'll auto load on start!
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT.