KSwap XP
KSwap XPby Kyonides Arkanthes
Introduction
Did you ever want to swap actors' skills or enemies' actions?
Or perhaps you failed to swap actor's weapons or enemies' atk attribute on you own.
If so, you would also need to be able to nullify such skills, don't you think?
Then you will be glad to find out that this scriptlet will make it possible!
The Script
Ruby:
# * KSwap XP
# Scripter : Kyonides Arkanthes
# 2022-01-04
# Swap the Skills of your Enemies!
# Heroes can swap the foes' ATK parameters.
# Monsters can also swap the heroes' Weapons at will!
# There is also a Nullify Swaps skill as well!
# Check the KSwap module and edit the CONSTANTS accordingly.
# You can prevent the party from casting the "Skill Swap" skill by turning on
# a specific game switch.
# * Aliased Methods * #
# Game_Battler#skill_effect(user, skill)
# Game_Actor#skill_can_use?(skill_id)
# Game_Enemy#atk and actions
# Scene_Battle#start_phase5
module KSwap
# If Switch is ON, then the player can't cast them
BOSS_BATTLE_SWITCH_ID = 1
# [ Weapon Swap ID, Skill Swap ID, Nullify Swaps ID ]
SKILL_IDS =
# Add Skill IDs that will be forbidden during Boss Battles
FORBIDDEN_SKILL_IDS =
# * END OF SETTINGS SECTION * #
extend self
def clear_all
@weapons = nil
@skills = nil
end
def weapon_skill_id() SKILL_IDS end
def skill_id() SKILL_IDS end
def nullify_skill_id() SKILL_IDS end
attr_accessor :weapons, :skills
end
class Array
def simple_shuffle
ary = []
size.times do |n|
elem = self
case rand(6)
when 0,2,4 then ary.unshift(elem)
when 1,3,5 then ary.push(elem)
end
end
ary.compact
end
end
class Game_Battler
alias :kyon_swap_skill_fx :skill_effect
def skill_effect(user, skill)
case skill.id
when KSwap.weapon_skill_id
return false unless rand(100) < user.hit
team.auto_swap_weapons
return true
when KSwap.skill_id
return false unless rand(100) < user.hit
team.auto_swap_skills
return true
when KSwap.nullify_skill_id
return false unless rand(100) < user.hit
team.nullify_swap
end
kyon_swap_skill_fx(user, skill)
end
end
class Game_Actor
attr_writer :skills, :weapon_id
alias :kyon_swap_gm_actor_skill_use? :skill_can_use?
def skill_can_use?(skid)
switch = KSwap::BOSS_BATTLE_SWITCH_ID
skill_ids = KSwap::FORBIDDEN_SKILL_IDS
return false if $game_switches and skill_ids.include?(skid)
kyon_swap_gm_actor_skill_use?(skid)
end
def team() $game_party end
end
class Game_Enemy
alias :kyon_swap_gm_nmy_actions :actions
alias :kyon_swap_gm_nmy_base_atk :base_atk
def alter_actions() $data_enemies[@alter_id].actions end
def alter_atk() $data_enemies[@atk_id].atk end
def base_atk
@atk_id ? alter_atk : kyon_swap_gm_nmy_base_atk
end
def actions
@alter_id ? alter_actions : kyon_swap_gm_nmy_actions
end
def team() $game_troop end
attr_writer :atk_id, :alter_id
end
class Game_Party
def auto_swap_weapons
KSwap.weapons ||= @actors.map{|a| a.weapon_id }
lotto = KSwap.weapons.simple_shuffle
@actors.each{|a| a.weapon_id = lotto.shift }
end
def auto_swap_skills
KSwap.skills ||= @actors.map{|a| a.skills }
lotto = KSwap.skills.simple_shuffle
@actors.each{|a| a.skills = lotto.shift }
end
def nullify_swap
list = KSwap.weapons
@actors.each{|a| a.weapon_id = list.shift } if list
list = KSwap.skills
@actors.each{|a| a.skills = list.shift } if list
KSwap.clear_all
end
end
class Game_Troop
def ids() @enemies.map{|e| e.id } end
def auto_swap_weapons
lotto = ids.simple_shuffle
@enemies.each{|a| a.atk_id = lotto.shift }
end
def auto_swap_skills
lotto = ids.simple_shuffle
@enemies.each{|e| e.alter_id = lotto.shift }
end
def nullify_swap
@enemies.each do |e|
e.atk_id = nil
e.alter_id = nil
end
end
end
class Scene_Battle
alias :kyon_swap_scn_bttl_start_ph5 :start_phase5
def start_phase5
$game_party.nullify_swap
kyon_swap_scn_bttl_start_ph5
end
end
Side Notes
As far as I know it is compatible with the Default XP Battle System and those that barely modify it.
Terms & Conditions
Mention my nickname in your game credits scene.
Free for non commercial games. Contact me if you want to go commercial.
That's all, folks!
本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/kswap-xp.143621/
页:
[1]