Galv’s Emotional Responses V.1.2

Demo – Version 1.2 >

#------------------------------------------------------------------------------#
#  Galv's Emotional Responses
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.2
#------------------------------------------------------------------------------#
#  2012-10-22 - Version 1.2 - updated alias names for compatibility
#  2012-10-22 - Version 1.1 - fixed a bug
#  2012-10-22 - Version 1.0 - release
#------------------------------------------------------------------------------#
#
#  This script allows you to bring up a selection of 4 emotional responses:
#  Angry, happy, sad and none.
#  Using scripts in conditional branches, you can continue the event depending
#  on the player's emotional response selection.
#
#  Every time the player selects a response, the party leader gains a point in
#  the emotion selected. Using script calls, you can refer to how many points
#  an actor has. These can be used in conditional branches to determine if you
#  want something to happen, for example, depending on how angry someone has
#  been with their responses.
#
#  Requires graphics located in the Graphics/System folder of the demo.
#
#  Script calls to use are below:.
#------------------------------------------------------------------------------#
#  call_emote                      # Calls the emote choices menu
#
#  emote("emote")                  # Used for conditional branches after player
#                                  # selects an emotion to determine what to do
#                                  # with their selection.
#
#  check_emote(actor_id, "emote")  # Used in conditional branches or variables
#                                  # Gives the value of an actor's emotion.
#                                  # Use 0 to get party leader.
#
#  check_party_emote("emote")      # Gets the total values for that emotion of
#                                  # all members in the party.
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  check_emote(1, "sad")          # the amount of sad points actor 1 has
#  check_emote(4, "happy")        # the amount of happy points actor 4 has
#  check_emote(0, "angry")        # the amount of angry points party leader has
#
#  emote("sad")                   # for conditional branch. Checks if the last
#                                 # emote selected was "sad"
#------------------------------------------------------------------------------#
#  The default emotions are: "sad", "happy", "angry", "none".
#  Always use lowercase when referring to them in a script call.
#  Try to demo for some examples of using these in conditional branches.
#------------------------------------------------------------------------------#
 
$imported = {} if $imported.nil?
$imported["Emote_Choices"] = true
 
module Emotes
 
#------------------------------------------------------------------------------#
#  SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#
 
  # Change what you want the emotes to be in your game. Note this will replace
  # all references to these emotions in the above examples with the ones you
  # replace them with.
 
  EMOTE1 = "angry"       # LEFT CHOICE
  EMOTE2 = "happy"       # TOP CHOICE
  EMOTE3 = "sad"         # BOTTOM CHOICE
  EMOTE4 = "none"        # RIGHT CHOICE
 
  # Included in the demo is a blank template for the choice boxes to add your
  # own if desired.
 
#------------------------------------------------------------------------------#
#  END SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#
 
end
 
class Scene_Emote < Scene_Base
  def start
    super
    create_background
    create_emotes
  end
  def create_background
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(16, 16, 16, 0)
  end
  def create_emotes
    @menu_btn = Sprite.new
    @menu_btn.bitmap = Cache.system("choices-menu")
    @menu_btn.x = Graphics.width / 2 - 150
    @menu_btn.y = Graphics.height / 2 - 100
    @emote = Emote_Choices.new
  end
  def update
    super
    @emote.selected = 1 if Input.trigger?(:UP)
    @emote.selected = 2 if Input.trigger?(:RIGHT)
    @emote.selected = 3 if Input.trigger?(:LEFT)
    @emote.selected = 4 if Input.trigger?(:DOWN)
    @emote.update
    if Input.trigger?(:B)
      $game_temp.emote_response = Emotes::EMOTE4
      SceneManager.return
    end
    if Input.trigger?(:C)
      Sound.play_ok
      case @emote.selected
      when 1 # up
        $game_temp.emote_response = Emotes::EMOTE2
        $game_party.members[0].emote_happy += 1
        SceneManager.return
      when 2 # right
        $game_temp.emote_response = Emotes::EMOTE4
        $game_party.members[0].emote_none += 1
        SceneManager.return
      when 3 # left
        $game_temp.emote_response = Emotes::EMOTE1
        $game_party.members[0].emote_angry += 1
        SceneManager.return
      when 4 # down
        $game_temp.emote_response = Emotes::EMOTE3
        $game_party.members[0].emote_sad += 1
        SceneManager.return
      end
    end
  end
  def terminate
    super
    dispose_all_sprites
  end
  def dispose_all_sprites
    instance_variables.each do |varname|
      ivar = instance_variable_get(varname)
      ivar.dispose if ivar.is_a?(Sprite)
    end
  end
end
 
class Emote_Choices < Sprite_Base
  attr_reader :selected
  def initialize
    super(nil)
    @cursor = Sprite.new
    @cursor.bitmap = Cache.system("choices-cursor")
    @cursor.x = Graphics.width / 2 - 50
    @cursor.y = Graphics.height / 2 - 100
    @selected = 1
    @pulse = 0
    update
  end
  def selected=(selected)
    Sound.play_cursor if @selected > 0
    mx = Graphics.width / 2
    my = Graphics.height / 2
    @selected = selected
    case selected
    when 1 # up
      @cursor.x = mx - 50
      @cursor.y = my - 100
    when 2 # right
      @cursor.x = mx + 50
      @cursor.y = my - 50
    when 3 # left
      @cursor.x = mx - 150
      @cursor.y = my - 50
    when 4 #down
      @cursor.x = mx - 50
      @cursor.y = my
    end
  end
  def update
    super
    @pulse += 1
    @cursor.opacity -= 5 if @pulse > 0
    @cursor.opacity += 5 if @pulse < 0
    @pulse = -20 if @pulse >= 20
  end
  def dispose
    super
    @cursor.bitmap.dispose
    @cursor.dispose
  end
end # Sprite_Menu < Sprite_Base
 
class Game_Temp
  attr_accessor   :emote_response
  alias galv_emotions_initialize initialize
  def initialize
    galv_emotions_initialize
    @emote_response = Emotes::EMOTE4
  end
  def emote_response
    @emote_response
  end
end # Game_Temp
 
class Game_Interpreter
  def emote(emote)
    return true if emote == $game_temp.emote_response
  end
 
  def check_emote(actor_id, emote)
    if actor_id < 1
      return if $game_party.members[actor_id] == nil
      charater = $game_party.members[actor_id]
    else
      return if $game_actors[actor_id] == nil
      charater = $game_actors[actor_id]
    end
    case emote
    when Emotes::EMOTE1
      charater.emote_angry
    when Emotes::EMOTE2
      charater.emote_happy
    when Emotes::EMOTE3
      charater.emote_sad
    when Emotes::EMOTE4
      charater.emote_none
    end
  end
  def call_emote
    SceneManager.call(Scene_Emote)
    wait(1)
  end
  def call_emote
    SceneManager.call(Scene_Emote)
    wait(1)
  end
 
  def check_party_emote(emote)
    no_members = $game_party.members.count
    total = 0
    case emote
    when Emotes::EMOTE1
      no_members.times { |i| total += $game_party.members[i].emote_angry}
    when Emotes::EMOTE2
      no_members.times { |i| total += $game_party.members[i].emote_happy}
    when Emotes::EMOTE3
      no_members.times { |i| total += $game_party.members[i].emote_sad}
    when Emotes::EMOTE4
      no_members.times { |i| total += $game_party.members[i].emote_none}
    end
    return total
  end
 
end # Game_Interpreter
 
class Game_Actor < Game_Battler
  attr_accessor :emote_angry
  attr_accessor :emote_happy
  attr_accessor :emote_sad
  attr_accessor :emote_none
  alias galv_emotions_setup setup
  def setup(actor_id)
    galv_emotions_setup(actor_id)
    @emote_angry = 0
    @emote_happy = 0
    @emote_sad = 0
    @emote_none = 0
  end
  def emote_happy
    @emote_happy
  end
  def emote_angry
    @emote_angry
  end
  def emote_sad
    @emote_sad
  end
  def emote_none
    @emote_none
  end
end # Game_Actor < Game_Battler

One thought on “Galv’s Emotional Responses V.1.2

  1. Anna says:

    Thank you so much for this script!! i will have many scripts made by you at my game and of course ill credit you
    i just want to say thank you!

Leave a comment