Hellu~
So I'm using TheoAllen - Stacking States
(Sorry, there's not link, I had to download it game to get the script)
I wanted to create a def that when the state is gonna be removed, it only remove 1 instance of said state.
I tried with several options, but as in most of my other post, I claimed, I'm not a scripter...
I tried to re-write the Game Battlerbase same as this script already do when you add a state, but couldn't figure out how to do it when erasing.
But as you would guess, my try was useless. (and I tried several other options too).
I also tried this def from another state stack script but doesn't seem to work neither:
So I'm using TheoAllen - Stacking States
Ruby:
# =============================================================================
# TheoAllen - Stacking States
# Version : 1.0
# Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
# (This script documentation is written in informal indonesian language)
# =============================================================================
($imported ||= {})[:Theo_StackingState] = true
# =============================================================================
# Change Logs:
# -----------------------------------------------------------------------------
# 2013.10.24 - Finished Script
# =============================================================================
=begin
Introduction:
This script allows you to assign statuses to enemies in batches.
For example, the enemy gets 3 poison statuses and the like.
How to use :
Install this script under the material but above the main
Use the <stack: n> tag on the notebox states in the database. Where n is
number for max for stack state
Terms of use :
My credit, TheoAllen. For example, if you can edit my scripts then it becomes more
cool, whatever. I free. Just don't claim it. If you want
used for commercial, don't forget, I share it for free.
=end
# =============================================================================
# Tidak ada konfigurasi
# =============================================================================
class RPG::State < RPG::BaseItem
attr_accessor :max_stack
def load_stack
@max_stack = 1
note.split(/[\r\n]+/).each do |line|
if line =~ /<stack:[ ]*(\d+)>/i
@max_stack = $1.to_i
end
end
end
end
class << DataManager
alias theo_stackstate_load_db load_database
def load_database
theo_stackstate_load_db
load_stackstate_db
end
def load_stackstate_db
$data_states.compact.each do |state|
state.load_stack
end
end
end
class Game_Battler < Game_BattlerBase
# ---------------------------------------------------------------------------
# Overwrite add state
# ---------------------------------------------------------------------------
def add_state(state_id)
if state_addable?(state_id)
add_new_state(state_id) unless state?(state_id) && state_maxed?(state_id)
reset_state_counts(state_id)
@result.added_states.push(state_id).uniq!
end
end
def state_stack(state_id)
(@states.count(state_id) || 0)
end
def state_maxed?(state_id)
@states.select {|id| id == state_id}.size ==
$data_states[state_id].max_stack
end
end
(Sorry, there's not link, I had to download it game to get the script)
I wanted to create a def that when the state is gonna be removed, it only remove 1 instance of said state.
I tried with several options, but as in most of my other post, I claimed, I'm not a scripter...
I tried to re-write the Game Battlerbase same as this script already do when you add a state, but couldn't figure out how to do it when erasing.
Code:
def erase_state(state_id)
if stack_state(state_id) > 1
@states.delete(state_id).uniq!
@state_turns.delete(state_id)
@state_steps.delete(state_id)
else
@states.delete(state_id)
@state_turns.delete(state_id)
@state_steps.delete(state_id)
end
But as you would guess, my try was useless. (and I tried several other options too).
I also tried this def from another state stack script but doesn't seem to work neither:
Code:
def erase_state(state_id)
@states -= [state_id] ## Line added to remove only one instance.
return if state?(state_id) ## Line added to prevent a stack from bugging.
@state_turns.delete(state_id)
@state_steps.delete(state_id)
end