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_resultmodule 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 endendclass 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 endendclass Game_Actor def specific_skill_sp_cost(skill_id, cost) cost += cost * SkillKost.hero(@actor_id, skill_id, @level) / 100 cost.round endendclass Game_Enemy def specific_skill_sp_cost(skill_id, cost) cost += cost * SkillKost.monster(@enemy_id, skill_id) / 100 cost.round endendclass 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 endendclass 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 endendclass 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 endend
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-16class 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) endend
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!
本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/skillkost-xp.125205/