10-09-2012, 05:04 PM
Introduction
This script causes certain states to be communicable. "What does that mean," you ask? Let's say the Cockatrice is a carrier of Bird Flu. Cockatrice attacks Aluxes, now Aluxes has Bird Flu state, now his friends are slowly starting to get it just by being in proximity of him.
Features
How to Use?
It's in the script. The example setup is...
Script
Compatibility
Should be compatible with most scripts, doesn't require SDK or MACL.
Author's Notes
Take two Asprin and call me in the morning!
Oh yeah, a big shot out to the homie Victor Sant for inspiring this script! He wrote it for VX Ace, so I decided to write it for all the O.G.'s rockin' the XP! Word to yo motha!
Terms and Conditions
Credit is a must or I will take revenge on your soul!
This script causes certain states to be communicable. "What does that mean," you ask? Let's say the Cockatrice is a carrier of Bird Flu. Cockatrice attacks Aluxes, now Aluxes has Bird Flu state, now his friends are slowly starting to get it just by being in proximity of him.
Features
- Spread disease to friends and foes!
- Symptoms might include dry mouth and constipation.
- Not guaranteed to be covered by your insurance.
- Not guaranteed to be curable by your doctor.
How to Use?
It's in the script. The example setup is...
Content Hidden
Code:
#-----------------------------------------------------------------------------
# * Spread = {id => [chance(, scope)], ...}
#-----------------------------------------------------------------------------
# -Chance is how likely from [chance] to 100 is it for this state to spread
# -Scope is does it affect friends, foes or all.
# :all (or 0) #=> Spreads to friends and foes
# :friends (or 1) #=> Spreads to friends
# :foes (or 2) #=> Spreads to foes
#-----------------------------------------------------------------------------
Spread = Hash.new
# Developer Customization
Spread[5] = [30, :all] # 30% chance to spread Mute to all
Spread[6] = [50, :friends] # 50% chance to spread Confuse to friends
Script
Content Hidden
Code:
#===============================================================================
# ** States : Spread
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
if Object.const_defined?(:SDK)
SDK.log('States.Spread', 'Kain Nobel ©', 4.0, '2012.10.09')
end
#===============================================================================
# ** RPG::State
#===============================================================================
class RPG::State
#-----------------------------------------------------------------------------
# * Spread = {id => [chance(, scope)], ...}
#-----------------------------------------------------------------------------
# -Chance is how likely from [chance] to 100 is it for this state to spread
# -Scope is does it affect friends, foes, all or none.
# :all (or 0) #=> Spreads to friends and foes
# :friends (or 1) #=> Spreads to friends
# :foes (or 2) #=> Spreads to foes
#-----------------------------------------------------------------------------
Spread = Hash.new
# Developer Customization
Spread[5] = [30, :all]
Spread[6] = [50, :friends]
#-----------------------------------------------------------------------------
# * Internal Use (*Don't touch*)
#-----------------------------------------------------------------------------
Spread_All = [nil, 0, :all]
Spread_Friends = [1, :friends]
Spread_Foes = [2, :foes]
#-----------------------------------------------------------------------------
# * Spread?
#-----------------------------------------------------------------------------
def can_spread?
# True if any settings are registered
Spread.has_key?(@id)
end
#-----------------------------------------------------------------------------
# * Spread Chance
#-----------------------------------------------------------------------------
def spread_chance
# If defined, returns value, else returns 0
can_spread? ? Spread[id][0] : 0
end
#-----------------------------------------------------------------------------
# * Spread to Friends?
#-----------------------------------------------------------------------------
def spread_to_friends?
# False if state doesn't have a spread setting
return false unless can_spread?
# True if spread all
return true if Spread_All.include?(Spread[id][1])
# True if spread friend
Spread_Friends.include?(Scope[id][1])
end
#-----------------------------------------------------------------------------
# * Spread to foes?
#-----------------------------------------------------------------------------
def spread_to_foes?
# False if state doesn't have a spread setting
return false unless can_spread?
# True if spread all
return true if Spread_All.include?(Spread[id][1])
# True if one of these values equals the second setting
Spread_Foes.include?(Scope[id][1])
end
#-----------------------------------------------------------------------------
# * Spread Success?
#-----------------------------------------------------------------------------
def spread_success?
# Spread chance is equal to or greater than a random between 1 and 100
spread_chance >= rand(100)
end
end
#===============================================================================
# ** Game_Battler
#===============================================================================
class Game_Battler
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :spreadstates_gmbattler_removestatesauto, :remove_states_auto
#-----------------------------------------------------------------------------
# * Remove States Auto
#-----------------------------------------------------------------------------
def remove_states_auto
# The usual...
spreadstates_gmbattler_removestatesauto
# Iterate through current states
spread_states
end
#-----------------------------------------------------------------------------
# * Spread States
#-----------------------------------------------------------------------------
def spread_states
# Iterate through inflicted states
@states.each do |id|
# Get state data
state = $data_states[id]
# Next unless state is spreadable
next unless state.can_spread?
# Spread to friends and/or foes where applicable
spread_state_to_friends(id) if state.spread_to_friends?
spread_state_to_foes(id) if state.spread_to_foes?
end
end
end
#===============================================================================
# ** Game_Actor
#===============================================================================
class Game_Actor
#-----------------------------------------------------------------------------
# * Spread State to Friends
#-----------------------------------------------------------------------------
def spread_state_to_friends(state)
$game_party.actors.each {|a| a.add_state(state) if state.spread_success?}
end
#-----------------------------------------------------------------------------
# * Spread State to Foes
#-----------------------------------------------------------------------------
def spread_state_to_foes(state)
$game_troop.enemies.each {|e| e.add_state(state) if state.spread_success?}
end
end
#===============================================================================
# ** Game_Enemy
#===============================================================================
class Game_Enemy
#-----------------------------------------------------------------------------
# * Spread State to Friends
#-----------------------------------------------------------------------------
def spread_state_to_friends(state)
$game_troop.enemies.each {|e| e.add_state(state) if state.spread_success?}
end
#-----------------------------------------------------------------------------
# * Spread State to Foes
#-----------------------------------------------------------------------------
def spread_state_to_foes(state)
$game_party.actors.each {|a| a.add_state(state) if state.spread_success?}
end
end
Compatibility
Should be compatible with most scripts, doesn't require SDK or MACL.
Author's Notes
Take two Asprin and call me in the morning!
Oh yeah, a big shot out to the homie Victor Sant for inspiring this script! He wrote it for VX Ace, so I decided to write it for all the O.G.'s rockin' the XP! Word to yo motha!
Terms and Conditions
Credit is a must or I will take revenge on your soul!