Save-Point
KElementRate VX - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker VX/VXAce (RGSS2/3) Engines (https://www.save-point.org/forum-117.html)
+---- Thread: KElementRate VX (/thread-9479.html)



KElementRate VX - kyonides - 09-19-2024

KElementRate VX

by Kyonides


Introduction

This script replaces the Database's Element Ranks with a Brand New One!
That means that your hero will now have a blank list of ranks.
It could be great for further improving a Ghim hero's customization process.

The comments embedded in my script Editor clearly explain what are the available script calls you can use starting today! Grinning

The Script

Code:
# * KElementRate VX
#   Scripter : Kyonides Arkanthes
#   v0.3.0 - 022-11-13

# This script replaces the Database's Element Ranks with a Brand New One!
# That means that your hero will now have a blank list of ranks.
# It could be great for further improving a hero's customization process.

# * Enable Custom Element Ranks From the Very Beginning * #
# CUSTOM_RATES_ACTORS = [Add, As, Many, Actor, IDs, As, Deemed, Necessary]

# * Enable / Disable Custom Element Ranks In Game * #
# $game_actors[ActorID].element_ranks_enabled = true
# $game_actors[ActorID].element_ranks_enabled = false

# * Alter a Hero's Element Rank * #
# - Default Table of Resistance: [0,200,150,100,50,0,-100]
# $game_actors[ActorID].element_ranks[ElementID] = Position aka Index

module KElem
  module Rate
    CUSTOM_RATES_INDEX = 3 # Default Percent: 100
    CUSTOM_RATES_ACTORS = [1]
    ARMOR_REDUCE_FACTOR = 2
    STATE_REDUCE_FACTOR = 2
  end
end

class Game_Actor
  include KElem::Rate
  ELEMENT_PERCENTS = [0,200,150,100,50,0,-100]
  attr_reader :element_ranks_enabled
  alias :kyon_elem_rate_gm_actor_setup :setup
  def setup(actor_id)
    kyon_elem_rate_gm_actor_setup(actor_id)
    self.element_ranks_enabled = CUSTOM_RATES_ACTORS.include?(actor_id)
  end

  def db_element_ranks
    $data_classes[@class_id].element_ranks
  end

  def element_ranks
    @element_ranks_enabled ? @element_ranks : db_element_ranks
  end

  def element_ranks_enabled=(bool)
    return bool if bool == @element_ranks_enabled
    if bool
      ranks = db_element_ranks
      @element_ranks = Array.new(ranks.xsize, CUSTOM_RATES_INDEX)
    end
    @element_ranks_enabled = bool
  end

  def element_rate(e_id)
    rank = self.element_ranks[e_id]
    result = ELEMENT_PERCENTS[rank]
    for armor in armors.compact
      result /= ARMOR_REDUCE_FACTOR if armor.element_set.include?(e_id)
    end
    for state in states
      result /= STATE_REDUCE_FACTOR if state.element_set.include?(e_id)
    end
    result
  end
end


Terms & Conditions

Free for use in any kind of game.
Just mention me in your game credits! Grinning