SkillKost XP - kyonides - 08-13-2020
SkillKost XP
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!
RE: SkillKost XP - kyonides - 08-14-2020
Merry Update!
If that ever existed as a greeting.
Why am I glad that I'm posting here once again?
You see, I have found some bug while working on how to avoid a large rewrite of default scripts like Scene_Skill and the like.
Of course, I've smashed it already!
Now I could reduce the list of overridden methods from 2 to 1!
That also means that I had to alias more methods but it was worth the effort!
Now I'm going back to playing and playtesting games!
RE: SkillKost XP - kyonides - 08-16-2020
Minor Update
This time I came back because I've received some feedback concerning the skill menu. It was true that I didn't provide you with a menu that displayed the modified cost of any skill available out there. Still, that's ancient history for I've posted such a modification.
I know, it might only work if people use scripts that don't alter the Window_Skill#draw_item method but I had no other choice anyway...
|