Save-Point
KBoomEffect XP - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+--- Thread: KBoomEffect XP (/thread-7574.html)



KBoomEffect XP - kyonides - 11-08-2019

KBoomEffect XP

by Kyonides Arkanthes


Introduction

Did you ever want your monster to explode if some normal or magical attack hit him? Confused 
Now you can for sure! Laughing
You can make the monster explode due to physical or magical attacks or even both of them! Shocked

Warning
This scriptlet does not depend on the default battle damage formula. Happy with a sweat It's quite weird, don't you think? Laughing + Tongue sticking out

XP Script
Code:
# * KBoomEffect XP
#   Scripter : Kyonides Arkanthes
#   2019-11-08 - with actual explosions!

# This scriptlet lets you make your monster explode when they get hit by some
# physical or magical attack.

module KBoom
  FAILURE = "Unharmed"
  ANIME_ID = 99
  # MonsterID => [SuccessRate, AllHeroes?, Variance %], etc.
  PHYSICAL_ATK = { 1 => [99, true, 5] }
  # MonsterID => [SuccessRate, AllHeroes?, SkillID1, etc.], etc.
  MAGICAL_ATK = { 1 => [40, true, 60] }
end

class Game_Battler
  alias :kyon_boom_effect_gm_battler_ae :attack_effect
  alias :kyon_boom_effect_gm_battler_se :skill_effect
  def attack_effect(user)
    rate, all, variance = KBoom::PHYSICAL_ATK[self.id]
    return setup_ignition(user, rate, all, variance, nil) if @troop_id and rate
    kyon_boom_effect_gm_battler_ae(user)
  end

  def skill_effect(user, skill)
    rate, all, *skills = KBoom::MAGICAL_ATK[self.id]
    if @troop_id and rate and skills.include?(skill.id)
      return setup_ignition(user, rate, all, skill.variance, skill)
    end
    kyon_boom_effect_gm_battler_se(user, skill)
  end

  def setup_ignition(user, rate, multiple, variance, skill)
    @will_explode = rand(100) < rate
    if @will_explode
      power = skill ? skill.power : self.atk
      targets = multiple ? $game_party.survivors : [user]
      targets.each{|h| ignition_target(h, power, variance) }
    end
    @damage = @hp
    @hp = 0
    @will_explode
  end

  def ignition_target(user, power, variance)
    power = power * @hp / user.pdef
    return user.damage = KBoom::FAILURE if power < 1
    amp = [power.abs * variance / 100, 1].max
    power += rand(amp+1) + rand(amp+1) - amp
    user.damage = power
    user.hp -= power
    user.explosion_pop = true
  end
  def clear_explosion() @will_explode = @explode = nil end
  attr_accessor :will_explode, :explode, :explosion_pop
end

class Game_Party
  def survivors() @actors.select{|a| a.hp > 0 } end
end

class Sprite_Battler
  alias :kyon_boom_effect_sbt_up :update
  def update
    kyon_boom_effect_sbt_up
    return unless @battler and @battler.explode
    animation($data_animations[KBoom::ANIME_ID], true)
    @battler.clear_explosion
  end
end

class Scene_Battle
  alias :kyon_boom_effect_up_ph4_s4 :update_phase4_step4
  alias :kyon_boom_effect_up_ph4_s5 :update_phase4_step5
  def update_phase4_step4
    kyon_boom_effect_up_ph4_s4
    @target_battlers.each{|target| target.explode = target.will_explode }
  end

  def update_phase4_step5
    kyon_boom_effect_up_ph4_s5
    for target in $game_party.actors
      target.damage_pop = target.explosion_pop
      target.explosion_pop = nil
    end
  end
end

Terms & Conditions

You must include my nickname and the current website's URL in your game credits.
You are free to use it in non commercial games.
Give me a free copy of your completed game if you include at least 2 of my scripts! Laughing + Tongue sticking out


RE: KBoomEffect XP - kyonides - 11-09-2019

Update

I have modified my script in order to let you watch monsters explode as expected. Damage sprites will pop pup immediately letting you notice how dangerous the explosion was for those ignorant heroes!
Yes, I am looking at you, Aluxes! Laughing + Tongue sticking out