This script retruns a function that was in old rpgmakers and in games like dragon quest: the option to reduce or sum battlers atributes temporally in combat based in a fixed number and not using %.
You can ask for bugs, suggerences, compatibilitzations and any other things.
You can get the code in this simple web. Im going to use it on now because it saves alot of time updating posts and other things.
http://usuarios.multimania.es/kisap/english_list.html
You can ask for bugs, suggerences, compatibilitzations and any other things.
You can get the code in this simple web. Im going to use it on now because it saves alot of time updating posts and other things.
http://usuarios.multimania.es/kisap/english_list.html
Code:
#==============================================================================
# Buff/Debuff dragon quest style skills
# By gerkrt/gerrtunk
# Version: 1.1
# License: GPL, credits
# Date: 23/12/2010
# IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
# script check here: [url=http://usuarios.multimania.es/kisap/english_list.html]http://usuarios.multimania.es/kisap/english_list.html[/url]
#==============================================================================
=begin
--------Introduction-----------
This script returns a function that was in old rpgmakers and in games like dragon
quest: the option to reduce or sum battlers atributes temporally in combat based
in a fixed number and not using %.
You can ask for bugs, suggerences, compatibilitzations and any other things.
-------In the future------------
-The option to use fixed values with very small variance and not traditional skill
formula
-A max uses for each skill. In this way, a skill can lose its effects after a
number of uses. In this way you can control overbuffering.
-A max % of buffering for atributes. Another way of dealing with extreme buffs.
------Instructions-------------
skill_id1 effect type skillid2 effect type, etc
Atribute_mod_skills = { 7=> [-777, 'maxhp'], 8=> [777, 'maxhp']}
For selecting buf or debuf you only need to put a positive or negative number.
Tags for the type(like in database ones)
maxhp
maxsp
str
dex
agi
int
atk
pdef
mdef
eva
---------Syntax notes--------------
'' delimites words in ruby
You can divide long linges like this:
Atribute_mod_skills = { 7=> [-777, 'maxhp'],
8=> [777, 'maxhp'],
9=> [777, 'maxhp']}
See that the new line have to be after a , and that the final one dont put a
final ,.
---------Other notes-----------------
-Is applied the skill variance, and force and intelligence influences
that you normally select in the database. It uses the same formula.
-The effects are acumulative.
-The effects are reset after combat.
=end
module Wep
Atribute_mod_skills = { 7=> [-777, 'maxhp'], 8=> [777, 'maxhp']}
end
class Scene_Battle
#--------------------------------------------------------------------------
# * Battle Ends
# result : results (0:win 1:lose 2:escape)
# moded to reset actors atributes
#--------------------------------------------------------------------------
def battle_end(result)
# Reset actors atributes modifiers
for actor in $game_party.actors
actor.reset_atr_mod_list
end
# Clear in battle flag
$game_temp.in_battle = false
# Clear entire party actions flag
$game_party.clear_actions
# Remove battle states
for actor in $game_party.actors
actor.remove_states_battle
end
# Clear enemies
$game_troop.enemies.clear
# Call battle callback
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
# Switch to map screen
$scene = Scene_Map.new
end
end
class Game_Battler
#--------------------------------------------------------------------------
# * Apply Skill Effects
# user : the one using skills (battler)
# skill : skill
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# Clear critical flag
self.critical = false
# If skill scope is for ally with 1 or more HP, and your own HP = 0,
# or skill scope is for ally with 0, and your own HP = 1 or more
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
# End Method
return false
end
# Clear effective flag
effective = false
# Set effective flag if common ID is effective
effective |= skill.common_event_id > 0
# First hit detection
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
# If hit occurs
if hit_result == true
# Check for atribute modifier
if Wep::Atribute_mod_skills[skill.id] != nil
# Extract and calculate effect
# Calculate power
ef = Wep::Atribute_mod_skills[skill.id][0] + user.atk * skill.atk_f / 100
ef -= self.pdef * skill.pdef_f / 200
ef -= self.mdef * skill.mdef_f / 200
# Calculate rate
ra = 20
ra += (user.str * skill.str_f / 100)
ra += (user.dex * skill.dex_f / 100)
ra += (user.agi * skill.agi_f / 100)
ra += (user.int * skill.int_f / 100)
# Calculate total effect
total_ef = ef * ra / 20
# Apply dispersion
if skill.variance > 0
amp = [total_ef * skill.variance / 100, 1].max
total_ef += rand(amp+1) + rand(amp+1) - amp
end
# Apply if exist
case Wep::Atribute_mod_skills[skill.id][1]
when 'maxhp':
self.atr_mod_list.maxhp += total_ef
when 'maxsp':
self.atr_mod_list.maxsp += total_ef
when 'str':
self.atr_mod_list.str += total_ef
when 'dex':
self.atr_mod_list.dex += total_ef
when 'int':
self.atr_mod_list.int += total_ef
when 'agi':
self.atr_mod_list.agi += total_ef
when 'atk':
self.atr_mod_list.atk += total_ef
when 'pdef':
self.atr_mod_list.pdef += total_ef
when 'mdef':
self.atr_mod_list.mdef += total_ef
when 'eva':
self.atr_mod_list.eva += total_ef
end
end
# Calculate power
power = skill.power + user.atk * skill.atk_f / 100
if power > 0
power -= self.pdef * skill.pdef_f / 200
power -= self.mdef * skill.mdef_f / 200
power = [power, 0].max
end
# Calculate rate
rate = 20
rate += (user.str * skill.str_f / 100)
rate += (user.dex * skill.dex_f / 100)
rate += (user.agi * skill.agi_f / 100)
rate += (user.int * skill.int_f / 100)
# Calculate basic damage
self.damage = power * rate / 20
# Element correction
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Guard correction
if self.guarding?
self.damage /= 2
end
end
# Dispersion
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# Second hit detection
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
end
# If hit occurs
if hit_result == true
# If physical attack has power other than 0
if skill.power != 0 and skill.atk_f > 0
# State Removed by Shock
remove_states_shock
# Set to effective flag
effective = true
end
# Substract damage from HP
last_hp = self.hp
self.hp -= self.damage
effective |= self.hp != last_hp
# State change
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# If power is 0
if skill.power == 0
# Set damage to an empty string
self.damage = ""
# If state is unchanged
unless @state_changed
# Set damage to "Miss"
self.damage = "Miss"
end
end
# If miss occurs
else
# Set damage to "Miss"
self.damage = "Miss"
end
# If not in battle
unless $game_temp.in_battle
# Set damage to nil
self.damage = nil
end
# End Method
return effective
end
end
# Struct used to save the atributes modifiers for each actor
AtrList = Struct.new( :maxhp, :maxsp, :str, :dex, :int, :agi, :atk, :pdef,
:mdef, :eva )
#==============================================================================
# ** Game_Battler (part 1)
#------------------------------------------------------------------------------
# This class deals with battlers. It's used as a superclass for the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :atr_mod_list
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias gb_wep_dq_init initialize
def initialize
@atr_mod_list = AtrList.new(0,0,0,0,0,0,0,0,0,0)
return gb_wep_dq_init
end
#--------------------------------------------------------------------------
# * Reset atr mod list (for when combat ends)
#--------------------------------------------------------------------------
def reset_atr_mod_list
@atr_mod_list = AtrList.new(0,0,0,0,0,0,0,0,0,0)
end
end
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Get Basic Maximum HP
#--------------------------------------------------------------------------
alias wep_dq_base_maxhp base_maxhp
def base_maxhp
# Max is 9999 and min is 0
if wep_dq_base_maxhp + @atr_mod_list.maxhp > 9999
return 9999
elsif wep_dq_base_maxhp + @atr_mod_list.maxhp <= 0
return 1
else
return wep_dq_base_maxhp + @atr_mod_list.maxhp
end
end
#--------------------------------------------------------------------------
# * Get Basic Maximum SP
#--------------------------------------------------------------------------
alias wep_dq_base_maxsp base_maxsp
def base_maxsp
# Max is 9999 and min is 0
if wep_dq_base_maxsp + @atr_mod_list.maxsp > 9999
return 9999
elsif wep_dq_base_maxsp + @atr_mod_list.maxsp <= 0
return 1
else
return wep_dq_base_maxsp + @atr_mod_list.maxsp
end
end
#--------------------------------------------------------------------------
# * Get Basic Strength
#--------------------------------------------------------------------------
alias wep_dq_base_str base_str
def base_str
# Max is 999 and min is 0
if wep_dq_base_str + @atr_mod_list.str > 999
return 999
elsif wep_dq_base_str + @atr_mod_list.str <= 0
return 1
else
return wep_dq_base_str + @atr_mod_list.str
end
end
#--------------------------------------------------------------------------
# * Get Basic Dexterity
#--------------------------------------------------------------------------
alias wep_dq_base_dex base_dex
def base_dex
# Max is 999 and min is 0
if wep_dq_base_dex + @atr_mod_list.dex > 999
return 999
elsif wep_dq_base_dex + @atr_mod_list.dex <= 0
return 1
else
return wep_dq_base_dex + @atr_mod_list.dex
end
end
#--------------------------------------------------------------------------
# * Get Basic Agility
#--------------------------------------------------------------------------
alias wep_dq_base_agi base_agi
def base_agi
# Max is 999 and min is 0
if wep_dq_base_agi + @atr_mod_list.agi > 999
return 999
elsif wep_dq_base_agi + @atr_mod_list.agi <= 0
return 1
else
return wep_dq_base_agi + @atr_mod_list.agi
end
end
#--------------------------------------------------------------------------
# * Get Basic Intelligence
#--------------------------------------------------------------------------
alias wep_dq_base_int base_int
def base_int
# Max is 999 and min is 0
if wep_dq_base_int + @atr_mod_list.int > 999
return 999
elsif wep_dq_base_int + @atr_mod_list.int <= 0
return 1
else
return wep_dq_base_int + @atr_mod_list.int
end
end
#--------------------------------------------------------------------------
# * Get Basic Attack Power
#--------------------------------------------------------------------------
alias wep_dq_base_atk base_atk
def base_atk
# Max is 999 and min is 0
if wep_dq_base_atk + @atr_mod_list.atk > 999
return 999
elsif wep_dq_base_atk + @atr_mod_list.atk <= 0
return 1
else
return wep_dq_base_atk + @atr_mod_list.atk
end
end
#--------------------------------------------------------------------------
# * Get Basic Physical Defense
#--------------------------------------------------------------------------
alias wep_dq_base_pdef base_pdef
def base_pdef
# Max is 999 and min is 0
if wep_dq_base_pdef + @atr_mod_list.pdef > 999
return 999
elsif wep_dq_base_pdef + @atr_mod_list.pdef <= 0
return 1
else
return wep_dq_base_pdef + @atr_mod_list.pdef
end
end
#--------------------------------------------------------------------------
# * Get Basic Magic Defense
#--------------------------------------------------------------------------
alias wep_dq_base_mdef base_mdef
def base_mdef
# Max is 999 and min is 0
if wep_dq_base_mdef + @atr_mod_list.mdef > 999
return 999
elsif wep_dq_base_mdef + @atr_mod_list.mdef <= 0
return 1
else
return wep_dq_base_mdef + @atr_mod_list.mdef
end
end
#--------------------------------------------------------------------------
# * Get Basic Evasion Correction
#--------------------------------------------------------------------------
alias wep_dq_base_eva base_eva
def base_eva
# Max is 999 and min is 0
if wep_dq_base_eva + @atr_mod_list.eva > 999
return 999
elsif wep_dq_base_eva + @atr_mod_list.eva <= 0
return 1
else
return wep_dq_base_eva + @atr_mod_list.eva
end
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Get Basic Maximum HP
#--------------------------------------------------------------------------
alias wep_dq_base_maxhp base_maxhp
def base_maxhp
# Max is 9999 and min is 0
if wep_dq_base_maxhp + @atr_mod_list.maxhp > 9999
return 9999
elsif wep_dq_base_maxhp + @atr_mod_list.maxhp <= 0
return 1
else
return wep_dq_base_maxhp + @atr_mod_list.maxhp
end
end
#--------------------------------------------------------------------------
# * Get Basic Maximum SP
#--------------------------------------------------------------------------
alias wep_dq_base_maxsp base_maxsp
def base_maxsp
# Max is 9999 and min is 0
if wep_dq_base_maxsp + @atr_mod_list.maxsp > 9999
return 9999
elsif wep_dq_base_maxsp + @atr_mod_list.maxsp <= 0
return 1
else
return wep_dq_base_maxsp + @atr_mod_list.maxsp
end
end
#--------------------------------------------------------------------------
# * Get Basic Strength
#--------------------------------------------------------------------------
alias wep_dq_base_str base_str
def base_str
# Max is 999 and min is 0
if wep_dq_base_str + @atr_mod_list.str > 999
return 999
elsif wep_dq_base_str + @atr_mod_list.str <= 0
return 1
else
return wep_dq_base_str + @atr_mod_list.str
end
end
#--------------------------------------------------------------------------
# * Get Basic Dexterity
#--------------------------------------------------------------------------
alias wep_dq_base_dex base_dex
def base_dex
# Max is 999 and min is 0
if wep_dq_base_dex + @atr_mod_list.dex > 999
return 999
elsif wep_dq_base_dex + @atr_mod_list.dex <= 0
return 1
else
return wep_dq_base_dex + @atr_mod_list.dex
end
end
#--------------------------------------------------------------------------
# * Get Basic Agility
#--------------------------------------------------------------------------
alias wep_dq_base_agi base_agi
def base_agi
# Max is 999 and min is 0
if wep_dq_base_agi + @atr_mod_list.agi > 999
return 999
elsif wep_dq_base_agi + @atr_mod_list.agi <= 0
return 1
else
return wep_dq_base_agi + @atr_mod_list.agi
end
end
#--------------------------------------------------------------------------
# * Get Basic Intelligence
#--------------------------------------------------------------------------
alias wep_dq_base_int base_int
def base_int
# Max is 999 and min is 0
if wep_dq_base_int + @atr_mod_list.int > 999
return 999
elsif wep_dq_base_int + @atr_mod_list.int <= 0
return 1
else
return wep_dq_base_int + @atr_mod_list.int
end
end
#--------------------------------------------------------------------------
# * Get Basic Attack Power
#--------------------------------------------------------------------------
alias wep_dq_base_atk base_atk
def base_atk
# Max is 999 and min is 0
if wep_dq_base_atk + @atr_mod_list.atk > 999
return 999
elsif wep_dq_base_atk + @atr_mod_list.atk <= 0
return 1
else
return wep_dq_base_atk + @atr_mod_list.atk
end
end
#--------------------------------------------------------------------------
# * Get Basic Physical Defense
#--------------------------------------------------------------------------
alias wep_dq_base_pdef base_pdef
def base_pdef
# Max is 999 and min is 0
if wep_dq_base_pdef + @atr_mod_list.pdef > 999
return 999
elsif wep_dq_base_pdef + @atr_mod_list.pdef <= 0
return 1
else
return wep_dq_base_pdef + @atr_mod_list.pdef
end
end
#--------------------------------------------------------------------------
# * Get Basic Magic Defense
#--------------------------------------------------------------------------
alias wep_dq_base_mdef base_mdef
def base_mdef
# Max is 999 and min is 0
if wep_dq_base_mdef + @atr_mod_list.mdef > 999
return 999
elsif wep_dq_base_mdef + @atr_mod_list.mdef <= 0
return 1
else
return wep_dq_base_mdef + @atr_mod_list.mdef
end
end
#--------------------------------------------------------------------------
# * Get Basic Evasion Correction
#--------------------------------------------------------------------------
alias wep_dq_base_eva base_eva
def base_eva
# Max is 999 and min is 0
if wep_dq_base_eva + @atr_mod_list.eva > 999
return 999
elsif wep_dq_base_eva + @atr_mod_list.eva <= 0
return 1
else
return wep_dq_base_eva + @atr_mod_list.eva
end
end
end