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.
Item Target Effects

0 Members and 1 Guest are viewing this topic.

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
Item Target Effects
Version: 1.0
Author: TDS
Date: February 19, 2012

Version History


  • Version 1.0 2012.02.19 - Original Release

Description


This script allows you to add effects such as "Recover HP" or "Run common event" for specific actors or enemies when using skills or items on them.

Features

  • Allows you to set on use effects for specific enemies or actors for skills and items.

Instructions

Just put the script on the materials area of the script editor and follow the instructions on the script.

Script


Code: [Select]
#==============================================================================
# ** TDS Item Target Effects
#    Ver: 1.0
#------------------------------------------------------------------------------
#  * Description:
#  This script allows you to set specific effects for selected targets.
#------------------------------------------------------------------------------
#  * Features:
#  Allows you to set on use effects for specific enemies or actors for skills
#  and items.
#------------------------------------------------------------------------------
#  * Instructions:
#  To add a on use effect to a skill or item add this to it's notebox:
#
#  ACTOR_X_EFFECT: code data_id value1 value2
#  ENEMY_X_EFFECT: (Same as above, but for enemies)
#
#  X: is the ID of the target (ACTOR_1_EFFECT)

#  code : the code effect ID. For example 11 is recover HP.
#  (The list can be found on the Game_BattlerBase and Game_Battler constants list)
#
#  data_id : the id used by the effect if applicable (For skills, states, common events)
#
#  value1: value in % percent for the effect. (Can be positive or negative)

#  value2: solid value for effect. (Can be positive or negative)
#
#  Example:
#
#  ACTOR_1_EFFECT: 11 0 0 500
#
#  This example would restore 500 extra HP when the item/skill is used on them.
#------------------------------------------------------------------------------
#  * Notes:
#  None.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================


#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass of the Game_Actor
# and Game_Enemy classes.
#==============================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Alias Listings
  #-------------------------------------------------------------------------- 
  alias tds_target_item_effects_game_battler_item_apply            item_apply 
  #--------------------------------------------------------------------------
  # * Apply Item Effect
  #--------------------------------------------------------------------------
  def item_apply(user, item)
    # Run Original Method
    tds_target_item_effects_game_battler_item_apply(user, item)
    # If Item was successfully used
    if @result.hit?
      # Make Target Effects Array
      effects = []
      # Get Regexp Header
      header = self.actor? ? "ACTOR" : "ENEMY"
      # Get ID
      id =  self.actor? ? self.id : self.enemy_id
      # Go Through Items Notes and Match Text
      item.note.scan(/#{header}_#{id}_EFFECT: (?'code'[0-9]+) (?'data_id'[0-9]+) (?'value1'[-0-9]+) (?'value2'[-0-9]+)/) {|t|
        # Get Match Information
        m = Regexp.last_match
        # Add Effect to Target Effects Array
        effects << RPG::UsableItem::Effect.new(m[:code].to_i, m[:data_id].to_i, m[:value1].to_i, m[:value2].to_i)
      }
      # Apply Actor Effects
      effects.each {|effect| item_effect_apply(user, item, effect)}
    end
  end
end

Credit


  • TDS

Thanks

  • Archeia for requesting it and testing.

Support


On this topic.

Known Compatibility Issues

None that I know of so far.


Author's Notes


With this script I decided to try something different in the regular expression by using the naming feature rather than $1 $2 etc. Also just in case anyone misses it in the instructions you can find the effect code list on the "Game_BattlerBase" and "Game_Battler" scripts.

Restrictions

Only for use in non-commercial games.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature 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
Nice little script there TDS :)