Jump to content
DP3

Morality Metre for Menu

Recommended Posts

Morality Metre for Menu

Version: 1.0

Author: DiamondandPlatinum3

Date: December 8, 2012

 

 

 

Planned Future Versions

  • You tell me :)
Description

This script puts a morality bar inside of your menu, allowing you to have different colours and titles along with it.

 

 

 

Features

  • Shows a bar inside of your menu which displays your current morality, the location of this bar can be move at user discretion
Screenshots

 

 

 

1101042150c6788504d03.png

 

 

 

Instructions

  • Setup what is necessary in the editable region of the script
Script

Get it from Here

 

Patches / Add-Ons

 

Morality Title Escape Character: This Add-On makes it so that in any of your events, when you display a variable with the same ID as the Morality Variable, it will convert the display into your current morality title.

 

Morality Gauge Difference: This Add-On makes it so that your morality metre now shows the offset between good and evil. The more you align yourself to one type of morality, the further the gauge goes in a certain direction.

 

 

Credit

  • DiamondandPlatinum3
ThanksSupport

Post in this thread or PM me.

 

 

Known Compatibility Issues

I am unaware of any scripts it doesn't work with; if you find any, post in this thread.

 

 

 

Demo

A demo is unnecessary for this script, just set the values and you're on your way.

 

 

Author's Notes

Ah morality... the one of very few things that stops most of us from dual-wielding blades and commiting mass-murder, notice how I said most.

 

 

Terms of Use

If you can find a use for it, this script is free to use in non-commercial games. If you want to use this script in a commercial game, please understand that I expect a free copy (that's means you PM me and let me know that you plan on using it for a commercial game).

Edited by DP3

Share this post


Link to post
Share on other sites

I have the default colour for the windows but neutral is black? Do you know how I can fix this.

Sorry it's my mistake, it's difficult to create an algorithm that accurately gives you colours based on your morality.

It's supposed to look more blackish as your morality decreases but it tends to get there very quickly due to the fact that it isn't trying to take away from your already neutral colour but instead tries to create a new one (which turns out black).

I'll try to fix it, so just put up with it for now and I should hopefully have a fix for you soon :)

Edited by DP3

Share this post


Link to post
Share on other sites

Hi, I'm new to this and was wondering how do you change the morality in game? Do you do it through events?

 

open the script, see where it says Morality_Variable_ID? well that is the variable number that stores the morality(by default its the second variable), increase or decrease that variable and so will your morality. yes you use the "control variable" command to change it.

 

 

Edited by Fornoreason1000

Share this post


Link to post
Share on other sites

I tried to code in an npc that the player talks to and he was supposed to say "Hey, your Morality is  \V[2]."

 

It was supposed to give the title.

 

All it gives is the number instead.

 

    [ 0,    "King Sombra"     ],
    [ 15,   "Evil"        ],
    [ 45,   "Terrible"    ],
    [ 70,   "Jerk"        ],
    [ 90,   "Neutral"     ],
    [ 110,  "Kind"        ],
    [ 140,  "Hero"        ],
    [ 170,  "Angel"       ],
    [ 190,  "Princess Celestia"  ],

 

So can you tell me what I should be using in the npc's text instead of \V[2]?

---

Also, I made an event where you touch something and you blow up.

How would I get it to check which morality the player has then?

Depending on which of the nine moralities(see above list) the player has, they would then go on to one of the nine afterlives in game.
 

Edited by Nightgazer Starlight

Share this post


Link to post
Share on other sites

On its own you cannot do that.

 

However, place the following code below the Morality Metre Script and it'll convert your variables to the relative title during messages

#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This is a super class of all windows within the game.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias dp3_windowsbase_convertescapecharacter_6s5d4g7     convert_escape_characters
  #--------------------------------------------------------------------------
  # * Preconvert Control Characters
  #--------------------------------------------------------------------------
  def convert_escape_characters(text)
    result = text.to_s.clone
    result.gsub!(/\\/)            { "\e" }
    result.gsub!(/\eV\[#{DiamondandPlatinum3::MoralityMetre::MORALITY_VARIABLE_ID.to_s}\]/i) { dp3_get_morality_title() }
    
    
    # Call Original Method
    return dp3_windowsbase_convertescapecharacter_6s5d4g7( result )
  end # Function
  
  #--------------------------------------------------------------------------
  # * Get Morality Title
  #--------------------------------------------------------------------------
  def dp3_get_morality_title()
    title = "Unknown"
    DiamondandPlatinum3::MoralityMetre::MORALITY_NAME.each do |innerarray|
      if $game_variables[DiamondandPlatinum3::MoralityMetre::MORALITY_VARIABLE_ID] >= innerarray[0]
        title = innerarray[1] 
      end
    end
    return title
  end
end # Class
 

 

 

 

 

 

Your other issue has to do with eventing, not scripting.

Just use conditional branches to check how high your morality is and adjust things accordingly.

Edited by DP3

Share this post


Link to post
Share on other sites

I made some adjustments to this to create a 'Virtue Meter' as well, and run both at the same time now.

 

It works fine.

 

What the problem is if I have the 'Virtue Window Base' script at the bottom the guy on the right reports the virtue title, but the guy on the left reports the morality number instead.

 

And if I have the 'Morality Window Base' script at the bottom the guy on the left reports the morality title, but the guy on the right reports the virtue number.

 

http://home.comcast.net/~nekohibiki/Problem.rar

 

The above link leads to a demo.

 

Can you tell me what I did wrong there?

Share this post


Link to post
Share on other sites

This would be a great script if it created its own window inside the menu. When I installed it it was windowless. I like the idea, but the word and bar floating out there is not likable. Can you please fix this?

Share this post


Link to post
Share on other sites
This would be a great script if it created its own window inside the menu. When I installed it it was windowless. I like the idea, but the word and bar floating out there is not likable. Can you please fix this?

You probably have WINDOW_VISIBLE  = false (line 27).  If you set it = true, the window will be visible.  Mine has a visible window, and the instructions explain this.

Share this post


Link to post
Share on other sites
Can you tell me what I did wrong there?
Basically you duplicated a method, in scripting the lower method takes higher priority, which is why virtue would be seen instead of morality if you put it below the Morality script.

However I modified the Window Base snippet posted above, so go grab it again, and you can make those same modifcations you already did and they should both work :)

 

This would be a great script if it created its own window inside the menu. When I installed it it was windowless. I like the idea, but the word and bar floating out there is not likable. Can you please fix this?
As Ekomega said, it does have it's own window, and it should be working fine so long as you haven't set WINDOW_VISIBLE to false.

Share this post


Link to post
Share on other sites
Can you tell me what I did wrong there?
Basically you duplicated a method, in scripting the lower method takes higher priority, which is why virtue would be seen instead of morality if you put it below the Morality script.

However I modified the Window Base snippet posted above, so go grab it again, and you can make those same modifcations you already did and they should both work :)

 

Thanks!^_^

 

Everything's good now!^_^

 

It's working fine, oh yes!^_^

Share this post


Link to post
Share on other sites

Script has been updated, you now have the option of having an effect for both Evil & Good Morality. See Spoilers.

As well as an add-on which allows you to have a left-to-right style of morality. Also See Spoilers.

 

 

 

MoralityMetreScreenShot1_zpsc0afe918.pngMoralityMetreScreenShot2_zps24072057.png

MoralityMetreScreenShot3_zpsd5065a0e.pngMoralityMetreScreenShot4_zps10b4d302.png

 

Share this post


Link to post
Share on other sites

This is a great script.

 

But...

 

I can only fit two gauges, "Morality" and "Fidelity" on the menu now.

 

And I have a lot more I would like to add to the game soon.

 

So I was wondering, is it possible to make the script so that instead of drawing the gauges on the menu they could get their own screens?

 

The screens could be triggered by some key items.

 

Calling a common event that uses a script call.

 

 

Share this post


Link to post
Share on other sites

 

#==============================================================================
# ** Morality_Scene
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Morality < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start(*args)
    super(*args)
    @moralitymetre_windows = Array.new()
    
    ##### Add New Morality Menu Variants Here ####
    @moralitymetre_windows.push( Window_MoralityMetre.new )
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update(*args)
    super(*args)
    return_scene() if Input.trigger?(:
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def terminate(*args)
    super(*args)
    for menu in @moralitymetre_windows
      menu.dispose unless menu.disposed?()
    end
  end
end




#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start( *args )
    dp3_scenemenu_start_18dyb09( *args )
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def terminate(*args)
    dp3_scenemenu_terminate_18dyb09(*args)
  end
end

 

 

 

 

Add that below the morality metre script. Now you can call a new scene using:

SceneManager.call(Scene_Morality)
Inside of the script itself you can add your own custom ones you made by simply adding it in the list:

  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start(*args)
    super(*args)
    @moralitymetre_windows = Array.new()
    
    ##### Add New Morality Menu Variants Here ####
    @moralitymetre_windows.push( Window_MoralityMetre.new )
    @moralitymetre_windows.push( Window_VirtueMetre.new ) # Your Custom One Goes Here
  end

Share this post


Link to post
Share on other sites

Hey great script, thank you so much for putting it here!

 

I do have an issue when using it with Galv's smaller menu list/larger character layout layout that causes the morality meter to go underneath the widened layout 

 

(here is Galv's script:

 

#------------------------------------------------------------------------------#
#  Galv's Menu Layout
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.5
#------------------------------------------------------------------------------#
#  2013-04-14 - Version 1.5 - Added future compatibility code
#  2012-11-10 - Version 1.4 - Added option to set how many actors visible
#  2012-10-19 - Version 1.3 - Fixed a bug that happened with lots of members
#  2012-10-13 - Version 1.2 - Fixed to work in all screen resolutions with some
#                             options to tweak position.
#  2012-10-13 - Version 1.1 - Changed to use /Pictures/ instead of /Faces/
#                             Seemed more appropriate as this would be used to
#                             draw the image as a picture in game.
#  2012-10-13 - Version 1.0 - release
#------------------------------------------------------------------------------#
#  This script overwrites the default menu so the actors on the main menu screen
#  are lined up horizontally and display a portrait image instead of the face.
#
#  INSTRUCTIONS:
#  Copy this script below materials and above main
#
#  You MUST have a portrait for each actor. This was designed to work with
#  the RTP potraits that you must have purchased the right stuff to use.
#  These portrat images are around 270px x 290px.
 
#  Put these portraits in the Graphics/faces/ and name them the same as the
#  face graphic the actor uses, plus the position of the face in it.
#  For example
#  If your actor uses "Actor1" face and uses the first face in that file then
#  you will name the portrait image "Actor1-1.png"
#
#  Download the demo if you don't understand
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#  
#  SCREEN SIZE
#------------------------------------------------------------------------------#
  # This menu layout looks better on larger screen size. The below line 
  # increases your screen size to the max. Remove it if you don't want this.
   
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
 
($imported ||= {})["Galv_Menu_Layout"] = true
module Galv_Menu  
#------------------------------------------------------------------------------#  
#  SETUP OPTIONS
#------------------------------------------------------------------------------#
   
  CURRENCY_ICON = 361       # Icon to display instead of currency vocab.
                            # Change this to 0 to use currency vocab instead.
 
  PORTRAIT_X_OFFSET = 0     # add a positive or negative number to offset 
  PORTRAIT_Y_OFFSET = 0     # each portrait's postion if the portraits you use
                            # do not line up with your screen width/height.
                             
  PORTRAIT_HEIGHT = 400     # So you can tweak the height of the portraits.
   
  NUMBER_OF_ACTORS = 4      # number of actors visible before scrolling
 
#------------------------------------------------------------------------------#  
#  END SETUP OPTIONS
#------------------------------------------------------------------------------#
end
 
class Window_MenuCommand < Window_Command
  def window_width
    return 130
  end
end
 
class Window_Gold < Window_Base
  def window_width
    return 130
  end
  def refresh
    contents.clear
    if Galv_Menu::CURRENCY_ICON > 0
      draw_currency_value(value, currency_icon, 4, 0, contents.width - 25)
    else
      draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
    end
  end
  def currency_icon
    draw_icon(Galv_Menu::CURRENCY_ICON, contents.width - 23, -1, true)
  end
 
end
 
 
class Window_MenuStatus < Window_Selectable
  def window_width
    Graphics.width - 130
  end
 
  def item_height
    (height - standard_padding * 2)
  end
 
  def draw_portrait(face_name, face_index, x, y, enabled = true)
    bitmap = Cache.picture(face_name + "-" + (face_index + 1).to_s)
    portrait_width = bitmap.width / 3 + Galv_Menu::PORTRAIT_X_OFFSET
    y_offset = Galv_Menu::PORTRAIT_Y_OFFSET
    rect = Rect.new(portrait_width, -70 + y_offset, col_width + tweak, Galv_Menu::PORTRAIT_HEIGHT)
    contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
    bitmap.dispose
  end
   
  def tweak
    if Galv_Menu::NUMBER_OF_ACTORS <= 3
      return -2
    else
      return 0
    end
  end
   
  def draw_actor_portrait(actor, x, y, enabled = true)
    draw_portrait(actor.face_name, actor.face_index, x, y, enabled)
  end
   
  def draw_item(index)
    actor = $game_party.members[index]
    enabled = $game_party.battle_members.include?(actor)
    rect = item_rect(index)
    draw_item_background(index)
    draw_actor_portrait(actor, rect.x + 1, rect.y + 1, enabled)
    draw_actor_simple_status(actor, rect.x, rect.y)
  end
   
  def ho
    return $imported["Galv_Menu_Themes"] ? -60 : 0
  end
   
  def draw_actor_simple_status(actor, x, y)
    draw_actor_name(actor, x, y)
    draw_actor_level(actor, x, y + line_height * 2)
    draw_actor_icons(actor, x, y + Graphics.height - line_height * 5 + ho)
    draw_actor_class(actor, x, y + line_height * 1)
    draw_actor_hp(actor, x, y + Graphics.height - line_height * 4 + ho)
    draw_actor_mp(actor, x, y + Graphics.height - line_height * 3 + ho)
    draw_actor_tp(actor, x, y + Graphics.height - line_height * 2 + ho)
  end
   
  def col_width
    window_width / Galv_Menu::NUMBER_OF_ACTORS - standard_padding - 2
  end
   
  def draw_actor_hp(actor, x, y, width = col_width)
    draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
    change_color(system_color)
    draw_text(x, y, 30, line_height, Vocab::hp_a)
    draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
    hp_color(actor), normal_color)
  end
 
  def draw_actor_mp(actor, x, y, width = col_width)
    draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
    change_color(system_color)
    draw_text(x, y, 30, line_height, Vocab::mp_a)
    draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
      mp_color(actor), normal_color)
  end
 
  def draw_actor_tp(actor, x, y, width = col_width)
    draw_gauge(x, y, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
    change_color(system_color)
    draw_text(x, y, 30, line_height, Vocab::tp_a)
    change_color(tp_color(actor))
    draw_text(x + width - 42, y, 42, line_height, actor.tp.to_i, 2)
  end
   
   
  def draw_current_and_max_values(x, y, width, current, max, color1, color2)
    change_color(color1)
    xr = x + width
    if width < 100
      draw_text(xr - 40, y, 42, line_height, current, 2)
    else
      draw_text(xr - 92, y, 42, line_height, current, 2)
      change_color(color2)
      draw_text(xr - 52, y, 12, line_height, "/", 2)
      draw_text(xr - 42, y, 42, line_height, max, 2)
    end
  end
  def draw_actor_name(actor, x, y, width = col_width)
    change_color(hp_color(actor))
    draw_text(x, y, width, line_height, actor.name)
  end
  def draw_actor_class(actor, x, y, width = col_width)
    change_color(normal_color)
    draw_text(x, y, width, line_height, actor.class.name)
  end
  def visible_line_number
    return 1
  end
  def col_max
    return Galv_Menu::NUMBER_OF_ACTORS
  end
  def spacing
    return 8
  end
  def contents_width
    (item_width + spacing) * item_max - spacing
  end
  def contents_height
    item_height
  end
  def top_col
    ox / (item_width + spacing)
  end
  def top_col=(col)
    col = 0 if col < 0
    @member_count = $game_party.members.count
    col = col_max + @member_count if col > col_max + @member_count
    self.ox = col * (item_width + spacing)
  end
  def bottom_col
    top_col + col_max - 1
  end
  def bottom_col=(col)
    self.top_col = col - (col_max - 1)
  end
  def ensure_cursor_visible
    self.top_col = index if index < top_col
    self.bottom_col = index if index > bottom_col
  end
  def item_rect(index)
    rect = super
    rect.x = index * (item_width + spacing)
    rect.y = 0
    rect
  end
  def alignment
    return 1
  end
  def cursor_down(wrap = false)
  end
  def cursor_up(wrap = false)
  end
  def cursor_pagedown
  end
  def cursor_pageup
  end
end

 

 

 

I'm not sure if there is a way for the morality window to be shrunk without cutting off any info so that it lines up with the smaller menu list?

If not just let me know - and thanks again! :)

Share this post


Link to post
Share on other sites

I'd prefer if you showed me a screenshot rather than gave me the script :)

 

 

So what exactly happens to be the issue :)

At first you say the morality window goes underneath the menu (which I assume means it's behind the menu).

Then you say you're not sure if it can be shrunk down properly :/

 

 

Well for both those issues: Locate line 144 in the Morality Metre Script, you should find the following.

#==============================================================================
# ** Window_MoralityMetre
#------------------------------------------------------------------------------
#  Defines the window and its contents
#==============================================================================
class Window_MoralityMetre < Window_Base
  include DiamondandPlatinum3::MoralityMetre
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize()
    super(WINDOW_X_POSITION, WINDOW_Y_POSITION, WINDOW_WIDTH, WINDOW_HEIGHT)
    self.opacity = 0 if !WINDOW_VISIBLE
    contents.font.size = 25
    refresh
  end
Change it to the following:

#==============================================================================
# ** Window_MoralityMetre
#------------------------------------------------------------------------------
#  Defines the window and its contents
#==============================================================================
class Window_MoralityMetre < Window_Base
  include DiamondandPlatinum3::MoralityMetre
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize()
    super(WINDOW_X_POSITION, WINDOW_Y_POSITION, WINDOW_WIDTH, WINDOW_HEIGHT)
    self.opacity = 0 if !WINDOW_VISIBLE
    self.z = 200
    contents.font.size = 25
    refresh
  end

Now you can change both the Font Size and the Z Coordinate.

The Font Size obviously changes the size of the text, though you shouldn't have to change that anyway.

The Z Coordinate is depth, if the Window is behind galv's menu as you say, then adjusting this value should resolve that problem.

 

 

Now as far as moving and shrinking the Morality Metre, that's all in the Editable region of the script. :)

Share this post


Link to post
Share on other sites

Thanks for the reply! Sorry for the confusion, a screenshot would definitely be more helpful ^^; I'll mess around with possibly changing the coordinates as you suggested, but I do have a screenshot now to post as well.

 

Here you go:

 

 

Untitled-1_zpsd30881d3.jpg

 

 

thanks again :)

Edited by esterk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×