RMRK RPG Maker Creation => VX Ace => VXA Scripts Database => Topic started by: SoulPour777 on January 31, 2014, 09:30:12 AM
Title: [RGSS3] Log Horizon Experience Pot System Script
Post by: SoulPour777 on January 31, 2014, 09:30:12 AM
[RGSS3] Log Horizon Experience Pot System Script Version:1 Author:SoulPour777
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 Japanese Animation Log Horizon.
Features
Experience Gain through Items
HP Regen
MP Regen
TP Regen
Instructions
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 Log Horizon, 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.
=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
# ------------------------------------- # 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
Credit
SoulPour777
DP3 - For the big help of note tag reading for item usage.
Thanks
Log Horizon
DP3
Support
If any questions, suggestions or script conflicts about this script, please don't hesitate to mail me on my website or PM me here at RMRK. I will answer you as soon as I get your message.
Known Compatibility Issues
- None
Author's Notes
Being inspired with the Japanese Animation Log Horizon, I was able to make this script.
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.
Title: Re: [RGSS3] Log Horizon Experience Pot System Script
Post by: vindaca on February 01, 2014, 08:10:20 AM
"According to Log Horizon, 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."
You are also re-writing the level_up method to play new sounds, it also gives a lot of limits to the developer. Seeing as how I just wrote this script, you should check out how I did it there's a lot more options. V's Item Experience (http://rmrk.net/index.php/topic,48631.0.html)
Title: Re: [RGSS3] Log Horizon Experience Pot System Script
Post by: SoulPour777 on February 01, 2014, 03:01:14 PM
I based the limitation of the script and what it actually does on Log Horizon. I might check up removing the rename for the using of item, but since LH only gives regen and exp boost, that's how it is. ^-^
Title: Re: [RGSS3] Log Horizon Experience Pot System Script
Post by: EvilM00s on February 01, 2014, 11:14:13 PM
I thought this thread was going to be about marijuana....
I'm sure the script makes things much easier, but couldn't this be done with common events instead?
(Making the point for non-scripters)
Title: Re: [RGSS3] Log Horizon Experience Pot System Script
Post by: vindaca on February 01, 2014, 11:50:29 PM
@Evilmoos~
Yes it can, but it is not always easy to find the people that are using items/ targets(for non-scripters). The purpose of the script is to make it easier on the developer.
@SoulPour777~
First of let me say this. Sorry for the abrupt welcoming. It's really nice to see other programmers here, it has been a while since anyone else has put up a new script. With that said nice job putting out so many too. I hope I don't come off as a jerk, I am only trying to help out.
My only point was that yes you based it on the limitation of a game, but you still gave options to change aspects of the system. Even to the point of controlling how many the player get when they receive the item. If you are going to go that far, you should have just made it limitless(in a sense). This script could have been used for more then just 1 item and lots of different features easily. And your Level_up sound mesh can be a whole new script all together.
A few tips to shorten the script more too. These two methods can be combined. The first one is not needed at all and is just taking up bytes.
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
def experience_pot_activate 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
This will save you from having to rewrite more of the script. You should also make the Item gain at level up optional and maybe an option to change the level they stop being received.
Side note~
Some advice as a fellow programmer take it or leave it. Don't create so many limits on something easy like that. Let the developer create there own limits for there own game and it could be used by a lot more people.
It is ok to be inspired by a game, but you should always try to be better then not equal too.
Title: Re: [RGSS3] Log Horizon Experience Pot System Script
Post by: D&P3 on February 02, 2014, 07:24:55 AM
=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
# 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 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
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
Title: Re: [RGSS3] Log Horizon Experience Pot System Script
Post by: vindaca on February 02, 2014, 12:45:56 PM
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?
# 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
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
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.
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.
=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
Title: Re: [RGSS3] Log Horizon Experience Pot System Script
Post by: SoulPour777 on February 02, 2014, 01:08:24 PM
Ohhh, that sums up what I've started. To be honest, I got that idea include from someone, and I thought doing that is easier since you don't have to call up the module name and just the functions instead. Now I know that has some conditions before doing it.
As for the alias, I seem to get something very important here. When I did my other scripts aside from this, I never called the original method.
I went ahead and aliased it without calling the original method >__<
Anyways, Vindaca and DiamondandPlatinum3, that was a nice lesson I learned from both of you. I got new things:
- Use includes unless its not a default class - when you alias, call the original method - global variables are not to be used when inside a module
PS EDIT:
does anyone know why the word [a.n.i.m.e.] (without the square brackets and dots) is automatically changed to something different? That's why I am using the word Animation instead o.O