Save-Point
KMonsterSacrifice XP & VX - 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: KMonsterSacrifice XP & VX (/thread-7565.html)



KMonsterSacrifice XP & VX - kyonides - 10-26-2019

KMonsterSacrifice XP & VX

by Kyonides Arkanthes

Introduction

Have you ever dreamed on a mob or boss consuming its pals to recover some HP or SP alias MP? Now that's possible! Shocked
Actually you can also let your monsters steal their fellows' strength or intelligence! Laughing

XP Script
Code:
# * KMonsterSacrifice XP
#   Scripter : Kyonides Arkanthes
#   2019-11-04

# This scriptlet allows you to configure monsters that can sacrifice its fellow
# monsters' life or mana points if it casts a special skill. Additionally they
# can steal some of their fellows' strength or intelligence.

# KMonster.mana_knockout = true OR false
#  Magical Beings with no remaining SP will (not) fall in battle automatically
#  if another monster drains all of their remaining SP.

module KMonster
  SACRIFICE_FAILED = "FAILED"
  LIFE_SACRIFICE_ID = 5
  MANA_SACRIFICE_ID = 6
  STR_SACRIFICE_ID = 7
  INT_SACRIFICE_ID = 8
  # Should it get killed if it has no more mana?
  @mana_knockout = true # true OR false
  # Options: :max or :rest or a percent (1 ~ 99 only)
  LIFE_SACRIFICE = {
    1 => :rest, 2 => 10, 3 => :max
  }
  MANA_SACRIFICE = {
    1 => :rest, 2 => 7, 3 => :max
  }
  # For STR and INT :rest option is the same as :max
  STR_SACRIFICE = {}
  INT_SACRIFICE = {}
  def self.mana_knockout() @mana_knockout end
  def self.mana_knockout=(bool) @mana_knockout = bool end
end

class Game_Battler
  attr_writer :str_plus, :int_plus
  alias :kyon_monster_sacrifice_gm_battler_se :skill_effect
  def skill_effect(user, skill)
    killed = @hp == 0
    result = kyon_monster_sacrifice_gm_battler_se(user, skill)
    if result
      if KMonster::LIFE_SACRIFICE_ID == skill.id
        return life_sacrifice_calculation
      elsif KMonster::MANA_SACRIFICE_ID == skill.id
        return mana_sacrifice_calculation
      elsif KMonster::STR_SACRIFICE_ID == skill.id
        return str_sacrifice_calculation
      elsif KMonster::INT_SACRIFICE_ID == skill.id
        return int_sacrifice_calculation
      end
    end
    result
  end

  def life_sacrifice_calculation
    mobs = $game_troop.enemies - [self]
    if mobs.size > 0
      mob = mobs[rand(mobs.size)]
      stype = KMonster::LIFE_SACRIFICE[mob.id]
      case stype
      when :max
        self.hp += total = mob.maxhp
        @damage = -total
        mob.damage = total
        mob.hp = 0
      when :rest
        self.hp += total = mob.hp
        @damage = -total
        mob.damage = total
        mob.hp = 0
      when 1..99
        self.hp += total = mob.maxhp * stype / 100
        @damage = -total
        mob.damage = total
        mob.hp -= total
      end
      return true if stype
    end
    @damage = KMonster::SACRIFICE_FAILED
    false
  end

  def mana_sacrifice_calculation
    mobs = $game_troop.enemies - [self]
    if mobs.size > 0
      mob = mobs[rand(mobs.size)]
      stype = KMonster::MANA_SACRIFICE[mob.id]
      case stype
      when :max
        self.sp += total = mob.maxsp
        @damage = -total
        mob.damage = total
        mob.sp = 0
      when :rest
        self.sp += total = mob.sp
        @damage = -total
        mob.damage = total
        mob.sp = 0
      when 1..99
        self.sp += total = mob.maxsp * stype / 100
        @damage = -total
        mob.damage = total
        mob.sp -= total
      end
      mob.hp = 0 if KMonster.mana_knockout and mob.sp == 0
      return true if stype
    end
    @damage = KMonster::SACRIFICE_FAILED
    false
  end

  def str_sacrifice_calculation
    mobs = $game_troop.enemies - [self]
    if mobs.size > 0
      mob = mobs[rand(mobs.size)]
      stype = KMonster::STR_SACRIFICE[mob.id]
      case stype
      when :max. :rest
        @str_plus += total = mob.base_str
        @damage = -total
        mob.damage = total
        mob.str_plus = -total
      when 1..99
        @str_plus += total = (mob.base_str - mob.str_plus) * stype / 100
        @damage = -total
        mob.damage = total
        mob.str_plus -= total
      end
      return true if stype
    end
    @damage = KMonster::SACRIFICE_FAILED
    false
  end

  def int_sacrifice_calculation
    mobs = $game_troop.enemies - [self]
    if mobs.size > 0
      mob = mobs[rand(mobs.size)]
      stype = KMonster::INT_SACRIFICE[mob.id]
      case stype
      when :max. :rest
        @int_plus += total = mob.base_int
        @damage = -total
        mob.damage = total
        mob.int_plus = -total
      when 1..99
        @int_plus += total = (mob.base_int - mob.int_plus) * stype / 100
        @damage = -total
        mob.damage = total
        mob.int_plus -= total
      end
      return true if stype
    end
    @damage = KMonster::SACRIFICE_FAILED
    false
  end
end

VX Script
Code:
# * KMonsterSacrifice VX
#   Scripter : Kyonides Arkanthes
#   2019-11-04

# This scriptlet allows you to configure monsters that can sacrifice its fellow
# monsters' life or mana points if it casts a special skill. Additionally they
# can steal some of their fellows' strength or intelligence.

# KMonster.mana_knockout = true OR false
#  Magical Beings with no remaining SP will (not) fall in battle automatically
#  if another monster drains all of their remaining SP.

module KMonster
  SACRIFICE_FAILED = "FAILED"
  LIFE_SACRIFICE_ID = 5
  MANA_SACRIFICE_ID = 6
  ATK_SACRIFICE_ID = 7
  SPI_SACRIFICE_ID = 8
  # Should it get killed if it has no more mana?
  @mana_knockout = true # true OR false
  # Options: :max or :rest or a percent (1 ~ 99 only)
  LIFE_SACRIFICE = {
    1 => :rest, 2 => 10, 3 => :max
  }
  MANA_SACRIFICE = {
    1 => :rest, 2 => 7, 3 => :max
  }
  # For ATK and SPI :rest option is the same as :max
  ATK_SACRIFICE = {}
  SPI_SACRIFICE = {}
  def self.mana_knockout() @mana_knockout end
  def self.mana_knockout=(bool) @mana_knockout = bool end
end

class Game_Battler
  attr_writer :hp_damage, :mp_damage
  attr_accessor :atk_plus, :spi_plus
  alias :kyon_monster_sacrifice_gm_battler_se :skill_effect
  def skill_effect(user, skill)
    killed = @hp == 0
    result = kyon_monster_sacrifice_gm_battler_se(user, skill)
    if result
      if KMonster::LIFE_SACRIFICE_ID == skill.id
        return life_sacrifice_calculation
      elsif KMonster::MANA_SACRIFICE_ID == skill.id
        return mana_sacrifice_calculation
      elsif KMonster::ATK_SACRIFICE_ID == skill.id
        return atk_sacrifice_calculation
      elsif KMonster::SPI_SACRIFICE_ID == skill.id
        return spi_sacrifice_calculation
      end
    end
    result
  end

  def life_sacrifice_calculation
    mobs = $game_troop.members - [self]
    if mobs.size > 0
      mob = mobs[rand(mobs.size)]
      stype = KMonster::LIFE_SACRIFICE[mob.id]
      case stype
      when :max
        self.hp += total = mob.maxhp
        @hp_damage = -total
        mob.hp_damage = total
        mob.hp = 0
      when :rest
        self.hp += total = mob.hp
        @hp_damage = -total
        mob.hp_damage = total
        mob.hp = 0
      when 1..99
        self.hp += total = mob.maxhp * stype / 100
        @hp_damage = -total
        mob.hp -= total
      end
      return true if stype
    end
    @hp_damage = KMonster::SACRIFICE_FAILED
    false
  end

  def mana_sacrifice_calculation
    mobs = $game_troop.members - [self]
    if mobs.size > 0
      mob = mobs[rand(mobs.size)]
      stype = KMonster::MANA_SACRIFICE[mob.id]
      case stype
      when :max
        self.mp += total = mob.maxmp
        @mp_damage = -total
        mob.mp_damage = total
        mob.mp = 0
      when :rest
        self.mp += total = mob.mp
        @mp_damage = -total
        mob.mp_damage = total
        mob.mp = 0
      when 1..99
        self.mp += total = mob.maxmp * stype / 100
        @mp_damage = -total
        mob.damage = total
        mob.mp -= total
      end
      mob.hp = 0 if KMonster.mana_knockout and mob.mp == 0
      return true if stype
    end
    @mp_damage = KMonster::SACRIFICE_FAILED
    false
  end

  def atk_sacrifice_calculation
    mobs = $game_troop.members - [self]
    if mobs.size > 0
      mob = mobs[rand(mobs.size)]
      stype = KMonster::ATK_SACRIFICE[mob.id]
      case stype
      when :max. :rest
        @atk_plus += total = mob.base_atk
        @damage = -total
        mob.damage = total
        mob.atk_plus = -total
      when 1..99
        @atk_plus += total = (mob.base_atk - mob.atk_plus) * stype / 100
        @damage = -total
        mob.damage = total
        mob.atk_plus -= total
      end
      return true if stype
    end
    @hp_damage = KMonster::SACRIFICE_FAILED
    false
  end

  def spi_sacrifice_calculation
    mobs = $game_troop.members - [self]
    if mobs.size > 0
      mob = mobs[rand(mobs.size)]
      stype = KMonster::SPI_SACRIFICE[mob.id]
      case stype
      when :max. :rest
        @spi_plus += total = mob.base_spi
        @damage = -total
        mob.damage = total
        mob.spi_plus = -total
      when 1..99
        @spi_plus += total = (mob.base_spi - mob.spi_plus) * stype / 100
        @damage = -total
        mob.damage = total
        mob.spi_plus -= total
      end
      return true if stype
    end
    @mp_damage = KMonster::SACRIFICE_FAILED
    false
  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: KMonsterSacrifice XP & VX - kyonides - 11-05-2019

VeXing Heroes a Little Bit More! Laughing 


From now on VX users can also "enjoy" the terrible experience of monsters stealing each others' life or mana! Laughing

All available versions also allow you to let them steal their fellows' strength or intelligence! Shocked