Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Lylac#c0ffee on March 06, 2014, 09:44:19 am

Title: Changing Skill Power via State
Post by: Lylac#c0ffee on March 06, 2014, 09:44:19 am
I have this little "Aura" system set up for my game. Basically, the auras are states that affect certain attributes. Each aura is related to an element. I would like for the auras to also increase the power of skills related to that element, but decrease the power of skills related to the opposing element.

Example:
Light Aura - increases magic defense and power of Light skills, but decreases the power of Dark skills

The magic defense part is easy; database configuration does that. I just hope there's an easy fix for the other.  :) If it's already out there, and I just can't seem to find it, a pointer in that direction would be awesome. I like to think this wouldn't be too hard, but what do I know?  :shy:

Any help is greatly appreciated. Thanks in advance!
Title: Re: Changing Skill Power via State
Post by: G_G on March 06, 2014, 10:52:55 am
Okay, here's the way I tackled it. Instead of coming up with new damage formulas, all I did was make the script temporarily change the skill's power attribute. After damage calculations, the power is reset.

The way it's setup, in the config, you have to apply element's to a state. One state ID can have as many element IDs inside it. Each element ID is then associated a percentage..... Here's an example, it might explain a bit better.

    STATES = {
    #===========================================================
    # STATES
    # Each state gets it's own hash. Then you add any element
    # you want affected and the percentage. Example below.
    #===========================================================
   
      # State: Light Boost
      17 => {
        # Light Element
        7 => 0.25, # Light is boosted by 25%
        # Dark Element
        8 => -0.5, # Dark power is decreased by 50%
      },
     
      # State ID 18
      18 => {
        7 => -0.5, # Light decreased by 50
        8 => 1.0, # Dark increased by 100 (doubled)
      },
     
    }


Here's the full scripted. I tested it with just the default battle system, but I know this will work for Blizz-ABS (and should with any custom battle system) as it just modifies the skill method.
#===============================================================================
# States Affect Skills
# Version 1.0
# Author gameus
#-------------------------------------------------------------------------------
# Intro:
# This script lets states affect skills power based on elements. For example,
# a state "Light Boost" can boost the power of skills with the "Light"
# element. It can also decrease the power of other skills, with this example,
# it could lower skills with the "Dark" element.
#
# What it's really doing is just modifying the skills power attribute and
# resetting it after damage calculations.
#
# Features:
# States can effect as many elements
# Power increase/decrease is based on a decimal percentage
# Easy to setup
#
# Instructions:
# In the config.
#
# Compatibility:
# Not tested with SDK
# Should work with anything
#
# Credits:
# gameus ~ For making it
# Lylac#c0ffee - For requesting it
#===============================================================================
module Gameus
  module SPS
    STATES = {
    #===========================================================
    # STATES
    # Each state gets it's own hash. Then you add any element
    # you want affected and the percentage. Example below.
    #===========================================================
   
      # State: Light Boost
      17 => {
        # Light Element
        7 => 0.25, # Light is boosted by 25%
        # Dark Element
        8 => -0.5, # Dark power is decreased by 50%
      },
     
      # State ID 18
      18 => {
        7 => -0.5, # Light decreased by 50
        8 => 1.0, # Dark increased by 100 (doubled)
      },
     
    }
  end
end

class Game_Battler
  include Gameus::SPS
  alias gg_state_power_skill_lat skill_effect
  def skill_effect(user, skill)
    old_power = skill.power
    user.states.each { |state_id|
      if STATES.has_key?(state_id)
        skill.element_set.each { |element_id|
          if STATES[state_id].has_key?(element_id)
            mod = (skill.power * STATES[state_id][element_id]).to_i
            skill.power > 0 ? skill.power += mod : skill.power -= mod
          end
        }
      end
    }
    result = gg_state_power_skill_lat(user, skill)
    skill.power = old_power
    return result
  end
end


Enjoy!
Title: Re: Changing Skill Power via State
Post by: Lylac#c0ffee on March 06, 2014, 01:26:28 pm
It works! I love you!  :D

Thank you so much!