Writing first from-scratch script: bypass reflection

Still getting a handle on Ruby, and trying to not be a cargo cultist.

I'm planning on having some skills that can sidestep a target's evasion, mag. evade, or damage reflection, but still be subject to PDR or MDR (as such, cannot use certain hit), and have these flagged by notetags.  Didn't find anything of the like on the master script list.

First trouble is that I don't know how to set it up to read notetags, and since I'm trying to avoid the cargo cultist route, I'd like to learn how to do that properly and why it works.

I was thinking that the best way to go about this was to have the thing outright skip the checking for these things.  Found the damage reflection without much issue, but for the evasion and mag. evade, I might have to temporarily set the those to zero and then put the value back afterwards, so as to not leave the target without evasion period (though that might make an interesting debilitating skill).  Anyways, for the damage reflection, here's what I've got:

Spoiler
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Invoke Magic Reflection
  #--------------------------------------------------------------------------

  alias :steak_bypass_mrf_go_ohio_beat_fiami :invoke_magic_reflection
  def invoke_magic_reflection(target, item)
    steak_bypass_mrf_go_ohio_beat_fiami(target, item)

    unless <bypass_mrf>
      @subject.magic_reflection = true
      @log_window.display_reflection(target, item)
      apply_item_effects(@subject, item)
      @subject.magic_reflection = false
  end
end

I left what I intend to put in the notetags in the angle brackets, since I don't know the syntax for notetags just yet.
Without knowing how to implement notetags, I cannot test this.  Thoughts, please?
You need to get at the note via actor.actor or enemy.enemy, since Game_Actor and Game_Enemy don't give you direct access to the note field. And since target could be either an actor OR an enemy, you can't really say target.actor or target.enemy - so I'd set up a couple of methods in those classes to give you access to the note field without having to figure out whether it's one or the other.

The line you're after in the code snippet above would be something like this:

unless target.note.include?('<bypass_mrf>')But you'd have to add this to make target.note a valid method:
Code:
class Game_Actor  def note    actor.note  endendclass Game_Enemy  def note    enemy.note  endend
This is untested. Let me know if you get any errors.
I first learned how to use notetags through Fomar's tutorial here, and looking at some other short yet simple scripts.  There are other guides here and there that would be of interest.  I have also learned that there is more often than not more than 1 way to do something.  For example I handled a multi part request for another person on the other forums which had a similar them to what you want(avoid certain hit hit type while getting the effects).  I originally intended to overwrite invoke_item instead of the individual invoke magic reflection/counterattack methods, then I discovered something that I overlooked.
 
The following script does exactly what you want and a little more.

Spoiler
Code:
#===============================================================================# Script: Never Miss Skills# Author: Selchar# Requestor: Animebryan#================================================================================beginThis script allows for the creation of skills that always hit their target,without using the Certain Hit Hit Type.#-------------------------------------------------------------------------------# Item/skill Notetag#-------------------------------------------------------------------------------Bypasses counter/magic reflect with: <no reaction> Bypass miss/eva with: <always hit> =end#===============================================================================# Script is beow#===============================================================================class Game_Battler < Game_BattlerBase  alias :no_reaction_item_cnt :item_cnt  def item_cnt(user, item)    return 0 if item.no_reaction    no_reaction_item_cnt(user, item)  end  alias :no_reaction_item_mrf :item_mrf  def item_mrf(user, item)    return 0 if item.no_reaction    no_reaction_item_mrf(user, item)  end  alias :always_hit_item_hit :item_hit  def item_hit(user, item)    return 1 if item.always_hit    always_hit_item_hit(user, item)  end  alias :always_hit_item_eva :item_eva  def item_eva(user, item)    return 0 if item.always_hit    always_hit_item_eva(user, item)  endend class RPG::UsableItem  def no_reaction    @note =~ /<no[-_ ]?reaction>/i ? @no_reaction = true : @no_reaction = false if @no_reaction.nil?    @no_reaction  end  def always_hit    @note =~ /<always[-_ ]?hit>/i ? @always_hit = true : @always_hit = false if @always_hit.nil?    @always_hit  endend
Now on to the code you presented. First things first, you're missing an end statement, tho I'll assume for the moment that was a result of your copying.  Next, you're calling your alias, and performing a check(or intend to, for a notetag).  The code that is run, looks like it's exactly what is in the original method, so you would be doing damage reflection twice if I'm not mistaken.  There's only one way to find out tho*sees Shaz post*.  Let's see what happens when you test what Shaz has given you first.
Oh - I didn't even consider that the note might be on something other than the actor or enemy! Sorry - I should have read it more carefully to start with - I see it now that you're talking about the note on a skill. In that case, my solution won't work - it SHOULD be a usable item that the note is on, which is exactly what Selchar provided (though I didn't look too closely through that either).


Sorry for the confusion.
i'm about to sound stupid (probaly) but i thought certain hit only negated the target's eva/meva/ceva(only if skill can crit)/reflect..... i dont think it allows the skills to ignore damage reduction..........

from the descript in the maker 

"certain hit: treats the successful use of a skill as a hit, counter attack, evasion, magic evasion, and reflection are disabled"

hit types only decerns how the accuracy of the skill takes effect so a new script isnt needed
That is the main purpose of the Certain Hit hit type, however if you look at the make_damage_value method.

def make_damage_value(user, item) value = item.damage.eval(user, self, $game_variables) value *= item_element_rate(user, item) value *= pdr if item.physical? value *= mdr if item.magical? value *= rec if item.damage.recover? value = apply_critical(value) if @result.critical value = apply_variance(value, item.damage.variance) value = apply_guard(value) @result.make_damage(value.to_i, item)endSee the lines:

value *= pdr if item.physical?
value *= mdr if item.magical?

These are ignored if the skill/item is labeled Certain Hit, since a Certain Hit hit type means it's not "magical" or "physical".
ahhh i see ok that explains it....... but there is another way with out scripting then..... make magic and element and use elemental resistances..... same thing really
Thanks, on both the script and the tutorial link.  I can't check on if this works now; I'll have to get that when I get home from work.

Seems to me this sort of thing ought to be on the master script list; how often does that get updated?

EDIT: checked, and perfect.  Many thanks.
Or you could manually multiply by the target's PDR or MDR in the damage formula bar.
Example:

(800 + a.mat * 7 - b.mdf * 2) * b.mdrCrap.  I just necro posted, didn't I?
Code:
#===============================================================================
# Script: Never Miss Skills
# Author: Selchar
# Requestor: Animebryan
#===============================================================================
=begin
This script allows for the creation of skills that always hit their target,
without using the Certain Hit Hit Type.
#-------------------------------------------------------------------------------
# Item/skill Notetag
#-------------------------------------------------------------------------------
Bypasses counter/magic reflect with: <no reaction> 
Bypass miss/eva with: <always hit> 
=end
#===============================================================================
# Script is beow
#===============================================================================
class Game_Battler < Game_BattlerBase  
  alias :no_reaction_item_cnt :item_cnt  
  def item_cnt(user, item)    
    return 0 if item.no_reaction    
    no_reaction_item_cnt(user, item)  
  end  
  alias :no_reaction_item_mrf :item_mrf  
  def item_mrf(user, item)    
    return 0 if item.no_reaction    
    no_reaction_item_mrf(user, item)  
  end  
  alias :always_hit_item_hit :item_hit  
  def item_hit(user, item)    
    return 1 if item.always_hit    
    always_hit_item_hit(user, item)  
  end  
  alias :always_hit_item_eva :item_eva  
  def item_eva(user, item)    
    return 0 if item.always_hit    
    always_hit_item_eva(user, item)  
  end
end 

class RPG::UsableItem  
  def no_reaction    
    @note =~ /<no[-_ ]?reaction>/i ? @no_reaction = true : @no_reaction = false if @no_reaction.nil?    
    @no_reaction  
  end  
  def always_hit    
    @note =~ /<always[-_ ]?hit>/i ? @always_hit = true : @always_hit = false if @always_hit.nil?    
    @always_hit  
  end
end
Fixed the script format

Original thread: https://forums.rpgmakerweb.com/threads/writing-first-from-scratch-script-bypass-reflection.22582/