RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[GW] Extra skill features

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 71
RMRK Junior
GW Magical Weapons
Version: 1.3
Author: Mr G W
Date: (DD/MM/YYYY) - 30/8/2011

Version History


  • <Version 1.3> 2011.8.30 - Bugfix: When damage to mp option was selected and
    damageboth tag was used, it wouldnt display the "no damage" message if hp damage
    was 0.
  • <Version 1.2> 2011.8.23 - New tag <multi>. Allows creation multi hit attacks.
  • <Version 1.1> 2011.8.18 - Fixed a crash when a enemy used a magical skill, added
    the <01damage> tag, values from <damageboth> can now be ommited to use defaults.
  • <Version 1.0> 2011.8.17 - Original Release

Planned Future Versions
  • More features.

Description

Gives many features to skills. Particulary useful for physical skills that are meant to work similarly to normal attacks, such as hitratio or elements.

Features

  • Allows skills to inherit many data from normal attack, such as hitratio, critical, elements.
  • Allows a skill to damage both HP and MP.
  • Allows a skill to be silenced without setting SPI F above zero. Useful for status skills or fixed damage spells.
  • Can also turn physical skills into magical skills if using Magical Weapons script.
  • NEW: Skills that deal 0 damage can have a 50% chance to deal 1 damage just like normal attack if <01damage> tag is used.
    Note that, like normal attack, this doesnt happen if the enemy guards the attack.

Screenshots

None.

Instructions

Place where it says Materials. Use the note tags to apply the effects you want.

This script also affects usable items

Script


Code: [Select]
=begin
==================================================================================================
==================================================================================================
Extra Skill Features
Version 1.3
By Mr G W - Rmrk.net
Date (DD/MM/YYYY) - 30/8/2011
<Version 1.3> 2011.8.30 - Bugfix: When damage to mp option was selected and
damageboth tag was used, it wouldnt display the "no damage" message if hp damage
was 0.
<Version 1.2> 2011.8.23 - New tag <multi>. Allows creation multi hit attacks.
<Version 1.1> 2011.8.18 - Fixed a crash when a enemy used a magical skill, added
the <01damage> tag, values from <damageboth> can now be ommited to use defaults.
<Version 1.0> 2011.8.17 - Original Release


This script allows skills to inherit data from the normal attack.
This is useful for melee skills that are meant to work in a similar way to
normal attacks and so you don't have to create many clone skills each with
different elements each.
Since weapons may have variable hitratios, you can make skills that get the
weapon hitratio. This is useful if you have a inaccurate weapon that gives an
insane attack bonus to nto be perfectly accurate when used by a skill.
It also allows to have skills to be silenced without setting SPI F above 0.

<element>

Use this tag to inherit the elements. This adds the elements from the
normal attack.
So if your skill has element Fire and inherits the norm attack elements it will
deal Fire + (elements). If you want the skill to deal the exact same number
of elements, just make it without any elements.

If using KGC_SetAttackElement, this will work on enemies too.

<addhitratio>
<removehitratio>
<hitratio>

This adds the normal attack hit ratio to the skill.
the final hitratio will be Normal Attack + Skill. This is useful to make
skills more or less accurate than normal attack. For example, you weapon has
70% hit, you could make a skill that increases the acuracy by 10% by inputting
10 in the skill hitratio.
If <removehitratio> is used, then the final hitratio will be normal attack - skill.
This is useful for making skills that are less accurate than normal. For example,
setting the skill hitratio to 15 will reduce accuracy by 15%.
To make the skill's accuracy the same as normal attack, just set the hitratio
to 0 or use the <hitratio> tag.

<silence>
This tag causes this skill to be disabled if the user is silenced, even if
SPI F = 0. This is useful for non damaging magic attacks or fixed damage attacks
that do not use SPI F.

<critical: x>
Allows the skill to do critical hits. The number is the critical ratio to add
or subtract. Setting to 0 means no change, in other words, uses the same as normal
attack. The tag <critical> can also be used instead of <critical 0>

<damageboth: damage atk_f spi_f variance>
Damages both HP and MP.
If Damage to MP is off, this will be the base MP damage.
If Damage to MP is on, this will be the base HP damage.
If atk_f, spi_f and variance are set to a negative number, it uses the value
set in the database.

<magical>
If using the Magical Weapons script, it allows a skill to become magical aswell.
It "transfers" it's ATK F to SPI F. If using both weapons and one is magical and
the other isnt, only half of the ATK F is transfered.

Examples:
Atk F = 100 and Spi F = 0 - Using normal weapon/No changes.
Atk F = 0 and Spi F = 100 - Using magic weapon.
Atk F = 50 and Spi F = 50 - Using a magical and a normal weapon.

Atk F = 100 and Spi F = 25 - Using normal weapon/No changes.
Atk F = 0 and Spi F = 125 - Using magic weapon.
Atk F = 50 and Spi F = 75 - Using a magical and a normal weapon.

<01damage>
It allows a skill to have 50% chance of dealing 1 damage when it's final damage
is 0, just like the normal attack.

<multi: x y>
Allows a skill to strike multiple times. x is the minimum number of hits and
y the maximum number of hits. If y is ommited or lower than x, it defaults to x.
If any number is 0 or less, it defaults to 1.
If used with Random enemy, it hits the enemies randomly.
If used with One Enemy/Ally, All Enemies/Allies, User, it will it
the target/all targets multiple times.
When used with One Enemy Dual, it does +1 extra hit.
Ex: <multi 5> deals 6 hits, instead of 5.
Ex: <multi 3 5> deals 4-6 hits, instead of 3-5.
When used with 2/3 Random Enemies it does +1/+2 extra hits.
Ex: <multi 3> deals 4/5 hits, instead of 3.
Ex: <multi 2 4> deals 3-5/4-6 hits, instead of 2-4.

==================================================================================================
==================================================================================================
Compatibility:
This script aliases calc_hit, make_obj_damage_value and skill_can_use?.
This script should work with other combat-related scripts unless they override
these methods and are placed below this script. If the overriding script
is placed above this one, then this script should work properly.

This script overrides make_obj_targets and display_hp_damage.
This script will not work if another script is placed below this one that also
overrides the same method. If this script is placed below instead, the other
script will not work. If another script aliases this method, place it below
this script.

=end
$imported = {} if $imported == nil
$imported["GWExtraSkillOptions"] = true

class Game_Battler
 
  #-----HIT RATIO----------
  alias gw_calc_hit calc_hit
  def calc_hit(user, obj = nil)
    hit = gw_calc_hit(user, obj) #Run original
    return hit unless obj.is_a?(RPG::Skill)
    return (user.hit) if obj.hitratio == true #Sets the skill hitratio to the user
    #Does nothing if both or none of the tags are used.
    return hit if obj.addhitratio == obj.removehitratio
    #Does nothing if a item or normal attack.
    #Set the hitratio to the user's.
    hit = gw_get_hitratio(user, obj)
    return hit
  end
 
 
  def gw_get_hitratio(user, obj)
    #Adds the hitratio to the user's hitratio.
    hit = (user.hit + obj.hit) if obj.addhitratio == true
    #Subtracts hitratio if the minus tag is used.
    hit = (user.hit - obj.hit) if obj.removehitratio == true
    return hit
    #Using "user" instead of "weapon" so it works on enemies and with items/stats that alter hitratio.
  end

  alias gw_make_obj_damage_value make_obj_damage_value
  def make_obj_damage_value(user, obj)
    #----Setup----
    skillelements = obj.element_set                #Stores the original skill elements
    atkf_temp = obj.atk_f #Stores the original skill atk f
    spif_temp = obj.spi_f #Stores the original skill spi f
    #----Setup for secondary----
    @atk_f = (obj.damageboth[1] < 0 ? obj.atk_f : obj.damageboth[1])
    @spi_f = (obj.damageboth[2] < 0 ? obj.spi_f : obj.damageboth[2])
    variance = (obj.damageboth[3] < 0 ? obj.variance : obj.damageboth[3])
    #----Elements----
    gw_skill_element_set(user, obj) #Gets the elements from weapon
    #----Magic----
    gw_magical_weapon(user, obj)    #Magical weapons
    #Secondary damage has no need for temporary storage since the script will
    #not alter the values in the notes, unlike when its messing up with the
    #database values.
    #----Original----
    gw_make_obj_damage_value(user, obj) #Original                                               
    #----Damage for secondary hit----
    damage = obj.damageboth[0]                       # get base damage
    nodamage = true if damage == 0 #To avoid hitting 1 50% of times, if no damage is set.
    if damage > 0                                   # a positive number?
      damage += user.atk * 4 * @atk_f  / 100      # Attack F of the user
      damage += user.spi * 2 * @spi_f  / 100      # Spirit F of the user
      unless obj.ignore_defense                     # Except for ignore defense
        damage -= self.def * 2 * @atk_f / 100    # Attack F of the target
        damage -= self.spi * 1 * @spi_f / 100 if $imported["RES Stat"] == false    # Spirit F of the target
        damage -= self.res * 1 * @spi_f / 100 if $imported["RES Stat"] == true    # Spirit F of the target
      end
      damage = 0 if damage < 0                      # If negative, make 0
    elsif damage < 0                                # a negative number?
      damage -= user.atk * 4 * @atk_f / 100      # Attack F of the user
      damage -= user.spi * 2 * @spi_f / 100      # Spirit F of the user
    end
    damage *= elements_max_rate(obj.element_set)    # elemental adjustment
    damage /= 100
    if damage == 0 and obj.damage == true and nodamage == false           # if damage is 0,
      damage = rand(2)                              # half of the time, 1 dmg
      nocritical = true #When this happens, no criticals just like normal attack.
    end
    damage = apply_variance(damage, variance)   # variance
    damage = apply_guard(damage)                    # guard adjustment
    if obj.damage_to_mp #This works the other way around as we are calculating the damage for the other hit.
      @hp_damage = damage                           # damage HP
    else
      @mp_damage = damage                           # damage MP
    end
   
    #----Critical---
    #The damage can be multiplied after applying guard since we are multiplying.
    if obj.allowcritical != nil
    if (@hp_damage > 0  or @mp_damage > 0)
    @critical = (rand(100) < user.cri + obj.allowcritical)
    @critical = false if prevent_critical
    @hp_damage *= 3 if @critical and @hp_damage > 0 and obj.damage_to_mp == false
    @mp_damage *= 3 if @critical and @mp_damage > 0 and obj.damage_to_mp == true
    #---Sec attack----
    @mp_damage *= 3 if @critical and @mp_damage > 0 and obj.damage_to_mp == false and nocritical == false
    @hp_damage *= 3 if @critical and @hp_damage > 0 and obj.damage_to_mp == true and nocritical == false
    end
    end
   
    #----1 Damage---
    #Placed below critical since this damage doesnt critical
   if obj.damage == true
    if obj.damage_to_mp == false
    applyguard = true  if @hp_damage == 0 #To avoid applying guard twice
    @hp_damage = rand(2) if @hp_damage == 0
    @hp_damage = apply_guard(@hp_damage) if applyguard = true #Guard is applied after this in the normal attack.
                                                              #This will always deal 0 damage if guarded.
    elsif obj.damage_to_mp == true
    applyguard = true  if @mp_damage == 0 #To avoid applying guard twice
    @mp_damage = rand(2) if @mp_damage == 0
    @mp_damage = apply_guard(@mp_damage) if applyguard = true #Guard is applied after this in the normal attack.
                                                              #This will always deal 0 damage if guarded.
    end                                                           
   end
   
    #---Restore
    obj.element_set = skillelements            #Restores the skill element set back to default
                                               #This stops the elements from being added permanently
    obj.atk_f = atkf_temp                                               
    obj.spi_f = spif_temp 
    applyguard = false
    nocritical = false
    nodamage = false
  end
 
  def gw_skill_element_set(user, obj)
    return unless obj.element                      #Checks for tag
    obj.element_set += user.element_set            #Adds the elements from the normal attack
  end
 
  def gw_magical_weapon(user, obj)
    return unless $imported["GWMagicWeapons"] == true #Does nothing if not using the Magical Weapon Script
    return unless obj.magical                         #Checks for tag
    return unless attacker.actor?
    if user.weapons[0] != nil and user.weapons[1] == nil #Using only weapon 0
    return unless user.weapons[0].magical == true
    obj.spi_f += obj.atk_f #"Tranfers" the skills Atk F to Spi F
    obj.atk_f = 0          #Sets Atk F to 0
    #---Secondary damage---
    @spi_f += @atk_f     #"Tranfers" the skills Atk F to Spi F
    @atk_f = 0          #Sets Atk F to 0
    elsif user.weapons[0] == nil and user.weapons[1] != nil #Using only weapon 1
    return unless user.weapons[1].magical == true
    obj.spi_f += obj.atk_f #"Tranfers" the skills Atk F to Spi F
    obj.atk_f = 0          #Sets Atk F to 0
    #---Secondary damage---
    @spi_f += @atk_f     #"Tranfers" the skills Atk F to Spi F
    @atk_f = 0          #Sets Atk F to 0
    elsif user.weapons[0] != nil and user.weapons[1] != nil #Using both weapons
    return unless user.weapons[0].magical == true or user.weapons[1].magical == true
     if user.weapons[0].magical == user.weapons[1].magical #Both weapons are magical: Transfers ATK_F.
     obj.spi_f += obj.atk_f #"Tranfers" the skills Atk F to Spi F
     obj.atk_f = 0          #Sets Atk F to 0
     #---Secondary damage---
     @spi_f += @atk_f     #"Tranfers" the skills Atk F to Spi F
     @atk_f = 0          #Sets Atk F to 0
     elsif user.weapons[0].magical != user.weapons[1].magical #One weapon is magical, the other isnt. Transfers half of the ATK_F
     obj.spi_f += (obj.atk_f / 2) #"Tranfers" half of the skills Atk F to Spi F
     obj.atk_f /= 2          #Halves ATK F
     #---Secondary damage---
     @spi_f += (@atk_f / 2)     #"Tranfers" the skills Atk F to Spi F
     @atk_f /= 2          #Sets Atk F to 0
     end #If
   end #If
   
   
  end
 
  alias gw_skill_can_use? skill_can_use?
  def skill_can_use?(skill)
    return false if silent? and skill.silence == true
    gw_skill_can_use?(skill)
  end
 
end #Game_Battler

class Game_BattleAction
  #--------------------------------------------------------------------------
  # * Create Skill or Item Targets
  #     obj : Skill or item
  #--------------------------------------------------------------------------
  def make_obj_targets(obj)
    targets = []
    obj.multi[0] = 1 if obj.multi[0] <= 0 #Defaults to 1 if <= 0.
    obj.multi[1] = 1 if obj.multi[1] <= 0 #Defaults to 1 if <= 0.
    obj.multi[1] = obj.multi[0] if obj.multi[1] < obj.multi[0] #If Max < Min, Max = Min.
    multihit = (obj.multi[0]-1) + rand(obj.multi[1]-obj.multi[0]+1)
    if obj.for_opponent?
      if obj.for_random?
        if obj.for_one?         # One random enemy
          number_of_targets = 1 + multihit
        elsif obj.for_two?      # Two random enemies
          number_of_targets = 2 + multihit
        else                    # Three random enemies
          number_of_targets = 3 + multihit
        end
        number_of_targets.times do
          targets.push(opponents_unit.random_target)
        end
      elsif obj.dual?           # One enemy, dual
        targets.push(opponents_unit.smooth_target(@target_index))
        targets += targets
        multihit.times do targets.push(opponents_unit.smooth_target(@target_index)) end
      elsif obj.for_one?        # One enemy
        targets.push(opponents_unit.smooth_target(@target_index))
        multihit.times do targets.push(opponents_unit.smooth_target(@target_index)) end
      else                      # All enemies
        targets += opponents_unit.existing_members
        multihit.times do targets += opponents_unit.existing_members end
      end
    elsif obj.for_user?         # User
      targets.push(battler)
       multihit.times do targets.push(battler) end
    elsif obj.for_dead_friend?
      if obj.for_one?           # One ally (incapacitated)
        targets.push(friends_unit.smooth_dead_target(@target_index))
        multihit.times do targets.push(friends_unit.smooth_dead_target(@target_index)) end
      else                      # All allies (incapacitated)
        targets += friends_unit.dead_members
        multihit.times do targets += friends_unit.dead_members end
      end
    elsif obj.for_friend?
      if obj.for_one?           # One ally
        targets.push(friends_unit.smooth_target(@target_index))
        multihit.times do targets.push(friends_unit.smooth_target(@target_index)) end
      else                      # All allies
        targets += friends_unit.existing_members
        multihit.times do targets += friends_unit.existing_members end
      end
    end
    return targets.compact
  end
end #Game_BattlerAction 

class Scene_Battle
  def display_hp_damage(target, obj = nil)
    if target.hp_damage == 0                # No damage
      return if obj != nil and obj.damage_to_mp and obj.damageboth[0] == 0
      return if obj != nil and obj.damage_to_mp == false and obj.base_damage == 0
      fmt = target.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
      text = sprintf(fmt, target.name)
    elsif target.absorbed                   # Absorb
      fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
      text = sprintf(fmt, target.name, Vocab::hp, target.hp_damage)
    elsif target.hp_damage > 0              # Damage
      if target.actor?
        text = sprintf(Vocab::ActorDamage, target.name, target.hp_damage)
        Sound.play_actor_damage
        $game_troop.screen.start_shake(5, 5, 10)
      else
        text = sprintf(Vocab::EnemyDamage, target.name, target.hp_damage)
        Sound.play_enemy_damage
        target.blink = true
      end
    else                                    # Recovery
      fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
      text = sprintf(fmt, target.name, Vocab::hp, -target.hp_damage)
      Sound.play_recovery
    end
    @message_window.add_instant_text(text)
    wait(30)
  end
end 

class RPG::BaseItem
 
  def hitratio
    self.note.scan(/<hitratio>/i){
    return true}
    return false
  end
 
  def addhitratio
    self.note.scan(/<addhitratio>/i){
    return true}
    return false
  end
 
  def removehitratio
    self.note.scan(/<removehitratio>/i){
    return true}
    return false
  end
 
   
  def element
    self.note.scan(/<element>/i){
    return true}
    return false
  end
 
  def silence
    self.note.scan(/<silence>/i){
    return true}
    return false
  end
 
  def allowcritical
    self.note.scan(/<critical>/i){
    return 0}
    self.note[/<critical: ([-0-9]+)>/]
    return nil if $1 == nil #Does nothing if there is no note tag or no number
    return $1.to_i
  end
 
  def damageboth
    self.note[/<damageboth: ([-0-9]+) ([-0-9]+) ([-0-9]+) ([-0-9]+)>/]
    #Does nothing if there is no note tag.
    return [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
  end
 
  def damage
    self.note.scan(/<01damage>/i){
    return true}
    return false
  end
 
  def multi
    self.note.scan(/<multi: ([-0-9]+)>/){
    return [$1.to_i,$1.to_i]}
    self.note[/<multi: ([-0-9]+) ([-0-9]+)>/]
    return [$1.to_i,$2.to_i]
  end
   
end #RPG::BaseItem

You can also get it from the attachment.

Credit


  • Mr G W

Thanks

  • People who made scripts - I've been learning on my own, so other scripts help me understand how RGSS works.

Support

Just post here. If i don't answer, it's because I can't be on.
Any errors or glitches, feel free to post.

Known Compatibility Issues

This script aliases calc_hit, make_obj_damage_value and skill_can_use?.
This script should work with other combat-related scripts unless they override
these methods and are placed below this script. If the overriding script
is placed above this one, then this script should work properly.

This script overrides make_obj_targets and display_hp_damage.
This script will not work if another script is placed below this one that also
overrides the same method. If this script is placed below instead, the other
script will not work. If another script aliases this method, place it below
this script.


Demo


None.

Author's Notes


This script also works with usable items.

Restrictions

For commercial use, contact me first. You can use this script how you want as long as you credit.
« Last Edit: August 30, 2011, 07:27:00 PM by Mr G W »

**
Rep: +0/-0Level 71
RMRK Junior
BUGFIX: Crash when Magical tag was used on enemies.
UPDATE: Added an option to allow a skill dealing no damage to have 50% chance of dealing 1 damage like normal attack.

**
Rep: +0/-0Level 71
RMRK Junior
UPDATE: Attacks can now deal multiple hits. Similar to Dual attack or Random enemies, but allows more hits.

***
Rep:
Level 69
RESIDENT ADONKADONK
I am going to try this with the SBS by Enu translated by Bubble.
EDIT:
Nope, no problems so far. All of the action sequences play fine, damage is calculated.
I am sure it is compatible.
« Last Edit: August 23, 2011, 03:16:46 PM by Adon »

I'm back.

**
Rep: +0/-0Level 71
RMRK Junior
Good. If you find any problems, just post. No matter how old his post might be.

**
Rep: +0/-0Level 71
RMRK Junior
BUGFIX: When Damage to MP is on and <damageboth> is used, when the hp damage is zero, the game will now show "enemy took no damage".