Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: syldocaine on February 20, 2015, 09:40:26 pm

Title: Element and State Efficiency for States
Post by: syldocaine on February 20, 2015, 09:40:26 pm
Hi all,

Im looking for a script for RMXP to change the efficieny of elements and states with a state.
For example a state such as the oil state in final fantasy where fire spells inflicted more damage.

Or an protection against poison, which lowers succes rate for poison attacks.

Is there something like that available?

Title: Re: Element and State Efficiency for States
Post by: chaucer on February 20, 2015, 11:36:51 pm
http://forum.chaos-project.com/index.php?topic=5061.0

Check the first feature. :D lol I spent forever googling for it cause i knew someone made it but couldnt find anything till now. not sure if it's exactly what you need, I'm sure you could easily modify it to add more states besides oil as well, also the poison thing could be done in the database already(not sure if thats what you need exactly?). You can go to states and add elemental defense to whatever state you want it to guard against(reduces damage by half i think, havent tried it.)
Title: Re: Element and State Efficiency for States
Post by: syldocaine on February 21, 2015, 05:55:38 am
Thx for that link.

Yes i think can modify the oil thing for all elements, thats nice. In the thread they were already talking about that. Would be interesting

But for the protection, I can't do this with the database. Because of that i'm searching for a script. I want to make a state which protects you against other states. Protection against poison makes your character immune to poison. Protection against silence makes him immune against silence and so on.

I think the easiest thing, would be a script which creates states to change temporarly the element and state efficiency of the target. For example set the element Fire to A or the state poison to F.
Would offer alot of more options. Atm the states are very limited in their functions. You could also do some absorb states if you set thunder as example to F. So adding this state to your character all thunder spelld would heal him.
Or combine these features. A state which sets fire to F and on the other hand water to A. Your character would be healed by fire and crushed by water then.
Would be awsome to have something like that.
Title: Re: Element and State Efficiency for States
Post by: KK20 on February 21, 2015, 03:01:46 pm
I can probably whip up something fast in the next couple of days.
Title: Re: Element and State Efficiency for States
Post by: syldocaine on February 21, 2015, 08:51:30 pm
That sounds cool.

Thx in advance.
Title: Re: Element and State Efficiency for States
Post by: KK20 on February 22, 2015, 08:23:22 pm

=begin

Side-Note: For any element-resist state configured below, it will ignore the
default RMXP system of handling element rates. This means that if the actor has
a state that makes him immune to fire damage, but has a shield that is set to
absorb fire damage, the state will trump the shield, meaning he will not absorb.

As for state success rates, armors that guard against a state will remain
fully resistant to that state regardless if the actor is applied with a state
that makes them more susceptible to gaining the state. For example, if the actor
has a Poison Pin that resists Poison and is affected with a state that increases
the rate of Poison being applied, the Poison Pin will still protect him from
ever being Poisoned.

Also, any state that is set to "Nonresistance" will always work 100% of the
time, regardless of any configuration you do below.

=end

module State_Element
  #:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
  # B E G I N   C O N F I G U R A T I O N
  #:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
  def self.element_resist(state_id)
    return case state_id
    #---------------------------------------------------------------------------
    # Defines element resistance rates when applied with a certain state. This
    # number will overrule the default system. If multiple states change the
    # rate, only the lowest will be applied. Do not use decimal numbers.
    #   Format:
    #   when STATE_ID then {ELEMENT_ID => RATE, ELEMENT_ID => RATE, ...}
    #---------------------------------------------------------------------------
    when 1 then {1 => 150} # When applied with state 1, element 1 will do 1.5x more damage
    when 2 then {2 => -100, 3 => 50} # When applied with state 2, element 2 will heal, element 3 will do half damage
    #---------------------------------------------------------------------------
    else
      {}
    end
  end
 
  def self.state_resist(state_id)
    return case state_id
    #---------------------------------------------------------------------------
    # Defines state resistance rates when applied with a certain state. This
    # number will overrule the default system. A state applied with the
    # 'Nonresistance' attribute will still have a 100% success rate. If multiple
    # states change the rate, only the lowest will be applied. Do not use
    # decimal numbers.
    #   Format:
    #   when STATE_ID then {STATE_ID => RATE, STATE_ID => RATE, ...}
    #---------------------------------------------------------------------------
    when 1 then {3 => 100} # When applied with state 1, state 3 will be applied all the time
    when 2 then {4 => 0, 5 => 50} # When applied with state 2, immune to state 4, state 5 applied half the time
    #---------------------------------------------------------------------------
    else
      {}
    end
  end
  #:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
  # E N D   C O N F I G U R A T I O N
  #:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
end

#==============================================================================
# ** Game_Battler
#==============================================================================
class Game_Battler
  #--------------------------------------------------------------------------
  # * State Change (+) Application
  #     plus_state_set  : State Change (+)
  #--------------------------------------------------------------------------
  alias check_for_state_resist_statesplus states_plus
  def states_plus(plus_state_set)
    # Clear effective flag
    effective = false
    # Create list for states that have customized resistances
    evaluated_states = []
    # Loop (added state)
    for i in plus_state_set
      # If this state is not guarded
      unless self.state_guard?(i)
        # Initialize resistance effects
        success_rate = 101
        # Cycle through all the battler's applied states
        @states.each{|applied_state|
          # Get the resistance data for this state
          resist = State_Element.state_resist(applied_state)[i]
          # Go to the next applied state if no resistance data
          next if resist.nil?
          effect_applied = true
          # Pick the smaller of the two success rates
          success_rate = [success_rate, resist].min
        }
        next unless success_rate != 101
        # Set effective flag if this state is not full
        effective |= self.state_full?(i) == false
        # If states offer [no resistance]
        if $data_states[i].nonresistance
          # Set state change flag
          @state_changed = true
          # Add a state
          add_state(i)
          evaluated_states.push(i)
        # If this state is not full
        elsif self.state_full?(i) == false
          # Convert state effectiveness to probability,
          # compare to random numbers
          if rand(100) < success_rate
            # Set state change flag
            @state_changed = true
            # Add a state
            add_state(i)
          end
          evaluated_states.push(i)
        end
      end
    end
    # Call alias
    also_effective = check_for_state_resist_statesplus(plus_state_set - evaluated_states)
    # End Method
    return effective || also_effective
  end
end
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Get Element Revision Value
  #     element_id : element ID
  #--------------------------------------------------------------------------
  alias set_element_rate_statically element_rate
  def element_rate(element_id)
    # Run through all applied states
    rate = nil
    for i in @states
      resist = State_Element.element_resist(i)[element_id]
      # Go to the next applied state if no resistance data
      next if resist.nil?
      # Pick the smaller of the two rates
      rate = [rate, resist].min
    end
    # If no customized rate for states, use default resistance
    if rate.nil?
      return set_element_rate_statically(element_id)
    else
      return rate
    end
  end
end
#==============================================================================
# ** Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # * Get Element Revision Value
  #     element_id : Element ID
  #--------------------------------------------------------------------------
  alias set_element_rate_statically element_rate
  def element_rate(element_id)
    # Run through all applied states
    rate = nil
    for i in @states
      resist = State_Element.element_resist(i)[element_id]
      # Go to the next applied state if no resistance data
      next if resist.nil?
      # Pick the smaller of the two rates
      rate = [rate, resist].min
    end
    # If no customized rate for states, use default resistance
    if rate.nil?
      return set_element_rate_statically(element_id)
    else
      return rate
    end
  end
end
Title: Re: Element and State Efficiency for States
Post by: syldocaine on February 24, 2015, 09:29:17 am
Awsome work! thx

You are the man, KK20.

I think this script should be databased, because its really cool.