じ☆ve冰风 发表于 2026-7-8 20:26:36

SkkillUses XP

SkkillUses XP

by Kyonides Arkanthes​


Introduction

This scriptlet allows you to set a skill use system instead of consuming mana!


It even allows you to set different use maximums for actors and enemies!



skills.default = Number
It lets you set a default maximum for actors and enemies in that order!

It's mainly because it appears twice in my script.



Warning!

It overwrites a few default methods and aliases some other methods like initialize.

Script
                Code:        
# * SkkillUses XP Default Version #   Scripter : Kyonides Arkanthes #   v1.0.0 - 2019-12-22# * Script Calls * ## Get an Actor #   battler = $game_party.actors # Get an Enemy #   battler = $game_troop.enemies # Change Skill Use Maximum - Checks Max and returns the New Maximum #   battler.change_skill_use_max(Skill_ID, USES_MAX) # Replenishes a Skill's Use Max #   battler.refill_skill_use(Skill_ID, USES) # Replenishes Skills' Use Max #   battler.refill_skill_usesmodule Skkill   USES = { :actor => {}, :enemy => {} }   # Actors' Skill IDs   skills = USES[:actor]   skills.default = 3   skills = 5   skills = 5   # Enemies' Skill IDs   skills = USES[:enemy]   skills.default = 3   skills = 5 endclass Game_Battler   def skill_can_use?(skill_id)   return false if dead? or self.skill_uses == 0   return false if $data_skills.atk_f == 0 and self.restriction == 1   occasion = $data_skills.occasion   if $game_temp.in_battle       return (occasion == 0 or occasion == 1)   else       return (occasion == 0 or occasion == 2)   end   end    def change_skill_use_max(sid, new_max)   temp_max = [@skill_use_max, 0].max   @skill_use_max = .min   skill_use_max(sid)   end    def refill_skill_use(sid, uses)   @skill_uses = [@skill_uses + uses, skill_use_max(sid)].min   end    def refill_skill_uses   @skill_uses.keys.each{|sid| @skill_uses = skill_use_max(sid) }   end   def skill_use_max(sid) Skkill::USES + @skill_use_max end   def skill_use(sid) @skill_uses -= 1 end   attr_reader :skill_uses endclass Game_Actor   alias :kyon_skilluses_gm_actor_init :initialize   def initialize(actor_id)   kyon_skilluses_gm_actor_init(actor_id)   @skill_uses = {}   @skill_use_max = {}   @skill_use_max.default = 0   @skills.each{|sid| @skill_uses = Skkill::USES[:actor] }   end    def kind() :actor end endclass Game_Enemy   alias :kyon_skilluses_gm_enemy_init :initialize   def initialize(troop_id, member_index)   kyon_skilluses_gm_enemy_init(troop_id, member_index)   @skill_uses = {}   @skill_use_max = {}   @skill_use_max.default = 0   $data_enemies[@enemy_id].actions.each do |action|       next if action.kind != 1       sid = action.skill_id       @skill_uses = Skkill::USES[:enemy]   end   end   def kind() :enemy end endclass Window_Skill   def draw_item(index)   skill = @data   usable = @actor.skill_can_use?(skill.id)   self.contents.font.color = usable ? normal_color : disabled_color   x = 4 + index % 2 * (288 + 32)   y = index / 2 * 32   rect = Rect.new(x, y, self.width / @column_max - 32, 32)   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))   bitmap = RPG::Cache.icon(skill.icon_name)   opacity = self.contents.font.color == normal_color ? 255 : 128   uses = @actor.skill_uses.to_s   use_max = @actor.skill_use_max(skill.id).to_s   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)   self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)   self.contents.draw_text(x + 200, y, 48, 32, uses, 2)   self.contents.draw_text(x + 248, y, 8, 32, '/')   self.contents.draw_text(x + 256, y, 48, 32, use_max)   end endclass Scene_Skill   def update_skill   if Input.trigger?(Input::B)       $game_system.se_play($data_system.cancel_se)       $scene = Scene_Menu.new(1)       return   elsif Input.trigger?(Input::C)       @skill = @skill_window.skill       unless @skill and @actor.skill_can_use?(@skill.id)         return $game_system.se_play($data_system.buzzer_se)       end       $game_system.se_play($data_system.decision_se)       if @skill.scope >= 3         @skill_window.active = false         @target_window.x = (@skill_window.index + 1) % 2 * 304         @target_window.visible = true         @target_window.active = true         if @skill.scope == 4 || @skill.scope == 6         @target_window.index = -1         elsif @skill.scope == 7         @target_window.index = @actor_index - 10         else         @target_window.index = 0         end         return       else         if @skill.common_event_id > 0         $game_temp.common_event_id = @skill.common_event_id         $game_system.se_play(@skill.menu_se)         @actor.skill_use(@skill.id)         @status_window.refresh         @skill_window.refresh         @target_window.refresh         return $scene = Scene_Map.new         end       end   elsif Input.trigger?(Input::R)       $game_system.se_play($data_system.cursor_se)       @actor_index += 1       @actor_index %= $game_party.actors.size       return $scene = Scene_Skill.new(@actor_index)   elsif Input.trigger?(Input::L)       $game_system.se_play($data_system.cursor_se)       @actor_index += $game_party.actors.size - 1       @actor_index %= $game_party.actors.size       $scene = Scene_Skill.new(@actor_index)   end   end    def update_target   if Input.trigger?(Input::B)       $game_system.se_play($data_system.cancel_se)       @skill_window.active = true       @target_window.visible = false       @target_window.active = false       return   end   if Input.trigger?(Input::C)       unless @actor.skill_can_use?(@skill.id)         return $game_system.se_play($data_system.buzzer_se)       end       if @target_window.index == -1         used = false         for i in $game_party.actors         used |= i.skill_effect(@actor, @skill)         end       end       if @target_window.index <= -2         target = $game_party.actors[@target_window.index + 10]         used = target.skill_effect(@actor, @skill)       end       if @target_window.index >= 0         target = $game_party.actors[@target_window.index]         used = target.skill_effect(@actor, @skill)       end       if used         $game_system.se_play(@skill.menu_se)         @actor.skill_use(@skill.id)         @status_window.refresh         @skill_window.refresh         @target_window.refresh         return $scene = Scene_Gameover.new if $game_party.all_dead?         if @skill.common_event_id > 0         $game_temp.common_event_id = @skill.common_event_id         return $scene = Scene_Map.new         end       end       $game_system.se_play($data_system.buzzer_se) unless used   end   end endclass Scene_Battle   def make_skill_action_result   @skill = $data_skills[@active_battler.current_action.skill_id]   unless @active_battler.current_action.forcing       unless @active_battler.skill_can_use?(@skill.id)         $game_temp.forcing_battler = nil         return @phase4_step = 1       end   end   @active_battler.skill_use(@skill.id)   @status_window.refresh   @help_window.set_text(@skill.name, 1)   @animation1_id = @skill.animation1_id   @animation2_id = @skill.animation2_id   @common_event_id = @skill.common_event_id   set_target_battlers(@skill.scope)   @target_battlers.each{|target| target.skill_effect(@active_battler, @skill)}   end end


Terms & Condition

You can freely use it in non commercial games except for anybody that got a nickname, namely Silly.


You must include my nickname in your game credits!
Include the URL of the website where you found my script!
Give me a free copy of your completed game if you include at least 2 of my scripts!
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7


本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/skkilluses-xp.116520/
页: [1]
查看完整版本: SkkillUses XP