Actor Specific Item Effects
Version: 1.0
Author: modern algebra
Date: August 23, 2010
Version History
- <Version 1.0> 08.23.2010 - Original Release
Description
This script allows you to set items that have different effects based on who the item is used on. Thus, if you want to make apples give 50 HP generally but 100 HP to a particular actor who loves apples, you can do it. Similarly, if you want it to give only 25 HP to an actor who hates apples, you may do so. (Note that if you are using a script which predicts the effect of an item before using, it will not predict special effects correctly unless you ask me to write a patch). To add a graphical component to this script, please see the
Graphical Favourite Items complementary script.
Features
- Allows you to create items that have special effects only on certain actors.
- Very customizable - should work with any special scripts that give special attributes to items and can customize the effect of any part of the item
- Can make it so that multiple items have special effects for any given actor.
Instructions
Place this script below the default scripts and above Main. If using Graphical Favourite Items, please ensure that this script is above that one.
Script
#==============================================================================
# Actor Specific Item Effects
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: August 23, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to set items that have different effects based on
# who the item is used on. Thus, if you want to make apples give 50 HP
# generally but 100 HP to a particular actor who loves apples, you can do it.
# Similarly, if you want it to give only 25 HP to an actor who hates apples,
# you may do so. (Note that if you are using a script which predicts the
# effect of an item before using, it will not predict special effects
# correctly unless you ask me to write a patch).
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Place this script above Main and below the default scripts in the Script
# Editor (F11).
#
# The script works by replacing the item with another item when used on a
# particular actor. This means that for each item that you want to have a
# special effect, you need to create a dummy item. After that, it is pretty
# simple. All you need to do is place the following code in the note field
# of the item:
# \favourite[actor_id, dummy_item_id]
#
# So, when this item is used on that actor, then the item will have the
# the effect of the dummy_item. So, for instance, if you put the following
# code in the notebox of Item 1 (Potion):
# \favourite[2, 2]
# then the potion would have its normal effect when used on other actors, but
# when used on Actor 2 (Ulrika), then it would have the effect of Item 2 (High
# Potion). Please note that the dummy item must be usable under the same
# conditions as the original item; otherwise it will not be used.
#
# Note that this script is independent from its complement script: Graphical
# Favourite Items. Therefore, setting items up in this script does not set
# them up for that script and vice versa. Also, while this script will allow
# you to make it so more than one item can have special effects on a single
# actor, that script will only allow display for one item per actor.
#==============================================================================
#==============================================================================
# ** RPG::Item
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new methods - setup_actor_favourites; actor_favourites
#==============================================================================
class RPG::Item
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Actor Favourites
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def actor_favourites (actor_id = 0)
setup_actor_favourites if @actor_favourites.nil?
return @actor_favourites[actor_id].nil? ? 0 : @actor_favourites[actor_id]
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Retrieve Actor Favourites
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def setup_actor_favourites
@actor_favourites = []
self.note.gsub (/\\FAVOU?RITE\[(\d+)[,;\s]\s*(\d+)\]/i) {
@actor_favourites[$1.to_i] = $2.to_i
}
return @actor_favourites
end
end
#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - item_effect
#==============================================================================
class Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Apply Item Effect
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mdrna_fvfd_itmefct_6yh2 item_effect
def item_effect (user, item, *args)
if item != nil && item.actor_favourites (@actor_id) != 0
# Run method with the favourite item replacement.
item_2 = $data_items[item.actor_favourites (@actor_id)]
if item_effective? (user, item_2, *args)
mdrna_fvfd_itmefct_6yh2 (user, item_2, *args)
else
mdrna_fvfd_itmefct_6yh2 (user, item, *args) # Run Original Method
end
else
mdrna_fvfd_itmefct_6yh2 (user, item, *args) # Run Original Method
end
end
end
Credit
Thanks
- hikomarukun, for the request
Support
Please post in this topic at RMRK for support, no matter how old the thread is. Do not PM me.
Known Compatibility Issues
No currently known compatibility issues. If you are using the
Graphical Favourite Items script, then that will need to be placed below this one.