08-13-2020, 06:42 AM
(This post was last modified: 08-16-2020, 07:53 AM by kyonides.
Edit Reason: Added Window_Skill Mod
)
SkillKost XP
version 1.0.2
version 1.0.2
by Kyonides Arkanthes
Introduction
This is a humble script that should allow you to customize your skill costs in three different ways as I stated in my comments.
Take in consideration that I have overwritten 2 methods found in the Default Scripts because I did not have another choice.
Default XP scripts were not very modular back in the days...
The Script
Code:
# * SkillKost XP
# Scripter : Kyonides Arkanthes
# 2020-08-13 - v1.0.2
# This scriptlet allows you to alter the Skill Cost in 3 different ways:
# - General Random Cost
# - General Custom Cost
# - Specific Custom Cost for a given Actor (per Level) or Enemy (no level)
# The last option needs you to set the values in the Constants found in the
# SkillKost module.
# Place this script in a script section below Scene_Debug. Here is why:
# * Script Calls * #
# Toggle Random SP Cost for every battler in game
# SkillKost.random = true or false
# Define a Custom SP Cost for every battler in game
# SkillKost.custom = Some Percent
# * End of Script Calls * #
# * Overridden Method * #
# - Game_Battler#skill_can_use?
# * Aliased Methods * #
# - Game_Battler#sp=
# - Interpreter#command_312 and #command_312
# - Scene_Skill#update_skill
# - Scene_Battle#make_skill_action_result
module SkillKost
@random = false
@random_max = 1 # 1 equals 100%
@custom = 0 # SP Percent: 0+
HEROES = {} # You better leave this line alone
MONSTERS = {} # You better leave this line alone
# HEROES[ [ActorID, SkillID] ] = { ActorMinLevel..MaxLevel => Percent, etc. }
HEROES[[1, 60]] = { 1..5 => 20, 6..10 => 15, 11..20 => 10 }
HEROES[[7, 81]] = { 1..2 => 25 }
# MONSTERS[ [EnemyID, SkillID] ] = Percent
class << self
attr_accessor :random, :custom, :skill_id, :used_event_command
def hero(actor_id, skill_id, level)
heroes = HEROES[[actor_id, skill_id]]
return 100 unless heroes
key = heroes.keys.select{|range| range.include?(level) }[0]
heroes[key] || 100
end
def monster(enemy_id, skill_id) MONSTERS[[enemy_id, skill_id]] || 100 end
end
end
class Game_Battler
alias :kyon_skillkost_gm_btlr_sp :sp=
def sp=(new_sp)
if !SkillKost.used_event_command and @sp > new_sp
new_sp = @sp - skill_sp_cost(SkillKost.skill_id)
end
kyon_skillkost_gm_btlr_sp(new_sp)
end
def skill_sp_cost(skill_id)
cost = $data_skills[skill_id].sp_cost
cost = rand(cost * 2 + 1).round if SkillKost.random
cost = (SkillKost.custom * cost / 100).round if SkillKost.custom > 0
specific_skill_sp_cost(skill_id, cost)
end
def skill_can_use?(skill_id)
return false if dead?
return false if self.skill_sp_cost(skill_id) > self.sp
return false if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
occasion = $data_skills[skill_id].occasion
return (occasion == 0 or occasion == 1) if $game_temp.in_battle
occasion == 0 or occasion == 2
end
end
class Game_Actor
def specific_skill_sp_cost(skill_id, cost)
cost += cost * SkillKost.hero(@actor_id, skill_id, @level) / 100
cost.round
end
end
class Game_Enemy
def specific_skill_sp_cost(skill_id, cost)
cost += cost * SkillKost.monster(@enemy_id, skill_id) / 100
cost.round
end
end
class Interpreter
alias :kyon_skillkost_inter_cmd312 :command_312
alias :kyon_skillkost_inter_cmd332 :command_332
def command_312
SkillKost.used_event_command = true
kyon_skillkost_inter_cmd312
SkillKost.used_event_command = nil
end
def command_332
SkillKost.used_event_command = true
kyon_skillkost_inter_cmd332
SkillKost.used_event_command = nil
end
end
class Scene_Skill
alias :kyon_skillkost_scn_skill_up_skill :update_skill
def update_skill
if Input.trigger?(Input::B)
SkillKost.skill_id = nil
elsif Input.trigger?(Input::C)
SkillKost.skill_id = @skill_window.skill.id
end
kyon_skillkost_scn_skill_up_skill
end
end
class Scene_Battle
alias :kyon_skillkost_scn_btl_make_skill_ar :make_skill_action_result
def make_skill_action_result
SkillKost.skill_id = @active_battler.current_action.skill_id
kyon_skillkost_scn_btl_make_skill_ar
SkillKost.skill_id = nil
end
end
A Window_Skill class Modification
It should allow you to get an updated version of the current skill's cost.
Code:
# * SkillKost XP - Default Skill Window Mod
# Scripter : Kyonides Arkanthes
# 2020-08-16
class Window_Skill
def draw_item(index)
skill = @data[index]
color = @actor.skill_can_use?(skill.id)? normal_color : disabled_color
contents.font.color = color
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = contents.font.color == normal_color ? 255 : 128
contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
cost = @actor.skill_sp_cost(skill.id).to_s
contents.draw_text(x + 232, y, 48, 32, cost, 2)
end
end
Terms & Conditions
Free for any game.
Include my nickname in your game credits.
Mention this forum as well.
Give me a free copy of your completed game if you include at least 2 of my scripts!
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE