Save-Point
Log Horizon Experience Pot System Script - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker VX/VXAce (RGSS2/3) Engines (https://www.save-point.org/forum-117.html)
+---- Thread: Log Horizon Experience Pot System Script (/thread-4994.html)



Log Horizon Experience Pot System Script - Mintyy - 02-27-2014

Log Horizon – Experience Pot System Script
Author: SoulPour777
Web URL: infinitytears.wordpress.com


Terms of Use:

- Preserve the Script Banner.
- Credit SoulPour777 for the script.
- You are allowed to share this script in a community, as long as SoulPour777
remains the author of the script.
- Don’t claim this script as your own.
- You are free to modify the script, but credits is necessary.

Description:

This script enables the party members lower than Level 30 to gain experience pots, an item that gives them boost on experience and fighting abilities. This is a script based on a system mentioned from the anime Log Horizon.

Instructions:
- Place the script below Materials above Main.

Usage:

On your Items in the database, place this note tag on the item:

<ExpPot: n>

n means the value of the experience you will give to your item user.

Example:

<ExpPot: 1000>

This means that when your item user uses that item, he or she will gain 1000 experience.

According to the Log Horizon anime, it says that not only would the player gain experience but also battle enhancements, so I added some HP, MP and TP regen as well for the item.


How to Set Up the Item Correctly:

- Make sure to remove the On Use Effect on the item. This is because the item won’t be used whenever you place anything on it.


Script:

Code:
=begin
#==============================================================================
# Log Horizon - Experience Pot System Script
# Author: SoulPour777
** Web URL: infinitytears.wordpress.com

#------------------------------------------------------------------------------
# Description: This script enables the party members lower than Level 30 to
# gain experience pots, an item that gives them boost on experience and
# fighting abilities. This is a script based on a system mentioned from the
# anime Log Horizon.

Instructions:
- Place the script below Materials above Main.

Usage:

On your Items in the database, place this note tag on the item:

<ExpPot: n>

n means the value of the experience you will give to your item user.

Example:

<ExpPot: 1000>

This means that when your item user uses that item, he or she will gain 1000
experience.

According to the Log Horizon anime, it says that not only would the player
gain experience but also battle enhancements, so I added some HP, MP and TP
regen as well for the item.

How to Set Up the Item Correctly:

- Make sure to remove the On Use Effect on the item. This is because the item
won't be used whenever you place anything on it.

Terms of Use:
- Preserve the Script Banner.
- Credit SoulPour777 for the script.
- You are allowed to share this script in a community, as long as SoulPour777
remains the author of the script.
- Don't claim this script as your own.
- You are free to modify the script, but credits is necessary.
#==============================================================================
=end

module LHExperiencePot
  # Experience Pot Variables
  # -------------------------------------
  EXP_POT_SE = "Item3"
  EXP_POT_SE_PITCH = 100
  EXP_POT_SE_VOL = 100
  EXP_POT_ITEM_ID = 1
  EXP_POT_ITEM_AMOUNT = 1
  # -------------------------------------

  def experience_pot_activate
    experience_pot
  end

  # -------------------------------------
  # This performs the action for the experience pot
  # -------------------------------------
  def experience_pot_action
    RPG::SE.new(EXP_POT_SE, EXP_POT_SE_VOL, EXP_POT_SE_PITCH).play
    $game_party.members.each do |actor|
      if actor.level <= 30
        $game_party.gain_item($data_items[EXP_POT_ITEM_ID], EXP_POT_ITEM_AMOUNT) # ID of the Exp. Item
      end
    end
  end

end

class Game_Actor < Game_Battler

  # we have to include the LHExperiencePot module to have our other methods
  # working in place.
  include LHExperiencePot
  #------------------------------------------------------------------------#
  # New Level Up Method
  # **this contains the experience pot. Everytime the level of an actor
  # is below level 30, an experience pot item comes.
  # -----------------------------------------------------------------------#

  alias experience_pot_and_level_up level_up
  def level_up
    experience_pot
    @level += 1
    self.class.learnings.each do |learning|
      learn_skill(learning.skill_id) if learning.level == @level
    end
  end

  def experience_pot
    experience_pot_action
  end

  alias exp_pot_game_actor_item_apply        item_apply
  alias exp_pot_game_actor_item_test        item_test

  #--------------------------------------------------------------------------
  # * Aliased Method: Apply Effect of Skill/Item
  #--------------------------------------------------------------------------
  def item_apply(*args)
    item = args[1]                                            # Get Item from arguments
    if item.is_a?(RPG::Item)                                  # Since this method is used for both Item & Skills, check to make sure the Item is actually an Item
      if $data_items[item.id].note =~ /<ExpPot:\s?(\d+)>/i   # Only the Data_Item contains the notetag, not the item itself. So  use the item id to get the database item and then check the notetag against the Regex. If matched, continue.
        new_exp = self.exp + $1.to_i                          # Get New Experience Points   
        self.change_exp(new_exp, false)                       # Gain Exp, simple as that.
        self.add_state(14) #HP Regen
        self.add_state(15) #MP Regen
        self.add_state(16) #TP Regen
      end
    end
    exp_pot_game_actor_item_apply(*args)                   # Call Original Method
  end
  #--------------------------------------------------------------------------
  # * Aliased Method: Test Skill/Item Application
  #--------------------------------------------------------------------------
  def item_test(*args)
    return true if $data_items[args[1].id].note =~ /<ExpPot:\s?(\d+)>/i  # Allow Item to be used no matter what if it contains this notetag
    return exp_pot_game_actor_item_test(*args)                        # Otherwise Call Original Method
  end

end