【7.20更新】仅用一个状态就能制作数十层的状态层数脚本
其实也不能算是完全原创吧,也是自己参考了一些状态堆叠脚本写出来的脚本时常会觉得制作层数太累太累了,而且有些手游现在还经常能看见那种30层,100层,甚至更多层数的状态,如果真的复制粘贴那么多那真的人都要没了,那为什么不让状态拥有一个层数的值呢?
# =============================================================================
# 状态层数脚本 By Akahara
# =============================================================================
# 是否时常因为制作层数状态需要复制粘贴好几个无法制作数十层而感到苦恼?
# 为状态新增了max_level和state_levels的概念
# 在状态的备注中填写,即该状态上限x层,未填写默认为1层
# 可以通过state_levels(state_id)来制作每层增加数值的效果
# 具体使用方法可以查阅https://rpg. blue/thread-486408-1-1.html
# =============================================================================
class RPG::State < RPG::BaseItem
attr_accessor :max_level
def load_level
@max_level = 1
note.split(/[]+/).each do |line|
if line =~ //i
@max_level = $1.to_i
end
end
end
end
class << DataManager
alias theo_levelstate_load_db load_database
def load_database
theo_levelstate_load_db
load_levelstate_db
end
def load_levelstate_db
$data_states.compact.each do |state|
state.load_level
end
end
end
class Game_BattlerBase
attr_reader :state_levels
alias clear_states_levels clear_states
def clear_states
clear_states_levels
@state_levels = {}
end
alias erase_state_levels erase_state
def erase_state(state_id)
erase_state_levels(state_id)
reset_state_levels(state_id)
end
def reset_state_levels(state_id)
@state_levels ||= {}
@state_levels.delete(state_id)
end
def set_state_levels(state_id)
@state_levels ||= {}
@state_levels ||= 0
end
def state_levels(state_id)
@state_levels ||= {}
d = @state_levels
d ? d : 0
end
end
class Game_Battler < Game_BattlerBase
alias akahara_r_20210719 remove_state
def remove_state(state_id)
akahara_r_20210719(state_id)
reset_state_levels(state_id)
end
alias akahara_20210719 add_state
def add_state(state_id)
akahara_20210719(state_id)
set_state_levels(state_id)
if state_addable?(state_id)
return if $data_states.max_level <= 1
if @state_levels < 1
@state_levels = 1
return ;
end
if state?(state_id)
@state_levels += 1 if @state_levels != $data_states.max_level
end
end
end
end
页:
[1]