Poison Damage Using Skills

Discussion in 'RGSS Script Requests' started by TheRiotInside, Sep 3, 2014.

  1. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Hey, folks. Got a little script request for good old RMXP.

    I'm using a DoT/HoT script currently where you can set a static number or % for HP/MP damage or healing, which is worlds better than the default poison state, but still limited. I want DoT skills that scale with my characters, and don't just take off a specific chunk of HP so they can be balanced on bosses and the like.

    So, the request in a nutshell: I would like certain states to cast a certain skill on the afflicted target every turn.

    To compare to a normal poison state, at the start of the afflicted target's action, instead of a flat damage number popping up there, a skill would be forced on them instead, with the animation, but not the name (so poison dealing damage won't say the name of the associated skill up top when the target acts).

    Basically, I want it to appear as close to a normal slip damage state as possible, with the damage popping up, but with the skill animation being visible as well (if the associated skill has an animation set).

    Here's what I'm looking for in point form if that makes it easier:

    > States casting skills each turn they are active (in the script, setting up the states and their skills as a "when x then y" kind of deal would be easiest to edit I think?).

    > No skill name display, but an animation if that skill has one set.

    > A way to keep track of who applied the state to who (essential, since A applying poison to B would execute like A using the skill on B every turn, which requires a user and target for damage processing and all that)

    Not sure how difficult this will be to get set up, but hopefully it's possible. Having states cast skills each turn would open up a whole host of battle possibilities outside of poison damage. You could do healing, group damage, different stat buffs/debuffs, etc.

    If you need any clarification at all, please let me know. Thanks in advance! :)
     
    #1
  2. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,303
    Likes Received:
    12,513
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    #2
  3. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Thanks for the quick reply, but unfortunately this is the RMXP section, and all of those fancy VXAce scripts won't do much for me. :(
     
    #3
  4. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,303
    Likes Received:
    12,513
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    Oops...sorry, missed that. Though, he does have RMXP scripts too...did you check to see if he has equivalent versions? If so that would solve it. If not...well, hopefully an RMXP scripter can help you with that (I don't know RMXP yet).
     
    #4
  5. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    I think this is doable but I have a question: Are you wanting this in addition to what you already have (the DoT/HoT script)? If you do, just post a link to the script you're using and I'll try to keep things compatible. If not, then never mind. 
     
    #5
  6. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    This should be able to easily replace the DoT/HoT script, since I can just make weak damage/healing skills to mimic the effects I think. Sorry, I should have made that clear originally, haha.
     
    #6
  7. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    It's cool. nbd. So anyways, I've pretty much got this to work. At the moment, any time you apply a state the script will remember who applied it. You can apply as many states as you want and it will calculate and apply all of the skill effects using the corresponding actor/enemy who applied it. However, it will only show an animation and damage pop for the highest applied state (i.e. the one with the highest rating/restriction). I'm trying to find a way around that limitation, but no luck so far.

    In the meantime though, I found another DBS oddity when it comes to states. Say you have a skill that applies a single state but then that state causes additional states to be applied, or Skill A cause State A which causes States B and C. Let's further say that State A will last 6 turns while States B and C will each last 3 turns. If you use Skill A, it will of course apply States A, B, and C and assign them all their appropriate turn counters. If you then use Skill A again on the subsequent turn, the DBS won't 'reapply' State A it will only raise it's turn counter back to 6, meaning that State B and C won't have their turn counters reset. So if you continue to use Skill A every turn, you'll never be able to reapply State B and C even if they wear off. You'd only be able to reapply them if State A wore off. So yea, once again I've found something I want to change while working on a script for you. lol  :)
     
    #7
  8. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Glad to hear it's working! The animation thing doesn't sound like a major deal-breaker, so if it's working besides only showing the highest rated state animation, I can definitely live with that. Edit: Oh! I realize now that you said it doesn't show the damage pop either. Hmm, ideally it would show them all, but I can see how that would get messy...

    About the thing that you found...if I'm correct in thinking this, a small change could possibly fix that. Instead of restarting the turn count, maybe it could just remove the state then add it again? Interesting find, nonetheless! Between the two of us, we'll eventually uncover and fix all of RMXP's quirks, haha.
     
    Last edited by a moderator: Sep 7, 2014
    #8
  9. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    I had to do a little bit of jerry-rigging to make it work and it's certainly not the prettiest thing I've written, but it'll get the job done. I've done some basic testing and haven't run into any bugs yet, but let me know if you find some.

    Code:
    #===============================================================================# State Slip Skills# Author: Mobius XVI# Version: 1.0# Date: 09 SEP 2014#===============================================================================## Introduction:##   The purpose of this script is to allow you to set skills to replace#   the default slip damage formula## Instructions:##  - Place this script below all the default scripts but above main##  - In the configuration section below, set up which states will call#    a skill in place of default slip damage. The format is very simple:#    'State_ID' => 'Skill_ID', (without quotes)#    Be sure each line ends in a comma, and make sure all of your lines#    are in between the two curly brackets, i.e. { and }##  - Lastly, in the database, check the box for 'slip damage' for any#    state that you set up in the configuration section. If you don't,#    the script won't call a skill. ##  - One last thing, if you want to use the default slip damage for #    anything, simply check the 'slip damage' box in the database but#    don't configure anything below and the script will use the default#    formula.## Issues/Bugs/Possible Bugs:##   - This script heavily modifies Game_Battler, and my cause bugs in #     in other custom battle systems.##  Credits/Thanks:#    - Mobius XVI, author#    - TheRiotInside, for requesting it##  License#    - This script is licensed under a Creative Commons #      Attribution-ShareAlike 3.0 Unported license.#      A human readable summary is available here: #      [URL="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US#"]http://creativecommons.org/licenses/by-sa/3.0/deed.en_US#[/URL]      The full license is availble here: #      [URL="http://creativecommons.org/licenses/by-sa/3.0/legalcode#"]http://creativecommons.org/licenses/by-sa/3.0/legalcode#[/URL]      In addition, this script is only authorized to be posted to the #      forums on RPGMakerWeb.com.#      Further, if you do decide to use this script in a commercial product, #      I'd ask that you let me know via a forum post or a PM. Thanks.##===============================================================================#                             CONFIGURATION#===============================================================================module Mobius  module State_Slip_Skills        States_to_Skills = {                        # The following is an example                        # that links slip damage on state #3                        # to call skill #5                        3 => 5,                        }      endend#===============================================================================# ** State Slip Skills - EDIT BELOW THIS LINE AT OWN RISK#===============================================================================# Changes to class Game_Battlerclass Game_Battler    # Alias old methods  alias mobius_initialize           initialize  alias mobius_add_state            add_state  alias mobius_remove_state         remove_state  alias mobius_attack_effect        attack_effect  alias mobius_skill_effect         skill_effect  alias mobius_slip_damage_effect   slip_damage_effect    # New methods    def initialize    mobius_initialize    @attacker = nil                 # Variable for temp storing attacker    @states_attacker = {}           # Variable for linking states to attacker  end    def add_state(state_id, force = false)    # Get result of old method (returns nil if ineffective)    result = mobius_add_state(state_id, force = false)    # If effective, link state_id to current attacker    if result      @states_attacker[state_id] = @attacker    end    # Pass result to caller    result  end    def remove_state(state_id, force = false)    # Get result of old method (returns nil if ineffective)    result = mobius_remove_state(state_id, force = false)    # If effective, remove state_id from @states_attacker hash    if result      @states_attacker.delete(state_id)    end    # Pass result to caller    result  end    def attack_effect(attacker)    # temporarily store value of attacker    @attacker = attacker    # call original method    mobius_attack_effect(attacker)    # reset value of attacker    @attacker = nil    # attack effect needs to return true to caller    return true  end    def skill_effect(attacker, skill)    # temporarily store value of attacker    @attacker = attacker    # skill effect return 'effective' to caller    effective = mobius_skill_effect(attacker, skill)    # reset value of attacker    @attacker = nil    # pass value of 'effectve' back to original caller    return effective  end    def slip_damage_effect    for state_id in @states      # If an applied state has slip damage      if $data_states[state_id].slip_damage        # Check if state has associated skill        if skill_id = Mobius::State_Slip_Skills::States_to_Skills[state_id]          # Check if state has associated attacker          if skill_attacker = @states_attacker[state_id]            # Call skill with attacker            skill = $data_skills[skill_id]            effective = self.skill_effect(skill_attacker, skill)            # Set animation info            self.animation_id = $data_skills[skill_id].animation2_id            self.animation_hit = (self.damage != "Miss")            self.damage_pop = true            # Update Spriteset_Battle            $scene.spriteset.update            # Update graphics so animation shows            while $scene.spriteset.effect?              Graphics.update              $scene.spriteset.update            end                      end        # If state not set with skill, use old slip damage effect        else          mobius_slip_damage_effect        end              end    end  end  end# Changes to class Scene_Battleclass Scene_Battle  # Allow public access to Spriteset_Battle  attr_reader :spritesetend 
     
    #9
    TheRiotInside and Another Fen like this.
  10. Another Fen

    Another Fen Veteran Veteran

    Messages:
    532
    Likes Received:
    246
    First Language:
    German
    I like the script. :)

    But is it necessary to do the spriteset-update-loop within the slip damage method? The default battle system discontinues doing phase-updates while a spriteset effect is active anyway and does not freeze the timer and screen effects in the meantime.

    Another suggestion would be perhaps to store a deep copy of the user instead of the user himself to preserve his current state.
     
    Last edited by a moderator: Sep 10, 2014
    #10
  11. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Oh, fantastic! I'll get to testing this out as soon as I can. Thanks in advance, as I'm hopeful this already exceeds my expectations!
     
    #11
  12. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    Yea, I really didn't want to do it that way. It's not IMO good programming style. So the problem is the slip_damage method is designed to only check for one state, and in fact if you only want to display one state you can remove the spriteset-update loop and everything will work just fine. But I wanted to check (and play) multiple states and animations. So the two other ways I thought about doing this was 1: Alter the flow of the DBS's phases to call slip_damage more than once. This didn't seem like a good idea as I'd have to completely rewrite a lot of the DBS unnecessarily since its phase methods don't have a lot of sub-methods. 2: Change how the sprite's animation display method works so I could queue up multiple animations. I actually really liked that idea but I guess I kept doing something wrong because it kept causing the sprites to disappear entirely. 

    As for your suggestion, I'm not really sure what you mean. Could you explain it more? If there's a better way, I'd definitely be interested in seeing it  :)  cause like I said, the script's not exactly pretty.
     
    #12
  13. Another Fen

    Another Fen Veteran Veteran

    Messages:
    532
    Likes Received:
    246
    First Language:
    German
    One thing I forgot to mention:
    When you iterate over an array that might get manipulated during the iteration process you should iterate over a copy instead (regarding the for state in @states line). Otherwise you might skip items or evaluate them multiple times when their positions in the array change (Sorry, had to mention that after learning it the hard way^^).

    About the graphics-loop:
    An alternative could remember the skill-states at the end of phase4_step1 of the battle process and execute them one by one at the beginning of phase4_step2 before the battler sets up his action. That would also allow to run a skills common event for example (although one should prevent Force Action within them since the BS can not remember more than one battler at once).
     

    About the suggestion:
    When the causer of a state was debuffed so the state would deal less damage, but the debuff is removed for any reason (for example when the causer dies) the state would deal more damage from now on, even though there is no real connection to the caster any more.

    This is not necessarily a flaw, but the suggestion was something like this to ensure the damage remains about constant (isn't the cleanest way either):

    Code:
    class Game_Battler   attr_accessor :state_copy   def add_state(state_id, force = false)    result = mobius_add_state(state_id, force)    if result  # when effective      # Create a copy of the attacker to preserve the values of his attributes:      if Mobius::State_Slip_Skills::States_to_Skills.include?(state_id) and      @attacker != nil and not @attacker.state_copy        @attacker = Marshal.load(Marshal.dump(@attacker))        @attacker.state_copy = true      end      # Set attacker:      @states_attacker[state_id] = @attacker    end  end end
     
    Last edited by a moderator: Sep 10, 2014
    #13
  14. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    So far this is working great! The only quirks that I notice are because I am so anal about details, haha. I'll mention them just for mentioning sake, these aren't problems that need to be addressed or anything. I noticed that when the damage pops, the HP reduces a fraction of a second afterwards, while during normal damage dealing, the change is pretty much synced up. Also there seems to be a small delay between the state skill running and the actor's actual action occurring. This could just be my slow laptop, however.

    Again, these aren't complaints, just little details that I thought I'd make known in case you were as anal about this stuff as I am, haha. Thanks a lot for the time spent helping me out. It's appreciated.
     
    #14
  15. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    So the more I work on this, the more I realize my code is terrible. I think I'm going to go with plan B - throw everything out and start over. Seriously. I'm determined to make this look good.
     
    #15
    TheRiotInside likes this.
  16. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    So like I initially thought the only way to really make this work the way I wanted it to was to go in and fork the flow of the DBS. But thankfully this wasn't as hard as I thought. I now present you to a much prettier version (that basically does the same thing lol)

    Code:
    #===============================================================================# State Slip Skills# Author: Mobius XVI# Version: 1.5# Date: 05 SEP 2014#===============================================================================## Introduction:##   The purpose of this script is to allow you to set skills to replace#   the default slip damage formula## Instructions:##  - Place this script below all the default scripts but above main##  - In the configuration section below, set up which states will call#    a skill in place of default slip damage. The format is very simple:#    'State_ID' => 'Skill_ID', (without quotes)#    Be sure each line ends in a comma, and make sure all of your lines#    are in between the two curly brackets, i.e. { and }##  - Lastly, in the database, check the box for 'slip damage' for any#    state that you set up in the configuration section. If you don't,#    the script won't call a skill. ##  - There are also a few more options described in detail in the#    configuration section below, so be sure to check those out.##  - One last thing, if you want to use the default slip damage for #    anything, simply check the 'slip damage' box in the database but#    don't configure anything below and the script will use the default#    formula.## Issues/Bugs/Possible Bugs:##   - This script heavily modifies Game_Battler, and my cause bugs in #     in other custom battle systems.##  Credits/Thanks:#    - Mobius XVI, author#    - TheRiotInside, for requesting it##  License#    - This script is licensed under a Creative Commons #      Attribution-ShareAlike 3.0 Unported license.#      A human readable summary is available here: #      [URL="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US#"]http://creativecommons.org/licenses/by-sa/3.0/deed.en_US#[/URL]      The full license is availble here: #      [URL="http://creativecommons.org/licenses/by-sa/3.0/legalcode#"]http://creativecommons.org/licenses/by-sa/3.0/legalcode#[/URL]      In addition, this script is only authorized to be posted to the #      forums on RPGMakerWeb.com.#      Further, if you do decide to use this script in a commercial product, #      I'd ask that you let me know via a forum post or a PM. Thanks.##===============================================================================#                             CONFIGURATION#===============================================================================module Mobius  module State_Slip_Skills        States_to_Skills = {                        # The following is an example                        # that links slip damage on state #3                        # to call skill #57                        3 => 57,                        23 => 23,                        }        # Setting this option to "true" causes the skill to track changes    # to the original caster, i.e. if the caster get buffed then    # the skill will cause more damage per turn or if the caster gets    # debuffed the skill will cause less damage.    # Setting this to "false" will cause the skill to take a snapshot    # of the original caster, i.e. the skill will deal the same damage    # each turn (with variance) regardless of what happens to the caster.    Allow_Changes = true        # >This option only works if "Allow_Changes" is set to true<    # >This option only effects skills that are set in States_to_Skills<    # Setting this option to "true" causes states to be removed when    # the original caster dies.    # Setting this option to false will allow states to remain even    # if the original caster dies.    End_State_on_Actor_Death = true      endend#===============================================================================# ** State Slip Skills - EDIT BELOW THIS LINE AT OWN RISK#===============================================================================#--------------------------------------------------------------------------# Changes to class Game_Battler#--------------------------------------------------------------------------class Game_Battler    # Alias old methods  alias mobius_initialize           initialize  alias mobius_add_state            add_state  alias mobius_remove_state         remove_state  alias mobius_attack_effect        attack_effect  alias mobius_skill_effect         skill_effect  alias mobius_slip_damage_effect   slip_damage_effect    # New methods    #--------------------------------------------------------------------------  # * New Public Instance Variables  #--------------------------------------------------------------------------  attr_reader                       :animation_queue    #--------------------------------------------------------------------------  # * Initialize - adds new variables for tracking states  #--------------------------------------------------------------------------  def initialize    mobius_initialize    @attacker = nil                 # Variable for temp storing attacker    @states_attacker = {}           # Variable for linking states to attacker    @animation_queue = []           # Variable for queuing animations  end  #--------------------------------------------------------------------------  # * Add State -  Links applied state to caster/actor that caused it  #--------------------------------------------------------------------------  def add_state(state_id, force = false)    # Get result of old method (returns nil if ineffective)    result = mobius_add_state(state_id, force = false)    # If effective, link state_id to current attacker    if result      if Mobius::State_Slip_Skills::Allow_Changes        @states_attacker[state_id] = @attacker      else        @states_attacker[state_id] = @attacker.clone      end    end    # Pass result to caller    result  end  #--------------------------------------------------------------------------  # * Remove State - Removes associated caster/actor link   #--------------------------------------------------------------------------  def remove_state(state_id, force = false)    # Get result of old method (returns nil if ineffective)    result = mobius_remove_state(state_id, force = false)    # If effective, remove state_id from @states_attacker hash    if result      @states_attacker.delete(state_id)    end    # Pass result to caller    result  end  #--------------------------------------------------------------------------  # * Attack Effect - Stores attacker in local variable for linking to state  #--------------------------------------------------------------------------  def attack_effect(attacker)    # temporarily store value of attacker    @attacker = attacker    # call original method    mobius_attack_effect(attacker)    # reset value of attacker    @attacker = nil    # attack effect needs to return true to caller    return true  end  #--------------------------------------------------------------------------  # * Skill Effect - Stores attacker in local variable for linking to state  #--------------------------------------------------------------------------  def skill_effect(attacker, skill)    # temporarily store value of attacker    @attacker = attacker    # skill effect return 'effective' to caller    effective = mobius_skill_effect(attacker, skill)    # reset value of attacker    @attacker = nil    # pass value of 'effectve' back to original caller    return effective  end  #--------------------------------------------------------------------------  # * Slip Damage Effect - drastically overhauled  #    Now checks for states that are linked to skills and calls those  #    skills up with an associated caster/actor. It will also store the  #    results of the skill for display at a later time.  #    If state is not set up that way, method calls original method  #--------------------------------------------------------------------------  def slip_damage_effect    for state_id in @states      # If an applied state has slip damage      if $data_states[state_id].slip_damage        # Check if state has associated skill        if skill_id = Mobius::State_Slip_Skills::States_to_Skills[state_id]          # Check if state has associated attacker          if skill_attacker = @states_attacker[state_id]            # Check if End_State option is true and actor is dead            if Mobius::State_Slip_Skills::End_State_on_Actor_Death and               skill_attacker.dead?               # Remove state               self.remove_state(state_id)               # Go to next state               next            end                      # Call skill with attacker            skill = $data_skills[skill_id]            effective = self.skill_effect(skill_attacker, skill)            # Set animation info            add_animation_to_queue(skill.animation2_id,                                   self.damage,                                    self.critical)            # Restore HP so it can be deducted when animation plays            if self.damage.is_a?(Numeric)              self.hp += self.damage            end          end        # If state not set with skill, use old slip damage effect        else          mobius_slip_damage_effect        end              end    end  end  #--------------------------------------------------------------------------  # New methods that allow for queuing damage animations  # Data structure - Array of arrays with sub arrays containing:  # [animation_id, damage, critical]  #--------------------------------------------------------------------------  # * Add Animation to Queue - adds an animation to the queue  #--------------------------------------------------------------------------  def add_animation_to_queue(id, dam, crit)    arr = [id, dam, crit]    @animation_queue.push(arr)  end    #--------------------------------------------------------------------------  # * Set Up Animation - Sets up new queued animation data  #--------------------------------------------------------------------------  def set_up_queued_animation    # Get animation data    arr = @animation_queue[0]    # Ensure it's not nil    if arr      # Set all parameters      self.animation_id = arr[0]      self.damage = arr[1]      self.animation_hit = (self.damage != "Miss")    end  end  #--------------------------------------------------------------------------  # * Unqueue Animation - Removes queued animation and plays damage pop  #--------------------------------------------------------------------------  def unqueue_animation    # Get animation data    arr = @animation_queue.shift    # Ensure it's not nil    if arr      # Set all parameters      self.damage = arr[1]      self.critical = arr[2]      self.damage_pop = true      # If damage is a number, i.e. not "Miss"      if self.damage.is_a?(Numeric)        # Deal the damage here, so that the timing is right        self.hp -= self.damage      end    end  end  #--------------------------------------------------------------------------  # * Animation Queued? - returns whether there are animations waiting  #--------------------------------------------------------------------------  def animation_queued?    return ( not (@animation_queue.empty?) )      endend # class Game_Battler end#--------------------------------------------------------------------------# Changes to class Scene_Battle#--------------------------------------------------------------------------class Scene_Battle    # alias old methods  alias mobius_update_phase4_step1     update_phase4_step1    #--------------------------------------------------------------------------  # * Update Phase 4 - Method branches phase 4 to different steps  #    Added steps 'slip1' and 'slip2'   #--------------------------------------------------------------------------  def update_phase4    case @phase4_step    when 1      update_phase4_step1    when 2      update_phase4_step2    when 3      update_phase4_step3    when 4      update_phase4_step4    when 5      update_phase4_step5    when 6      update_phase4_step6    when "slip1"      update_phase4_slip1    when "slip2"      update_phase4_slip2    end  end  #--------------------------------------------------------------------------  # * Update Phase 4 Slip 1 - Plays state animation on target  #--------------------------------------------------------------------------  def update_phase4_slip1    # Animation for target    @active_battler.set_up_queued_animation    # Animation has at least 8 frames, regardless of its length    @wait_count = 8    # Shift to step slip2    @phase4_step = "slip2"  end  #--------------------------------------------------------------------------  # * Update Phase 4 Slip 2 - Plays damage pop on target  #--------------------------------------------------------------------------  def update_phase4_slip2        # Display damage    @active_battler.unqueue_animation    # Refresh status window    @status_window.refresh    # Check if additional animations to show    if @active_battler.animation_queued?      # Shift to step slip1      @phase4_step = "slip1"    else      # Shift to step 2      @phase4_step = 2    end  end  #--------------------------------------------------------------------------  # * Update Phase 4 Step 1 - After old method runs, checks if there are  #    animations to play and if there are, then it unsets the damage pop  #--------------------------------------------------------------------------    def update_phase4_step1    # Call old method    result = mobius_update_phase4_step1    # Check that the active battler is valid and animations are waiting    if result and @active_battler.animation_queued?        # Set damage pop to false        @active_battler.damage_pop = false        # Shift to slip phase        @phase4_step = "slip1"    end  endend # class Scene_Battle end 
     
    #16
    TheRiotInside likes this.
  17. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    Ah! This seems like a definite improvement. The timing issues I mentioned are all fixed, and everything matches the flow of the DBS very nicely. This is fantastic!
     
    #17
    MobiusXVI likes this.
  18. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    I have unfortunately encountered a crash in the script. I didn't notice it earlier because I was doing all of my battle testing in the database, but after a battle in-game, I'm getting this: (note: I started a new game after installing the script, just in case it doesn't cooperate with previous saves)

    [​IMG]

    [​IMG]

    Hopefully this isn't too painful to sort out. Loving the script so far. :)

    EDIT: Okay, I've done some troubleshooting, and this is turning out to be a weird problem. It looks like battles in-game are not directly causing this issue. I have on-screen enemies that run around and trigger fights when they catch you, but when I added an event to the map with just a battle processing event command, it did not throw the error. Then I tried adding little bits to the event one at a time until I either recreated the other monster events completely, or the error returns.

    It turns out that a common event that I call after fights is what is causing the error, but it's weird. I do a pre-battle check in a common event where it stores all party members' levels with variables, and then another after the battle to check to see if the value is smaller than their level (to see if they level up). It looks like the post-battle common event is throwing the error, but I have no idea why, since it's outside of battle processing.

    Furthermore, it looks like it has absolutely nothing to do with battle. I made an event with just the post-battle common event in it and nothing else, and it throws the error. Here's the common event:

    [​IMG]

    Something to do with it running conditional branches for actors not in the party, but I have no idea why that would cause this error. Any help is greatly appreciated!
     
    Last edited by a moderator: Oct 4, 2014
    #18
  19. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    362
    Likes Received:
    84
    First Language:
    English
    Are you sure it's not the common event marked "Level up"? That would seem more likely to me. Anyways, this should be an easy fix. Try this patched version.

    Code:
    #===============================================================================# State Slip Skills# Author: Mobius XVI# Version: 1.5# Date: 05 SEP 2014#===============================================================================## Introduction:##   The purpose of this script is to allow you to set skills to replace#   the default slip damage formula## Instructions:##  - Place this script below all the default scripts but above main##  - In the configuration section below, set up which states will call#    a skill in place of default slip damage. The format is very simple:#    'State_ID' => 'Skill_ID', (without quotes)#    Be sure each line ends in a comma, and make sure all of your lines#    are in between the two curly brackets, i.e. { and }##  - Lastly, in the database, check the box for 'slip damage' for any#    state that you set up in the configuration section. If you don't,#    the script won't call a skill. ##  - There are also a few more options described in detail in the#    configuration section below, so be sure to check those out.##  - One last thing, if you want to use the default slip damage for #    anything, simply check the 'slip damage' box in the database but#    don't configure anything below and the script will use the default#    formula.## Issues/Bugs/Possible Bugs:##   - This script heavily modifies Game_Battler, and my cause bugs in #     in other custom battle systems.##  Credits/Thanks:#    - Mobius XVI, author#    - TheRiotInside, for requesting it##  License#    - This script is licensed under a Creative Commons #      Attribution-ShareAlike 3.0 Unported license.#      A human readable summary is available here: #      [URL="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US#"]http://creativecommons.org/licenses/by-sa/3.0/deed.en_US#[/URL]      The full license is availble here: #      [URL="http://creativecommons.org/licenses/by-sa/3.0/legalcode#"]http://creativecommons.org/licenses/by-sa/3.0/legalcode#[/URL]      In addition, this script is only authorized to be posted to the #      forums on RPGMakerWeb.com.#      Further, if you do decide to use this script in a commercial product, #      I'd ask that you let me know via a forum post or a PM. Thanks.##===============================================================================#                             CONFIGURATION#===============================================================================module Mobius  module State_Slip_Skills        States_to_Skills = {                        # The following is an example                        # that links slip damage on state #3                        # to call skill #57                        3 => 57,                        23 => 23,                        }        # Setting this option to "true" causes the skill to track changes    # to the original caster, i.e. if the caster get buffed then    # the skill will cause more damage per turn or if the caster gets    # debuffed the skill will cause less damage.    # Setting this to "false" will cause the skill to take a snapshot    # of the original caster, i.e. the skill will deal the same damage    # each turn (with variance) regardless of what happens to the caster.    Allow_Changes = true        # >This option only works if "Allow_Changes" is set to true<    # >This option only effects skills that are set in States_to_Skills<    # Setting this option to "true" causes states to be removed when    # the original caster dies.    # Setting this option to false will allow states to remain even    # if the original caster dies.    End_State_on_Actor_Death = true      endend#===============================================================================# ** State Slip Skills - EDIT BELOW THIS LINE AT OWN RISK#===============================================================================#--------------------------------------------------------------------------# Changes to class Game_Battler#--------------------------------------------------------------------------class Game_Battler    # Alias old methods  alias mobius_initialize           initialize  alias mobius_add_state            add_state  alias mobius_remove_state         remove_state  alias mobius_attack_effect        attack_effect  alias mobius_skill_effect         skill_effect  alias mobius_slip_damage_effect   slip_damage_effect    # New methods    #--------------------------------------------------------------------------  # * New Public Instance Variables  #--------------------------------------------------------------------------  attr_reader                       :animation_queue    #--------------------------------------------------------------------------  # * Initialize - adds new variables for tracking states  #--------------------------------------------------------------------------  def initialize    mobius_initialize    @attacker = nil                 # Variable for temp storing attacker    @states_attacker = {}           # Variable for linking states to attacker    @animation_queue = []           # Variable for queuing animations  end  #--------------------------------------------------------------------------  # * Add State -  Links applied state to caster/actor that caused it  #--------------------------------------------------------------------------  def add_state(state_id, force = false)    # Get result of old method (returns nil if ineffective)    result = mobius_add_state(state_id, force = false)    # If effective, link state_id to current attacker    if result       unless @attacker == nil        if Mobius::State_Slip_Skills::Allow_Changes          @states_attacker[state_id] = @attacker        else          @states_attacker[state_id] = @attacker.clone        end      end    end    # Pass result to caller    result  end  #--------------------------------------------------------------------------  # * Remove State - Removes associated caster/actor link   #--------------------------------------------------------------------------  def remove_state(state_id, force = false)    # Get result of old method (returns nil if ineffective)    result = mobius_remove_state(state_id, force = false)    # If effective, remove state_id from @states_attacker hash    if result      @states_attacker.delete(state_id)    end    # Pass result to caller    result  end  #--------------------------------------------------------------------------  # * Attack Effect - Stores attacker in local variable for linking to state  #--------------------------------------------------------------------------  def attack_effect(attacker)    # temporarily store value of attacker    @attacker = attacker    # call original method    mobius_attack_effect(attacker)    # reset value of attacker    @attacker = nil    # attack effect needs to return true to caller    return true  end  #--------------------------------------------------------------------------  # * Skill Effect - Stores attacker in local variable for linking to state  #--------------------------------------------------------------------------  def skill_effect(attacker, skill)    # temporarily store value of attacker    @attacker = attacker    # skill effect return 'effective' to caller    effective = mobius_skill_effect(attacker, skill)    # reset value of attacker    @attacker = nil    # pass value of 'effectve' back to original caller    return effective  end  #--------------------------------------------------------------------------  # * Slip Damage Effect - drastically overhauled  #    Now checks for states that are linked to skills and calls those  #    skills up with an associated caster/actor. It will also store the  #    results of the skill for display at a later time.  #    If state is not set up that way, method calls original method  #--------------------------------------------------------------------------  def slip_damage_effect    for state_id in @states      # If an applied state has slip damage      if $data_states[state_id].slip_damage        # Check if state has associated skill        if skill_id = Mobius::State_Slip_Skills::States_to_Skills[state_id]          # Check if state has associated attacker          if skill_attacker = @states_attacker[state_id]            # Check if End_State option is true and actor is dead            if Mobius::State_Slip_Skills::End_State_on_Actor_Death and               skill_attacker.dead?               # Remove state               self.remove_state(state_id)               # Go to next state               next            end                      # Call skill with attacker            skill = $data_skills[skill_id]            effective = self.skill_effect(skill_attacker, skill)            # Set animation info            add_animation_to_queue(skill.animation2_id,                                   self.damage,                                    self.critical)            # Restore HP so it can be deducted when animation plays            if self.damage.is_a?(Numeric)              self.hp += self.damage            end          end        # If state not set with skill, use old slip damage effect        else          mobius_slip_damage_effect        end              end    end  end  #--------------------------------------------------------------------------  # New methods that allow for queuing damage animations  # Data structure - Array of arrays with sub arrays containing:  # [animation_id, damage, critical]  #--------------------------------------------------------------------------  # * Add Animation to Queue - adds an animation to the queue  #--------------------------------------------------------------------------  def add_animation_to_queue(id, dam, crit)    arr = [id, dam, crit]    @animation_queue.push(arr)  end    #--------------------------------------------------------------------------  # * Set Up Animation - Sets up new queued animation data  #--------------------------------------------------------------------------  def set_up_queued_animation    # Get animation data    arr = @animation_queue[0]    # Ensure it's not nil    if arr      # Set all parameters      self.animation_id = arr[0]      self.damage = arr[1]      self.animation_hit = (self.damage != "Miss")    end  end  #--------------------------------------------------------------------------  # * Unqueue Animation - Removes queued animation and plays damage pop  #--------------------------------------------------------------------------  def unqueue_animation    # Get animation data    arr = @animation_queue.shift    # Ensure it's not nil    if arr      # Set all parameters      self.damage = arr[1]      self.critical = arr[2]      self.damage_pop = true      # If damage is a number, i.e. not "Miss"      if self.damage.is_a?(Numeric)        # Deal the damage here, so that the timing is right        self.hp -= self.damage      end    end  end  #--------------------------------------------------------------------------  # * Animation Queued? - returns whether there are animations waiting  #--------------------------------------------------------------------------  def animation_queued?    return ( not (@animation_queue.empty?) )      endend # class Game_Battler end#--------------------------------------------------------------------------# Changes to class Scene_Battle#--------------------------------------------------------------------------class Scene_Battle    # alias old methods  alias mobius_update_phase4_step1     update_phase4_step1    #--------------------------------------------------------------------------  # * Update Phase 4 - Method branches phase 4 to different steps  #    Added steps 'slip1' and 'slip2'   #--------------------------------------------------------------------------  def update_phase4    case @phase4_step    when 1      update_phase4_step1    when 2      update_phase4_step2    when 3      update_phase4_step3    when 4      update_phase4_step4    when 5      update_phase4_step5    when 6      update_phase4_step6    when "slip1"      update_phase4_slip1    when "slip2"      update_phase4_slip2    end  end  #--------------------------------------------------------------------------  # * Update Phase 4 Slip 1 - Plays state animation on target  #--------------------------------------------------------------------------  def update_phase4_slip1    # Animation for target    @active_battler.set_up_queued_animation    # Animation has at least 8 frames, regardless of its length    @wait_count = 8    # Shift to step slip2    @phase4_step = "slip2"  end  #--------------------------------------------------------------------------  # * Update Phase 4 Slip 2 - Plays damage pop on target  #--------------------------------------------------------------------------  def update_phase4_slip2        # Display damage    @active_battler.unqueue_animation    # Refresh status window    @status_window.refresh    # Check if additional animations to show    if @active_battler.animation_queued?      # Shift to step slip1      @phase4_step = "slip1"    else      # Shift to step 2      @phase4_step = 2    end  end  #--------------------------------------------------------------------------  # * Update Phase 4 Step 1 - After old method runs, checks if there are  #    animations to play and if there are, then it unsets the damage pop  #--------------------------------------------------------------------------    def update_phase4_step1    # Call old method    result = mobius_update_phase4_step1    # Check that the active battler is valid and animations are waiting    if result and @active_battler.animation_queued?        # Set damage pop to false        @active_battler.damage_pop = false        # Shift to slip phase        @phase4_step = "slip1"    end  endend # class Scene_Battle end 
     
    #19
  20. TheRiotInside

    TheRiotInside Extra Ordinaire Veteran

    Messages:
    273
    Likes Received:
    125
    Location:
    Canada
    First Language:
    English
    I believe that the level up common event is fine, because when I engage a battle and my actor levels up, it calls the level up common event for that actor fine, but crashes right after that. So I'm thinking it had something to do with checking actors that weren't in the party.

    Regardless, the issue seems to be resolved! Thanks for the quick support, and being generally helpful as always, haha.
     
    #20
    MobiusXVI likes this.

Share This Page