Group: Member
Posts: 20
Type: Developer
RM Skill: Skilled
Simple Reputation System v1.0
by XIV
Introduction This script enables you to use reputation values which can alter the gameplay significally. Primarily, it obsoletes the need of assigning separate variables for each reputation value as it is the case with most evented reputation systems. By using this script in combination with chioces, a player has to think about his character's future relations with other characters or factions before making a choice.
Features - a separate reputation scene for viewing the values easily - simple script calls for managing the reputation list - a handy pop-up window which pops out whenever a reputation value changes, a new reputation is added or when a reputation is removed from the list
Screenshots
Screenshots
How to Use Copy the script below. Paste it above Main in your project. Customize the script in the customization section and read the instructions. Use and enjoy!
# Credits $ Thanks: # - a big thank-you goes to OriginalWij for his "Chest Item Pop-Up 2" script from # where I got the pop-up text box code for this script,if you use SRS you should # definitely credit him
# Function: # Creates a new scene for managing character/faction reputation. Removes the need of tons # for variables for each individual character/faction reputation value.
# Instructions: # 1. Paste above Main. # 2. Learn the method calls. # 3. Customize the script to your liking using the customization section below. # 4. Use and enjoy!
# Tips & Tricks: # - you should note that the reputation scene is called with an event command # so if you want to call this scene from the menu you should either use the # included menu patch (if you don't use any menu altering scripts) or you # can check for a custom menu script that allows for easy command addition, # if you fail to do it yourself you should contact me at rpgmakervx.net forums # and I'll see what I can do
# Method calls: # Call these methods in the "Script.." event command:
# - $scene = Scene_Rep.new => calls the reputation scene
# - add_rep("name") => adds the name to the list where name is the name of the # character or faction
# - change_rep("name", value) => where name is the name of the char's/faction's # reputation you want to change and value is, well, value by which you want to # increase the reputation (use negative value if you want to subtract)
# - check_rep("name", var) => saves the reputation value of the char/faction # into a variable with ID var
# - rep_defined?("name") => returns true if there is a char/faction in the # reputation list, should be used in a conditional branch
# - delete_rep("name") => removes the char/faction from the reputation list
module XIV module SimRep # ------------------------------------------------------------------------------ # *Customization # ------------------------------------------------------------------------------ # Change the title of the scene TITLE = "Reputation"
# While this switch is OFF the text pop-up will show when you change reputation # or add a new char/faction to the list POPUP_SWITCH = 99
# Determine the speed of the text pop-up (0-slowest, 4-fastest) POPUP_SPEED = 2
# Set this to true if you want the text window to pop up (otherwise it will be # static) POPUP = false
# Set this to false if you don't want a sound to play on pop-up PLAY_SOUND = true # Sound to play upon pop-up S_NAME = 'Audio/SE/Chime2' S_VOLUME = 100 S_PITCH = 150
# Set this to true if you want a button press to terminate the window BUTTON_WAIT = false # Which buttons should be pressed to terminate the pop-up window BUTTON_1 = Input::C BUTTON_2 = Input::B
# Frames to wait to terminate the pop-up window automatically (if the above is # false) TIME = 60 # ------------------------------------------------------------------------------ # *End Customization # ------------------------------------------------------------------------------ end end
#------------------------------------------------------------------------------- # - reputation data dump #------------------------------------------------------------------------------- class Game_System attr_accessor :rep_name attr_accessor :rep_val
alias rep_initialize initialize def initialize rep_initialize @rep_name = [] @rep_val = [] end end
#------------------------------------------------------------------------------- # - control methods #------------------------------------------------------------------------------- class Game_Interpreter def add_rep(name) $game_system.rep_name.push name $game_system.rep_val.push 0 $scene.item_popup(name,0) unless $game_switches[XIV::SimRep::POPUP_SWITCH] end
def change_rep(name, value) $game_system.rep_val[$game_system.rep_name.index(name)] += value $scene.item_popup(name,value) unless $game_switches[XIV::SimRep::POPUP_SWITCH] end
def check_rep(name,var) ret = $game_system.rep_val[$game_system.rep_name.index(name)] $game_variables[var] = ret end
def rep_defined?(name) for i in 0...$game_system.rep_name.size if $game_system.rep_name[i] == name return true end end return false end
def delete_rep(name) del = $game_system.rep_name.index(name) $game_system.rep_name.delete_at(del) $game_system.rep_val.delete_at(del) $scene.item_popup(name,0,true) unless $game_switches[XIV::SimRep::POPUP_SWITCH] end end
#------------------------------------------------------------------------------- # - window setting #------------------------------------------------------------------------------- class Window_Reputation < Window_Selectable def initialize(x, y, width, height) super(x, y, width, height) @column_max = 1 self.index = 0 @data = $game_system.rep_name refresh end
def refresh @item_max = @data.size create_contents for i in 0...@item_max draw_item(i) end end
def draw_rep_name(name, x, y) if name != nil self.contents.font.color = normal_color self.contents.draw_text(x+10, y, 172, WLH, name) end end
def sign(num) if num > 0 self.contents.font.color.set(0,255,0) sign = "+%d" elsif num < 0 self.contents.font.color.set(255,0,0) sign = "%d" elsif num == 0 sign = "%d" end return sign end
def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) item = @data[index] if item != nil number = $game_system.rep_val[index] rect.width -= 4 draw_rep_name(@data[index], rect.x, rect.y) self.contents.draw_text(rect, sprintf(sign(number), number), 2) self.contents.font.color = normal_color end end end #------------------------------------------------------------------------------- # - popup window by OriginalWij #------------------------------------------------------------------------------- class Scene_Base def item_popup(text, amount, del=false) x = $game_player.screen_x - 26 y = $game_player.screen_y - 48 @popup_window = Window_Base.new(x, y, 56, 56) @popup_window.opacity = @popup_window.contents_opacity = 0 if $game_temp.in_battle @popup_window.x = (Graphics.width - @popup_window.width) / 2 @popup_window.y = Graphics.height / 2 - 64 end max = XIV::SimRep::POPUP_SPEED * 4 + 16 for i in 1..max @popup_window.contents_opacity = i * (256 / max) @popup_window.y -= (32 / max) @popup_window.update Graphics.update end if XIV::SimRep::PLAY_SOUND Audio.se_play(XIV::SimRep::S_NAME, XIV::SimRep::S_VOLUME, XIV::SimRep::S_PITCH) end
if del am_str = "REMOVED!" elsif amount > 0 am_str = "+"+amount.to_s elsif amount < 0 am_str = amount.to_s elsif amount == 0 am_str = "NEW!" end
width = @popup_window.contents.text_size(text).width + 10 a_width = @popup_window.contents.text_size(am_str).width x = (Graphics.width - (width + a_width + 32)) / 2 y = (Graphics.height - 56) / 2 y += 32 if XIV::SimRep::POPUP @name_window = Window_Base.new(x, y, width + a_width + 32, 56) @name_window.opacity = @name_window.contents_opacity = 0 w = width + a_width
if amount > 0 @name_window.contents.font.color.set(0,255,0) elsif amount < 0 @name_window.contents.font.color.set(255,46,0) elsif amount == 0 @name_window.contents.font.color.set(255,255,0) end
@name_window.contents.draw_text(width, 0, w, 24, am_str) @name_window.contents.font.color.set(255,255,255) @name_window.contents.draw_text(0, 0, w, 24, text) for i in 1..max @name_window.y -= (32 / max) if XIV::SimRep::POPUP @name_window.contents_opacity = i * (256 / max) @name_window.opacity = i * (256 / max) @name_window.update Graphics.update end count = 0 loop do Graphics.update Input.update count += 1 unless XIV::SimRep::BUTTON_WAIT break if Input.trigger?(XIV::SimRep::BUTTON_1) and XIV::SimRep::BUTTON_WAIT break if Input.trigger?(XIV::SimRep::BUTTON_2) and XIV::SimRep::BUTTON_WAIT break if count == XIV::SimRep::TIME and !XIV::SimRep::BUTTON_WAIT end for i in 1..max @popup_window.contents_opacity = 256 - i * (256 / max) @name_window.opacity = 256 - i * (256 / max) @name_window.contents_opacity = 256 - i * (256 / max) @popup_window.update @name_window.update Graphics.update end @popup_window.dispose @name_window.dispose Input.update end end
#------------------------------------------------------------------------------- # - reputation scene processing #------------------------------------------------------------------------------- class Scene_Rep < Scene_Base def start super create_menu_background @viewport = Viewport.new(0, 0, 544, 416) @help_window = Window_Help.new @help_window.viewport = @viewport x = (Graphics.width/2)-(350/2) @rep_window = Window_Reputation.new(x, 56,350, 360) @rep_window.viewport = @viewport @rep_window.help_window = @help_window @rep_window.active = true @help_window.set_text(XIV::SimRep::TITLE,1) end
def terminate super dispose_menu_background @viewport.dispose @help_window.dispose @rep_window.dispose end
def return_scene $scene = Scene_Menu.new(0) end
def update super update_menu_background @help_window.update @rep_window.update if @rep_window.active update_rep_selection end end
def update_rep_selection if Input.trigger?(Input::B) Sound.play_cancel return_scene end end
end
Credit - OriginalWij (pop-up window) - myself(XIV), not mandatory
Author's Notes Any bugs reports and suggestions should be posted in this thread or sent to me via PM. This script should have very high compatibility as almost all methods are new.
This post has been edited by XIV: Nov 25 2010, 09:36 AM
Group: Member
Posts: 1
Type: Developer
RM Skill: Intermediate
(I know this is a little old -.-) I seem to only be able to play it in the demo...and even then it crashes at times. When I started the cataclysm it crashed & after I gave the red crown to the blue castle it crashed....&& when I tried to put it in my own game it wasn't compatible with any Scripts I had.
Scripts Used
Phone System - Necrozard (I know why, because of the menu)
Item Storage System - IMP1
Map Name Popup - Dargor
Skill Teaching Equipment & Items - modern algebra
When I used the call scripts they never worked. I even copied them from your demo and tried. I tried with none of the scripts I was using and it wouldn't work. I don't really know the problem
But other than that it looked amazing ^.^
First Error: When I started the Cataclysm Error_1.jpg ( 11.64K )
Number of downloads: 11
Second Error: When I talk to the Red King after getting his crown (Might just be a switch mistake or something ) Error_2.jpg ( 12.39K )
Number of downloads: 7
This post has been edited by skullwarrier: Jun 10 2011, 01:05 PM
__________________________
Open it :O
HOLY CRAP :O SPOILER!!!!
Skillz
Eventing-Intermediate Graphics-Beginner Scripting-NONE :( Open Mind-Grand Master
Group: Member
Posts: 20
Type: Developer
RM Skill: Skilled
I downloaded the same demo linked here and checked for the crashes you mentioned and they didn't happen. Are you sure you use the script commands in the right format because these errors point that the commands aren't used properly...maybe you don't have the variable fix, I guess that could be the problem. About compatibility, this script should, theoretically, be compatible with every other script since it doesn't overwrite any of the basic methods. I suggest you definitely check if you have the variable fix (if you don't, get it) and if that doesn't work post the exact script commands you use. I hope you can get this to work
# Credits $ Thanks: # - a big thank-you goes to OriginalWij for his "Chest Item Pop-Up 2" script from # where I got the pop-up text box code for this script,if you use SRS you should # definetly credit him
# Function: # Creates a new scene for managing character/faction reputation. Removes the need of tons # for variables for each individual character/faction reputation value.
# Instructions: # 1. Paste above Main. # 2. Learn the method calls. # 3. Customize the script to your liking using the customization section below. # 4. Use and enjoy!
# Tips & Tricks: # - you should note that the reputation scene is called with an event command # so if you want to call this scene from the menu you should either use the # included menu patch (if you don't use any menu altering scripts) or you # can check for a custom menu script that allows for easy command additon, # if you fail to do it yourself you should contact me at rpgmakervx.net forums # and I'll se what I can do
# Method calls: # Call these methods in the "Script.." event command:
# - $scene = Scene_Rep.new => calls the reputation scene
# - add_rep("name") => adds the name to the list where name is the name of the # character or faction
# - change_rep("name", value) => where name is the name of the char's/faction's # reputation you want to change and value is, well, value by which you want to # increase the reputation (use negative value if you want to subtract)
# - check_rep("name", var) => saves the reputation value of the char/faction # into a variable with ID var
# - rep_defined?("name") => returns true if there is a char/faction in the # reputation list, should be used in a conditional branch
# - delete_rep("name") => removes the char/faction from the reputation list
module XIV module SimRep # ------------------------------------------------------------------------------ # *Customization # ------------------------------------------------------------------------------ # Change the title of the scene TITLE = "Reputation"
# The maximum amount of rep/hate LIMIT = 9999
# While this switch is OFF the text pop-up will show when you change reputation # or add a new char/faction to the list POPUP_SWITCH = 99
# Determine the speed of the text pop-up (0-slowest, 4-fastest) POPUP_SPEED = 2
# Set this to true if you want the text window to pop up (otherwise it will be # static) POPUP = false
# Set this to false if you don't want a sound to play on pop-up PLAY_SOUND = true # Sound to play upon pop-up S_NAME = 'Audio/SE/Chime2' S_VOLUME = 100 S_PITCH = 150
# Set this to true if you want a button press to terminate the window BUTTON_WAIT = false # Which buttons should be pressed to terminate the pop-up window BUTTON_1 = Input::C BUTTON_2 = Input::B
# Frames to wait to terminate the pop-up window automatically (if the above is # false) TIME = 60 # ------------------------------------------------------------------------------ # *End Customization # ------------------------------------------------------------------------------ end end
#------------------------------------------------------------------------------- # - reputation data dump #------------------------------------------------------------------------------- class Game_System attr_accessor :rep_name attr_accessor :rep_val
alias rep_initialize initialize def initialize rep_initialize @rep_name = [] @rep_val = [] end end
#------------------------------------------------------------------------------- # - control methods #------------------------------------------------------------------------------- class Game_Interpreter def add_rep(name) $game_system.rep_name.push name $game_system.rep_val.push 0 $scene.item_popup(name,0) unless $game_switches[XIV::SimRep::POPUP_SWITCH] end
def check_rep(name,var) ret = $game_system.rep_val[$game_system.rep_name.index(name)] $game_variables[var] = ret end
def rep_defined?(name) for i in 0...$game_system.rep_name.size if $game_system.rep_name[i] == name return true end end return false end
def delete_rep(name) del = $game_system.rep_name.index(name) $game_system.rep_name.delete_at(del) $game_system.rep_val.delete_at(del) $scene.item_popup(name,0,true) unless $game_switches[XIV::SimRep::POPUP_SWITCH] end end
#------------------------------------------------------------------------------- # - window setting #------------------------------------------------------------------------------- class Window_Reputation < Window_Selectable def initialize(x, y, width, height) super(x, y, width, height) @column_max = 1 self.index = 0 @data = $game_system.rep_name refresh end
def draw_bar(curr, max, x, y, width, height, gc1, gc2 = Color.new(255, 255, 255), color_back = Color.new(0, 0, 0)) gw = width * curr / max self.contents.fill_rect(x, y + 2, width, WLH - 4, color_back) self.contents.gradient_fill_rect(x, y + 2, gw, WLH - 4, gc1, gc2) end
def refresh @item_max = @data.size create_contents for i in 0...@item_max draw_item(i) end end
def draw_rep_name(name, x, y) if name != nil self.contents.font.color = normal_color self.contents.draw_text(x+10, y, 172, WLH, name) end end
def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) item = @data[index] if item != nil number = $game_system.rep_val[index] if number == 0 c1 = normal_color elsif number > 0 c1 = Color.new(0, 255, 0) else c1 = Color.new(255, 0, 0) end red = [[c1.red + 30, 0].max, 255].min green = [[c1.green + 30, 0].max, 255].min blue = [[c1.blue + 30, 0].max, 255].min c2 = Color.new(red, green, blue) contents.font.color = c1 contents.draw_text(rect.x, rect.y, rect.width / 2, rect.height, item) x = rect.x + rect.width / 2 draw_bar(number.abs, XIV::SimRep::LIMIT, x, rect.y, rect.width / 2, rect.height, c1, c2) self.contents.font.color = normal_color end end end #------------------------------------------------------------------------------- # - popup window by OriginalWij #------------------------------------------------------------------------------- class Scene_Base def item_popup(text, amount, del=false) x = $game_player.screen_x - 26 y = $game_player.screen_y - 48 @popup_window = Window_Base.new(x, y, 56, 56) @popup_window.opacity = @popup_window.contents_opacity = 0 if $game_temp.in_battle @popup_window.x = (Graphics.width - @popup_window.width) / 2 @popup_window.y = Graphics.height / 2 - 64 end max = XIV::SimRep::POPUP_SPEED * 4 + 16 for i in 1..max @popup_window.contents_opacity = i * (256 / max) @popup_window.y -= (32 / max) @popup_window.update Graphics.update end if XIV::SimRep::PLAY_SOUND Audio.se_play(XIV::SimRep::S_NAME, XIV::SimRep::S_VOLUME, XIV::SimRep::S_PITCH) end
if del am_str = "REMOVED!" elsif amount > 0 am_str = "+"+amount.to_s elsif amount < 0 am_str = amount.to_s elsif amount == 0 am_str = "NEW!" end
width = @popup_window.contents.text_size(text).width + 10 a_width = @popup_window.contents.text_size(am_str).width x = (Graphics.width - (width + a_width + 32)) / 2 y = (Graphics.height - 56) / 2 y += 32 if XIV::SimRep::POPUP @name_window = Window_Base.new(x, y, width + a_width + 32, 56) @name_window.opacity = @name_window.contents_opacity = 0 w = width + a_width
if amount > 0 @name_window.contents.font.color.set(0,255,0) elsif amount < 0 @name_window.contents.font.color.set(255,46,0) elsif amount == 0 @name_window.contents.font.color.set(255,255,0) end
@name_window.contents.draw_text(width, 0, w, 24, am_str) @name_window.contents.font.color.set(255,255,255) @name_window.contents.draw_text(0, 0, w, 24, text) for i in 1..max @name_window.y -= (32 / max) if XIV::SimRep::POPUP @name_window.contents_opacity = i * (256 / max) @name_window.opacity = i * (256 / max) @name_window.update Graphics.update end count = 0 loop do Graphics.update Input.update count += 1 unless XIV::SimRep::BUTTON_WAIT break if Input.trigger?(XIV::SimRep::BUTTON_1) and XIV::SimRep::BUTTON_WAIT break if Input.trigger?(XIV::SimRep::BUTTON_2) and XIV::SimRep::BUTTON_WAIT break if count == XIV::SimRep::TIME and !XIV::SimRep::BUTTON_WAIT end for i in 1..max @popup_window.contents_opacity = 256 - i * (256 / max) @name_window.opacity = 256 - i * (256 / max) @name_window.contents_opacity = 256 - i * (256 / max) @popup_window.update @name_window.update Graphics.update end @popup_window.dispose @name_window.dispose Input.update end end
#------------------------------------------------------------------------------- # - reputation scene processing #------------------------------------------------------------------------------- class Scene_Rep < Scene_Base def start super create_menu_background @viewport = Viewport.new(0, 0, 544, 416) @help_window = Window_Help.new @help_window.viewport = @viewport x = (Graphics.width/2)-(350/2) @rep_window = Window_Reputation.new(x, 56,350, 360) @rep_window.viewport = @viewport @rep_window.help_window = @help_window @rep_window.active = true @help_window.set_text(XIV::SimRep::TITLE,1) end
def terminate super dispose_menu_background @viewport.dispose @help_window.dispose @rep_window.dispose end
def return_scene $scene = Scene_Menu.new(0) end
def update super update_menu_background @help_window.update @rep_window.update if @rep_window.active update_rep_selection end end
def update_rep_selection if Input.trigger?(Input::B) Sound.play_cancel return_scene end end
end
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.