/*
<mdata.ini>
[game]
status=0 || 0 = None | 1 = Starting | 2 = On-going
gstatus=0 || 1 = Morning | 2 = Night
stimer=0 || The timer number used when starting the game.
<musers.ini>
[Someone] || Nickname.
alive=1 || 0 = Dead | 1 = Alive
alignment=1 || 0 = Non-aligned | 1 = Town | 2 = Mafia
role=0 || t = Townie | rb = Roleblocker | c = Cop | ic = Insane Cop | m = Mafioso | sk = Serial Killer | rd = Redirector | v = Vigilante | d = doctor
nightaction=0 || 0 = Unused | 1 = Used.
votedfor=outsomnia || Person they voted for.
votes=5 || Number of votes against the user.
vkicks=2 || Number of votes to kick the user.
vkicked=null || Whether or not the played has voted to kick somebody. Only one kick can be made a game.
vstopped=null || Whether or not the player has voted to stop the game.
<mrank.ini>
[Someone] || Username.
password=12345 || Character limit: 4-14.
twlt=0/0/0 || Town. wins/loses/ties
mwlt=0/0/0 || Mafia. wins/loses/ties
swlt=0/0/0 || Serial Killer. wins/loses/ties
level=0 || 0 = user | 1 = moderator | 2 = admin
*/
ON *:TEXT:*:#dmsmafia:{ if ($me == Someone) { var %status $readini(mdata.ini,game,status)
var %timer $readini(mdata.ini,game,stimer)
var %alive $readini(musers.ini,$nick,alive)
var %gstatus $readini(mdata.ini,game,gstatus)
if ($1 == !in) { if (%status == 1) { if (%alive != $null) { notice $nick You are already in this game! | halt } writeini musers.ini $nick alive 1
mode $chan +v $nick
notice $nick You are now in this game! If you want to leave, use !out.
}
}
else if ($1 == !start) { if (%status == 0 || %status == $null) { mode $chan +v $nick
mmsg $chan A game of Mafia is now starting. Please type !in to join the game.
notice $nick You are now in this game! If you want to leave, use !out.
writeini mdata.ini game status 1
writeini mdata.ini game starter $nick
writeini mdata.ini game round 0
timer 1 180 startMafia $chan
writeini mdata.ini game stimer $ltimer
writeini musers.ini $nick alive 1
}
}
else if ($1 == !go) { if (%status == 1) { mmsg $chan Mafia will start in 10 seconds.
$+(timer,%timer) 1 10 startMafia $chan
}
}
else if ($1 == !vote) { if (%status == 2 && %gstatus == 1) { }
}
else if ($1 == !out) { if (%status == 1) { if (%alive == $null) { notice $nick You are not in this game! | halt } notice $nick You have left the game!
remini musers.ini $nick
mode $chan -v $nick
if ($nick == $readini(mdata.ini,game,starter)) { mmsg $chan The game has ended due to the Game Starter leaving.
stopMafia $chan
$+(timer,%timer) off
}
}
}
else if ($1 == !wait) { if (%status == 1) { var %newtime $calc($+($timer(%timer).secs) + 60)
mmsg $chan The game has been extended 60 seconds. Mafia will start in $+(,%newtime,) seconds.
$+(timer,%timer) 1 %newtime startMafia $chan
}
}
else if ($1 == !stop) { if (%status == 1) { }
else if (%status == 2) { }
}
else if ($1 == !alive) { if (%status == 2 || %status == 1) { if ($getalive != $null) { mmsg $chan Alive players: $+(,$getalive,.)
}
}
}
else if ($1 == !votes) { if (%status == 2 && %gstatus == 1) { }
}
else if ($1 == !vkick) { if ($2 == $null) halt
if (%alive == 1) { var %vkicks $readini(musers.ini,$2,vkicks)
if (%vkicks == $null) { notice $nick $+(,$2,) does not exist. | halt } var %newvkicks $calc(%kicks + 1)
writeini musers.ini $2 vkicks %newvkicks
mmsg $chan $+(,$nick,) has voted to kick $+(,$2,). Vote %newvkicks of 3.
}
}
else if ($1 == !coin) { mmsg $chan The coin came up $+($iif($r(1,2) == 1,heads,tails),.)
}
else if ($1 == !status) { if (%status == 1) { mmsg $chan A game of Mafia is currently starting. Use !in to go in. Time left: $+(,$timer($readini(mdata.ini,game,stimer)).secs,secs.)
}
else if (%status == 2) { if (%gstatus == 1) { var %m %m It takes $+(,$floor($calc($ini(musers.ini,0) / 2 + 1)),) votes to lynch.
}
mmsg $1 %m
}
else { mmsg $chan No games are currently active. Use !start to start one.
}
}
else if ($1 == !mod) { if ($2 == tbn) { /*
if ($0 > 4 || $3 !isnum) { notice $nick Syntax: !mod tbn <minutes> <name> <reason> | halt } var %time $calc($3 * 60)
quote tban $chan %time $address($4,2)
kick $chan $4 5Temp banned for $+(,$duration(%time),) Reason: $+(,$iif($5- != $null, $5-, No reason specified.),)
*/
}
else if ($2 == modkill) { }
else if ($2 == forceend) { /*
stopmafia $chan
mmsg $chan Moderator $+(,$nick,) has force-ended the game.
*/
}
else { notice $nick Syntax: !mod [command]. [command] can be
notice $nick tbn [nick] [minutes] (reason) - Tempbans [nick] for [minutes] and then kicks [nick] out of the channel. User must be in the IRC server.
notice $nick modkill [nick] (reveal) - Modkills [nick]. [reveal] can be true or false. If true, the kill reveals the user's role. If [reveal] is not specified, it will reveal the role automatically.
notice $nick forceend - Force ends the current game (if one is going on). Reveals all roles.
}
}
else if ($1 == !admin) { if ($2 == addmod) { }
else if ($2 == delmod) { }
else { notice $nick Syntax: !admin [command]. [command] can be
notice $nick addmod [username] - Makes [username] a moderator.
notice $nick delmod [username] - Removes [username] from the mod list.
}
}
}
}
ON *:TEXT:*:?:{ if ($me == Someone) { if ($1 == !help) { if ($2 == commands) { notice $nick !in, !out, !start, !go, !wait, !stop, !vkick [name] - Joins a game if it is starting.; Leaves a game if it is starting.; Starts a game if none are active.; Forces the game to start early.; Extends the waiting time.; Vote to stop the game. (If you started it, you can end it without voting if it is still starting); Kicks [name] from the game. (Total Players/2) votes are required.
notice $nick !vote [name], !unvote, !votes, !alive, !status - Votes for [name].; Unvotes; Shows the voting results.; Shows the people alive.; Shows the status (Day/Morning/Night and Round).
notice $nick !coin - Flips a coin.
notice $nick PM Commands: !help [category], !rank [name], !mods - Gets help on [category].; Checks the w/l/t of [name].; Gives you the list of mods.
}
else if ($2 == rules) { notice $nick 1. Do not spam the bot!
notice $nick 2. Only join games that you can complete.
notice $nick 3. Play to win! Do not reveal your role if you are mafia.
notice $nick 4. Do not quote the bot to prove your innocence. You are allowed to paraphrase what your role does.
notice $nick 5. Do not talk with other players at night UNLESS you are mafia.
notice $nick 6. Do not go AFK in a game without getting a replacement or letting the other players know.
notice $nick If it is your first time playing, feel free to ask anything about the game. Use !help first!
notice $nick If anybody is breaking rules or idling too long, query a moderator and report them. Use !mods for a list of moderators. Moderators can temp ban, modkill and force end the game.
}
else if ($2 == basics) { notice $nick A tutorial of mafia can be found here: http://cataldo.freeshell.org/mafia/mafiascum04.swf
notice $nick The roles in this game are different. Use !help roles for information on each role!
notice $nick If there are 3 players, the game starts in the day. If there are 4+, the game starts at night.
notice $nick The periods of time are Morning and Night.
}
else if ($2 == roles) { if ($3 == Townie) { notice $nick Townie (town, common) - Has no special actions or abilities.
}
else if ($3 == Roleblocker) { notice $nick Roleblocker (town/mafia, common) - Able to block one person from doing their night action. Abilities: block [target].
}
else if ($3 == Mafioso) { notice $nick Mafioso (mafia, common) - Has no special actions or abilities other than 'mafiakill [target]'.
}
else if ($3 == Godfather) { notice $nick Godfather (mafia, uncommon) - Shows up with 'town' on death and cop inspects. Unable to be killed by night actions. Otherwise has no other special abilities.
}
else if ($3 == Serial) { notice $nick Serial Killer (sk, uncommon) - Serial Killer. Able to kill one user each night. Abilities: kill [target].
}
else if ($3 == Watcher) { notice $nick Watcher (town/mafia, uncommon) - Able to target one person at night and see whether they were targeted or who they targetted. Abilities: watch [target].
}
else if ($3 == Redirector) { notice $nick Redirector (town/mafia, uncommon) - Able to redirect one player's action to another player at night. Abilities: redirect [target] [target2]
}
else if ($3 == Cop) { notice $nick Cop (town, common) - Able to inspect one person each night to learn their alignment. Results are not guaranteed to be accurate. Abilities: inspect [target]
notice $nick Cops can be Sane or Insane. Insane cops get the opposite of the player's alignment. Sanity is revealed on death.
}
else if ($3 == Coward) { notice $nick Coward (town, uncommon) - Able to hide once at night during the game. During this night, all actions targetted player will do nothing. Abilities: hide (1 use)
}
else if ($3 == Super-Saint) { notice $nick Super-Saint (town, uncommon) - Whoever places the finishing vote on this player dies along with him/her.
}
else if ($3 == Vigilante) { notice $nick Vigilante (town, uncommon) - Able to kill one person per night. Abilities: kill [target]
}
else if ($3 == Doctor) { notice $nick Doctor (town, common) - Able to protect one person each night. Abilities: protect [target]
}
else { notice $nick To get help on any of them, use !help roles [role].
notice $nick The avaliable roles are Townie, Doctor, Roleblocker, Cop, Mafioso, Godfather, Serial Killer, Watcher, Redirector, Coward, Super-Saint, Vigilante.
notice $nick The roles which are not bolded are currently disabled.
}
}
else if ($2 == todo) { notice $nick -Make it so that you know who your mafia group is.
notice $nick -Complete gameplay.
notice $nick -Complete rank system.
notice $nick -Complete Admin/Moderator system.
}
else { notice $nick Welcome to Mafia! To get help on a category, Use
notice $nick !help [category]
notice $nick Avaliable categories: basics, rules, roles, todo, commands.
}
}
else if ($1 == !rank) { var %target $iif($2 != $null, $2, $nick)
var %w $readini(mranks.ini,%target,w)
var %l $readini(mranks.ini,%target,l)
var %t $readini(mranks.ini,%target,t)
if (%w == $null) { var %w 0 } if (%l == $null) { var %l 0 } if (%t == $null) { var %t 0 } notice $nick User Ranking: $+(,%target,) Wins: %w | Loses: %l | Ties: %t
}
else if ($1 == !mods) { }
}
}
ON *:JOIN:#dmsmafia:{ if ($me == Someone && $nick != Someone) { var %status $readini(mdata.ini,game,status)
var %alive $readini(musers.ini,$nick,alive)
if (%status == 0) { notice $nick Hi there. Welcome to Mafia. No games are currently active.
}
if (%status == 1) { if (%alive == $null) { notice $nick Hey there! A game of Mafia is currently starting. Use !in if you want to join!
}
else { notice $nick Welcome back! The game is still starting. Time left: $+(,$timer($readini(mdata.ini,game,stimer)).secs,secs.)
}
}
else if (%status == 2) { if (%alive == 1) { mode #dmsmafia +v $nick
notice $nick Welcome back! Alive players: $+(,$getalive,.) Round: $getgstatus $+ $readini(mdata.ini,game,round)
}
}
}
}
alias getalive { var %z 1
while (%z <= $ini(musers.ini,0)) { var %player $ini(musers.ini,%z)
if ($readini(musers.ini,%player,alive) == 1) { var %m %m %player
}
inc %z
}
return %m
}
alias startmafia { var %users $ini(musers.ini,0)
if (%users < 3) { mmsg $1 Mafia has been cancelled due to a lack of players. You need at least 3 players to play the game.
stopmafia $1
halt
}
writeini mdata.ini game status 2
writeini mdata.ini game gstatus $iif(%users == 3,1,2)
mmsg $1 Mafia has started! It is $+(,$getgstatus,0,.)
mode $1 +m
var %m Alive players: $+(,$getalive,.)
if (%users > 3) { mvoice $1 -
}
else { var %m %m It takes $+(,$floor($calc(%users / 2 + 1)),) votes to lynch.
}
mmsg $1 %m
hmake mids 14
var %counter 1
var %mafia $floor($calc(%users / 3))
var %mrb $iif(%mafia > 1,1,0)
var %mrd $floor($calc(%mafia / 3))
var %trb $iif(%users > 6, $r(0,1), 0)
var %tv $iif(%users > 6, 1, 0)
var %td $iif(%users > 4, 1, 0)
var %trd $iif(%users > 6 && %trb < 1, 1, 0)
var %tc $floor($calc(%users / 8 + 1))
var %sk 1
while (%counter <= %users) { var %id $r(1,%users)
if ($hget(mids,%id) == $null) { if (%mafia > 0) { if (%mrb > 0) { var %role rb
dec %mrb
}
else if (%mrd > 0) { var %role rd
dec %mrd
}
else { var %role m
}
dec %mafia
var %alignment 2
if ($r(1,4) == 1 && %sk > 0) { var %role sk
var %alignment 0
dec %sk
}
}
else if (%trb > 0) { var %role rb
var %alignment 1
dec %trb
}
else if (%trd > 0) { var %role rd
var %alignment 1
dec %trd
}
else if (%tv > 0) { var %role v
var %alignment 1
dec %tv
}
else if (%td > 0) { var %role d
var %alignment 1
dec %td
}
else if (%tc > 0) { var %role $iif($r(1,3) != 3, c, ic)
var %alignment 1
dec %tc
}
else { var %role t
var %alignment 1
}
writeini musers.ini $ini(musers.ini,%id) role %role
writeini musers.ini $ini(musers.ini,%id) alignment %alignment
writeini musers.ini $ini(musers.ini,%id) nightaction 0
mmsg $1 $+(,$ini(musers.ini,%id),) is a $+(,$getrole(%role),,$chr(40),$getalignment(%alignment),$chr(41))
notice $ini(musers.ini,%id) $getrolepm(%role,%alignment)
inc %counter
hadd mids %id Used
}
}
hfree mids
}
alias getrolepm { var %role $1
var %alignment $2
var %msg Night Actions:
if (%role == rb) { var %msg %msg block [user] : Blocks [user] from using his/her night action
}
else if (%role == rd) { var %msg %msg redirect [user] [target] : Changes [user]'s target to [target].
}
else if (%role == v) { var %msg %msg kill [user] : Kills [user].
}
else if (%role == d) { var %msg %msg protect [user] : Protects [user] from nightkills.
}
else if (%role == c || %role == ic) { var %msg %msg inspect [user] : Inspects [user] to find out their alignment. Note: Results are not guaranteed to be accurate.
}
else if (%role == sk) { var %msg %msg kill [user] : Kills [user].
}
else if (%role == t) { var %msg You do not have any special actions or abilities.
}
if (%alignment == 2) { var %msg %msg mafiakill [user] : Kills [user]. Note: The mafia can only make ONE kill each night!
}
return You are a $+(,$getrole(%role),,$chr(40),$getalignment(%alignment),$chr(41),.) %msg
}
alias stopmafia { if ($readini(mdata.ini,game,gstatus) != 2) { mvoice $1 -
}
mode $1 -m
writeini mdata.ini game status 0
var %z $ini(musers.ini,0)
remini mdata.ini game stimer
.remove musers.ini
.remove mdata.ini
}
alias mvoice { var %alive $getalive
mode $1 $+($2,$str(v,$numtok(%alive,32))) %alive
}
alias getgstatus { var %gstatus $readini(mdata.ini,game,gstatus)
if (%gstatus == 1) return Morning
else if (%gstatus == 2) return Night
else return None
}
alias getalignment { if ($1 == 0) return sk
else if ($1 == 1) return town
else if ($1 == 2) return mafia
else return None
}
alias getrole { if ($1 == rb) return Roleblocker
else if ($1 == rd) return Redirector
else if ($1 == v) return Vigilante
else if ($1 == d) return Doctor
else if ($1 == c) return Cop
else if ($1 == ic && $2 != true) return Cop
else if ($1 == ic) return Insane Cop
else if ($1 == m) return Mafioso
else if ($1 == sk) return Serial Killer
else if ($1 == t) return Townie
else return None
}