Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- #
- #
- # L'James Skill Traits
- #
- #
- # Requires L'James Notetag System
- #==============================================================================
- # Description
- #==============================================================================
- # Script allows to assign special traits to skills and items and then choose
- # behaviour in reaction to them, namely:
- #
- # * Set damage rate recieved from skills/items with specified trait
- # * Set damage rate dealt by skills/items with specified trait
- # * Allow states to be removed in reaction to skills/items with specified
- # traits, like FFX Nul-spells
- # * Restrict usage of skills/items with specified traits
- #
- #==============================================================================
- # Instruction
- #==============================================================================
- # Insert this script between L'J Notetag System and Main
- # Set list of traits
- module LJ
- module SKILL_TRAITS
- TRAITS = [
- :physical,
- :magical,
- :fire,
- :ice,
- :lightning,
- :heal,
- ]
- end
- end
- # Use notetags to change game behaviour
- #
- # Note:
- # some tags have multiple versions that can be written like
- # <tag arg1, arg2, arg3>
- # or
- # <tag>
- # arg1
- # arg2
- # arg3
- # </tag>
- #
- #------------------------------------------------------------------------------
- # Skill and Item notetags
- #------------------------------------------------------------------------------
- # These notetags go in the skill or item notebox in the database.
- #
- # * <<x>> assigns trait x to skill/item. E.g. <<fire>>
- #
- # * <take x> assigns trait x to skill/item but only if user of this skill/item
- # has feature <give x>. Also: <take x1, x2...>
- #
- # * <<take all>> same as <take x> but applied for all traits
- #
- #------------------------------------------------------------------------------
- # State notetags
- #------------------------------------------------------------------------------
- # This notetag go in the state notebox in the database.
- #
- # * <removed by x> - state with this tag will be removed when skill/item with
- # trait x is applied to character with this state. Also <removed by x1, x2>
- # * <added by x> - state with this tag will be added when skill/item with
- # trait x is applied to character with this state. Also <added by x1, x2>
- #------------------------------------------------------------------------------
- # Feature notetags
- #------------------------------------------------------------------------------
- # These notetag go in the actor, class, equipment, enemy or state notebox in
- # the database. The behave like features of RPG Maker VXA
- #
- # * <give x> - assigns trait x to skills/items which take trait x.
- # * <power x y%> - battler with this tag will deal y% damage when using
- # skills/items with trait x. y may be negative. Also <power x1 y1%, x2 y2%>
- #
- # * <damage x y%> - battler with this tag will receive y% damage from
- # skills/items with trait x. y may be negative. Also <damage x1 y1%, x2 y2%>
- #
- # * <ignore x> - battler with this tag will not be affected by skills/items
- # with trait x. Different from <damage x 0%> in that battler also ignores
- # state modifications, not only damage
- #
- # * <seal x> - battler can't use skills/items with trait x
- #==============================================================================
- # Terms of use
- #==============================================================================
- # Free to use in commercial and non-commercial projects as long as you give
- # credit to L'James
- #==============================================================================
- # Notetag editing
- #==============================================================================
- # Here you can rename notetags if you prefer other names or these names
- # are used in other scripts
- module LJ
- module SKILL_TRAITS
- # Skills:
- # Parameter that takes selected given traits
- TAKE = :take
- # Parameter that takes all possible given traits
- TAKE_ALL = :take_all
- # States:
- # List of traits that remove this state
- REMOVED_BY = :removed_by
- # List of traits that add this state
- ADDED_BY = :added_by
- # Features:
- # List of traits that will be applied on skills/items with TAKE
- GIVE = :give
- # Damage multiplier for attacker
- POWER = :power
- # Damage multiplier for defender
- DAMAGE = :damage
- # List of traits that will make skills/items have no effect
- IGNORE = :ignore
- # List of traits that will make skills/items unusable
- SEAL = :seal
- end
- end
- module LJ
- module SKILL_TRAITS
- LJ::NOTETAGS.extension do
- # Here you can specify extension styling if you know how
- #==============================================================================
- # Don't touch unless you really want it
- #==============================================================================
- declare_usableitem do
- TRAITS.each do |t|
- register t, trait
- end
- register TAKE, array(:sym).set_limit(*TRAITS)
- register TAKE_ALL, trait
- end
- declare_state do
- register REMOVED_BY, array(:sym).set_limit(*TRAITS)
- register ADDED_BY, array(:sym).set_limit(*TRAITS)
- end
- declare_features do
- register GIVE, array(:sym).set_limit(*TRAITS)
- register SEAL, array(:sym).set_limit(*TRAITS)
- register IGNORE, array(:sym).set_limit(*TRAITS)
- register POWER, hash(:percent).set_key_limit(*TRAITS)
- register DAMAGE, hash(:percent).set_key_limit(*TRAITS)
- end
- end
- end
- end
- class RPG::UsableItem::Damage
- attr_writer :multiplier
- alias eval_ljskilltraits eval
- def eval(a,b,v)
- @multiplier ||= 1
- res = @multiplier*eval_ljskilltraits(a,b,v)
- @multiplier = 1
- res
- end
- end
- class RPG::UsableItem < RPG::BaseItem
- def get_all_skill_traits(user)
- res = LJ::SKILL_TRAITS::TRAITS.select {|tr| get_param(tr)}
- if get_param(LJ::SKILL_TRAITS::TAKE_ALL)
- res += user.get_feature(LJ::SKILL_TRAITS::GIVE)
- else
- res += user.get_feature(LJ::SKILL_TRAITS::GIVE) &
- get_param(LJ::SKILL_TRAITS::TAKE)
- end
- res
- end
- end
- class Game_Battler < Game_BattlerBase
- alias make_damage_value_ljskilltraits make_damage_value
- def make_damage_value(user, item)
- item.damage.multiplier = item.get_all_skill_traits(user).inject(1) do
- |acc, tr|
- acc * user.get_feature(LJ::SKILL_TRAITS::POWER)[tr]
- end
- make_damage_value_ljskilltraits(user, item)
- end
- alias item_element_rate_ljskilltraits item_element_rate
- def item_element_rate(user, item)
- res = item_element_rate_ljskilltraits(user,item) *
- item.get_all_skill_traits(user).inject(1) do
- |acc, tr|
- acc * get_feature(LJ::SKILL_TRAITS::DAMAGE)[tr]
- end
- end
- alias item_test_ljskilltraits item_test
- def item_test(user, item)
- return false unless (item.get_all_skill_traits(user) &
- get_feature(LJ::SKILL_TRAITS::IGNORE)).empty?
- item_test_ljskilltraits(user, item)
- end
- alias item_apply_ljskilltraits item_apply
- def item_apply(user, item)
- item_apply_ljskilltraits(user, item)
- if @result.hit?
- traits = item.get_all_skill_traits(user)
- states.each do
- |state|
- remove_state(state.id) unless
- (state.get_param(LJ::SKILL_TRAITS::REMOVED_BY) & traits).empty?
- end
- $data_states.each do |state|
- add_state(state.id) unless state.nil? ||
- (state.get_param(LJ::SKILL_TRAITS::ADDED_BY) & traits).empty?
- end
- end
- end
- #overload
- def usable?(item)
- return false if item.is_a?(RPG::UsableItem) &&
- !(item.get_all_skill_traits(self) &
- get_feature(LJ::SKILL_TRAITS::SEAL)).empty?
- super(item)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement