Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Weapons Swap
#1
Weapons Swap

XP + VX + ACE

by Kyonides


Introduction

The title makes it extremely clear, but just case here we go: your party members can now swap their weapons at any given time. It will do it either BY FORCE or Lazily (by running a couple of internal checks).

Just call:
Force? is a placeholder for true or false.
Code:
$game_party.swap_weapons(Force?, FirstPosition, SecondPosition)

...and it will let you make the change swiftly!

It will ignore your request if for ANY REASON you provide it with identical positions.

Just in Case you are using VX or VX ACE:

It does NOT ALTER the Actor's Two Swords Style or Dual Wield feature at all.

To get the corresponding Skill Scripts, click Here!

The Scripts

XP Script

Code:
# * Weapons Swap XP * #
#   Scripter : Kyonides Arkanthes
#   2023-01-15

# - Free for use in Non Commercial Projects - #

# * Script Calls - #

# - Swap Weapons either by Force or by Unequipping Forbidden Weapons
#   Force? stands for true or false.
#   $game_party.swap_weapons(Force?, PartyIndex1, PartyIndex2)

# - Allow Dual Wield alias Two Swords Style
#   $game_actors[ActorID].dual_wield = true

class Game_Actor
  attr_writer :weapon_id, :armor1_id
  attr_accessor :dual_wield
  alias :two_swords_style :dual_wield
  alias :two_swords_style= :dual_wield=
  def equip_weapon?
    $data_classes[@class_id].weapon_set.include?(@weapon_id)
  end
   
  def equip_armor1?
    klass = $data_classes[@class_id]
    if @dual_wield
      return klass.weapon_set.include?(@weapon_id)
    else
      return klass.armor_set.include?(@armor1_id)
    end
  end

  def unequip_weapon
    $game_party.gain_weapon(@weapon_id, 1)
    @weapon_id = 0
    nil
  end

  def unequip_armor1
    $game_party.gain_armor(@armor1_id, 1)
    @armor1_id = 0
    nil
  end

  def swap_weapon(new_id, force=true)
    return unequip_weapon if equip_fix?(0) or (!force and equip_weapon?)
    @weapon_id = new_id
    true
  end

  def swap_armor1(new_id, force=true)
    return unequip_armor1 if equip_fix?(1) or (!force and !equip_armor1?)
    @armor1_id = new_id
    true
  end
end

class Game_Party
  def swap_weapons(force, *indexes)
    return if indexes[0] == indexes[1]
    heroes = indexes.map{|n| @actors[n] }
    r1, r2 = nil, nil
    if heroes[0].dual_wield and heroes[1].dual_wield
      r2 = swap_armor_ids(force, *heroes)
    end
    r1 = swap_weapon_ids(force, *heroes)
    return (r1 or r2)
  end
  private
  def swap_weapon_ids(force, hero1, hero2)
    w1, w2 = hero1.weapon_id, hero2.weapon_id
    r1 = hero1.swap_weapon(w2, force)
    r2 = hero2.swap_weapon(w1, force)
    return (r1 or r2)
  end

  def swap_armor_ids(force, hero1, hero2)
    a1, a2 = hero1.armor1_id, hero2.armor1_id
    r1 = hero1.swap_armor1(a2, force)
    r2 = hero2.swap_armor1(a1, force)
    return (r1 or r2)
  end
end


VX Script

Code:
# * Weapons Swap VX * #
#   Scripter : Kyonides Arkanthes
#   2023-01-14

# - It's free as in beer. - #

# * Script Call * #
#   $game_party.swap_weapons(PartyIndex1, PartyIndex2)

class Game_Actor
  attr_writer :weapon_id, :armor1_id
end

class Game_Party
  def swap_weapons(*indexes)
    return if indexes[0] == indexes[1]
    heroes = indexes.map{|n| $game_actors[@actors[n]] }
    if heroes[0].two_swords_style and heroes[1].two_swords_style
      swap_armor_ids(*heroes)
    end
    swap_weapon_ids(*heroes)
  end
  private
  def swap_weapon_ids(hero1, hero2)
    hero1.weapon_id, hero2.weapon_id = hero2.weapon_id, hero1.weapon_id
  end

  def swap_armor_ids(hero1, hero2)
    hero1.armor1_id, hero2.armor1_id = hero2.armor1_id, hero1.armor1_id
  end
end


VX ACE Script

Code:
# * Weapons Swap ACE * #
#   Scripter : Kyonides Arkanthes
#   2023-01-15

# - It's free as in beer. - #

# * Script Call - #

# - Swap Weapons - Force? Options: true or false - #
#   $game_party.swap_weapons(Force?, PartyIndex1, PartyIndex2)

class Game_BaseItem
  attr_accessor :item_id
end

class Game_Actor
  def just_equips() @equips end
end

class Game_Party
  def get_hero(pos)
    $game_actors[@actors[pos]]
  end

  def swap_equip_item_ids(force, pos, hero1, hero2)
    he1 = hero1.just_equips[pos]
    he2 = hero2.just_equips[pos]
    he1.item_id, he2.item_id = he2.item_id, he1.item_id
    return if force
    hero1.refresh
    hero2.refresh
  end
  private :get_hero, :swap_equip_item_ids

  def swap_weapons(force, *indexes)
    return if indexes[0] == indexes[1]
    hero1 = get_hero(indexes.shift)
    hero2 = get_hero(indexes.shift)
    if hero1.dual_wield? and hero2.dual_wield?
      swap_equip_item_ids(force, 1, hero1, hero2)
    end
    swap_equip_item_ids(force, 0, hero1, hero2)
    return true
  end
  def member_ids() @actors end
end


Terms & Conditions

Check out the comments embedded in each script! Happy with a sweat
Just keep in mind you should mention me in your game credits. Winking
Do Not Repost 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 }
#2
Weapons Swap Skill

XP + VX + ACE

by Kyonides

Introduction

This is the natural outcome of implementing the Weapons Swap script:

to let Witch Ghost Zombie Golem Your Foes Use It Against You! Slayne Ghim Deedlit Orson 

The Scripts

XP Script with Enemy's Skill

Code:
# * Weapons Swap & Skill XP * #
#   Scripter : Kyonides Arkanthes
#   2023-01-15

# - Free for use in Non Commercial Projects - #

# * Script Calls * #

# - Swap Weapons either by Force or by Unequipping Forbidden Weapons
#   Force? stands for true or false.
#   $game_party.swap_weapons(Force?, PartyIndex1, PartyIndex2)

# - Allow Dual Wield alias Two Swords Style
#   $game_actors[ActorID].dual_wield = true

# * NOTES * #

# Set the SKILL_ID Constant to the corresponding Skill Number in the DB.

# Set the ID of the BY_FORCE_SWITCH_ID Constant and set the corresponding
# Game Variable to true before any battle where you want the mobsters to
# perform the swap BY FORCE.

module KWSwap
  SKILL_ID = 91
  BY_FORCE_SWITCH_ID = 3
end

class Game_Battler
  alias :kyon_weapon_swap_skill_skill_fx :skill_effect
  def skill_effect(user, skill)
    if user.is_a?(Game_Enemy) and KWSwap::SKILL_ID == skill.id
      heroes = $game_party.actors
      return if heroes.size < 2
      pos1 = self.index
      pos2 = rand(heroes.size)
      force = $game_switches[KWSwap::BY_FORCE_SWITCH_ID]
      return $game_party.swap_weapons(force, pos1, pos2)
    end
    kyon_weapon_swap_skill_skill_fx(user, skill)
  end
end

class Game_Actor
  attr_writer :weapon_id, :armor1_id
  attr_accessor :dual_wield
  alias :two_swords_style :dual_wield
  alias :two_swords_style= :dual_wield=
  def equip_weapon?
    $data_classes[@class_id].weapon_set.include?(@weapon_id)
  end
   
  def equip_armor1?
    klass = $data_classes[@class_id]
    if @dual_wield
      return klass.weapon_set.include?(@weapon_id)
    else
      return klass.armor_set.include?(@armor1_id)
    end
  end

  def unequip_weapon
    $game_party.gain_weapon(@weapon_id, 1)
    @weapon_id = 0
    nil
  end

  def unequip_armor1
    $game_party.gain_armor(@armor1_id, 1)
    @armor1_id = 0
    nil
  end

  def swap_weapon(new_id, force=true)
    return unequip_weapon if equip_fix?(0) or (!force and equip_weapon?)
    @weapon_id = new_id
    true
  end

  def swap_armor1(new_id, force=true)
    return unequip_armor1 if equip_fix?(1) or (!force and !equip_armor1?)
    @armor1_id = new_id
    true
  end
end

class Game_Party
  def swap_weapons(force, *indexes)
    return if indexes[0] == indexes[1]
    heroes = indexes.map{|n| @actors[n] }
    r1, r2 = nil, nil
    if heroes[0].dual_wield and heroes[1].dual_wield
      r2 = swap_armor_ids(force, *heroes)
    end
    r1 = swap_weapon_ids(force, *heroes)
    return (r1 or r2)
  end
  private
  def swap_weapon_ids(force, hero1, hero2)
    w1, w2 = hero1.weapon_id, hero2.weapon_id
    r1 = hero1.swap_weapon(w2, force)
    r2 = hero2.swap_weapon(w1, force)
    return (r1 or r2)
  end

  def swap_armor_ids(force, hero1, hero2)
    a1, a2 = hero1.armor1_id, hero2.armor1_id
    r1 = hero1.swap_armor1(a2, force)
    r2 = hero2.swap_armor1(a1, force)
    return (r1 or r2)
  end
end


VX Script

Code:
# * Weapons Swap Skill VX * #
#   Scripter : Kyonides Arkanthes
#   2023-01-14

# - It's free as in beer. - #

# Just leave the following comment in the Skill's Note Box:
#   <weapon swap>

class Game_Battler
  WEAPON_SWAP_REGEX = /<weapon swap>/i
  alias :kyon_weapon_swap_skill_skill_fx :skill_effect
  def apply_weapon_swap(user, skill)
    if skill.note[WEAPON_SWAP_REGEX] and user.is_a?(Game_Enemy)
      clear_action_results
      heroes = $game_party.member_ids
      return @skipped = true if heroes.size < 2
      pos1 = self.index
      pos2 = rand(heroes.size)
      result = $game_party.swap_weapons(pos1, pos2)
      return @missed = nil
    end
  end

  def skill_effect(user, skill)
    kyon_weapon_swap_skill_skill_fx(user, skill)
    apply_weapon_swap(user, skill)
  end
end


VX ACE Script with Enemy's Skill

NOTE: VX Ace will always attempt to remove the forbidden weapons as stated in the comments embedded in my script. What I did was creating a WS state to prevent it from doing it while in battle. Once you go back to the map, you will find your weapons in your party's inventory.

Code:
# * Weapons Swap & Skill ACE * #
#  Scripter : Kyonides Arkanthes
#  2023-01-15

# - It's free as in beer. - #

# * Script Call - #

# - Swap Weapons - Force? Options: true or false - #
#  $game_party.swap_weapons(Force?, PartyIndex1, PartyIndex2)

# - Define the WS Skill by leaving a comment in the Skill's Note Box:
#  <weapon swap force>  or  <weapon swap lazy>

# - Create a Weapons Swap State in the States DB and Set the value of the
#  STATE Constant accordingly. It is found in the KWSwap Module.

# * Warning * #

#  VX ACE will ALWAYS attempt to REMOVE unequippable weapons whenever ANY
#  State Change or Buff or Debuff and other alterations takes place.

module KWSwap
  STATE = 26
  REGEX = /<weapon swap (force|lazy)>/i
end

class Game_BaseItem
  attr_accessor :item_id
end

class Game_Battler
  alias :kyon_weapon_swap_skill_item_user_fx :item_user_effect
  def apply_weapon_swap(user, skill)
    return unless skill.note[KWSwap::REGEX] and user.is_a?(Game_Enemy)
    heroes = $game_party.member_ids
    if heroes.size < 2
      @result.missed = true
      return
    end
    pos1 = self.index
    pos2 = rand(heroes.size)
    force = $1[/force/] != nil
    success = $game_party.swap_weapons(force, pos1, pos2)
    if success
      hero2 = heroes[pos2]
      $game_actors[hero2].add_state(KWSwap::STATE)
      add_state(KWSwap::STATE)
    end
    @result.used = success
  end

  def item_user_effect(user, item)
    swapped = false
    swapped |= apply_weapon_swap(user, item) if item.is_a?(RPG::Skill)
    kyon_weapon_swap_skill_item_user_fx(user, item) unless swapped
  end
end

class Game_Actor
  alias :kyon_weapon_swap_skill_refresh :refresh
  def refresh
    if state?(KWSwap::STATE)
      super
      return
    end
    kyon_weapon_swap_skill_refresh
  end
  def just_equips() @equips end
end

class Game_Party
  def get_hero(pos)
    $game_actors[@actors[pos]]
  end

  def swap_equip_item_ids(force, pos, hero1, hero2)
    he1 = hero1.just_equips[pos]
    he2 = hero2.just_equips[pos]
    he1.item_id, he2.item_id = he2.item_id, he1.item_id
    return if force
    hero1.refresh
    hero2.refresh
  end
  private :get_hero, :swap_equip_item_ids

  def swap_weapons(force, *indexes)
    return if indexes[0] == indexes[1]
    hero1 = get_hero(indexes.shift)
    hero2 = get_hero(indexes.shift)
    if hero1.dual_wield? and hero2.dual_wield?
      swap_equip_item_ids(force, 1, hero1, hero2)
    end
    swap_equip_item_ids(force, 0, hero1, hero2)
    return true
  end
  def member_ids() @actors end
end


Same Terms & Conditions as the Main Script on the Main Thread.
"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 }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Weapons Blocked from Attacks DerVVulfman 0 351 12-03-2023, 03:41 AM
Last Post: DerVVulfman
   KEW XP - Enemies + Weapons kyonides 1 3,645 01-27-2019, 06:26 PM
Last Post: kyonides
   Weapons : Target All Kain Nobel 1 4,862 06-04-2016, 11:23 PM
Last Post: Steel Beast 6Beets
   Tileset Swap ccoa 4 10,527 04-15-2014, 04:18 AM
Last Post: DerVVulfman
   Two-Handed Weapons RPG Advocate 2 6,514 07-07-2013, 03:52 AM
Last Post: DerVVulfman
   Weapons That Use HP/SP DerVVulfman 0 4,271 12-31-2009, 05:07 AM
Last Post: DerVVulfman
   Variable Swap [Snippet] PK8 0 4,143 11-09-2009, 07:32 AM
Last Post: PK8
   Switch Swap [Snippet] PK8 0 4,121 11-09-2009, 07:07 AM
Last Post: PK8
   Cursed Weapons and Armor RPG Advocate 0 3,905 03-03-2008, 04:51 AM
Last Post: RPG Advocate



Users browsing this thread: