Request Tsuki's Battle Reactions Add On: ITEM Battle reactions

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
192
Reaction score
12
First Language
Portuguese
Primarily Uses
RMVXA

Good Morning / Day / Afternoon / Evening everyone.

I have a request for a certain kind of script

Is it possible to create an addon to this "Battle Reactions" script and make it so the battler can react with items as well as skills?

Any help would be appreciated.
 

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
192
Reaction score
12
First Language
Portuguese
Primarily Uses
RMVXA
friendly bump
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
649
Reaction score
424
First Language
English
Primarily Uses
RMVXA
This should work:
Ruby:
=begin
#==============================================================================#
#   AMN HimeWorks Battle Reactions add-on - Use Items
#   Version   1.01
#   Author:   AMoonlessNight
#   Date:     30 Jun 2020
#   Latest:   30 Jun 2020
#==============================================================================#
#   UPDATE LOG
#------------------------------------------------------------------------------#
# 30 Jun 2020 - created the script
#==============================================================================#
#   TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Please credit Tsukihime/HimeWorks and follow their terms of use
# - Free for non-commercial use; contact for commercial use
# - If you would like to edit/adjust this script, please make edits as a new
#   script (do not edit this script directly) and provide proper credit
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#

This script is an add-on for Tsukihime's Battle Reactions script:
http://himeworks.com/2013/09/battle-reactions/

It makes it so that you can set certain reactions to use an item instead of
a skill.

Set up the reaction notetags as per the original script. For reactions that you
want to use an item instead, put the Item ID instead of reaction skill ID.

Add the following notetag:

  <item reaction: id1,id2, ... >
 
Where id1, id2, etc., are the unique IDs of the reactions that you want to use
items for instead of skills. Each reaction has a unique ID, in the order that
they are written in your notebox. The first reaction is 1, the second reaction
is 2, and so on.

This notetag works for enemies as well.

NOTE: You will need to set a condition that the party has the item, otherwise
you will use the items even if you don't have them, e.g. something like this:
 
  <reaction condition: id1>
  FORMULA && $game_party.has_item?($data_items[X])
  </reaction condition>

(Obviously don't use this for enemies, because they don't have inventory).

=end
#==============================================================================
#  Please do not edit below this point unless you know what you are doing.
#==============================================================================

module TH
  module Battle_Reactions
    Item_React_Regex = /<item[ _-]reaction:(.*?)>/i
  end
end

class RPG::BaseItem
 
  alias amn_himebr_rpgbaseitem_lnbr load_notetag_battle_reactions
  def load_notetag_battle_reactions
    amn_himebr_rpgbaseitem_lnbr
    load_notetag_item_reactions
  end
 
  def load_notetag_item_reactions
    results = self.note.scan(TH::Battle_Reactions::Item_React_Regex)
    results.each do |res|
      res[0].split(",").map {|id| id.to_i - 1 }.each do |id|
        next unless @reactions[id]
        @reactions[id].react_type = :item
      end
    end
  end
 
end

class Game_Battler < Game_BattlerBase

  def set_action_by_reaction_type(user, reaction, action)
    case reaction.react_type
    when :skill
      if reaction.react_id > $data_skills.size
        puts "AMN HimeWorks Battle Reactions add-on: #{reaction.react_id} is not a valid Skill ID"
        return false
      end
      item = $data_skills[reaction.react_id]
    when :item
      if reaction.react_id > $data_items.size
        puts "AMN HimeWorks Battle Reactions add-on: #{reaction.react_id} is not a valid Item ID"
        return false
      end
      item = $data_items[reaction.react_id]
    end
    return false unless item
    if item.for_opponent?
      action.target_index = user.index
    elsif item.for_friend?
      action.target_index = self.index
    end
    return false unless action.respond_to?("set_#{reaction.react_type}")
    action.send("set_#{reaction.react_type}", reaction.react_id)
    return true
  end
 
  # Overwrite to consider react_type
  def make_reaction(user, reaction)
    return unless reaction.condition_met?(self, user)
    return unless movable? || reaction.forced
    chance = reaction.chance(self, user)   
    return if chance < rand
    
    action = Game_Action.new(self, reaction.forced)
    return unless set_action_by_reaction_type(user,reaction,action)
    
    action.make_targets
    @actions.push(action)
    BattleManager.force_reaction(self)
  end
 
end

Pop that in a new slot below Hime's Battle Reactions script.
 

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
192
Reaction score
12
First Language
Portuguese
Primarily Uses
RMVXA
First. I want to thank you for taking the time to help me achieve this. I am trying to create "auto-potion" from Final Fantasy

Unfortunately. It doesn't seem to be working. I tagged a state with <item reaction: 128(skill to react to), 1 (item id: Potion) 100 (100% chance of success) forced (to be a forced action).

Auto-Potion.png

I tested this on a mock battle and added the "Auto-Potion" State to the battlers, but it did not work... perhaps there is something I did wrong.

I was wondering if it were possible to change it up so you can make it so a character reacts with an item when the enemy uses a skill of a certain TYPE, rather than individual skills, like for example <stype reaction: 6 i1 (item 1) 100 forced> Tsuki's default script does this for skills.

Or maybe there is something I am not doing correctly. I appreciate all the support.

I understand if you are busy.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
649
Reaction score
424
First Language
English
Primarily Uses
RMVXA
No, you need to set the reaction first as per the original script, using the item ID instead of the skill ID, and then you would add <item reaction: 1> below it, since you would be setting the first reaction as an item reaction. Hope that makes sense.

Code:
Set up the reaction notetags as per the original script. For reactions that you
want to use an item instead, put the Item ID instead of reaction skill ID.

Add the following notetag:

  <item reaction: id1,id2, ... >

Where id1, id2, etc., are the unique IDs of the reactions that you want to use
items for instead of skills. Each reaction has a unique ID, in the order that
they are written in your notebox. The first reaction is 1, the second reaction
is 2, and so on.
EDIT: Here's a screenshot with an example:
screenshot.png
So if the character is hit with element 3 (Fire in the default), they use item 1 (Potion in the default).
 
Last edited:

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
192
Reaction score
12
First Language
Portuguese
Primarily Uses
RMVXA
Thank you so much for your pacience. I finally got my "Auto-Potion" Ability to work exactly how I wanted it thanks to you!

If I encounter any other issues I will be sure to let you know.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

My old project is now a sitcom
How to do implementation the social politcal mechanics in rpg maker? Thank you for quick spark of ideas. Fear of going to the thread lol.
MerlinCross wrote on Switz's profile.
Not sure if you'll see this but I stumbled across your "Open Locker" sprite in a topic. Could I use those?
topic in question
Going to watch an episode of The Office and eat something after this little progress!

Forum statistics

Threads
100,780
Messages
979,428
Members
132,417
Latest member
U2M
Top