Roleplaying script

By NiveusLuna on Mar 30, 2008

The point of this script is to automatically NPC/NPCA your roleplaying character in channels where you have halfop or higher. It should keep you from needing to change nicks. It's also useful if you need to use two separate characters at once. If you have IRCop power, it should use FSAY/FACTION instead of NPC/NPCA, and won't check for chanop status.
This script assumes that your IRC server or network uses the m_roleplay module for Unreal IRCd developed by Falerin of Caelestia. Unfortunately, you most likely will need to disable any other "on INPUT" scripts to make this one work.
Update: Added support for multiple characters at a time.
Another update: Script now deactivates on exiting mIRC.
Update the third: added the ability to switch between a whitelist and blacklist of channels.
Fourth update: added character-specific channel functionality
Update V: added a toggle to turn on/off the deactivation at exit as well as titlebar changing commands.
Update version six: if you can't npc or fsay and you're using the wrong nick, it'll add the character's name in parentheses. NOTE: THIS DOES NOT CHECK FOR m_roleplay!
It's really hard to come up with new ways to say update seven: added support for TelLaerad/ArgentCitadel's +E channel mode that allows +v users to use npc and npca.

Usage instructions:
/roleplay on <-- activates the script. charactername is optional unless the character you want isn't already set.
/roleplay off <-- deactivates the script.
/roleplay channeladd #channel <-- adds a channel to the channel list
/roleplay channeldel #channel <-- removes #channel from the channel list
/roleplay characteradd character <-- adds character to the character list
/roleplay characterdel character <-- removes character from the character list
/roleplay charswitch <-- switches between characters incrementally.
/roleplay whitelist <-- switches between whitelist and blacklist mode
/roleplay blacklist <-- switches between whitelist and blacklist mode
/roleplay chancharadd #channel charactername <-- sets charactername to always be used in #channel
/roleplay chanchardel #channel <-- unsets charactername to always be used in #channel
/roleplay exittoggle <-- toggles the deactivation of the script on exiting mIRC.
/roleplay chancharonly <-- enables/disables the specific channel thing only and not the rest of the script

Note: this script was made using mIRC version 6.32 and higher. It may not work properly under previous ones. A helpful tester reported a bug with chanchardel using version 6.21 that did not exist in 6.32. That bug has since been repaired, but other ones may exist. Please report any bugs you see.

;Roleplaying script made by NiveusLuna of the Caelestia IRC Network.
;The point of this script is to automatically NPC whatever character you are using.
;This way, you do not accidentally use the wrong nick.
;FSAY functionality, support for colons, the add/remove channels command, and the popups added by Goofy of Caelestia.
;blacklist/whitelist, specific characters for channels, and on LOAD text ideas from Falerin.

on *:LOAD:{
  set %roleplaywhitelist 0
  set %exitrptoggle 0
  echo -ag Roleplaying script is now loaded.
  echo -ag Syntax: /roleplay on charactername <-- activates the script. charactername is optional.
  echo -ag Syntax: /roleplay off <-- deactivates the script
  echo -ag Syntax: /roleplay channeladd #channel <-- adds #channel to the channel listing
  echo -ag Syntax: /roleplay channeldel #channel <-- removes #channel from the channel listing
  echo -ag Syntax: /roleplay charswitch <-- switches between characters in the character list in the order they were added
  echo -ag Syntax: /roleplay characteradd charactername <-- adds charactername to the character list
  echo -ag Syntax: /roleplay characterdel charactername <-- removes charactername from the character list
  echo -ag Syntax: /roleplay whitelist <-- enables whitelist mode if it is not enabled, otherwise enables blacklist mode
  echo -ag Syntax: /roleplay blacklist <-- enables blacklist mode if it is not enabled, otherwise enables whitelist mode
  echo -ag Syntax: /roleplay chancharadd #channel charactername <-- adds charactername to be used in #channel to the channelcharacter list
  echo -ag Syntax: /roleplay chanchardel #channel charactername <-- removes charactername to be used in #channel from the channelcharacter list
  echo -ag Syntax: /roleplay exittoggle <-- toggles the "deactivate script on exit" option
  echo -ag Syntax: /roleplay chancharonly <-- enables the specific channel thing only and not the rest of the script
  echo -ag You can use F11 to enable or disable the script, and F12 to switch between configured characters.
  echo -ag You can use /man roleplay to view the commands again.
}

alias rpsay {
  if ((%roleplay == 0 ) || (%chancharonly == 0)) {
    if (($me isop $active) || ($me ishop $active) || (o isincs $usermode) || ((E isincs $chan($active).mode) && ($me isvoice $active))) {
      if ($left($$1,1) != /) {
        .quote fsay $chan %character $chr(58) $+ $$1-
        haltdef
      }  
      else if ($$1 == /me) {
        .quote faction $chan %character $chr(58) $+ $$2-
        haltdef
      }
      else if ($$1 == /my) {
        .quote faction $chan %character $+ $chr(39) $+ s $chr(58) $+ $$2-
        haltdef
      }
      else if ($$1 == /language) {
        .quote fsay $chan %character $chr(58) $+ $chr(91) $+ $$2 $+ $chr(93) $$3-
        haltdef
      }
    }
    else if ($left($$1,1) != /) {
      if ( %character [ $+ . $+ [ $chan ] ] ) {
        if ($me != %character [ $+ . $+ [ $chan ] ] ) {
          msg $chan $chr(40) $+ %character [ $+ . $+ [ $chan ] ] $+ $chr(41) $1-
          haltdef
        }
        else {
          msg $chan $1-
          haltdef
        }
      }
      else if ((%roleplay == 0) && ($me != %character)) {
        msg $chan $chr(40) $+ %character $+ $chr(41) $1-
        haltdef
      }
      else {
        msg $chan $1-
        haltdef
      }
    }
    else if ($$1 == /me) {
      if ( %character [ $+ . $+ [ $chan ] ] ) {
        if ($me != %character [ $+ . $+ [ $chan ] ] ) {
          describe $chan $chr(40) $+ %character [ $+ . $+ [ $chan ] ] $+ $chr(41) $2-
          haltdef
        }
        else {
          describe $chan $2-
          haltdef
        }
      }
      else if ((%roleplay == 0) && ($me != %character)) {
        describe $chan $chr(40) $+ %character $+ $chr(41) $2-
        haltdef
      }
      else {
        describe $chan $2-
        haltdef
      }
    }  
    else if ($$1 == /my) {
      if ( %character [ $+ . $+ [ $chan ] ] ) {
        if ($me != %character [ $+ . $+ [ $chan ] ] ) {
          describe $chan $chr(39) $+ s $chr(40) $+ %character [ $+ . $+ [ $chan ] ] $+ $chr(39) $+ s $+ $chr(41) $2-
          haltdef
        }
        else {
          describe $chan $chr(39) $+ s $2-
          haltdef
        }
      }
      else if ((%roleplay == 0) && ($me != %character)) {
        describe $chan $chr(39) $+ s $chr(40) $+ %character $+ $chr(39) $+ s $+ $chr(41) $2-
        haltdef
      }
      else {
        describe $chan $chr(39) $+ s $2-
        haltdef
      }
    }
    else if ($$1 == /language) {
      if ( %character [ $+ . $+ [ $chan ] ] ) {
        if ($me != %character [ $+ . $+ [ $chan ] ] ) {
          msg $chan $chr(40) $+ %character [ $+ . $+ [ $chan ] ] $+ $chr(41) $chr(91) $+ $$2 $+ $chr(93) $$3-
          haltdef
        }
        else {
          msg $chan $chr(91) $+ $$2 $+ $chr(93) $$3-
          haltdef
        }
      }
      else if ((%roleplay == 0) && ($me != %character)) {
        if ($istok(%roleplaychannels,$chan,32)) {
          msg $chan $chr(40) $+ %character $+ $chr(41) $chr(91) $+ $$2 $+ $chr(93) $$3-
          haltdef
        }
        else {
          msg $chan $chr(91) $+ $$2 $+ $chr(93) $$3-
        }
      }
      else {
        msg $chan $chr(91) $+ $$2 $+ $chr(93) $$3-
        haltdef
      }
    }
  }
  else if ($left($$1,1) != /) {
    msg $chan $$1-
    haltdef
  }  
  else if ($$1 == /me) {
    describe $chan $$2-
    haltdef
  }  
  else if ($$1 == /my) {
    describe $chan $chr(39) $+ s $$2-
    haltdef
  }
  else if ($$1 == /language) {
    msg $chan $chr(91) $+ $$2 $+ $chr(93) $$3-
    haltdef
  }
}

alias lang {
  if (%chancharonly == 0) {
    if (%character [ $+ . $+ [ $chan ] ]) {
      chancharsay /language $$1-
    }
    else rpsay /language $$1-
  }
  else rpsay /language $$1 $$2-
}

alias quenya {
  lang Quenya $$1-
}

alias elven {
  lang Elven $$1-
}

alias wolven {
  lang Wolven $$1-
}

alias chancharsay {
  var %temp %character
  set %character %character [ $+ . $+ [ $chan ] ]
  rpsay $$1-
  set %character %temp
}

on *:INPUT:#:{
  if (($1 == !roll ) && ($2) && ($3)) {
    haltdef
    if ($2 !isnum) {
      echo -ag $2 is not a number.
      halt
    }
    if ($3 !isnum) {
      echo -ag $3 is not a number.
      halt
    }
    var %numberofdice = $$2
    var %numberofsides = $$3
    var %result = 0
    var %iteration = 0
    while (%iteration < %numberofdice ) {
      %result = %result + $rand(1, %numberofsides )
      inc %iteration
    }
    echo -ag Roll %numberofdice $+ d $+ %numberofsides $+ $chr(58) %result
  }
  if (%roleplaywhitelist == $null) set %roleplaywhitelist 0
  if (%chancharonly == 0) {
    ; FOR CHANNELS THAT ALWAYS HAVE THE SAME CHARACTER
    if (%character [ $+ . $+ [ $chan ] ]) chancharsay $$1-
    ;else if ((%roleplay == 0) && ($istok(%roleplaychannels,$chan,32))) {
    else if (%roleplay == 0) {
      goto nonspecific
    }
    else return
  }
  ; FOR CHANNELS THAT DON'T ALWAYS HAVE THE SAME CHARACTER
  else if ((%roleplay == 0)) {
    ; whitelist mode
    :nonspecific
    if (%roleplaywhitelist == 0) {
      if ($istok(%roleplaychannels,$chan,32)) {
        rpsay $$1-
      }
    }
    ; BLACKLIST MODE
    else {
      if (!$istok(%roleplaychannels,$chan,32)) {
        if (($me isop $chan) || ($me ishop $chan) || (h isincs $usermode)) {
          rpsay $$1-
        }
      }
    }
  }
  else if (($istok(%roleplaychannels,$chan,32)) && (%roleplay != 0) && (%chancharonly == 0)) echo -ag $timestamp Channel-character mode is on. 
}

; Turns off the script when exiting mIRC
on *:EXIT:{ 
  if (%exitrptoggle == $null) set %exitrptoggle 0
  if (%exitrptoggle == 0) { 
    roleplay off 
  }
  titlebar
}

;The configuration command.
;Syntax: /roleplay on charactername <-- activates the script. charactername is optional.
;Syntax: /roleplay off <-- deactivates the script
;Syntax: /roleplay channeladd #channel <-- adds #channel to the channel listing
;Syntax: /roleplay channeldel #channel <-- removes #channel from the channel listing
;Syntax: /roleplay charswitch <-- switches between characters in the character list in the order they were added
;Syntax: /roleplay characteradd charactername <-- adds charactername to the character list
;Syntax: /roleplay characterdel charactername <-- removes charactername from the character list
;Syntax: /roleplay whitelist <-- enables whitelist mode if it is not enabled, otherwise enables blacklist mode
;Syntax: /roleplay blacklist <-- enables blacklist mode if it is not enabled, otherwise enables whitelist mode
;Syntax: /roleplay chancharadd #channel charactername <-- adds charactername to be used in #channel to the channelcharacter list
;Syntax: /roleplay chanchardel #channel charactername <-- removes charactername to be used in #channel from the channelcharacter list
;Syntax: /roleplay exittoggle <-- toggles the "deactivate script on exit" option
;Syntax: /roleplay chancharonly <-- enables/disables the specific channel thing only and not the rest of the script

alias roleplay {
  if ($1 == off) {
    set %roleplay 1
    echo -ag $timestamp Roleplay is now disabled.
    titlebar
    halt
  }
  else if ($1 == on) {
    if ($2 != $null) {
      set %roleplay 0
      set %character $2
      if (%CharacterNames == $null) {
        set %CharacterNames $2
        set %CharacterPosition 1
      }
      else if (!$istok(%CharacterNames,%character,32)) {
        var %temp = %CharacterNames
        set %CharacterNames %temp %character
        set %CharacterPosition $findtok($gettok(%CharacterNames,-1,32),%character,1,32)
      }
      else if ($istok(%CharacterNames, %character, 32)) { 
        set %CharacterPosition $findtok(%CharacterNames, %character, 1, 32))
      }
      echo -ag $timestamp Roleplay is now enabled using character %character $+ .
      titlebar Roleplay using %character
    }
    else if (%character != $null) {
      set %roleplay 0
      echo -ag $timestamp Roleplay is now enabled using character %character $+ .
      titlebar Roleplay using %character
    }
    else echo -ag $timestamp Pick a character, stupid.
  }
  else if ($1 == channeladd) {
    if ($3) {
      echo -ag $timestamp One channel at a time.
      halt
    }
    if ($istok(%roleplaychannels,$2,32)) {
      echo -ag $timestamp That is already in the list.
      halt
    }
    else if (!$istok(%roleplaychannels,$2,32)) { 
      set %roleplaychannels $addtok(%roleplaychannels,$2,32)
      echo -ag $timestamp Roleplay channel list: %roleplaychannels
      halt
    }
  }
  else if ($1 == channeldel) { 
    if ($3) {
      echo -ag $timestamp One channel at a time.
      halt
    }
    if (!$istok(%roleplaychannels,$2,32)) {
      echo -ag $timestamp That channel is not in the list.
      halt
    }
    if ($istok(%roleplaychannels,$2,32)) { 
      set %roleplaychannels $remtok(%roleplaychannels,$2,1,32)
      echo -ag $timestamp Roleplay channel list: $iif((%roleplaychannels), %roleplaychannels, There are no channels set. )
      halt
    }
  }
  else if ($1 == characteradd) {
    set %characternames $addtok(%characternames,$2-,32)
    echo -ag $timestamp The character list now reads: %characternames
    echo -ag $timestamp Note that there may be issues if you try to add one that's already in there.
  }
  else if ($1 == characterdel) {
    if ($3) {
      echo -ag $timestamp One character at a time.
      halt
    }
    if (!$istok(%characternames,$2,32)) {
      echo -ag $timestamp That character is not in the list.
      halt
    }
    else if ($istok(%characternames,$2,32)) {
      set %characternames $remtok(%characternames,$2,1,32)
      echo -ag $timestamp $qt($2) has been removed from the character list. The list now reads: %characternames
      halt
    }
    else echo -ag $timestamp Invalid argument.
  }
  else if ($1 == chanlist) { echo -ag $timestamp $iif(%roleplaychannels, The current list: %roleplaychannels, There are no channels saved.) }
  else if ($1 == charlist) { echo -ag $timestamp $iif(%characternames, The current list: %characternames, There are no characters saved.) }
  else if ($1 == charswitch) {
    if (($2 isnum) && ($2 < $numtok(%CharacterNames,32))) { 
      set %character $gettok(%characternames,$2,32)
      set %characterposition $findtok(%characternames,$2,1,32)
      echo -ag $timestamp New character is %character $+ . 
      if (%roleplay == 0) titlebar Roleplay using %character
      halt
    }
    else if (($2 >= $numtok(%CharacterNames,32)) || (%characterposition >= $numtok(%characternames,32))) {
      set %character $gettok(%characternames,$rand(1,$numtok(%characterposition,32)),32)
      set %characterposition $findtok(%characternames,%character,1,32)
      echo -ag $timestamp New character is %character $+ .
      if (%roleplay == 0) titlebar Roleplay using %character
    }
    else if ($2 !isnum) {
      set %character $gettok(%characternames,$calc(%characterposition + 1),32)
      set %temp $calc(%characterposition + 1)
      set %characterposition %temp
      echo -ag $timestamp New character is %character $+ .
      if (%roleplay == 0) titlebar Roleplay using %character
      halt
    }
  }
  else if ($1 == whitelist) {
    if (%roleplaywhitelist != 0) { 
      set %roleplaywhitelist 0
      echo -ag $timestamp Whitelist mode enabled.
    }
    else {
      set %roleplaywhitelist 1
      echo -ag $timestamp Blacklist mode enabled.
    }
  }
  else if ($1 == blacklist) {
    if (%roleplaywhitelist != 0) { 
      set %roleplaywhitelist 0
      echo -ag $timestamp Whitelist mode enabled.
    }
    else {
      set %roleplaywhitelist 1
      echo -ag $timestamp Blacklist mode enabled.
    }
  }
  else if ($1 == chancharadd) {
    if (($4) || (!$3)) { echo -ag $timestamp Syntax: roleplay chancharadd #channel charactername }
    else {
      set %character [ $+ . $+ [ $2 ] ] $3
      echo -ag $timestamp $2 will now only use $3 $+ .
    }
  }
  else if ($1 == chanchardel) {
    if (($3) || (!$2)) { echo -ag $timestamp Syntax: roleplay chanchardel #channel }
    else {
      if (!%character [ $+ . $+ [ $2 ] ]) {
        echo -ag $timestamp $2 does not have a character assigned to it.
      }
      else {
        unset %character [ $+ . $+ [ $2 ] ]
        echo -ag $timestamp $2 will no longer use only one character.
      }
    }
  }
  else if ($1 == exittoggle) {
    if (%exitrptoggle != 0) { 
      set %exitrptoggle 0
      echo -ag $timestamp RP script will now deactivate on exit.
    }
    else {
      set %exitrptoggle 1
      echo -ag $timestamp RP script will no longer deactivate on exit.
    }
  }
  else if ($1 == chancharonly) {
    if (%chancharonly != 0) {
      set %chancharonly 0
      echo -ag $timestamp Channel-characters are enabled.
    }
    else {
      set %chancharonly 1
      echo -ag $timestamp Channel-characters are disabled.
    }
  }
}

alias F9 roleplay chancharonly

; allows users to toggle the roleplay script on/off by pressing F11
alias F11 {
  if (%roleplay == 0) roleplay off
  else roleplay on
}

; Allows users to press F12 to switch between characters
alias F12 roleplay charswitch

; channel popups for the roleplay script. Made by Goofy of the Caelestia IRC Network.
menu channel {
  RolePlay Functions:
  .Roleplay On/Off: { 
    set %roleplay $$?"On or Off"
    roleplay %roleplay $iif(%roleplay == on, $$?"Character?")
  }
  .Roleplay List 
  ..Channel: { echo -ag $timestamp Roleplay channel list: $iif((%roleplaychannels), %roleplaychannels, There are no channels set. ) }
  ..Character:{ echo -ag $timestamp $iif(%characternames, The current list: %characternames , There are no names saved. ) }
  .RP CharSwitch
  ..Number ( $+ 1- $+ $numtok(%CharacterNames,32) $+ ): {
    roleplay charswitch $input(What number would you like? $+ $crlf $+ You can choose numbers 1- $+ $numtok(%CharacterNames,32) $+ . $+ $crlf $+ $crlf $+ **If the option that is chosen is not between 1- $+ $numtok(%CharacterNames,32) or nothing is chosen a random one will be chosen.,eo,Character Switch Numer.)
    if (($2 isnum) && ($2 <= $numtok(%CharacterNames,32))) { 
      set %character $gettok(%characternames,$2,32) 
    }
  }
  ..Random: {
    roleplay charswitch
    set %character $gettok(%characternames,$rand(1,$numtok(%CharacterNames,32)),32) 
  }
  .RolePlay Add
  ..Channel: {
    roleplay channeladd $$?"Channel to add?"
    set %roleplaychannels $addtok(%roleplaychannels,$2,32)
  }
  ..Character: { 
    roleplay characteradd $$?"Character to add?"
    set %characternames $addtok(%characternames,$2-,32)
  }
  .RolePlay Delete
  ..Channel: { 
    roleplay channeldel $$?"Channel to delete?"
    set %roleplaychannels $remtok(%roleplaychannels,$2,1,32)
  }
  ..Character: { 
    roleplay characterdel $$?"Character to delete?"
    if ($istok(%characternames,$2,32)) { set %characternames $remtok(%characternames,$2,32) | echo -ag $timestamp $qt($2) has been removed from the character list. The list now reads: %characternames }
    if (!$istok(%characternames,$2,32)) { echo -ag $timestamp That character is not in the list. }
  }
  .RolePlay White/Black
  ..WhiteList $iif(%roleplaywhitelist == 0, Disable?, Enable?) $+ : { 
    if (%roleplaywhitelist != 0) { set %roleplaywhitelist 0 }
    else { set %roleplaywhitelist 1 }
  }
  ..BlackList $iif(%roleplaywhitelist == 0, Enable?, Disable?) $+ : { 
    if (%roleplaywhitelist != 0) { set %roleplaywhitelist 0 }
    else { set %roleplaywhitelist 1 }
  }
  .RP ChanChar
  ..Only $iif(%chancharonly == 0, Disable?, Enable?) $+ : { 
    if (%chancharonly != 0) { 
      set %chancharonly 0
      echo -ag $timestamp Character per channel on.
    }
    else { 
      set %chancharonly 1
      echo -ag $timestamp Character per channel off.
    }
  }
  ..Add: { roleplay chancharadd $$?"Channel?" $$?"Character"  }
  ..Delete: { roleplay chanchardel $$?"Channel?" }
  .RP Exit Toggle
  ..$iif(%exitrptoggle == 1, Enable?,Disable?): {
    if (%exitrptoggle != 0) { 
      set %exitrptoggle 0
      echo -ag $timestamp RP script will now deactivate on exit.
    }
    else {
      set %exitrptoggle 1
      echo -ag $timestamp RP script will no longer deactivate on exit.
    }
  }
}

; RTFM
alias man {
  if ($1 == roleplay) {
    echo -ag Syntax: /roleplay on charactername <-- activates the script. charactername is optional.
    echo -ag Syntax: /roleplay off <-- deactivates the script
    echo -ag Syntax: /roleplay charlist <-- returns list of characters
    echo -ag Syntax: /roleplay chanlist <-- returns list of channels
    echo -ag Syntax: /roleplay channeladd #channel <-- adds #channel to the channel listing
    echo -ag Syntax: /roleplay channeldel #channel <-- removes #channel from the channel listing
    echo -ag Syntax: /roleplay charswitch <-- switches between characters in the character list in the order they were added
    echo -ag Syntax: /roleplay charswitch $chr(35) <-- chooses a character based on the number if the number is within the number of names
    echo -ag Syntax: /roleplay characteradd charactername <-- adds charactername to the character list
    echo -ag Syntax: /roleplay characterdel charactername <-- removes charactername from the character list
    echo -ag Syntax: /roleplay whitelist <-- enables whitelist mode if it is not enabled, otherwise enables blacklist mode
    echo -ag Syntax: /roleplay blacklist <-- enables blacklist mode if it is not enabled, otherwise enables whitelist mode
    echo -ag Syntax: /roleplay chancharadd #channel charactername <-- adds charactername to be used in #channel to the channelcharacter list
    echo -ag Syntax: /roleplay chanchardel #channel charactername <-- removes charactername to be used in #channel from the channelcharacter list
    echo -ag Syntax: /roleplay exittoggle <-- toggles the "deactivate script on exit" option
    echo -ag Syntax: /roleplay chancharonly <-- enables the specific channel thing only and not the rest of the script
  }
}

Comments

Sign in to comment.
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.