#Allows you to give players titles, such as Sir, Madam etc.
Code:
#===============================================================================
# Cool Player Titles
# by Swdfm
#===============================================================================
#
# To use, call $Trainer.title
# Recommended for use in Trainer Cards etc.
#
#===============================================================================
#===============================================================================
#
# - PLAYERTITLES is a constant used for the variable to store all the
# unlocked titles.
# - The array from pbPlayerTitle is where you are to put your title
# names.
# - Use pbUnlockTitle(NUMBER) to unlock titles. NUMBER is the index of
# the title from the array just mentioned. Begins with 0.
# - pbLockTitle(NUMBER) locks the title.
# - pbStripTitle(NUMBER) makes the title blank.
# - Call pbChooseTitle to pick a title from a list of unlocked titles.
# add an argument to give a message while selecting.
# eg. pbChooseTitle("Pick a cool title!")
# Ensure at least one title is unlocked before calling this.
# - Call pbCheckTitle(NUMBER) to check if a certain title has been
# unlocked.
#
#===============================================================================
#
# Thanks for using, and please credit Swdfm if used in your game.
#
#===============================================================================
PLAYERTITLES = 19 #Change this number to an empty global variable.
def pbPlayerTitle
#Change these to titles you want for your own game.
array=[
(_INTL("Trainer")), (_INTL("Sir")), (_INTL("Lord")),
(_INTL("Count")), (_INTL("Duke")), (_INTL("Master")),
(_INTL("Priest")), (_INTL("Ninja")), (_INTL("Student")),
(_INTL("Warrior")), (_INTL("Fighter")), (_INTL("Champion"))
]
if $Trainer.isFemale?
array[1]=(_INTL("Madam"))
array[2]=(_INTL("Lady"))
array[3]=(_INTL("Countess"))
array[4]=(_INTL("Duchess"))
array[6]=(_INTL("Priestess"))
end
return array
end
def pbInitTitles
#Makes all the titles into an array full of falses.
if pbGet(PLAYERTITLES)==0
$game_variables[PLAYERTITLES]=[[]]
for i in 0...pbPlayerTitle.length
$game_variables[PLAYERTITLES][i]=false
end
end
end
def pbListTitles
#Returns an array of your unlocked titles.
pbInitTitles
array=[]
unlock=$game_variables[PLAYERTITLES]
for i in 0...unlock.length
if unlock[i]==true
array.push(pbPlayerTitle[i])
end
end
return array
end
def pbChooseTitle(message=nil)
#Gives a list of available titles that you can select from and pick a title.
array=pbListTitles
if array != nil
command=Kernel.pbShowCommands(message,array,-1) if message==nil
command=Kernel.pbMessage(message,array) if message != nil
if command != -1
name=array[command]
if name==$Trainer.title
Kernel.pbMessage(_INTL("You already have this title!"))
return true
end
$Trainer.title=name
Kernel.pbMessage(_INTL("Your title has been changed to {1}!",name))
return true
end
end
return false
end
def pbStripTitle
#Obviously, removes your title without locking it.
$Trainer.title=""
end
def pbUnlockTitle(num)
#Unlocks a title
pbInitTitles
if !pbCheckTitle(num)
$game_variables[PLAYERTITLES][num]=true
name=pbPlayerTitle[num]
Kernel.pbMessage(_INTL("You can now get the title of {1}!",name))
end
end
def pbLockTitle(num)
#Locks a title
pbInitTitles
$game_variables[PLAYERTITLES][num]=false
end
def pbCheckTitle(num)
#Checks you have a certain title.
pbInitTitles
return true if $game_variables[PLAYERTITLES][num]
return false
end
class PokeBattle_Trainer
attr_accessor(:title)
end