Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Iinfamy / Arrest System

Infamy / Arrest system
v1.0

Intro
This is a basic script which allows you to get the character arrested for certain crimes. You can escape by bailing with money, appealing, or pleading guilty (getting executed)

Okay heres how it works.
You do something bad like talk to someone rudely and your Reputation goes down.
You do something wrong, for example, attack a police officer and it goes down even further, or your Infamy goes up. If you lose the battle against the police officer though, they will take you to jail.
In jail you have three options.
1 - Pay a bail of 2000G.
This will get you out easily, but will raise your Infamy by 1. If you don't have the money, you can't do this.
2 - Appeal
This will allow you to try to plead innocent. This is based on your Rep. If you do this, and your rep is below 5, you will be executed. If it is 5 or over, you will live, your Rep will be reduced, and your Infamy will be 0 again.
3 - Plead guilty
If all else fails, say you did it and die. This is a last resort.

To understand it all, you need to play the demo really. It helps you understand.

OTHER STUFF
Number of arrests is how many times you've seen the Infamy screen.
This is a working progress and all this will be made better at a later date.

FUTURE ADDONS:
- Ability to arrest other people
- More options
- More flexible offences
- More detailed trial in 'Appeal'.


SCRIPTS:
Insert in a new scene above Main and call it Infamy System.
Code:
#=====================
#Infamy and Reputation System v1.0
#by Rubymatt
#=====================

class Scene_Infamy
  def main
    $game_variables[$data_system.variables.index("Arrest No.")] += 1
    s1 = "Pay Bail"
    s2 = "Appeal"
    s3 = "Plead Guilty"
    @command_window = Window_Command.new(192, [s1, s2, s3])
    @command_window.x = 32
    @command_window.y = 320
    @offence_window = Window_Offence.new
    @info_window = Window_Info.new
    @arrest_window = Window_Arrest.new
    if $game_party.gold < 2000
      @command_window.disable_item(0)
    end
    if $game_variables[$data_system.variables.index("Infamy")] >= 5
      @command_window.disable_item(1)
    end
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @info_window.dispose
    @arrest_window.dispose
    @offence_window.dispose
    if $scene.is_a?(Scene_Title)
      Graphics.transition
      Graphics.freeze
    end
  end
  def update
    @command_window.update
    @offence_window.update
    @info_window.update
    @arrest_window.update
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        if $game_party.gold < 2000
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_PayBail.new
      when 1  
        if $game_variables[$data_system.variables.index("Infamy")] >= 5
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Appeal.new
      when 2         
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Guilty.new
      end
      return
    end
  end
end

#Scene_PayBail
class Scene_PayBail
  def main
    @pay_window = Window_Pay.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @pay_window.dispose
    if $scene.is_a?(Scene_Title)
      Graphics.transition
      Graphics.freeze
    end
  end
  def update
    @pay_window.update
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      $game_variables[$data_system.variables.index("Infamy")] += 1
      $game_party.lose_gold(2000)
      $scene = Scene_Map.new
    end
  end
end


#Scene_Guilty
class Scene_Guilty
  def main
    @guilty_window = Window_Guilty.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @guilty_window.dispose
    if $scene.is_a?(Scene_Title)
      Graphics.transition
      Graphics.freeze
    end
  end
  def update
    @guilty_window.update
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      $scene = Scene_Gameover.new
    end
  end
end

#Scene_Appeal
class Scene_Appeal
  def main
    @appeal_window = Window_Appeal.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @appeal_window.dispose
    if $scene.is_a?(Scene_Title)
      Graphics.transition
      Graphics.freeze
    end
  end
  def update
    @appeal_window.update
    if Input.trigger?(Input::C)
      if $game_variables[$data_system.variables.index("Rep")] < 5
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Gameover.new
      else
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new    
        $game_variables[$data_system.variables.index("Rep")] -= 3
        $game_variables[$data_system.variables.index("Infamy")] == 0
      end
    end
  end
end


#Window_Offence
class Window_Offence < Window_Base
  def initialize
    super(32, 32, 576, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 22
    self.contents.font.name = "Arial"
    refresh
  end
  def refresh
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 0, 560, 32,  "You have committed the following offence:", 1)
    self.contents.font.color = Color.new(255, 255, 255)
    if $game_variables[$data_system.variables.index("Crime")] == 0
      self.contents.draw_text(0, 32, 544, 32,  "Assault of a Police Officer") #Edit your reasons here.
    elsif $game_variables[$data_system.variables.index("Crime")] == 1
      self.contents.draw_text(0, 32, 544, 32,  "Assault of an Innocent Person") #Edit your reasons here.
    elsif $game_variables[$data_system.variables.index("Crime")] == 2
      self.contents.draw_text(0, 32, 544, 32,  "Insert Third Custom Offence Here") #Edit your reasons here.
    else
      self.contents.draw_text(0, 32, 544, 32,  "")
    end
    self.contents.draw_text(0, 64, 544, 32,  "")
  end
end  

#Window_Info
class Window_Info < Window_Base
  def initialize
    super(32, 128, 192, 192)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 22
    self.contents.font.name = "Arial"
    refresh
  end
  def refresh
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 0, 176, 32,  "Status", 1)
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 32, 176, 32, "Arrest No.")
    self.contents.font.color = Color.new(255, 255, 255)
    self.contents.draw_text(80, 32, 80, 32, $game_variables[$data_system.variables.index("Arrest No.")].to_s, 2)
    cx = contents.text_size($data_system.words.gold).width
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 64, 176, 32, "Money:")
    if $game_party.gold > 2000
      self.contents.font.color = Color.new(110, 255, 110)
    else
      self.contents.font.color = Color.new(255, 255, 255)
    end
    self.contents.draw_text(60, 64, 100-cx-2, 32, $game_party.gold.to_s, 2)
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(160-cx, 64, cx, 32, $data_system.words.gold, 2)
    self.contents.draw_text(0, 96, 176, 32,  "Reputation:")
    if $game_variables[$data_system.variables.index("Rep")] >= 10
      self.contents.font.color = Color.new(110, 255, 110)
    elsif $game_variables[$data_system.variables.index("Rep")] < 0
      self.contents.font.color = Color.new(255, 0, 0)
    else
      self.contents.font.color = Color.new(255, 255, 255)
    end
    self.contents.draw_text(80, 96, 80, 32,  $game_variables[$data_system.variables.index("Rep")].to_s, 2)
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 128, 176, 32,  "Infamy: ")
    if $game_variables[$data_system.variables.index("Infamy")] == 0
      self.contents.font.color = Color.new(110, 255, 110)
    elsif $game_variables[$data_system.variables.index("Infamy")] >= 5
      self.contents.font.color = Color.new(255, 0, 0)
    else
      self.contents.font.color = Color.new(255, 255, 255)
    end
    self.contents.draw_text(80, 128, 80, 32,  $game_variables[$data_system.variables.index("Infamy")].to_s, 2)
  end
end

#Window_Arrest
class Window_Arrest < Window_Base
  def initialize
    super(224, 128, 384, 320)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 22
    self.contents.font.name = "Arial"
    self.opacity = 0
    refresh
  end
  def refresh
    @logo = RPG::Cache.picture("Guilty.png")
    self.contents.blt(96, 64, @logo, Rect.new(0, 0, 160, 160))
  end
end

#Window_PleadGuilty
class Window_Guilty < Window_Base
  def initialize
    super(32, 144, 576, 128)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 24
    self.contents.font.name = "Arial"
    refresh
  end
  def refresh
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 0, 544, 32,  "You have plead guilty to your offence.", 1)
    self.contents.font.color = Color.new(255, 255, 255)
    self.contents.draw_text(0, 32, 544, 32,  "You were taken to a grotty jail cell for a week before finally")
    self.contents.draw_text(0, 64, 544, 32,  "being taken away by the police and executed.  Your life has ended.")
  end
end  

#Window_Pay
class Window_Pay < Window_Base
  def initialize
    super(160, 192, 288, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 24
    self.contents.font.name = "Arial"
    refresh
  end
  def refresh
    self.contents.font.color = Color.new(255, 255, 255)
    self.contents.draw_text(0, 0, 544, 32,  "Paid 2000" + $data_system.words.gold + " to escape jail.")
  end
end

#Window_Appeal
class Window_Appeal < Window_Base
  def initialize
    super(32, 128, 576, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 24
    self.contents.font.name = "Arial"
    refresh
  end
  def refresh
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 0, 544, 32,  "You have chosen to appeal.", 1)
    self.contents.font.color = Color.new(255, 255, 255)
    if $game_variables[$data_system.variables.index("Rep")] < 5
      self.contents.draw_text(0, 32, 544, 32,  "Your Reputation was low.  The appeal failed.", 1)
      self.contents.draw_text(0, 64, 544, 32,  "You were taken to a grotty jail cell for a week before finally")
      self.contents.draw_text(0, 96, 544, 32,  "being taken away by the police and executed.  Your life has ended.")
    else
      self.contents.draw_text(0, 32, 544, 32,  "Your Reputation was high.  The appeal Succeeded!", 1)
      self.contents.draw_text(0, 64, 544, 32,  "You were released without charge.  Your reputation was")
      self.contents.draw_text(0, 96, 544, 32,  "reduced by 3 and your infamy was also reduced to 0.")
    end
  end
end
And then a little addon for your Status scene.
Call this Scene_JailInfo, and below the other script.

Code:
class Scene_JailInfo
  def main
    @jail_window = Window_JailInfo.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @jail_window.dispose
    if $scene.is_a?(Scene_Title)
      Graphics.transition
      Graphics.freeze
    end
  end
  def update
    @jail_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.decision_se)
      $scene = Scene_Map.new #CHANGE THIS LINE IF NEEDED
    end
  end
end

class Window_JailInfo < Window_Base
  def initialize
    super(224, 144, 192, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 24
    self.contents.font.name = "Arial"
    refresh
  end
  def refresh
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 0, 144, 32,  "Status", 1)
    self.contents.draw_text(0, 32, 144, 32,  "Arrests:")
    self.contents.font.color = Color.new(255, 255, 255)
    self.contents.draw_text(80, 32, 80, 32, $game_variables[$data_system.variables.index("Arrest No.")].to_s, 2)
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 64, 144, 32,  "Reputation:")
    self.contents.font.color = Color.new(255, 255, 255)
    self.contents.draw_text(80, 64, 80, 32, $game_variables[$data_system.variables.index("Rep")].to_s, 2)
    self.contents.font.color = Color.new(192, 224, 255)
    self.contents.draw_text(0, 96, 144, 32,  "Infamy")
    self.contents.font.color = Color.new(255, 255, 255)
    self.contents.draw_text(80, 96, 80, 32, $game_variables[$data_system.variables.index("Infamy")].to_s, 2)
  end
end
To call an arrest, use $scene = Scene_Infamy.new
Call the status window with $scene = Scene_JailInfo.new

Insert the scripts and call them as required.
Add the graphic below to the pictures folder.
Go into your variable editor and make 4 variables. Doesn't matter what ID.
Just call em:
"Crime", "Arrest No.", "Rep", and "Infamy" without the ""s.

EDITING THE CRIME:
At the top of the main scene is the crime you comitted. You can make your own on the lines around line 189 of Scene_Infamy. Then before calling the scene, change this to the number as is with the others.
So by default:
0 = Assault of a police officer
1 = Assault of an innocent person
2 = Insert Third Custom Offence Here

NOTE: The status script is NOT required. It is just a simple thing you can use if you want to see how your Police Records are.

ADDING THE GRAPHIC
You need to put this graphic in your pictures folder:
http://www.rubygames.net/gallery/albums ... Guilty.png[/IMG]

Use any colour as the transparency.

ALTERNATIVELY: Make a graphic 160x160 and entitle it "Guilty" and put it in the Pictures folder.

DEMO:
http://www.uploading.com/files/CGWDSBZG/Infamy_v1.0.rar.html

Give credit and enjoy!


 
1) Limit the use of the in-game variables, I would suggest creating a Game_PoliceRecord or Game_CrimeRecord (what ever name you want) (using the variables you used as instance variables) and then let it be an object of class Game_Actor, this way you can have individual Crime Records.

2) Bug?
Code:
$game_variables[$data_system.variables.index("Infamy")] == 0

3) Instead of hard-coding numbers and strings make them constants, it will increase user friendliness since they woun't have to goto line 48 to change this number and then line 78 to change that same number, stuff like the gold required and the reputation lost from a appeal would have been better off as a constant

4)
Code:
    if Input.trigger?(Input::C)
      if $game_variables[$data_system.variables.index("Rep")] < 5
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Gameover.new
      else
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new    
        $game_variables[$data_system.variables.index("Rep")] -= 3
        $game_variables[$data_system.variables.index("Infamy")] == 0
      end
    end

If a line of code is in both the if and else sections of the if-else block then you can move it out of the block, in this case, $game_system.se_play($data_system.decision_se) could have been moved out.

But well I kind-of liked the design of the windows. I see that you put that code I gave you to good use as well, even though you shouldn't use ingame variables in a script, unless it refers to events.
 
I got the idea when playing Need for Speed Most Wanted the other day and I could choose to pay, use a tag or have my car destroyed :P

Thanks for the feedback Trickster, I'll be remaking it like all my other scripts in time.
 
Perhaps you could make some lighter sentences. Maybe they could go to jail and loose experience from lack of use. Not all crimes call for the death penalty.

Pretty interesting otherwise.
 
Kickass script. I would like to be able to change the punishment given, though. Loss of experience seems lieka good idea, someone here said so. In a game called 'Morrowind' which has a very similar system to this, you go to jail; therefore, the game clock numbre of days goes up and your stats go down thanks to not upgrading them in prison. It's a good system, maybe you could add that?
 
I was thinkning about the no. of days thing but I need a No. of Days script to work off.

EXP will come soon, maybe out of Appeal.
 
Number of days wouldn't really be important unless days were already an important part of the sript, such as in morrowind (It's funny to look back and see you wasted 105 days doing nothing important to the big plot). In any case Appeal and bail money should have a little more randomosity thrown in. Bail money and exp lost from prison time for being charged guilty shoud should be based off of seriousness of crime.
 
the Demo is OK, in my project dont'work, 1 error Game_Variables on line 20,
here :    if variable_id <= 5000 and @data[variable_id] != nil

Very a good work! is magnificent
 
Dude, awesome script! It works perfectly. I am just sorry I am not going to use it. I have a thieving system using events in my game...
Knights of Cydonia? I see someone is quite original. Like Muse do you?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top