Since I'm here, allow me to critique the entire script.
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 $exp_pt_level_max = 30 # ------------------------------------- end
This all looks fine until I hit the $exp_pt_level_max variable. You've already created it inside of a module, and as far as I can tell this variable will always remain the same value throughout the entire game, so why is it a global variable instead of a Constant like the other variables?
Change it to a Constant: EXP_POT_LEVEL_MAX = 30.
class Game_Actor < Game_Battler # we have to include the LHExperiencePot module to have our other methods # working in place. include LHExperiencePot
This is not recommended. Game_Actor is a default class, by including a module like this you are opening your variable names to conflict with other scripts people may use in their games. In this case it's not very likely there will be another script in a project with the variable name: EXP_POT_SE. However you still need to take that into consideration
Allow me to elaborate
module Module1 SoundName = "Battle1" end module Module2 SoundName = "Battle2" end class Game_System include Module1 include Module2 def play_sound RPG::BGM.new(SoundName, 100, 100).play # Inconsistency, SoundName has been defined twice, so the one you want to hear may not be heard. end end
Alternatively you may use it like this instead:
module Module1 SoundName = "Battle1" end module Module2 SoundName = "Battle2" end class Game_System def play_sound RPG::BGM.new(Module1::SoundName, 100, 100).play # Now the Compiler knows which variable you actually meant end end
You can feel free to use include when using your own custom class, but I recommend you avoid it when dealing with any default classes.
alias experience_pot_and_level_up level_up def level_up RPG::SE.new(EXP_POT_SE, EXP_POT_SE_VOL, EXP_POT_SE_PITCH).play $game_party.members.each do |actor| if actor.level <= $exp_pt_level_max $game_party.gain_item($data_items[EXP_POT_ITEM_ID], EXP_POT_ITEM_AMOUNT) # ID of the Exp. Item end end @level += 1 self.class.learnings.each do |learning| learn_skill(learning.skill_id) if learning.level == @level end end
You have not actually used the alias properly here. You've instead overwritten the method completely.
Fixed:
alias experience_pot_and_level_up level_up def level_up RPG::SE.new(EXP_POT_SE, EXP_POT_SE_VOL, EXP_POT_SE_PITCH).play if actor.level <= $exp_pt_level_max $game_party.gain_item($data_items[EXP_POT_ITEM_ID], EXP_POT_ITEM_AMOUNT) # ID of the Exp. Item end experience_pot_and_level_up # Call Original Method 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
Just a preferential thing, I don't mind you copying my code, but the coding style just looks inconsistent with the rest of the script; just saying.
Feel free to modify any snippets I give you in future.
So, with that said, here's how I would have written the script.
Spoiler for :
=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 # MLP fetish porn 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 MLP fetish porn, 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 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Editable Region //// == #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ItemID = 1 # Item ID of the Exp Pot. ie Item to receive upon level up. Quantity = 1 # Quantity of Said Item MaxLevel = 30 # Actor's Level when they stop receiving Exp Pots # Filename, Volume, Pitch SoundEffect = [ "Item3", 100, 100 ] # Sound Effect to play upon receiving EXP Pot #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # End Editable Region //// == #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Regex = /<ExpPot:\s?(\d+)>/i end class Game_Actor < Game_Battler #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # *= Alias Listings #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias sp_experience_pot_and_level_up level_up alias sp_exp_pot_game_actor_item_apply item_apply alias sp_exp_pot_game_actor_item_test item_test #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Aliased Method: New Level Up Method #-------------------------------------------------------------------------- # This contains the experience pot. Everytime the level of an actor # is below level 30 (Default), an experience pot item is given. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def level_up(*args) pot_given = false pot_item = $data_items[LHExperiencePot::ItemID] $game_party.members.each do |actor| if actor.level <= LHExperiencePot::MaxLevel pot_given = true $game_party.gain_item(pot_item, LHExperiencePot::Quantity) end end RPG::SE.new(*LHExperiencePot::SoundEffect).play if pot_given sp_experience_pot_and_level_up(*args) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * 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 =~ LHExperiencePot::Regex # 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 sp_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 =~ LHExperiencePot::Regex # Allow Item to be used no matter what if it contains this notetag return sp_exp_pot_game_actor_item_test(*args) # Otherwise Call Original Method end end