Forcing a conditional miss.

Discussion in 'RGSS3 Script Requests' started by SaburoX, Jul 29, 2019.

  1. SaburoX

    SaburoX Veteran Veteran

    Messages:
    79
    Likes Received:
    7
    I'm looking for a script that will allow me to force a skill to miss based on conditions.
    The scenario I have in mind is that a character has a suplex skill, sort of like Sabin in FF6, but it doesn't work on flying enemies. I figure I can make those enemies distinct by using a state or Hime's Tag Manager, but I'm not sure how to go about actually getting the skill to miss on them exclusively.
     
    #1
  2. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,442
    Likes Received:
    5,031
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Do it yourself. Assume you're using tag manager, here is how.
    Hit and miss is handled in Game_Battler, look into def item_hit
    Code:
      def item_hit(user, item)
        rate = item.success_rate * 0.01     # Get success rate
        rate *= user.hit if item.physical?  # Physical attack: Multiply hit rate
        return rate                         # Return calculated hit rate
      end
    
    You can change the code into something like
    Code:
      def item_hit(user, item)
        return 0 if has_tag?("flying") # <-- modification here
        rate = item.success_rate * 0.01     # Get success rate
        rate *= user.hit if item.physical?  # Physical attack: Multiply hit rate
        return rate                         # Return calculated hit rate
      end
    
    0 means it has zero chance to hit
    1 means it's always hit
    between 0 ~ 1 is a chance to hit. 0.5 means 50% chance to hit
     
    #2
  3. SaburoX

    SaburoX Veteran Veteran

    Messages:
    79
    Likes Received:
    7
    That overwrites every skill and attack, effectively making the enemy with that tag untouchable. I'm looking for a way to limit that to specific instances like with a specific skill.
     
    #3
  4. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,442
    Likes Received:
    5,031
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Just add the extra condition, like
    Code:
    has_tag?("flying") && item.is_a?(RPG::Skill) && item.id == 99
     
    #4
  5. SaburoX

    SaburoX Veteran Veteran

    Messages:
    79
    Likes Received:
    7
    Okay, that makes sense.
    Is there any way to force a miss in a damage formula? I ask because I know that you can make a higher rate for criticals that way.
     
    #5
  6. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,249
    Likes Received:
    507
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    Not without using a script, as Theo suggested. The reason behind that is that the damage formula is only evaluated when the attack hits. If you evaluate the formula it is already too late to miss.
     
    #6
  7. SaburoX

    SaburoX Veteran Veteran

    Messages:
    79
    Likes Received:
    7
    Thanks for the advice.
    One final question: What condition can I use to check to see if the skill has missed? Would it just be "@result.missed = true"? I'm trying to figure out how to code a sideview sequence now for this skill.
     
    #7
  8. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,249
    Likes Received:
    507
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    If you want to check it within the damage formula you simply cannot, for the very same reason I explained before: when you miss, the whole formula box is not evaluated. This means that you cannot use it to have your character miss, but you cannot use it to check if you missed either, because when you miss it does not run. If you want to use a script, then it is a different story.
     
    #8
  9. SaburoX

    SaburoX Veteran Veteran

    Messages:
    79
    Likes Received:
    7
    I understood that part. I'm not asking about how to phrase it in the damage formula, but rather in a script condition. The sideview system I'm using (Journey/Tankentai) allows for script based conditional statements that change/end the animation sequence. I was asking how to phrase a result missing for that since I can't use the tag for that part.
     
    #9
  10. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,442
    Likes Received:
    5,031
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    You're using an (entirely) different battle system, which means the workflow may be different than the default.
    Checking if the attack/skill/item miss can be as simple as use this code as long as the said skill is already evaluated beforehand (and the result don't get reset for whatever reason).
    Code:
    !@result.hit
    When exactly the skill/item is already evaluated? That is the thing I don't know. I'm not familiar with the script, and you didn't even link it here for the reference.
     
    #10
    Heirukichi likes this.
  11. SaburoX

    SaburoX Veteran Veteran

    Messages:
    79
    Likes Received:
    7
    I'm sorry. I really should have linked it. This is the sideview I'm using.
    I didn't think it was relevant as it actually doesn't reference item_hit at all.
     
    #11

Share This Page