Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # CARDGAME ON DRAW/PLAY EFFECTS
- # Author: pencilcase27
- # Version: v1.00
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- #
- # Description
- #
- # This addon allows you to create weapon, armors and stats that heal or damage
- # the users hp, mp or tp whenever he uses or draws a card. Actors cannot die
- # through this effect.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- #
- # Notetags
- #
- # <on card play: effect_name>
- # <on card draw: effect_name>
- # Adds the darw or play effects to your card. To define card effects, go to
- # "Options" -> EFFECTS and create a new effect.
- # Example:
- # <on card draw: vampiric_sword_1>
- # <on card play: vampiric_sword_2>
- # Whenever an actor with this equipment draws a card, he heals 25 mp and tp, but
- # when he plays a card, he looses 50 hp.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- module PC27
- module CG
- #---------------------------------------------------------------------------
- # Options
- #---------------------------------------------------------------------------
- # SE played whenever the effect takes place. If an effect heals one
- # parameter but damages another, both sounds are played. ["name", vol, pitch]
- LOOSE_SE = ["Absorb1", 100, 100]
- GAIN_SE = ["Absorb2", 100, 100]
- # Effect names
- EFFECTS = {
- # "effect_name" => { :hp => hp_value,
- # :mp => mp_value,
- # :tp => tp_value, },
- "vampiric_sword_1" => { :hp => 0,
- :mp => +25,
- :tp => +25, },
- "vampiric_sword_2" => { :hp => -50,
- :mp => 0,
- :tp => 0, },
- } #do not remove this
- #---------------------------------------------------------------------------
- # End Options
- #---------------------------------------------------------------------------
- end
- end
- #============================================================================
- # BaseItem
- #============================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # * Load on card draw notetags
- #--------------------------------------------------------------------------
- def on_card_draw
- return @on_card_draw if @on_card_draw
- self.note.split(/[\r\n]+/).each { |line|
- if /<on[ -_]card[ -_]draw: +(?<ocd>.+)>/i =~ line
- @on_card_draw = PC27::CG::EFFECTS[ocd]
- end
- }
- @on_card_draw = 0 unless @on_card_draw
- return @on_card_draw
- end
- #--------------------------------------------------------------------------
- # * Load on card play notetags
- #--------------------------------------------------------------------------
- def on_card_play
- return @on_card_play if @on_card_play
- self.note.split(/[\r\n]+/).each { |line|
- if /<on[ -_]card[ -_]play: +(?<ocp>.+)>/i =~ line
- @on_card_play = PC27::CG::EFFECTS[ocp]
- end
- }
- @on_card_play = 0 unless @on_card_play
- return @on_card_play
- end
- end
- #============================================================================
- # Game_Actor
- #============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Alias method draw cards
- #--------------------------------------------------------------------------
- alias draw_cards_state_addon draw_cards
- def draw_cards(n, show = true, sound = true)
- draw_cards_state_addon(n, show, sound)
- change = draw_effect_check_all(n)
- evaluate_on_card_draw_and_play(change)
- end
- #--------------------------------------------------------------------------
- # * Evaluate card draw and play effects
- #--------------------------------------------------------------------------
- def evaluate_on_card_draw_and_play(change)
- unless change[:hp] == 0
- @hp = cage_number(@hp + change[:hp], 1, mhp)
- change[:hp] > 0 ? RPG::SE.new(*PC27::CG::GAIN_SE).play : RPG::SE.new(*PC27::CG::LOOSE_SE).play
- end
- unless change[:mp] == 0
- @mp = cage_number(@mp + change[:mp], 0, mmp)
- change[:mp] > 0 ? RPG::SE.new(*PC27::CG::GAIN_SE).play : RPG::SE.new(*PC27::CG::LOOSE_SE).play
- end
- unless change[:tp] == 0
- @tp = cage_number(@tp + change[:tp], 0, max_tp)
- change[:tp] > 0 ? RPG::SE.new(*PC27::CG::GAIN_SE).play : RPG::SE.new(*PC27::CG::LOOSE_SE).play
- end
- end
- #--------------------------------------------------------------------------
- # * Check for on card draw effects
- #--------------------------------------------------------------------------
- def draw_effect_check_all(n)
- change = {:hp => 0, :mp => 0, :tp => 0}
- # --- check states ---
- for id in @states
- if $data_states[id].on_card_draw != 0
- hash = $data_states[id].on_card_draw
- change[:hp] += hash[:hp] * n
- change[:mp] += hash[:mp] * n
- change[:tp] += hash[:tp] * n
- end
- end
- # --- check armor ---
- for armor in self.armors
- if armor.on_card_draw != 0
- hash = armor.on_card_draw
- change[:hp] += hash[:hp] * n
- change[:mp] += hash[:mp] * n
- change[:tp] += hash[:tp] * n
- end
- end
- # --- check weapons ---
- for weapon in self.weapons
- if weapon.on_card_draw != 0
- hash = weapon.on_card_draw
- change[:hp] += hash[:hp] * n
- change[:mp] += hash[:mp] * n
- change[:tp] += hash[:tp] * n
- end
- end
- return change
- end
- #--------------------------------------------------------------------------
- # * Evaluates play effects from scene battle
- #--------------------------------------------------------------------------
- def evaluate_on_card_play
- change = play_effect_check_all
- evaluate_on_card_draw_and_play(change)
- end
- #--------------------------------------------------------------------------
- # * Check for on card play effects
- #--------------------------------------------------------------------------
- def play_effect_check_all
- change = {:hp => 0, :mp => 0, :tp => 0}
- # --- check states ---
- for id in @states
- if $data_states[id].on_card_play != 0
- hash = $data_states[id].on_card_play
- change[:hp] += hash[:hp]
- change[:mp] += hash[:mp]
- change[:tp] += hash[:tp]
- end
- end
- # --- check armor ---
- for armor in self.armors
- if armor.on_card_play != 0
- hash = armor.on_card_play
- change[:hp] += hash[:hp]
- change[:mp] += hash[:mp]
- change[:tp] += hash[:tp]
- end
- end
- # --- check weapons ---
- for weapon in self.weapons
- if weapon.on_card_play != 0
- hash = weapon.on_card_play
- change[:hp] += hash[:hp]
- change[:mp] += hash[:mp]
- change[:tp] += hash[:tp]
- end
- end
- return change
- end
- #--------------------------------------------------------------------------
- # * Method to cage a number between two values
- #--------------------------------------------------------------------------
- def cage_number(number, min, max)
- x = number
- x = [x, min].max
- x = [x, max].min
- return x
- end
- end
- #============================================================================
- # Scene_Battle
- #============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # * Alias Method evaluate item
- #--------------------------------------------------------------------------
- alias evaluate_item_state_addon evaluate_item
- def evaluate_item(actor, item)
- evaluate_item_state_addon(actor, item)
- if item.id != actor.attack_skill_id && item.id != actor.guard_skill_id
- actor.evaluate_on_card_play
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement