Save-Point
KBareHands - 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 XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: KBareHands (/thread-8355.html)



KBareHands - kyonides - 08-31-2021

KBareHands XP
v1.0.2

by Kyonides Arkanthes


Introduction

This scriptlet lets you add base attack, physical and magical defense to any hero. It could be especially useful for barehanded martial artists.
Those stats might also get increased per every level the hero gains. They can be increased or decreased by using script calls.

If you ever consider that to be pretty boring, then let me tell you that you got an alternative, namely the "Preferred Stat" option!
It will add the totals of all 3 stats to the preferred one while the others get no boost at all. This can be altered in game at any given time.

There are also the Base Stat and Stat Increase Lottos!

A given stat might get an increase or decrease depending on your luck.

Take into consideration that you need to configure several Constants found in the module below or you could just set the generic default values there and take care of the rest in game via calling the script...

You can also seal and unlock an hero's preferred stat.

There is no screenshot for obvious reasons.  Tongue sticking out

You can also find a demo if you visit the KBareHandsLotto XP thread. Winking

The Script

Code:
# * KBareHands XP
#   Scripter : Kyonides Arkanthes
#   2021-09-02 - v1.0.2
#   Not a Plug & Play Script!

# This scriptlet lets you add base attack, physical and magical defense to any
# hero. It could be especially useful for barehanded martial artists.
# Those stats might also get increased per every level the hero gains.
# They can be increased or decreased by using script calls.

# If you ever consider that to be pretty boring, then let me tell you that you
# got an alternative, namely the "Preferred Stat" option!
# It will add the totals of all 3 stats to the preferred one while the others
# get no boost at all. This can be altered in game at any given time.

# There are also the Base Stat and Stat Increase Lottos!
# A given stat might get an increase or decrease depending on your luck.

# Take into consideration that you need to configure several Constants found in
# the module below or you could just set the generic default values there and
# take care of the rest in game via calling the script...

# * Aliased Methods * #
# Game_Actor#base_atk
# Game_Actor#base_pdef
# Game_Actor#base_mdef

# Stat stands for either :atk or :pdef or :mdef
# PreferredStat stands for either nil or :atk or :pdef or :mdef

# * Script Calls * #

# Set Bare Hands Preferred Stat In Game
# $game_actors[ActorID].prefer_stat = PreferredStat

# Seal or Unseal Bare Hands Preferred Stat In Game
# $game_actors[ActorID].seal_stat = true or false

# Set Bare Hands Stat In Game
# $game_actors[ActorID].hands_stat[Stat] = Number
# $game_actors[ActorID].hands_atk = Number
# $game_actors[ActorID].hands_pdef = Number
# $game_actors[ActorID].hands_mdef = Number

# Set Bare Hands Increase In Game
# $game_actors[ActorID].hands_step[Stat] = Number
# $game_actors[ActorID].step_atk = Number
# $game_actors[ActorID].step_pdef = Number
# $game_actors[ActorID].step_mdef = Number

# Bare Hands Stat Lotto ( Between -50% and +50% )
# $game_actors[ActorID].hands_stat_lotto(Stat)

# Bare Hands Increase Lotto ( Between -50% and +50% )
# $game_actors[ActorID].hands_step_lotto(Stat)

module KBareHands
  # Better leave the following 4 lines alone!
  PREFERRED_STAT = {}
  BASE_ATTACK = {}
  BASE_PDEF = {}
  BASE_MDEF = {}
  # Base Stat and Increase per Level for Actors not listed below
  PREFERRED_STAT.default = nil # Options: nil, :atk, :pdef, :mdef
  BASE_ATTACK.default = [5, 2]
  BASE_PDEF.default = [5, 2]
  BASE_MDEF.default = [5, 2]
  # [ActorID] = nil or :atk or :pdef or :mdef
  PREFERRED_STAT[1] = :pdef
  # [ActorID] = [Base Attack, Increase]
  BASE_ATTACK[1] = [6, 3]
  # [ActorID] = [Base PDEF, Increase]
  BASE_PDEF[1] = [6, 3]
  # [ActorID] = [Base MDEF, Increase]
  BASE_MDEF[1] = [6, 3]
end

class Game_Actor
  alias :kyon_hands_gm_actor_setup :setup
  alias :kyon_hands_gm_actor_base_atk :base_atk
  alias :kyon_hands_gm_actor_base_pdef :base_pdef
  alias :kyon_hands_gm_actor_base_mdef :base_mdef
  def setup(actor_id)
    kyon_hands_gm_actor_setup(actor_id)
    bsatk, incr = KBareHands::BASE_ATTACK[actor_id]
    bpdef, pinc = KBareHands::BASE_PDEF[actor_id]
    bmdef, minc = KBareHands::BASE_MDEF[actor_id]
    @hands_stats = { :atk => bsatk, :pdef => bpdef, :mdef => bmdef }
    @hands_step = { :atk => incr, :pdef => pinc, :mdef => minc }
    @prefer_stat = KBareHands::PREFERRED_STAT[actor_id]
  end
  
  def hands_stat_lotto(key)
    stat = @hands_stats[key]
    @hands_stats[key] = stat / 2 + rand(stat + 1)
  end
  
  def hands_step_lotto(key)
    stat = @hands_step[key]
    @hands_step[key] = stat / 2 + rand(stat + 1)
  end

  def bare_calc(stat)
    if @prefer_stat == stat
      st = @hands_stats.values.inject{|a,b| a + b }
      st + @level * @hands_step.values.inject{|a,b| a + b }
    elsif @prefer_stat == nil
      @hands_stats[stat] + @hands_step[stat] * @level
    else
      0
    end
  end

  def base_atk
    kyon_hands_gm_actor_base_atk + barehands_calc(:atk)
  end

  def base_pdef
    kyon_hands_gm_actor_base_pdef + barehands_calc(:pdef)
  end

  def base_mdef
    kyon_hands_gm_actor_base_mdef + barehands_calc(:mdef)
  end
  def prefer_stat=(stat) @prefer_stat = @seal_stat ? @prefer_stat : stat  end
  def hands_atk() @hands_stats[:atk] end
  def hands_pdef() @hands_stats[:pdef] end
  def hands_mdef() @hands_stats[:mdef] end
  def hands_atk=(n) @hands_stats[:atk] = n end
  def hands_pdef=(n) @hands_stats[:pdef] = n end
  def hands_mdef=(n) @hands_stats[:mdef] = n end
  def step_atk() @hands_step[:atk] end
  def step_pdef() @hands_step[:pdef] end
  def step_mdef() @hands_step[:mdef] end
  def step_atk=(n) @hands_step[:atk] = n end
  def step_pdef=(n) @hands_step[:pdef] = n end
  def step_mdef=(n) @hands_step[:mdef] = n end
  attr_reader :hands_stats, :hands_step, :prefer_stat
  attr_accessor :seal_stat
end

class Game_Actors
  def initialize
    $data_weapons[0] = RPG::Weapon.new
    $data_armors[0] = RPG::Armor.new
    @data = []
  end
end


Terms & Conditions

Feel free to use it anywhere but not as a punch bag. [Image: confused.gif]
Include me in your game credits! [Image: wink.gif]
Do not repost this script! [Image: laughingtongue.gif]


RE: KBareHands - Steel Beast 6Beets - 08-31-2021

I'm using a script with the same functionality and yours offers far more options for customization. Mine merely bases Attack, PDEF, and MDEF on Strength, Dexterity and Intellect, respectively.


RE: KBareHands - kyonides - 09-02-2021

A Bare Hands Update

From now on you can also seal the hero's preferred stat at any given time in game. Winking
Make sure you are using version 1.0.2 or it will not be possible to block the stat. Laughing

Grinning If you visit the KBareHandsLotto XP thread, you can also get a good looking menu made exclusively for this script! Laughing