Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Cannibalism
- # Version 1.07
- # Author : LiTTleDRAgo
- #==============================================================================
- #------------------------------------------------------------------------------
- # ▼ INTRODUCTION
- #------------------------------------------------------------------------------
- # Based on Cannibalism script by Kread-EX for VX Ace
- # This script allows you to create skills to absorb a fraction of a target
- # parameters if it kills it. The gain is permanent.
- #
- #------------------------------------------------------------------------------
- # ▼ Notetags Instructions
- #------------------------------------------------------------------------------
- # For VX and VXA user can use notetags at Enemy Tabs to determine percentage
- # of enemy stat which will be absorbed
- # (notetags configuration will be prioritized):
- #
- #------------------------------------------------------------------------------
- # ** Notetags for Enemies
- #------------------------------------------------------------------------------
- #
- # <cannibal: maxhp,maxsp,str,dex,agi,int> # for XP
- # <cannibal: maxhp,maxmp,atk,def,spi,agi> # for VX
- # <cannibal: maxhp,maxmp,atk,def,mat,mdf,agi,luk> # for VXA
- # all parameter must be integer
- #
- #
- # <cannibal devour limit: x> # max limit for devouring that enemy
- # <cannibal static> # use static gain instead of percentage?
- # x must be integer
- #
- # <cannibal devour limit: x> is necessary to activate the script
- #
- # This tags below only have meaning if EXCLUDE_IF_DEVOUR is false
- #
- # <cannibal exclude exp> # exclude exp if enemy is devoured
- # <cannibal exclude gold> # exclude gold if enemy is devoured
- # <cannibal exclude item> # exclude drop item if enemy is devoured
- #
- #------------------------------------------------------------------------------
- # ** Notetags for Skills
- #------------------------------------------------------------------------------
- #
- # <cannibal devour skill> # Sets the skill as devour skill
- #
- #==============================================================================
- module LiTTleDRAgo
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # BEGIN CONFIGURATION
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- CANNIBALIZE = { # do not delete
- #----------------------------------------------------------------------------
- # Configure enemy ID here, you can set the percentage of enemy stat which
- # will be absorbed,
- # - If you want to use static gain instead of percentage,
- # change :static into true
- # - For lazy user who wants to set every unconfigured enemy, use 0 as ID.
- # - You can disable devouring some enemies (such as boss) by setting the
- # :limit to 0
- #----------------------------------------------------------------------------
- #
- #----------------------------------------------------------------------------
- # Delete if you're not using XP
- # For XP (8 args)
- :id => [:maxhp, :maxsp, :str, :dex, :agi, :int, :limit, :static],
- 1 => [ -2, 1, -1, 0, 0, 1, 15, true],
- #----------------------------------------------------------------------------
- #----------------------------------------------------------------------------
- # Delete if you're not using VX
- # For VX (8 args)
- :id => [:maxhp, :maxmp, :atk, :def, :spi, :agi, :limit, :static],
- # 1 => [ 0, 0, -1, 0, 1, 0, 15, true],
- # 2 => [ 2, -3, 0, 0, 0, 0, 15, true],
- # 3 => [ -1, 0, 2, 0, 0, 0, 15, true],
- #----------------------------------------------------------------------------
- #----------------------------------------------------------------------------
- # Just in case, added support for VXA, although I recommend you to get
- # Kread-Ex's version instead.
- # Delete if you're not using VXA
- # For VXA (10 args)
- :id =>[:maxhp, :maxmp, :atk, :def, :mat, :mdf, :agi, :luk, :limit,:static],
- # 0 =>[ 0, 0, 0, 0, 0, 0, 0, 0, 999, true],
- # 4 =>[ 10, 0, 2, -5, 0, 0, 4, 5, 14, true],
- #----------------------------------------------------------------------------
- #----------------------------------------------------------------------------
- #----------------------------------------------------------------------------
- } # do not delete
- #----------------------------------------------------------------------------
- # Below you can set which skills that devour the enemy when enemy is dead
- # Enemy will be absorbed only if you kill it with devour skills
- DEVOUR_SKILL = [57]
- #----------------------------------------------------------------------------
- #----------------------------------------------------------------------------
- # This feature maybe not working for some CBS'es or some battle addon
- # (ex: Multi Drop, XAS)
- #
- # EXCLUDE_IF_DEVOUR = [:exp, :gold, :item]
- # :exp = Enemy will not give exp if devoured?
- # :gold = Enemy will not drop gold if devoured?
- # :item = Enemy will not drop items if devoured?
- EXCLUDE_IF_DEVOUR = [false, false, false]
- #----------------------------------------------------------------------------
- #----------------------------------------------------------------------------
- # Text Related function
- VOCAB_DEVOURED_PLUS = "absorbs"
- VOCAB_DEVOURED_MIN = "loses"
- #----------------------------------------------------------------------------
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # END CONFIGURATION
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #----------------------------------------------------------------------------
- # Don't Edit
- CANNIBAL_TAGS = {
- :cannibal => /<cannibal:(.+?)\>/i,
- :devour_limit => /<cannibal[-_ ]?devour[-_ ]?limit:\s*([-]?\d+)\s*>/i,
- :devour_skill => /<cannibal[-_ ]?devour[-_ ]?skill>/i,
- :exclude_exp => /<cannibal[-_ ]?exclude[-_ ]?exp>/i,
- :exclude_gold => /<cannibal[-_ ]?exclude[-_ ]?gold>/i,
- :exclude_item => /<cannibal[-_ ]?exclude[-_ ]?item>/i,
- :static => /<cannibal[-_ ]?static>/i,
- }
- #----------------------------------------------------------------------------
- end
- ($imported||={})[:drg_cannibalism_xp] = 1.07
- core_engine = "This script needs Drago - Core Engine ver 1.55 or above"
- ($imported[:drg_core_engine] || 0) >= 1.55 || raise(core_engine)
- #==============================================================================
- # ** 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
- #--------------------------------------------------------------------------
- # ● Public Instance Variables
- #--------------------------------------------------------------------------
- attr_sec_accessor :cannibal_bonus, :devoured, "Array.new(10, 0)"
- #--------------------------------------------------------------------------
- # ● Object Initialize
- #--------------------------------------------------------------------------
- define_pre_alias(:setup) { @cannibal_bonus, @devoured = Array.new(10,0), []}
- #--------------------------------------------------------------------------
- # ● Total Devour <for RMVXA>
- # For XP users, you can use this feature if you place Wecoc's VX Ace Formula
- # (http://forum.chaos-project.com/index.php/topic,14523.0.html)
- #
- # Note : If you want to add this variable into damage formula, do it like
- # this example (will throws an error if enemy is using it).
- # a.atk + a.mat * a.total_devour(b.enemy_id) - b.def - b.mdf
- # a.atk + a.mat * a.total_devour - b.def - b.mdf
- #
- # Using total_devour without any args will result to sum all of the enemy
- # devour count.
- #--------------------------------------------------------------------------
- def total_devour(*id)
- if id.size == 0
- array = devoured.compact
- else
- array = id.collect {|e| e.is_a?(Range) ? e.to_a : e }.flatten
- array.collect! {|e| devoured[e.to_i] ||= 0 }
- end
- array.sum
- end
- #--------------------------------------------------------------------------
- # ● Purge Devour <for RMVXA>
- # For XP users, you can use this feature if you place Wecoc's VX Ace Formula
- # (http://forum.chaos-project.com/index.php/topic,14523.0.html)
- #
- # Similar to total_devour. However, once this syntax is used, it will reset
- # devour count back to 0.
- # If you played Final Fantasy XII, think of Shemhazai's Ultimate Skill,
- # Flame Purge which uses total devoured souls as damage multiplier. Once
- # skill is used, the count resets back to 0.
- # Example : (will throws an error if enemy is using it)
- # a.atk + a.mat * a.purge_devour(b.enemy_id) - b.def - b.mdf
- # a.atk + a.mat * a.purge_devour - b.def - b.mdf
- #
- # Using purge_devour without any args will result to sum all of the enemy
- # devour count, and then reset all the devour count to 0.
- #--------------------------------------------------------------------------
- def purge_devour(*id)
- result = total_devour(*id)
- if id.size == 0
- devoured.clean
- else
- array = id.collect {|e| e.is_a?(Range) ? e.to_a : e }.flatten
- array.each {|e| devoured[e.to_i] = nil }
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● Returns the parameter bonuses
- #--------------------------------------------------------------------------
- if LiTTleDRAgo::VXA
- define_third_method(:param,:drg_cannibal_param) do |param_id|
- drg_cannibal_param(param_id) + cannibal_bonus[param_id]
- end
- else
- (LiTTleDRAgo::VX ? [:maxhp,:maxmp,:atk,:def,:spi,:agi] :
- [:maxhp,:maxsp,:str,:dex,:agi,:int]).each_with_index do |m,i|
- define_third_method(:"#{m}",:"drg190_#{m}") do |*args|
- stat, ex = cannibal_bonus, [0,1].include?(i) ? 9999 : 999
- (send(:"drg190_#{m}",*args) + stat[i]).clamp(1, ex)
- end
- end
- end
- end
- #==============================================================================
- # ** Game_Enemy
- #------------------------------------------------------------------------------
- # This class handles enemies. It's used within the Game_Troop class
- # ($game_troop).
- #==============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # ● Class Variables
- #--------------------------------------------------------------------------
- @@prob = method_defined?(:treasure_prob) ? :treasure_prob : :drop_item_rate
- #--------------------------------------------------------------------------
- # ● Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :enemy_id
- attr_sec_reader :devour_limit, -1
- attr_sec_reader :cannibal_tags, 'LiTTleDRAgo::CANNIBAL_TAGS'
- #--------------------------------------------------------------------------
- # ● Alias Listing
- #--------------------------------------------------------------------------
- alias_sec_method :drg_cannibal_gold, :gold
- alias_sec_method :drg_cannibal_exp, :exp
- #--------------------------------------------------------------------------
- # ● Object Initialize
- #--------------------------------------------------------------------------
- define_post_alias(:initialize) { load_cannibal_initialize }
- #--------------------------------------------------------------------------
- # ● Gold, Exp
- #--------------------------------------------------------------------------
- define_method(:gold) { |*args| @gold_replace || drg_cannibal_gold(*args) }
- define_method(:exp) { |*args| @exp_replace || drg_cannibal_exp(*args) }
- #--------------------------------------------------------------------------
- # * Get Drop Item
- #--------------------------------------------------------------------------
- [:drop_item1,:drop_item2,:"#{@@prob}"].each do |method|
- if method_defined?(:"#{method}")
- define_third_method(:"#{method}",:":drg_cannibal_#{method}") do |*args|
- result = send(:":drg_cannibal_#{method}", *args)
- result.kind = 0 if @drop_replace && result.respond_to?(:kind)
- result = 0 if @drop_replace && result.is_a?(Numeric)
- result
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● load_cannibal_initialize
- #--------------------------------------------------------------------------
- def load_cannibal_initialize
- @devour_ratio_p = Array.new(10, 0)
- @gold_replace = @exp_replace = @drop_replace = nil
- cannibalize = LiTTleDRAgo::CANNIBALIZE[@enemy_id]
- cannibalize ||= LiTTleDRAgo::CANNIBALIZE[0]
- return if cannibalize.nil?
- param_array = (0..5).to_a
- param_array = (0..7).to_a if LiTTleDRAgo::VXA
- param_array.each do |i|
- if cannibalize[i] != 0 && cannibalize[i].is_a?(Numeric)
- @devour_ratio_p[i] = cannibalize[i]
- end
- end
- note_array = "#{enemy.get_note[cannibal_tags[:cannibal]]}".get_ints
- note_array.each_with_index do |note,index|
- @devour_ratio_p[index] = note if note.is_a?(Numeric)
- end
- @devour_limit = cannibalize[param_array.size] || -1
- @static_gain = cannibalize[param_array.size + 1] == true
- @devour_limit = $1.to_i if enemy.get_note =~ cannibal_tags[:devour_limit]
- @static_gain = true if enemy.get_note =~ cannibal_tags[:static]
- end
- #--------------------------------------------------------------------------
- # ● Determine if the enemy can be eaten
- #--------------------------------------------------------------------------
- def can_devour?
- devour_limit > 0
- end
- #--------------------------------------------------------------------------
- # ● Returns the parameter gain upon eating
- #--------------------------------------------------------------------------
- def devour_param_bonus(param_id)
- if !@static_gain
- if @devour_ratio.not.nil?
- return ((param_base(param_id) * @devour_ratio) / 100.00).round
- end
- return ((param_base(param_id) * @devour_ratio_p[param_id])/100.00).round
- else
- return @devour_ratio if @devour_ratio.not.nil?
- return @devour_ratio_p[param_id]
- end
- end
- end
- #==============================================================================
- # ** Game_Battler
- #------------------------------------------------------------------------------
- # This class deals with battlers. It's used as a superclass for the Game_Actor
- # and Game_Enemy classes.
- #==============================================================================
- Klass = LiTTleDRAgo::VXA ? Scene_Battle : Game_Battler
- class Klass
- #--------------------------------------------------------------------------
- # ● Public Instance Variables
- #--------------------------------------------------------------------------
- attr_sec_reader :cannibal_tags, 'LiTTleDRAgo::CANNIBAL_TAGS'
- #--------------------------------------------------------------------------
- # ● Param Base
- #--------------------------------------------------------------------------
- define_sec_method(:param_base) do |index|
- vx = LiTTleDRAgo::VX
- return base_maxhp if index == 0
- return vx ? base_maxmp : base_maxsp if index == 1
- return vx ? base_atk : base_str if index == 2
- return vx ? base_def : base_dex if index == 3
- return vx ? base_spi : base_agi if index == 4
- return vx ? base_agi : base_int if index == 5
- return 0
- end
- #--------------------------------------------------------------------------
- # * Apply Skill Effects
- #--------------------------------------------------------------------------
- define_third_method(LiTTleDRAgo::VXA ? :apply_item_effects : :skill_effect,
- :drg_sb_aie) do |user, skill, *args|
- result = drg_sb_aie(user, skill, *args)
- devour(user, skill)
- return result
- end
- #--------------------------------------------------------------------------
- # ● Skill can Devour
- #--------------------------------------------------------------------------
- def devour_skill?(skill)
- result = LiTTleDRAgo::DEVOUR_SKILL.include?(skill.id)
- result ||= skill.get_note =~ cannibal_tags[:devour_skill]
- return result
- end
- #--------------------------------------------------------------------------
- # ● Devours the enemy
- #--------------------------------------------------------------------------
- def devour(user, item)
- target, user, devour_ok = self, user, false
- target, user = user, @subject if LiTTleDRAgo::VXA
- if item.is_a?(RPG::Skill) && devour_skill?(item) && user.is_a?(Game_Actor)
- if target.is_a?(Game_Enemy) && target.can_devour? && target.dead?
- if (user.devoured[target.enemy_id] || 0) < target.devour_limit
- exp_is_gone = LiTTleDRAgo::EXCLUDE_IF_DEVOUR[0]
- gold_is_gone = LiTTleDRAgo::EXCLUDE_IF_DEVOUR[1]
- item_is_gone = LiTTleDRAgo::EXCLUDE_IF_DEVOUR[2]
- gold_is_gone |= target.get_note=~target.cannibal_tags[:exclude_gold]
- exp_is_gone |= target.get_note=~target.cannibal_tags[:exclude_exp]
- item_is_gone |= target.get_note=~target.cannibal_tags[:exclude_item]
- target.instance_variable_set(:@gold_replace, 0) if gold_is_gone
- target.instance_variable_set(:@exp_replace, 0) if exp_is_gone
- target.instance_variable_set(:@drop_replace, 0) if item_is_gone
- (0..7).each do |i|
- n = target.devour_param_bonus(i)
- user.cannibal_bonus[i] += n
- if n != 0
- if n > 0
- text = "#{user.name} #{LiTTleDRAgo::VOCAB_DEVOURED_PLUS} #{n}"
- text += " #{$data_system.words.params[i]}."
- else
- text = "#{user.name} #{LiTTleDRAgo::VOCAB_DEVOURED_MIN} #{n}"
- text += " #{$data_system.words.params[i]}."
- end
- devour_ok = true
- if LiTTleDRAgo.scene.is_a?(Scene_Battle) && !LiTTleDRAgo::VXA
- LiTTleDRAgo.scene.devour_logs << text
- else
- devour_log(text)
- end
- end
- end
- user.hp = user.hp
- user.respond_to?(:sp) ? (user.sp = user.sp) : (user.mp = user.mp)
- user.devoured[target.enemy_id] ||= 0
- user.devoured[target.enemy_id] += 1 if devour_ok
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● Devour Log
- #--------------------------------------------------------------------------
- def devour_log(text='')
- res = [300,64]
- @devour_window = Window_Help.new
- @devour_window.visible = false
- @devour_window.width = res.at(0)
- @devour_window.height = res.at(1)
- @devour_window.center_window
- @devour_window.contents = Bitmap.new(res.at(0)-32, res.at(1)-32)
- @devour_window.visible = true
- @devour_window.draw_text(0,0,@devour_window.contents.width,
- @devour_window.line_height,text,1)
- 10.times { [Graphics,@devour_window].update }
- Graphics.wait_for_input
- $game_system.se_play($data_system.decision_se)
- @devour_window.dispose
- @devour_window = nil
- 10.times { [Graphics,Input].update }
- end
- end
- #==============================================================================
- # ** Scene_Battle
- #------------------------------------------------------------------------------
- # This class performs battle screen processing.
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● Public Instance Variables
- #--------------------------------------------------------------------------
- attr_sec_reader :devour_logs, "Array.new"
- #--------------------------------------------------------------------------
- # ● display_action_effects
- #--------------------------------------------------------------------------
- define_post_alias(LiTTleDRAgo::VX ? :display_action_effects :
- :update_phase4_step5) do
- devour_logs.each {|text| @active_battler.devour_log(text)}
- devour_logs.clear
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement