Dethy mafia game

By Blitzjager on Feb 03, 2010

This is a mafia game with 4 inspectors and a wolf. The wolf has to fake results while killing off the inspectors. There's a sane, insane, paranoid, and naive inspector.
Sane - Correct results. Good is good, bad is bad.
Insane - Opposite results. Good is bad, bad is good.
Paranoid - Always bad result.
Naive - Always good result.

Commands:
!c5join, !c5quit, !c5players, !c5help, !c5reset, !spread, and '!c5sub user'
I trust people enough not to add flood protection or screw up peoples' games with !c5reset
During the game 'vote user/vote nolynch' to vote and message the bot with 'kill user/hook user/inspect user'

This works on 6.35 but not 6.17.
On line 16 is the spreadsheet command, make a google documents spreadsheet and let anyone use it (Share --> See who has access --> Change --> Let people edit without signing in) Then replace the X with the link to the spreadsheet.

I had it personalized for my channel so hopefully I didn't screw anything up when I changed it.

on *:LOAD: {
  set %c5chan $?="Channel for Cop5? (Make sure to put a #, ex #Cop5)"
}
on *:TEXT:*:%c5chan: {
  if ($1 == !c5join) && ($numtok($hget(Cop5,Players),32) < 5) && (!$istok($hget(Cop5,Players),$nick,32)) {
    hadd -m Cop5 Players $hget(Cop5,Players) $nick
    mode # +v $nick
    msg %c5chan $nick has joined c5.
  }
  if ($1 == !c5quit) && ($istok($hget(Cop5,Players),$nick,32)) && (!%c5act) {
    hadd -m Cop5 Players $remove($hget(Cop5,Players),$nick)
    mode %c5chan -v $nick
    msg %c5chan $nick has quit c5.
  }
  if ($1 == !c5reset) { endgame }
  if ($1 == !spread) { msg %c5chan Spreadsheet: X }
  if ($1 == !c5help) {
    msg %c5chan Dethy, or cop5, is a mafia game with 4 inspectors and 1 wolf. The inspectors are of varying sanity, and thus get different results. There's sane (correct), insane (incorrect), paranoid (always evil) and naive (always clean) results. The cops are not told which sanity they have.
    msg %c5chan Commands are !c5join, !c5quit, and !c5players and !spread.
  }
  if ($1 == !c5players) { msg %c5chan Current/Living players: $hget(Cop5,Players) }
  if ($numtok($hget(Cop5,Players),32) == 5) && (!%c5act) {
    set %c5act 1
    mode %c5chan +m
    hadd -m Cop5 Roles Wolf Sane Insane Paranoid Naive
    roles
  }
  if (%c5act) {
    if ($1 == !c5sub) {
      if ($2) {
        if ($istok($hget(Cop5,Players),$nick,32)) && (!$istok($hget(Cop5,Players),$2,32)) && ($2 ison %c5chan) && (!%sub) {
          set -u60 %sub $2
          set -u60 %subx $nick
          .timersub 1 61 /msg %c5chan $2 hasn't subbed in for $nick $+ .
          notice $2 Would you like to sub in for $nick in a game of c5? You have 60 seconds to type !c5sub in %c5chan to accept.
        }
      }
      elseif ($nick == %sub) {
        timersub off
        sub %subx %sub
      }
    }
    if ($1 == vote) && ($istok($hget(Cop5,Players),$nick,32)) && (%c5 == Day) {
      if (!$istok($hget(Cop5,Voted),$nick,32)) {
        if ($istok($hget(Cop5,Players),$2,32)) || ($2 == NoLynch) {
          hinc -m Votes $2
          hinc -m Cop5 Votes
          hadd -m Cop5 Voted $hget(Cop5,Voted) $nick
          hadd -m Voted $nick $2
          var %g $hget(Voted,0).item
          while (%g) {
            var %h %h $hget(Voted,%g).item $+ :  $hget(Voted,%g).data $+(,$chr(124),)
            dec %g
          }
          msg %c5chan $+(,$nick,) has voted for $+(,$2,.) $left(%h,$calc($len(%h) - 3))
          var %x 1
          while (%x <= $hget(Votes,0).item) {
            var %y $hget(Votes,%x).data
            if (!%z) { var %z %y }
            elseif (%y > %z) { var %z %y }
            elseif (%y == %z) { var %a %z }
            inc %x
          }
          if ($hget(Cop5,Votes) == $hget(C5,0).item) || (%z > $calc($hget(C5,0).item / 2)) {
            votes
          }
        }
      }
      elseif ($hget(Voted,$nick) != $2) {
        if ($istok($hget(Cop5,Players),$2,32)) || ($2 == NoLynch) {
          hdec -m Votes $hget(Voted,$nick)
          if ($hget(Votes,$hget(Voted,$nick)) == 0) { hdel Votes $hget(Voted,$nick) }
          hinc -m Votes $2
          hadd -m Voted $nick $2
          var %g $hget(Voted,0).item
          while (%g) {
            var %h %h $hget(Voted,%g).item $+ :  $hget(Voted,%g).data $+(,$chr(124),)
            dec %g
          }
          msg %c5chan $+(,$nick,) has changed their vote to $+(,$2,.) $left(%h,$calc($len(%h) - 3))
          var %x 1
          while (%x <= $hget(Votes,0).item) {
            var %y $hget(Votes,%x).data
            if (!%z) { var %z %y }
            elseif (%y > %z) { var %z %y }
            elseif (%y == %z) { var %a %z }
            inc %x
          }
          if (%z > $calc($hget(C5,0).item / 2)) {
            votes
          }
        }
      }
    }
  }
}
alias sub {
  hadd -m Cop5 Players $reptok($hget(Cop5,Players),$1,$2,1,32)
  hadd -m C5 $2 $hget(C5,$1)
  hdel C5 $1
  if ($istok($hget(Cop5,Voted),$1,32)) { hadd -m Cop5 Voted $reptok($hget(Cop5,Voted),$1,$2,1,32) }
  if ($hget(Votes,$1)) {
    hadd -m Votes $2 $hget(Votes,$1)
    hdel Votes $1
  }
  var %x $numtok($hget(Cop5,Players),32)
  while (%x) {
    if ($hget(Actions,%x).data == $1) { hadd -m Actions $hget(Actions,%x).item $2 }
    dec %x
  }
  if ($hget(C5,$2) == Wolf) {
    msg $2 You are the wolf. You can hook n0 and kill afterwards using 'hook nick' and 'kill nick'. You may hook yourself(=idling). It is currently %c5 $+ .
  }
  else {
    msg $2 You are an inspector.
  }
  msg %c5chan $1 has been subbed out for $2. All votes and actions have been switched from $1 to $2 $+ . Type !spread to view the spreadsheet or ask for $1 $+ 's (and everyone else's) results. 
}
on *:TEXT:*:?: {
  if ($istok($hget(Cop5,Players),$nick,32)) {
    if ($hget(C5,$nick) == Wolf) {
      if ($istok(Night1 Night2,%c5,32)) {
        if ($1 == kill) && ($istok($hget(Cop5,Players),$2,32)) {
          if ($2 == $nick) { msg $nick You cannot kill yourself. | halt }
          hadd -m Actions Wolf $2
          msg $nick Killing $2
        }
      }
      elseif (%c5 == Night0) && ($1 == hook) && ($istok($hget(Cop5,Players),$2,32)) {
        hadd -m Actions Wolf $2
        msg $nick Hooking $2
      }
    }
    Else {
      if ($1 == inspect) && ($istok($hget(Cop5,Players),$2,32)) && ($istok(Night0 Night1 Night2,%c5,32)) {
        if ($2 == $nick) { msg $nick You cannot inspect yourself. | halt }
        var %p1 $hget(C5,$nick)
        var %p2 $hget(C5,$2)
        if (%p1 == Paranoid) { var %r BAD. }
        if (%p1 == Naive) { var %r GOOD. }
        if (%p1 == Sane) {
          if (%p2 == Wolf) { var %r BAD. }
          else { var %r GOOD. }
        }
        if (%p1 == Insane) {
          if (%p2 == Wolf) { var %r GOOD. }
          else { var %r BAD. }
        }
        hadd -m Actions %p1 $2 is %r
        msg $nick Inspecting $2
      }
    }
    if ($hget(Actions,0).item == $hget(C5,0).item) {
      actions
    }
  }
}
alias random { return $gettok($$1-,$rand(1,$numtok($1-,32)),32) }
alias roles {
  var %x $hget(Cop5,Roles)
  var %y $hget(Cop5,Players)
  while (%x) {
    var %r $random(%x)
    var %p $random(%y)
    hadd -m C5 %p %r
    if (%r == Wolf) {
      msg %p You are the wolf. You can kill after night 0. Message me with 'kill nick' after N0. N0 message me with 'hook nick'. You may hook yourself.
    }
    set %c5roles $addtok(%c5roles,%p was %r,45)
    var %x $remtok(%x,%r,1,32)
    var %y $remtok(%y,%p,1,32)
  }
  set %c5roles $replace(%c5roles,-,$+(, - ,))
  msg %c5chan Roles are out. If you didn't receive a PM then you are an inspector. Message me with 'inspect nick'.
  set %c5 Night0
  msg %c5chan It is now %c5 $+ . The players are $hget(Cop5,Players) $+ .
}
alias actions {
  if (%c5 != Night0) {
    var %x $hget(Actions,Wolf)
    var %y $hget(C5,%x)
    hadd -m Cop5 Players $remtok($hget(Cop5,Players),%x,32)
    hadd -m Cop5 Roles $remtok($hget(Cop5,Roles),%y,32)
    hdel C5 %x
    hdel Actions %y
    msg $hfind(C5,Wolf).data %x has been killed. 10 seconds until inspection PMs are sent out.
    set %c5death %x
  }
  else {
    var %x $hget(Actions,Wolf)
    if (%x == $hfind(C5,Wolf).data) { msg %x You have 'hooked' yourself. "I seem to have lost your inspection results..." is what the hookee receives should you need it. 10 seconds until inspection PMs are sent out. }
    else { hadd -m Actions $hget(C5,%x) I seem to have lost your inspection results... }
  }
  timer 1 10 actionpms
}
alias actionpms {
  var %x 1
  while (%x <= $hget(C5,0).item) {
    if ($hget(C5,%x).data != Wolf) {
      msg $hget(C5,%x).item $hget(Actions,$hget(C5,%x).data)
    }
    inc %x
  }
  hdel -w Actions *
  if (%c5 == Night0) { set %c5next Night1 }
  elseif (%c5 == Night1) { set %c5next Night2 }
  set %c5 Day
  msg %c5chan PMs are out. Day start. Type 'vote nick' to lynch someone or 'vote NoLynch' to skip the day's lynch.
  if (%c5death) { msg %c5chan $+(,%c5death,) has died. Players still alive are: $hget(Cop5,Players) | mode %c5chan -v %c5death }
}
alias votes {
  var %x 1
  while (%x <= $hget(Votes,0).item) {
    var %y $hget(Votes,%x).data
    if (!%z) { var %z %y }
    elseif (%y > %z) { var %z %y }
    elseif (%y == %z) { var %a %z }
    inc %x
  }
  if (%z == %a) {
    msg %c5chan Tie. No one will be lynched.
  }
  else {
    var %q $hfind(Votes,%z).data
    if (%q == NoLynch) && (!$istok($hget(Cop5,Players),NoLynch,32)) {
      msg %c5chan No one will be lynched.
    }
    else {
      var %x %q
      var %y $hget(C5,%x)
      hadd -m Cop5 Players $remtok($hget(Cop5,Players),%x,32)
      hadd -m Cop5 Roles $remtok($hget(Cop5,Roles),%y,32)
      hdel C5 %x
      if (%y == Wolf) { msg %c5chan The wolf has been lynched, congratulations inspectors! | msg %c5chan %c5roles | mode %c5chan -v %x | endgame | halt }
      Else { msg %c5chan $+(,%x,) has been lynched. | mode %c5chan -v %x }
    }
  }
  hdel -w Votes *
  hdel Cop5 Votes
  hdel Cop5 Voted
  set %c5 %c5next
  if ($hget(C5,0).item <= 3) {
    if (%c5 == Night2) { msg %c5chan AWOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO! Congratulations Werewolf! | msg %c5chan %c5roles | endgame | halt }
  }
  msg %c5chan It is now %c5 $+ .
}
alias endgame {
  mode %c5chan $+(-,$str(v,$numtok($hget(Cop5,Players),32))) $hget(Cop5,Players)
  mode %c5chan -m
  unset %c5 %c5next %c5act %c5death %c5roles
  hdel -w Cop5 *
  hdel -w C5 *
  hdel -w Actions *
  hdel -w Votes *
  hdel -w Voted *
  hfree Actions
  hfree C5
  hfree Cop5
  hfree Votes
  hfree Voted
}

Comments

Sign in to comment.
cptpan   -  Jul 14, 2014

Try this game we've just developed: http://www.textgangsters.com

 Respond  
Blitzjager   -  Feb 04, 2010

I'm not much for games, but it looks like you did a lot of work here :)
Did you invent this game?
I did a lot more work than was needed because my mirc didn't always seem to do what I told it to. >:F
And this is just one of the many variations of mafia games.

 Respond  
napa182   -  Feb 03, 2010

the mafia game is a spin off of wolf game

 Respond  
Jethro   -  Feb 03, 2010

Did you invent this game?I wish everyone was suspicious enough when it comes to "cross-examining" the originality of a posted script. lol

 Respond  
FordLawnmower   -  Feb 03, 2010

I'm not much for games, but it looks like you did a lot of work here :)
Did you invent this game?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.