On going RPG
Posted by Chappy
Monday, August 29, 2005
Description: RPG I started recently, hoping to make into a largescale project.

;;;;;;;
;;**Start off by changing the 2nd line from "ChapBot" to whatever your bot's name is.**
;;Commands:
;; !battle - Sets it up so that several players can join.
;; !join - Joins the game after !battle has been typed.
;; !start - Starts the game. There must be 2 or more people.
;; !attack - attacks one of the joined members.
;;
;;For testing purposes:
;; /start starts a game automatically. The character Bob is added.
;; /addchar adds a character under the name of $1
;;;;;;;

on *:text:*:#: {
  if ($me == ChapBot) {
    if ($1 == !battle && %battlej != true) {
      msg $chan type !join to join the fight. !start to begin.
      set %battlej true
      set %start false
      set %pcount 0
    }
    if ($1 == !join && %battlej == true && $char($nick) == $false) {
      inc %pcount
      set %bplayers %bplayers $nick
      set %hpc %hpc $calc(20 + $stat(%bonus, $char($nick)))
      set %hp %hp $calc(20 + $stat(%bonus, $char($nick)))
      set %dead %dead false
      msg $chan $nick has joined with a starting health of $hp($nick) points.
    }
    if ($1 == !start && %start == false) {
      if (%pcount < 2) { notice $nick Not enough players! | halt }
      msg $chan Game has started! !attack <insertnickhere> to attack.
      set %battlej false
      set %start true
    }

    if ($1 == !stop && %start == true) {
      msg $chan Battle has stopped! !battle to start again.
      unset %battlej
      unset %bplayers
      unset %countchar
      unset %hpc
      unset %hp
      unset %damage
      unset %start
      unset %dead
    }

    if ($1 == !attack && %start == true ) {
      ;Where the physical damage is done. Generates a random number, and subtracts that number from the health of $2
      ;Does a few checks to see if the person attacking or the person being attacked is elligable for attacking/being attacked
      ;If the character attacked has 0 health, that person can not be attacked or attack others.

      if ($dead($nick) == true) { notice $nick You are already dead! Wait until next round to play again. | halt }
      if ($char($$2) == $false) { notice $nick $2 does not exist. | halt }
      if ($nick == $2) { notice $nick You can not attack yourself! | halt }
      if ($nick !isin %bplayers) { notice $nick You have not joined, wait until next round to join. | halt }
      if ($hpc($2) <= 0) { notice $nick $charname($2) is already dead! | halt }

      if ($hpc($2) > 0) {
        set %damage $rand(1,5)
        chpc $2 $calc($hpc($2) - %damage)
        if ($hpc($2) <= 0) {
          cdead $2 true

          msg # $nick has killed $charname($2) $+ !
        }
        else msg $chan $nick did %damage damage to $charname($2) $+ . $charname($2) has $hpc($2) health left.
      }
    }
  }
}
alias char {
  ;returns the position in %bplayers. The first person to join would be number one.
  set %countchar 1
  while ($gettok(%bplayers,%countchar,32) != $null) {
    if ($gettok(%bplayers,%countchar,32) == $1) return %countchar
    else inc %countchar
  }
  return $false
}

;returns the stat of %$1 of $char(name)
alias stat return $gettok($1,$2,32)

alias addchar {
  ;automatically adds a character with the name $1
  inc %countchar
  set %bplayers %bplayers $1
  set %hpc %hpc 20
  set %hp %hp 20
  set %dead %dead false
  msg $chan $1 has been created
}

alias start {
  ;automatically starts a game. Makes it easier for testing.
  msg # !battle
  msg # !join
  addchar Bob
  msg # !start
}

;returns the corresponding stat of $1 ($nick)
alias hpc return $stat(%hpc,$char($1))
alias hp return $stat(%hp,$char($1))
alias charname return $stat(%bplayers,$char($1))
alias dead return $stat(%dead,$char($1))

;edits $1's data and replaces it with $2
alias chpc set %hpc $puttok(%hpc,$2,$char($1),32)
alias cdead set %dead $puttok(%dead,$2,$char($1),32)
Simple...
Posted by GaMa
Friday, September 16, 2005 06:47am PDT
Uhm, the system itself is too simple, like the algorithms for damage and what not. I have already created an rpg game and I could help you if you need the help.

The outcome of someone winning this is random, how much damage the user receives all depends on a $rand(1,5). Characters should be created by command, and can be re-used by the specified user who created the character. There are alot of things wrong with this, and should probably be fixed/added

Oh, btw, as funny as this may seem, the identifiers/alias's you created for this are almost identicle to mine ($char, /start, /addchar) but have a different purpose. The commands to start, join and begin the battle are EXACTLY the same... how weird =P
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world