KExtra XP WAS
#1
KExtra XP
WAS Version


by Kyonides-Arkanthos


Introduction

This is just another scriptlet for XP only that should let you modify skills by "cursing" them from the very beginning or once a skill has been learned by any hero. It is not a plug and play script because you need to setup initial values in the KExtra module. How many should they be? As many as you need!

There is one list for actors aka as heroes, this one will be checked out by my script if the actor has been initialized. The second list will be applied to the actor's skill while learning it only if there's no previous "curse" on that skill.

It is possible to configure some weapons to break after a few uses or curse them or reduce its attack power. Even so keep in mind that the maker does not include an unique weaponry...

Script

Code:
# * KExtra XP WAS Version
#   Scripter : Kyonides-Arkanthos
#   2018-01-12

#  Primer Paso del Llamado a Script - Obtener al Héroe del Equipo...
#    a = $game_party.actors[Indice_Actor]
#  O a un Héroe que no forma parte del grupo
#    a = $game_actors[ID_Actor]

#  Y justo debajo de esa línea agreguen alguna de las siguientes.

#  Para devolver algo del poder a una técnica embrujada
#    a.increase_skill_power(ID_Tecnica)

#  Para desbloquear por completo una técnica embrujada (con éxito del 100%)
#    a.unblock_skill(ID_Tecnica)

#  Para aumentar el número de usos de una técnica embrujada
#    a.add_skill_uses(ID_Tecnica) # usando un objeto
#    a.add_skill_uses(ID_Tecnica, Usos_Extras) # sin objeto

#  Para remover el embrujo al consumir un objeto preseleccionado, no fallará.
#    a.lift_skill_curse(ID_Tecnica)

#  Para dejar que un clérigo o evento remueva el embrujo de la técnica
#    a.priest_lift_skill_curse(Nivel_Clerigo, ID_Tecnica)

#  Para remover el embrujo por la fuerza (con éxito del 100%)
#    a.force_lift_curse(ID_Tecnica)

#  Para verificar si una técnica está embrujada (1 de 2 opciones)
#  ¡Necesitará incluir los datos del miembro o héroe!
#    $game_party.actors[Indice_Actor].skill_cursed?(ID_Tecnica)
#    $game_actors[ID_Actor].skill_cursed?(ID_Tecnica)

#  Para devolver algo del poder a una arma embrujada
#    a.increase_weapon_power(ID_Arma)
#    a.increase_armor_resist(ID_Armadura)

#  Para dejar que un herrero o evento reforje el arma o la armadura rota
#    a.reforge_weapon(Nivel_Herrero, ID_Arma)
#    a.reforge_armor(Nivel_Herrero, ID_Armadura)

#  Para dejar que un "clérigo" remueva el embrujo del arma o de la armadura
#    a.lift_weapon_curse(Persona, Nivel, ID_Arma)
#    a.lift_armor_curse(Persona, Nivel, ID_Armadura)

#  Abreviaturas o Siglas
#    Persona - Puede ser :clerigo o :herrero o :tecnico
#    RP - Reducción de Poder, IP - Incremento de Poder, CF - Costo de Forja
#    NE - Nivel del Embrujo, PF - Prob. de Fracasar en Forja
#    CRE - Costo de Remoción del Empbrujo
#    ID_Obj - objeto removedor de embrujo, 0 para ninguno
module KExtra
  DEFAULT_USES = 5 # Valor Típico de Usos que se sumarán a la t. embrujada
  SKILL_USES_ITEM_ID = 28 # ID del Objeto que incrementa los Usos
  SEAL_SKILL_ID = 81 # Técnica de algún Enemigo
  BREAK_WEAPONS = {}
  BREAK_ARMORS = {}
  # [ID_Arma] = [Usos, ¿Rota?, ¿Embrujada?, NE, PF, PR, PI, ID_Obj, CF, CRE]
  BREAK_WEAPONS[1] = [3, nil, nil, 1, 5, 90, 15, 34, 250, 300]
  BREAK_WEAPONS[2] = [2, nil, nil, 2, 10, 90, 10, 34, 500, 600]
  BREAK_WEAPONS[3] = [1, nil, true, 2, 15, 95, 5, 34, 750, 900]
  # [ID_Armadura] = [Usos, ¿Rota?, ¿Embrujada?, NE, PF, PR, PI, ID_Obj, CF, CRE]
  BREAK_ARMORS[1] = [2, nil, nil, 1, 5, 90, 15, 34, 350, 400]
  # Agregue ID_Actor => {}, incluye la coma excepto en el último valor
  # Le permite agregar limitaciones a las técnicas de un héroe específico
  ACTOR_HANDICAPS = { 1 => {} }
  # [ID_Actor][ID_Tecnica] = [Usos, ¿Bloqueada?, Nivel_Embrujo, RP, IP, ID_Obj]
  ACTOR_HANDICAPS[1][57] = [3, nil, 1, 90, 10, 0]
  SKILL_HANDICAPS = {}
  # [ID_Tecnica] = [Usos, ¿Bloqueada?, Nivel_Embrujo, RP, IP, ID_Obj]
  SKILL_HANDICAPS[57] = [2, nil, 1, 70, 10, 0]
  # [Usos, ¿Bloqueada?, Nivel_Embrujo, RP, IP, ID_Obj]
  SEALED_SKILL_HANDICAP = [0, true, 2, 95, 5, 33]
  class ItemBase
    attr_accessor :kind, :uses, :level, :power_reduction, :power_increase
    attr_accessor :remover_item_id
    def initialize
      @uses = DEFAULT_USES
      @level = 1
      @power_reduction = 0
      @power_increase = 0
      @remover_item_id = 0
    end
  end

  class Equipment < ItemBase
    attr_accessor :broken, :cursed, :failure_rate, :cost
    def initialize
      super
      @broken = @cursed = nil
      @failure_rate = 0
      @cost = {}
    end
  end

  class Skill < ItemBase
    attr_accessor :blocked
    def initialize
      super
      @kind = :skill
      @blocked = nil
    end
  end
end

class Game_Battler
  alias kyon_kextra_was_gm_battler_attack_effect attack_effect
  alias kyon_kextra_was_gm_battler_skill_effect skill_effect
  def attack_effect(attacker)
    foe = attacker
    effective = kyon_kextra_was_gm_battler_attack_effect(foe)
    if effective
      if foe.respond_to?(:weapon_id) and foe.weapon_id > 0
        return effective unless breakable = foe.break_weapons[foe.weapon_id]
        breakable.uses -= 1 if breakable.uses > 0
        if breakable.uses == 0
          breakable.broken = true
          foe.equip(0, 0)
        end
      end
      if self.respond_to?(:armor1_id)
        ids = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
        ids.each do |aid| next if aid == 0
          next unless (breakable = @break_armors[aid])
          breakable.uses -= 1 if breakable.uses > 0
          next if breakable.uses > 0
          breakable.broken = true
          equip(ids.index(aid), 0)
        end
      end
    end
    return effective
  end

  def skill_effect(user, skill)
    sid = skill.id
    if user.respond_to?(:troop_id) and sid == KExtra::SEAL_SKILL_ID and
      self.respond_to?(:skill_handicaps)
      if @skills.size > 0
        cursed = self.skill_cursed?(sid)
        @skill_hit = @skills[rand(@skills.size)] if !@skill_hit
        self.add_skill_handicaps(@skill_hit, KExtra::SEALED_SKILL_HANDICAP)
        return (!cursed and self.skill_cursed?(sid))
      end
      return false
    elsif user.respond_to?(:skill_handicaps) and user.skill_handicaps[sid]
      sh = user.skill_handicaps[sid]
      sh.uses -= 1
      skill = $data_skills[sid].dup
      skill.power -= skill.power * sh.power_reduction / 100
      skill.str_f -= skill.str_f * sh.power_reduction / 100
      skill.dex_f -= skill.dex_f * sh.power_reduction / 100
      skill.agi_f -= skill.agi_f * sh.power_reduction / 100
      skill.int_f -= skill.int_f * sh.power_reduction / 100
    end
    effective = kyon_kextra_was_gm_battler_skill_effect(user, skill)
    @skill_hit = sid if effective and self.respond_to?(:troop_id)
    return effective
  end
end

class Game_Actor
  attr_reader :break_weapons, :break_armors, :skill_handicaps
  alias kyon_kextra_was_gm_actor_setup setup
  alias kyon_kextra_was_gm_actor_base_atk base_atk
  alias kyon_kextra_was_gm_actor_base_pdef base_pdef
  alias kyon_kextra_was_gm_actor_base_mdef base_mdef
  alias kyon_kextra_was_gm_actor_equip equip
  alias kyon_kextra_was_gm_actor_learn_skill learn_skill
  def setup(actor_id)
    @levels = { :priest => 0, :smith => 0, :tech => 0 }
    @break_weapons = {}
    @break_armors = {}
    @skill_handicaps = {}
    kyon_kextra_was_gm_actor_setup(actor_id)
    add_break_weapon(@weapon_id)
    ids = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
    ids.each {|aid| add_break_armor(aid) }
    if (handicaps = KExtra::ACTOR_HANDICAPS[actor_id])
      handicaps.each {|sid, data| add_skill_handicaps(sid, data) }
    end
  end

  def base_atk
    old_atk = kyon_kextra_was_gm_actor_base_atk
    weapon = @break_weapons[@weapon_id]
    old_atk -= old_atk * weapon.power_reduction / 100 if weapon
    return old_atk
  end

  def base_pdef
    old_pdef = kyon_kextra_was_gm_actor_base_pdef
    armors = [@break_armors[@armor1_id], @break_armors[@armor2_id]]
    armors += [@break_armors[@armor3_id], @break_armors[@armor4_id]]
    armors.compact.each {|a| old_pdef -= old_pdef * a.power_reduction / 100 }
    return old_pdef
  end

  def base_mdef
    old_mdef = kyon_kextra_was_gm_actor_base_mdef
    armors = [@break_armors[@armor1_id], @break_armors[@armor2_id]]
    armors += [@break_armors[@armor3_id], @break_armors[@armor4_id]]
    armors.compact.each {|a| old_mdef -= old_mdef * a.power_reduction / 100 }
    return old_mdef
  end

  def equip_fix?(equip_type)
    actor = $data_actors[@actor_id]
    case equip_type
    when 0
      cursed = @break_weapons[@weapon_id].cursed rescue false
      return (actor.weapon_fix or cursed)
    when 1
      cursed = @break_armors[@armor1_id].cursed rescue false
      return (actor.armor1_fix or cursed)
    when 2
      cursed = @break_armors[@armor2_id].cursed rescue false
      return (actor.armor12_fix or cursed)
    when 3
      cursed = @break_armors[@armor3_id].cursed rescue false
      return (actor.armor3_fix or cursed)
    when 4
      cursed = @break_armors[@armor4_id].cursed rescue false
      return (actor.armor4_fix or cursed)
    else false
    end
  end

  def equip(equip_type, id)
    if equip_type == 0 and id > 0
      if (none = @break_weapons[id] == nil)
        add_break_weapon(id)
      elsif !none and @break_weapons[id].broken
        return
      end
    end
    kyon_kextra_was_gm_actor_equip(equip_type, id)
  end

  def add_break_weapon(wid)
    source = KExtra::BREAK_WEAPONS[wid]
    return if !source or @break_weapons[wid]
    @break_weapons[wid] = weapon = KExtra::Equipment.new
    weapon.kind = :weapon
    breakable_setup(weapon, source)
  end

  def add_break_armor(aid)
    source = KExtra::BREAK_ARMORS[aid]
    return if !source or @break_armors[aid]
    @break_armors[aid] = armor = KExtra::Equipment.new
    armor.kind = :armor
    breakable_setup(armor, source)
  end

  def breakable_setup(thing, source)
    thing.uses = source[0]
    thing.broken = source[1]
    thing.cursed = source[2]
    thing.level = source[3]
    thing.failure_rate = source[4]
    thing.power_reduction = source[5]
    thing.power_increase = source[6]
    thing.remover_item_id = source[7]
    thing.cost = { :broken => source[8], :cursed => source[9] }
  end

  def increase_weapon_power(weapon_id)
    return unless (weapon = @break_weapons[weapon_id])
    reduction = [weapon.power_reduction - weapon.power_increase, 0].max
    weapon.power_reduction = reduction
  end

  def increase_armor_resist(armor_id)
    return unless (armor = @break_armors[armor_id])
    reduction = [armor.power_reduction - armor.power_increase, 0].max
    armor.power_reduction = reduction
  end

  def reforge_weapon(smith_level, weapon_id)
    weapon = @break_weapons[weapon_id]
    return unless weapon and weapon.broken
    return reforge_equip(smith_level, weapon)
  end

  def reforge_armor(smith_level, armor_id)
    armor = @break_armors[armor_id]
    return unless armor and armor.broken
    return reforge_equip(smith_level, armor)
  end

  def reforge_equip(smith_level, eq)
    repair = (rand(100) > eq.failure_rate and eq.level <= smith_level)
    eq.broken = !repair
    eq.uses = KExtra::DEFAULT_USES * smith_level if repair and eq.uses == 0
    return repair
  end

  def lift_weapon_curse(caster, level, weapon_id)
    lift_equip_curse(caster, level, @break_weapons[weapon_id])
  end

  def lift_armor_curse(caster, level, armor_id)
    lift_equip_curse(caster, level, @break_armors[armor_id])
  end

  def lift_equip_curse(caster, level, thing)
    return if thing == nil
    thing.cursed = cursed = case caster
    when :priest, :clerigo then thing.level > level
    when :smith, :herrero then thing.level + 1 > level
    when :tech, :tecnico then thing.level + 2 > level
    end
    return !cursed
  end

  def add_skill_handicaps(skill_id, source)
    return if @skill_handicaps[skill_id]
    @skill_handicaps[skill_id] = skill = KExtra::Skill.new
    skill.uses = source[0]
    skill.blocked = source[1]
    skill.level = source[2]
    skill.power_reduction = source[3]
    skill.power_increase = source[4]
    skill.remover_item_id = source[5]
  end

  def increase_skill_power(skill_id)
    return unless (handicap = @skill_handicaps[skill_id])
    reduction = [handicap.power_reduction - handicap.power_increase, 0].max
    handicap.power_reduction = reduction
  end

  def add_skill_uses(skill_id, extra_uses=0)
    if extra_uses == 0
      item_id = KExtra::SKILL_USES_ITEM_ID
      return unless item_number(item_id) > 0
      $game_party.lose_item(item_id)
      extra_uses = KExtra::DEFAULT_USES
    end
    @skill_handicaps[skill_id].uses += extra_uses
  end

  def lift_skill_curse(skill_id)
    return unless (handicap = @skill_handicaps[skill_id])
    item_id = handicap.remover_item_id
    return unless item_number(item_id) > 0
    $game_party.lose_item(item_id)
    @skill_handicaps.delete(skill_id)
  end

  def priest_lift_skill_curse(priest_level, skill_id)
    return unless (skill = @skill_handicaps[skill_id])
    @skill_handicaps.delete(skill_id) if skill.level <= priest_level
  end

  def broken_weapons?() @break_weapons.select{|wid,w| w.broken }.size > 0 end
  def cursed_weapons?() @break_weapons.select{|wid,w| w.cursed }.size > 0 end
  def broken_armors?() @break_armors.select{|aid,w| w.broken }.size > 0 end
  def cursed_armors?() @break_armors.select{|aid,w| w.cursed }.size > 0 end
  def force_lift_curse(skill_id) @skill_handicaps.delete(skill_id) end
  def skill_cursed?(skill_id) @skill_handicaps[skill_id] end
  def unblock_skill(skill_id) @skill_handicaps[skill_id].blocked = nil end
  def priest_level() @levels[:priest] end
  def smith_level() @levels[:smith] end
  def tech_level() @levels[:tech] end

  def learn_skill(skill_id)
    already_learned = @skills.include?(skill_id)
    kyon_kextra_was_gm_actor_learn_skill(skill_id)
    recently_learned = @skills.include?(skill_id)
    return unless !already_learned and recently_learned
    return if @skill_handicaps[skill_id]
    return unless (skill = KExtra::SKILL_HANDICAPS[skill_id])
    add_skill_handicaps(skill_id, skill)
  end

  def skill_can_use?(skill_id)
    if (skill = @skill_handicaps[skill_id])
      return if skill.uses == 0 or skill.blocked or skill.power_reduction == 100
    end
    super
  end
end

class Game_Enemy
  attr_reader :troop_id
end

class Game_Party
  def broken_weapons?() @actors.select{|a| a.broken_weapons? }.size > 0 end
  def cursed_weapons?() @actors.select{|a| a.cursed_weapons? }.size > 0 end
  def broken_armors?() @actors.select{|a| a.broken_armors? }.size > 0 end
  def cursed_armors?() @actors.select{|a| a.cursed_armors? }.size > 0 end
end

Terms & Conditions

Just the usual, include me in your game credits, don't use it on commercial games unless you have contacted me first...
"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 }
#2
Even if there are not even 4 cats following this scriptlet, I have posted a new and complete version, in my humble opinion. Here you can even make an enemy curse one of your hero's skills, meaning he or she won't be able to use it unless they find a cure or a highly trained priest with the appropriate level to lift that curse. You can also make them consume a predefined item to increase the number of cursed skill uses, among a few other things that are currently available. :P
"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 }
#3
I have updated this script to include features that affect weapons like letting them break (kind of...) or get cursed. Because of these issues I also implemented ways to reforge them or lift the curses. Here you will only find script calls, no GUI included. Do you need a GUI? Then get my other script KWorkshop XP as well, then you will be able to do that by means of a simple visual menu!
"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 }
#4
I included a few more features as well as a couple of minor changes to improve the code, especially when other scripts like KWorkshop XP have been included in your game project, too. Perhaps I also fixed a couple of bugs I found or that were reported by some furry forumer.
"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 }




Users browsing this thread: 3 Guest(s)