Jump to content
PhoenixSoul

Conditionals based on notetag?

Recommended Posts

I'm simply looking to have an arbitrary value change based on if an actor (preferably party member) has any features that contain a specific notetag, but I keep running into error after error, and it has led me to and past the 'toss the keyboard and mouse at the wall' level of frustration.

I've actually tried using previous scriptlets but none of them are doing me any damn bit of good.

I currently have a module set up with a single value; this I want to be altered if the notetag calls for it.

I'll provide more detail if this gets any traction; as is there's not a lot more detail to provide.

Share this post


Link to post
Share on other sites

My first question is, how does a feature have a note tag?

States, skills, items etc can have note tags. but a feature is placed in the object. The object can have note tags, not the feature.

Apart from that, you need to decide where to check for the note tag.

@item.notetag = true ( if you set up the database to include that notetag variable)

for example

  #--------------------------------------------------------------------------
  # new method: load_notetags_jp
  #--------------------------------------------------------------------------
  def self.load_notetags_jp
    groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
      $data_states, $data_enemies, $data_items, $data_skills]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_jp
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::BaseItem
#==============================================================================

class RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :jp_rate
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_jp
  #--------------------------------------------------------------------------
  def load_notetags_jp
    @jp_rate = 1.0
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::BASEITEM::JP_RATE
        @jp_rate = $1.to_i * 0.01
      #---
      end
    } # self.note.split

 

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, roninator2 said:

but a feature is placed in the object. The object can have note tags, not the feature.

On 7/2/2022 at 11:09 AM, PhoenixSoul said:

has any features that contain a specific notetag

I meant if the notetag is present on the actor itself, the actor's class, any skills the actor knows, any states applied, any equipment... I mean, I guess in code I worded "actor's features" incorrectly, but that is what I meant. So, like, actor.note =~ /<note>/ is what I'm looking for, or whatever similar code bit works for that. I don't know if the scriptlet provided will do much, but I can see what I am able to come up with.

 

Share this post


Link to post
Share on other sites
45 minutes ago, PhoenixSoul said:

I don't know if the scriptlet provided will do much, but I can see what I am able to come up with.

That code was just a copy of the code in Yanfly's JP Manager script.

So then if you need more help, I would need to know where in the code you want to do the check. Game_Actors, Game_Party, $data_Items etc.

Share this post


Link to post
Share on other sites
1 hour ago, roninator2 said:

I would need to know where in the code you want to do the check. Game_Actors, Game_Party, $data_Items etc.

Okay.
The module is what's important; I'm looking to have that change based on notetag conditionals.

Spoiler

=begin
Parameter Formulas
Based on Yanfly's Extra Param Formulas
Cobbled together by KBGaming, 2022
=end

$imported = {} if $imported.nil?
$imported["KB-Parameter_Formulas"] = true
    
  module KB
    module MULT
      V = 1
    end
    module PARAM
      
#     Formula Config
    FORMULA ={
    
#   This sets the formula for maximum hp (MHP).
#   Currently, the default provided formula
#   uses the actor's defense and magic defense (DEF & MDF)
#   to set the maximum hp. Set mhp_n_value to "0",
#   and mhp_formula to "base_mhp" to not use this.
    :mhp_n_value => "((param(3)+mdf)*0.4).round",
    :mhp_formula => "(n+((level-1)*3))",
    
#   This sets the formula for maximum mp (MMP).
#   Currently, the default provided formula
#   uses the actor's magic attack (MAT)
#   to set the maximum mp. Set mmp_n_value to "0",
#   and mhp_formula to "base_mmp" to not use this.
    :mmp_n_value => "(mat*KB::MULT::V).round",
    :mmp_formula => "(n)",
    
    :atk_n_value => "0",
    :atk_formula => "base_atk",
    
    :def_n_value => "0",
    :def_formula => "base_def",
    
    :mat_n_value => "0",
    :mat_formula => "base_mat",
    
    :mdf_n_value => "0",
    :mdf_formula => "base_mdf",
    
    :agi_n_value => "0",
    :agi_formula => "base_agi",
    
    :luk_n_value => "0",
    :luk_formula => "base_luk",
    
    
    
    } # Be sure to copy and paste this part.
      
    end
  end
class Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # mass alias methods
  #--------------------------------------------------------------------------
  alias_param = ["mhp", "mmp", "atk", "def", "mat", "mdf", "agi", "luk"]
  alias_param.each { |param|
  aStr = %Q(
  alias game_battlerbase_#{param}_pf #{param}
  def #{param}
    base_#{param} = game_battlerbase_#{param}_pf
    n = eval(KB::PARAM::FORMULA[:#{param}_n_value])
    return eval(KB::PARAM::FORMULA[:#{param}_formula])
  end
  )
  module_eval(aStr)
  } # Be sure to copy and paste this part.
  
end # Game_BattlerBase
  

 

As far as where I'm looking, it would be under (I'm guessing) Game_Party (?); I am trying to have it so it checks for party member notetags (as aforementioned it would be any of the party member's possible notetagged attributes-Actor/Class/Equips/Skills/States)
I'm also having this check be done in a common event script call. 

Share this post


Link to post
Share on other sites
Posted (edited)

OK, so doing the same as what yanfly does, put the condition for the note tag in each class. (actpr, class, RPG::EquipItem, skills, states)

This will make a record of everything that has the note tag.

Then you will want to use a Game_Interpreter method to do a call to another method in Game_Party.

In Game_Party you can do the repeative check in many ways, but usually it would be something like 

def (method to use)
  $game_party.members.each do |act|
    act.skills.each do |s|
      code # if s.note.include?("notetag"); stuff; end
    end
    act.states.each do |st|
   	 code
    end
    act.note.include?("notetag")
   	 code
    end
    cl = act.class # this may require a bit of testing to get the class
    $data_classes[cl].note.include?("notetag")
  	  code
    end
    act.equips.note.include?("notetag")
   	 code
    end
  end
end

 

Now that's off the top of my head, but the actual code that will work could be very different.

 

Edited by roninator2
added note word that was missing
  • Like 1

Share this post


Link to post
Share on other sites

@PhoenixSoul If I understood it correctly, you want to check if an actor has anything with a specific notetag and return a boolean out of it?

If so, try this

#===============================================================================
# // Checking Actor Features
# Desc: Check if a party member has a specific notetag in actor, class, equips',
#       states' or skills' notes and return BOOLEAN (true / false).
# Author: Rikifive
# Engine: RPG Maker VX Ace
#
# Instructions: Simply use a script conditional like:
#   if $game_party.members[0].has_feature?("<cursed>")
#
# to check if the party member has anything tagged with <cursed>
# or to put it simply, to check if any relevant note containts "<cursed>" text.
#===============================================================================
class Game_Actor < Game_Battler
  def has_feature?(notetag)
    return true if actor.note.include?(notetag)
    return true if self.class.note.include?(notetag)
    equips.each {|item|
      next if item.nil?
      return true if item.note.include?(notetag)
    }
    states.each {|state|
      return true if state.note.include?(notetag)
    }
    skills.each {|skill|
      return true if skill.note.include?(notetag)
    }
    return false
  end
end

 

This will allow you to search for text (notetag) in actor note and their class/skills/equips/states notes with a single call.

For example,

if $game_party.members[0].has_feature?("<cursed>")

will check leader's actor/class/equips/states/skills notes for a <cursed> tag and will return true/false. Basically any text will do as well.

 

You can normally use that in eventing and such.

Is that what you were looking for?

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, Rikifive said:

If I understood it correctly, you want to check if an actor has anything with a specific notetag and return a boolean out of it?

I had put this whole thing on the backburner and forgot it...

Yeah, that script will do. Merci beaucoup.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted