Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # TheoAllen - Realtime States
- # Version : 1.0
- # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
- # (This script documentation is written in informal indonesian language)
- # =============================================================================
- ($imported ||= {})[:Theo_RealtimeState] = true
- # =============================================================================
- # CHANGE LOGS:
- # -----------------------------------------------------------------------------
- # 2013.05.18 - Started and Finished script
- # =============================================================================
- =begin
- Perkenalan :
- Script ini ngebikin sebuah state bisa expired secara realtime. Semisal status
- poison bisa hilang setelah 10 detik berada di map. Perhitungan realtime hanya
- dilakukan jika player hanya berada pada map
- Cara penggunaan :
- Pasang script ini diatas main namun dibawah material.
- Gunakan tag ini pada database state
- <expired time: n>
- dimana n adalah angka dalam hitungan detik. Apabila kamu ingin satu menit,
- maka tulis 60. dst ...
- Terms of use :
- Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
- keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
- dipake buat komersil, jangan lupa, gw dibagi gratisannya.
- =end
- # =============================================================================
- # Konfigurasi :
- # =============================================================================
- module THEO
- module STATE
- MESSAGE_PAUSE = true
- # set true jika ingin perhitungan realtime diberhentikan saat ada message
- # (ngomong ama NPC, dll...)
- PAUSE_SWITCH_ID = 0
- # Jika switch dengan id tersebut ON, maka perhitungan realtime akan
- # dihentikan.
- end
- end
- # =============================================================================
- # Akhir konfigurasi. Setelah ini jangan diedit kecuali ente ngerti
- # =============================================================================
- module THEO
- module STATE
- module REGEXP
- TIME = /<(?:EXPIRED_TIME|expired time):[ ]*(\d+)>/i
- end
- end
- end
- module DataManager
- class << self
- alias pre_rt_states_db load_database
- end
- def self.load_database
- pre_rt_states_db
- load_realtime_states
- end
- def self.load_realtime_states
- $data_states.compact.each do |state|
- state.load_realtime_count
- end
- end
- end
- class RPG::State < RPG::BaseItem
- attr_accessor :expire_time
- def load_realtime_count
- @expire_time = 0
- self.note.split(/[\r\n]+/).each do |line|
- case line
- when THEO::STATE::REGEXP::TIME
- @expire_time = $1.to_i * 60
- end
- end
- end
- end
- class Game_System
- attr_accessor :rt_count
- alias pre_realtime_state_init initialize
- def initialize
- pre_realtime_state_init
- init_rt_state_count
- end
- def init_rt_state_count
- @rt_count = 0
- end
- def update_rt_count
- @rt_count += 1
- end
- end
- class Game_Actor < Game_Battler
- alias pre_realtime_states_init initialize
- def initialize(actor_id)
- pre_realtime_states_init(actor_id)
- init_rt_state_hash
- end
- def init_rt_state_hash
- @rt_hash = {}
- end
- alias pre_rt_reset_state_counts reset_state_counts
- def reset_state_counts(state_id)
- pre_rt_reset_state_counts(state_id)
- exp_time = $data_states[state_id].expire_time
- return if exp_time <= 0
- @rt_hash[state_id] = $game_system.rt_count + exp_time
- end
- def check_rt_states
- @states.each do |id|
- state = $data_states[id]
- next if state.expire_time <= 0
- remove_state(id) if remove?(id)
- end
- end
- def remove?(id)
- return false unless @rt_hash[id]
- return $game_system.rt_count >= @rt_hash[id]
- end
- end
- class Scene_Map < Scene_Base
- alias pre_rt_state_update update
- def update
- pre_rt_state_update
- update_rt_count
- check_realtime_states
- end
- def update_rt_count
- $game_system.update_rt_count unless message_pause?
- puts $game_system.rt_count
- end
- def check_realtime_states
- $game_party.members.each do |actor|
- actor.check_rt_states
- end
- end
- def message_pause?
- (THEO::STATE::MESSAGE_PAUSE && !scene_change_ok?) ||
- $game_switches[THEO::STATE::PAUSE_SWITCH_ID]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment