KWeaponDamage XP
#1
KWeaponDamage XP
Version 1.1.0

by Kyonides

Introduction

Thinking Did you ever dream about making a weapon heal your comrades instead of hitting the foe?
Thinking Or did you ever want to hit your foes harder than usual?

Now you can do that! Grinning

You just need to make a few script calls to bless a specific actor with any of those new abilities.
Please read the instructions embedded in my script comments.

Available Features
  • SP Consuming Weapons
  • Blessed Weapons that Partially Heal Heroes
  • Vampiric Weapons that consuming Heroes' HP but Hit Harder

The Script

Code:
# * KWeaponDamage XP * #
#   Scripter : Kyonides Arkanthes
#   v1.1.0 - 2023-05-19

# This scriptlet allows you to either consume some SP while attacking
# your enemy physically or hit an ally, partially healing him or her
# in the process.
# It also features the vampiric weapons that drain part of your hero's HP
# in order to hit the enemy (way) harder than usual.

# * Script Calls * #

# - First Step: Find an Actor - 2 Methods
# actor = $game_actors[ActorID]
# actor = $game_party.actors[Index]

# - Make a Weapon Consume SP for Extra Damage
# actor.weapon_sp_use(WeaponID, SP, Percent)

# - Weapon No Longer Consumes SP
# actor.weapon_no_sp(WeaponID)

# - Clear All Weapons that Consume SP
# actor.clear_weapon_sp

# - Add a Weapon Blessing
# actor.bless_weapon(WeaponID, Percent)

# - Remove a Weapon Blessing
# actor.unbless_weapon(WeaponID)

# - Clear All Blessed Weapons
# actor.clear_weapon_blessing

# - Add a Vampiric Weapon
# actor.vampire_weapon(WeaponID, HP's, Extra DMG %)

# - Remove a Vampiric Weapon
# actor.no_vampire_weapon(WeaponID)

# - Clear All Vampiric Weapons
# actor.clear_vampire_weapons

class Game_Battler
  DMG_MISSED = "Miss"
  alias :kyon_weapon_dmg_gm_btlr_attack_fx :attack_effect
  def attack_effect(attacker)
    result = kyon_weapon_dmg_gm_btlr_attack_fx(attacker)
    calculate_new_weapon_damage(attacker)
    result
  end

  def calculate_new_weapon_damage(attacker)
    return if @damage == DMG_MISSED
    if attacker.weapon_sp_use?
      total_sp = attacker.get_weapon_sp_cost
      return if @sp < total_sp
      attacker.sp -= total_sp
      new_damage = @damage * attacker.weapon_sp_percent / 100
      @damage += new_damage if @hp > 0
      self.hp -= new_damage
      return
    elsif attacker.weapon_blessing?
      @damage = -@damage - @damage * attacker.weapon_blessing / 100
      dead_no_damage
      self.hp -= @damage
      return
    elsif attacker.vampire_weapon?
      attacker.vampire_weapon_hp_cost
      dead_no_damage
      self.hp -= @damage * attacker.vampire_weapon_dmg / 100
    end
  end

  def dead_no_damage
    @damage = 0 if self.maxhp == @hp
  end
end

module GameBattlerTest
  def actor?
    @actor_id != nil
  end

  def enemy?
    @enemy_id != nil
  end
end

class Game_Actor
  include GameBattlerTest
  alias :kyon_weapon_dmg_gm_act_setup :setup
  def setup(actor_id)
    kyon_weapon_dmg_gm_act_setup(actor_id)
    @weapon_use_sp = {}
    @weapon_blessings = {}
    @vampire_weapons = {}
    @vampire_weapons.default = { :hp => 0, :dmg => 0 }
  end

  def weapon_sp_use(weapon_id, cost, percent)
    @weapon_use_sp[weapon_id] = { :sp => cost, :percent => percent }
  end

  def weapon_no_sp(weapon_id)
    @weapon_use_sp.delete(weapon_id)
  end

  def weapon_sp_cost
    @weapon_use_sp[@weapon_id][:sp]
  end

  def weapon_sp_percent
    @weapon_use_sp[@weapon_id][:percent]
  end

  def get_weapon_sp_cost
    self.weapon_sp_cost * self.maxsp / 100
  end

  def clear_weapon_sp
    @weapon_use_sp.clear
  end

  def weapon_sp_use?
    @weapon_use_sp.has_key?(@weapon_id)
  end

  def bless_weapon(weapon_id, percent)
    @weapon_blessings[weapon_id] = percent
  end

  def unbless_weapon(weapon_id)
    @weapon_blessings.delete(weapon_id)
  end

  def weapon_blessing
    @weapon_blessings[@weapon_id]
  end

  def clear_weapon_blessing
    @weapon_blessings.clear
  end

  def weapon_blessing?
    @weapon_blessings.has_key?(@weapon_id)
  end

  def vampire_weapon(weapon_id, hp_cost, dmg_percent)
    @vampire_weapons[weapon_id] = { :hp => hp_cost, :dmg => dmg_percent }
  end

  def no_vampire_weapon(weapon_id)
    @vampire_weapons.delete(weapon_id)
  end

  def clear_vampire_weapons
    @vampire_weapons.clear
  end

  def vampire_weapon_hp_cost
    self.hp -= @vampire_weapons[@weapon_id][:hp]
  end

  def vampire_weapon_dmg
    @vampire_weapons[@weapon_id][:dmg]
  end

  def vampire_weapon?
    @vampire_weapons.has_key?(@weapon_id)
  end
  attr_reader :weapon_use_sp, :weapon_blessings, :vampire_weapons
end

class Game_Enemy
  include GameBattlerTest
  def weapon_sp_use?() nil end
  def weapon_blessing?() nil end
end

class Scene_Battle
  alias :kyon_weapon_dmg_scn_btl_up_ph3_bsc_comm :update_phase3_basic_command
  alias :kyon_weapon_dmg_scn_btl_mk_bsc_action_res :make_basic_action_result
  def update_phase3_basic_command
    if Input.trigger?(Input::C) and @actor_command_window.index == 0
      $game_system.se_play($data_system.decision_se)
      @active_battler.current_action.kind = 0
      @active_battler.current_action.basic = 0
      blessed = @active_battler.weapon_blessing?
      blessed ? start_actor_select : start_enemy_select
      return
    end
    kyon_weapon_dmg_scn_btl_up_ph3_bsc_comm
  end

  def make_altered_weapon_attack_result
    return unless @active_battler.weapon_blessing?
    @animation1_id = @active_battler.animation1_id
    @animation2_id = @active_battler.animation2_id
    if @active_battler.restriction == 3
      target = $game_party.random_target_actor
    elsif @active_battler.restriction == 2
      target = $game_troop.random_target_enemy
    else
      index = @active_battler.current_action.target_index
      target = $game_party.smooth_target_actor(index)
    end
    return unless target
    target.attack_effect(@active_battler)
    @target_battlers = [target]
    true
  end
 
  def make_basic_action_result
    if @active_battler.current_action.basic == 0
      if @active_battler.actor?
        result = make_altered_weapon_attack_result
        return if result
      end
    end
    kyon_weapon_dmg_scn_btl_mk_bsc_action_res
  end
end


Terms & Conditions

Free for use in any game.
Include my nickname in your game credits.
Don't adopt any stray cats or blue squirrels or any kind of pokemon!
That's it!
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Messages In This Thread
KWeaponDamage XP - by kyonides - 05-17-2023, 10:47 PM
RE: KWeaponDamage XP - by kyonides - 05-20-2023, 04:46 AM



Users browsing this thread: 1 Guest(s)