RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Actor Specific Item Effects

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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


Code: [Select]
#==============================================================================
#    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


  • modern algebra

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.
« Last Edit: August 23, 2010, 08:00:39 PM by modern algebra »

**
Rep: +0/-0Level 75
Hello everyone ^_^
Thank you so much Modern Algebra! I can't wait to implement this in my game! You're are SUCH a champion!

-ps, you misspelled my name in the 'thanks' section (-o, +u) - not a big deal tho ^_^
RPMG2k forever!

**
Rep: +0/-0Level 70
RMRK Junior
I just found this Script today & was wondering If it Could also be used on weapons etc. I was looking for something like that.   :lol: