赞 | 81 |
VIP | 0 |
好人卡 | 0 |
积分 | 68 |
经验 | 0 |
最后登录 | 2025-2-15 |
在线时间 | 593 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 6755
- 在线时间
- 593 小时
- 注册时间
- 2017-11-10
- 帖子
- 688

|
=begin
#===============================================================================
Title: 状态充能
Author: Hime
Date: Jun 14, 2015
--------------------------------------------------------------------------------
** Change log
Jun 14, 2015
- only reset state counts if state is still applied
Mar 22, 2014
- fixed bug where states with charges are not removed after battle
Feb 28, 2014
- state is correctly removed when charges drop to zero
Nov 16, 2013
- is it possible to have the state but no state charge recorded?
Sep 14, 2013
- added some methods for adding/removing state charges
Jun 23, 2013
- Initial release
--------------------------------------------------------------------------------
** Terms of Use
* Free to use in non-commercial projects
* Contact me for commercial use
* No real support. The script is provided as-is
* Will do bug fixes, but no compatibility patches
* Features may be requested but no guarantees, especially if it is non-trivial
* Credits to Hime Works in your project
* Preserve this header
--------------------------------------------------------------------------------
** 说明
此脚本可以让状态有“充能”的效果,要求状态彻底移除前,需要被移除的次数
例如某个状态有3次充能,则状态移除3次后才会真正被移除.
这和“状态堆叠”不同,因为状态充能并不会让状态多次附加。
--------------------------------------------------------------------------------
** Installation
Place this script below Materials and above Main.
如果和 Yanfly的状态管理 同时使用, 请放在其之下
--------------------------------------------------------------------------------
** 使用方法
使用状态备注:
<state charges: x>
代表状态附加时,充能x次.
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TH_StateCharges"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
module State_Charges
Regex = /<state[-_ ]charges: (\d+)>/i
end
end
#===============================================================================
# ** Rest of the script
#===============================================================================
module RPG
class State
def state_charges
return @state_charges unless @state_charges.nil?
load_notetag_state_charges
return @state_charges
end
def load_notetag_state_charges
res = self.note.match(TH::State_Charges::Regex)
@state_charges = res ? res[1].to_i : 1
end
end
end
class Game_BattlerBase
alias :th_state_charges_clear_states :clear_states
def clear_states
th_state_charges_clear_states
@state_charges = {}
end
alias :th_state_charges_erase_state :erase_state
def erase_state(state_id)
th_state_charges_erase_state(state_id)
@state_charges.delete(state_id)
end
end
class Game_Battler < Game_BattlerBase
alias :th_state_charges_remove_state :remove_state
def remove_state(state_id)
if has_state_charges?(state_id)
remove_state_charges(state_id, 1)
reset_state_counts(state_id) if state?(state_id)
else
th_state_charges_remove_state(state_id)
end
end
alias :th_state_charges_add_new_state :add_new_state
def add_new_state(state_id)
set_state_charges(state_id, $data_states[state_id].state_charges)
th_state_charges_add_new_state(state_id)
end
def state_charges(state_id)
return @state_charges[state_id]
end
def set_state_charges(state_id, amount)
@state_charges[state_id] = amount
end
def add_state_charges(state_id, amount)
@state_charges[state_id] += amount
end
def remove_state_charges(state_id, amount)
@state_charges[state_id] = [@state_charges[state_id]-amount, 0].max
th_state_charges_remove_state(state_id) if @state_charges[state_id] == 0
end
def has_state_charges?(state_id)
return state?(state_id) && @state_charges[state_id] && @state_charges[state_id] > 0
end
alias :th_state_charges_remove_battle_states :remove_battle_states
def remove_battle_states
remove_battle_state_charges
th_state_charges_remove_battle_states
end
#-----------------------------------------------------------------------------
# New.
#-----------------------------------------------------------------------------
def remove_battle_state_charges
states.each do |state|
@state_charges[state.id] = 0 if state.remove_at_battle_end
end
end
end |
|