Jump to content
Sign in to follow this  
WCouillard

YEA Party System: Unequip when Removing?

Recommended Posts

Would anyone be able to assist me in modding Yanfly's Party System to make it so when a characer is taken out of the party via the "Remove" command, their equipment is also removed?

 

  #--------------------------------------------------------------------------
  # * Remove All Equipment
  #--------------------------------------------------------------------------
  def clear_equipments
    equip_slots.size.times do |i|
      change_equip(i, nil) if equip_change_ok?(i)
    end
  end

This is from Game_Actor, which does exactly what I need, I'm just having some trouble getting it to run this when a party member is removed in Yanfly's Party System. I'm not getting crashes, but I don't seem to be able to get it to actually clear out the equipment.

 

  #--------------------------------------------------------------------------
  # alias method: remove_actor
  #--------------------------------------------------------------------------
  alias game_party_remove_actor_ps remove_actor
  def remove_actor(actor_id)
    game_party_remove_actor_ps(actor_id)
    return unless @battle_members_array.include?(actor_id)
    index = @battle_members_array.index(actor_id)
    @battle_members_array[index] = 0
    $game_player.refresh
    $game_map.need_refresh = true
    rearrange_actors
  end

Here is the aliased method from Yanfly's Party System which handles removing an actor, which is in Game_Party.

Share this post


Link to post
Share on other sites

After line 1203 I added

      $game_actors[$game_party.battle_members_array[index]].clear_equipments
 

  #--------------------------------------------------------------------------
  # on_party_ok
  #--------------------------------------------------------------------------
  def on_party_ok
    case @command_window.current_symbol
    when :change
      @list_window.activate
    when :remove
      index = @party_window.index
      actor = $game_actors[$game_party.battle_members_array[index]]
      $game_actors[$game_party.battle_members_array[index]].clear_equipments
      Sound.play_equip
      $game_party.battle_members_array[index] = 0
      window_refresh
      @party_window.activate
    end
  end

 

Share this post


Link to post
Share on other sites

Ah, so I was looking at the wrong thing. I figured it'd be something added to that remove_actor method. Thank you! :D

 

EDIT: So, that works perfectly, but only when removing a character with the Remove command (which, I realize, is what I asked for). However, if using the "Change" command to swap a character with one in reserve, the character who gets removed still keeps their equipment on. Anyway we can make that remove equipment when swapping characters (but only for the one who ends up in reserve?)

 

  #--------------------------------------------------------------------------
  # on_list_ok
  #--------------------------------------------------------------------------
  def on_list_ok
    Sound.play_equip
    replace = $game_actors[@party_window.item]
    actor = $game_actors[@list_window.item]
    index1 = @party_window.index
    actor_id1 = actor.nil? ? 0 : actor.id
    if actor.nil?
      $game_party.battle_members_array[index1] = 0
      window_refresh
      @party_window.activate
      return
    end
    actor_id2 = replace.nil? ? 0 : replace.id
    if $game_party.battle_members_array.include?(actor_id1)
      index2 = $game_party.battle_members_array.index(actor_id1)
      $game_party.battle_members_array[index2] = actor_id2
    end
    $game_party.battle_members_array[index1] = actor_id1
    window_refresh
    @party_window.activate
  end

I believe it'd be an edit to this method.

Edited by WCouillard

Share this post


Link to post
Share on other sites
1 hour ago, WCouillard said:

an edit to this method

You are correct.

A little bit of trial and testing produces this as a positive result.

    $game_actors[$game_party.battle_members_array[replace.id - 1]].clear_equipments
 

  #--------------------------------------------------------------------------
  # on_list_ok
  #--------------------------------------------------------------------------
  def on_list_ok
    Sound.play_equip
    replace = $game_actors[@party_window.item]
    actor = $game_actors[@list_window.item]
    index1 = @party_window.index
    actor_id1 = actor.nil? ? 0 : actor.id
    if actor.nil?
      $game_party.battle_members_array[index1] = 0
      window_refresh
      @party_window.activate
      return
    end
    actor_id2 = replace.nil? ? 0 : replace.id
    if $game_party.battle_members_array.include?(actor_id1)
      index2 = $game_party.battle_members_array.index(actor_id1)
      $game_party.battle_members_array[index2] = actor_id2
    end
    $game_actors[$game_party.battle_members_array[replace.id - 1]].clear_equipments
    $game_party.battle_members_array[index1] = actor_id1
    window_refresh
    @party_window.activate
  end

 

Share this post


Link to post
Share on other sites

Hmmm, that is returning an error for me. Tested with a new save file.

 

YEA: Party System:1306:in `on_list_ok': undefined method `battle_members_array' for nil:NilClass (NoMethodError)

The line in question is the line you added in your previous post.

 

$game_actors[$game_party.battle_members_array[replace.id - 1]].clear_equipments

 

Share this post


Link to post
Share on other sites

For me that's line 1276.

What have you added in?

Yanfly Party is also the only script I have in the test project. Maybe there is an incompatibility?

Edited by roninator2

Share this post


Link to post
Share on other sites

Only things I've edited in were things to show some background images, which is why there's extra lines. Never messed with any of the mechanics of it, other than the line added in this thread to remove equipment with the "Remove" command. So I copied the text over again, made sure there were no hidden characters (can sometimes happen when copy/pasting) and now it returns an error saying that "id" has no definition, even though it should be clearly defined before this line happens. Strange.

 

 

Share this post


Link to post
Share on other sites

Did that, same result. It returns an error when trying to swap two actors, and a different error when trying to swap an actor with an empty slot.

 

I'll start digging around for incompatibilities.

Share this post


Link to post
Share on other sites

I see. I didn't try with an empty slot. It give me the error too when selecting an empty slot. Sorry.

Have to work on it some more.

 

*forgot about my last post where it removed.

 

Edited by roninator2

Share this post


Link to post
Share on other sites

That is actually doing the opposite of the desired effect. The above unequips characters when selecting change and swapping two party members who are already in the party. Characters who are already in the party, and remain there, should not be unequipped. Only when a character ends up in the reserve, should they be unequipped.

 

It's annoying, I know. Since it has to check and compare both slots being selected, it's not as simple as the first edit, where the remove command simply strips a character's equipment.

Share this post


Link to post
Share on other sites

Try this..

 

I can't get it to error out.

I was overthinking the structure. I thought I had to point to the party window to get the id.

  def on_list_ok
    Sound.play_equip
    replace = $game_actors[@party_window.item]
    actor = $game_actors[@list_window.item]
    index1 = @party_window.index
    actor_id1 = actor.nil? ? 0 : actor.id
    if actor.nil?
      $game_party.battle_members_array[index1] = 0
      $game_actors[replace.id].clear_equipments
      window_refresh
      @party_window.activate
      return
    end
    actor_id2 = replace.nil? ? 0 : replace.id
    if actor_id2 != 0 && !$game_party.battle_members_array.include?(actor_id1)
      $game_actors[replace.id].clear_equipments
      window_refresh
    end
    if $game_party.battle_members_array.include?(actor_id1)
      index2 = $game_party.battle_members_array.index(actor_id1)
      $game_party.battle_members_array[index2] = actor_id2
    end
    $game_party.battle_members_array[index1] = actor_id1
    window_refresh
    @party_window.activate
  end

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×