Author Topic: RPG Bot  (Read 10786 times)

0 Members and 2 Guests are viewing this topic.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: RPG Bot
« Reply #15 on: November 21, 2005, 09:20:04 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

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: RPG Bot
« Reply #16 on: November 21, 2005, 09:22:51 pm »
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

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. 

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: RPG Bot
« Reply #17 on: November 21, 2005, 09:27:04 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

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: RPG Bot
« Reply #18 on: November 21, 2005, 09:31:31 pm »
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

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: RPG Bot
« Reply #19 on: November 22, 2005, 12:03:44 am »
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

Code: [Select]
#!/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;
}
« Last Edit: November 22, 2005, 12:48:37 am by Newby »
- 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

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. 

Offline Hitmen

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 1913
    • View Profile
Re: RPG Bot
« Reply #20 on: November 22, 2005, 12:37:18 am »
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

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: RPG Bot
« Reply #21 on: November 22, 2005, 12:47:02 am »
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

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. 

Offline Towelie

  • pwnstar
  • x86
  • Hero Member
  • *****
  • Posts: 4873
    • View Profile
Re: RPG Bot
« Reply #22 on: November 22, 2005, 01:19:22 am »
programing sounds like it could be a hassle and frustrating at times!

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: RPG Bot
« Reply #23 on: November 22, 2005, 01:28:59 am »
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. :)

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: RPG Bot
« Reply #24 on: November 22, 2005, 11:19:43 am »
Yeah, Newby just has an angry personality :-)

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

Incidentally, how do I use that?

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: RPG Bot
« Reply #25 on: November 22, 2005, 05:15:25 pm »
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

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.