Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ■ Item Script Call
- # ItemCallScript.rb
- #------------------------------------------------------------------------------
- #
- # Create an item or skill that will run any script when used.
- # When used on the menu screen, can be done without returning to the map screen.
- # Knowledge of RGSS is required for use.
- #
- # ●How to use
- # 1. Specify the following in the item or skill note box.
- # <=(Script you want to run)=>
- #
- # Example(If used, value [100] will be set to variable [1])
- # <=
- # $game_variables[1] = 100
- # =>
- #
- # If the effect range is set for all allies and all enemies,
- # the script will be executed for all targets.
- #
- # The following variables and functions can be used in the script.
- # user : Item user
- # target : Item target
- #
- # ●Terms of use
- # It's possible to modify and redistribute without permission from the author.
- #-----------------------------------------------------------------------------
- # (C)2018 Triacontane
- # This software is released under the MIT License.
- # http://opensource.org/licenses/mit-license.php
- #-----------------------------------------------------------------------------
- # Version
- # 1.0.0 2018/09/20 Inital release
- # ----------------------------------------------------------------------------
- # [Blog] : https://triacontane.blogspot.jp/
- # [Twitter]: https://twitter.com/triacontane/
- # [GitHub] : https://github.com/triacontane/
- #=============================================================================
- class Game_Battler < Game_BattlerBase
- #--------------------------------------------------------------------------
- # ● Use skills / items
- # Called to apply effects or target.
- #--------------------------------------------------------------------------
- alias ics_use_item use_item
- def use_item(item)
- ics_use_item(item)
- if !item.for_opponent? and !item.for_friend?
- apply_script_if_exist(self, item)
- end
- end
- #--------------------------------------------------------------------------
- # ● Skill / item application test
- # Determine whether recovery is prohibited when the target is used.
- #--------------------------------------------------------------------------
- alias ics_item_test item_test
- def item_test(user, item)
- return true if ics_item_test(user, item)
- get_item_script(item) != nil
- end
- #--------------------------------------------------------------------------
- # ● Skill / item effects on users
- #--------------------------------------------------------------------------
- alias ics_item_user_effect item_user_effect
- def item_user_effect(user, item)
- ics_item_user_effect(user, item)
- apply_script_if_exist(user, item)
- end
- #--------------------------------------------------------------------------
- # ● Get script
- #--------------------------------------------------------------------------
- def get_item_script(item)
- item.note.match(/<=(.*?)=>/m) {$1}
- end
- #--------------------------------------------------------------------------
- # ● If script is specified, it is used.
- #--------------------------------------------------------------------------
- def apply_script_if_exist(user, item)
- script = get_item_script(item)
- if script != nil
- target = self
- eval(get_item_script(item))
- end
- end
- end
Add Comment
Please, Sign In to add comment