Jump to content
PhoenixSoul

How to check for which party member is changing equipment

Recommended Posts

...

Is there a way to check for which party member is currently changing equipment? I think if I could use that in a conditional branch, I wouldn't continue to run into this weird and otherwise nonsensical eval error that only occurs with more than one member in the party when changing equipment.

Scripts involved:
@Tsukihime's Common Event on Equip/Dequip.

What's going on:
With more than one party member, I have variables set up to check on specific equip setups of each party member, however, I think there's a hangup in that it considers equip checks as checks for nil if the party member in question is not being equipped or dequipped. There's nothing in @Tsukihime's script that could be interfering so it must be something else.

I still think that if one could check to see who is currently changing equipment, that would be fantastic.

Share this post


Link to post
Share on other sites
20 hours ago, PhoenixSoul said:

which party member is currently changing equipment?

A quick test and if you add into the script in Game_actor -> change_equip method

    $game_variables[7] = actor.id

Pick whatever variable you want to use

It will have the value for you to use in the common event.

Share this post


Link to post
Share on other sites

@roninator2 I figured it out.

It wasn't Game_Actor though.

 

Spoiler

class Game_Party < Game_Unit

  #--------------------------------------------------------------------------
  # * Get Actor Selected on Menu Screen
  #--------------------------------------------------------------------------
  def menu_actor
    $game_actors[@menu_actor_id] || members[0]
  end
  #--------------------------------------------------------------------------
  # * Set Actor Selected on Menu Screen
  #--------------------------------------------------------------------------
  def menu_actor=(actor)
    @menu_actor_id = actor.id
    $game_variables[98] == @menu_actor_id
  end
  #--------------------------------------------------------------------------
  # * Select Next Actor on Menu Screen
  #--------------------------------------------------------------------------
  def menu_actor_next
    index = members.index(menu_actor) || -1
    index = (index + 1) % members.size
    self.menu_actor = members[index]
#   $game_variables[98] == members[index]
  end
  #--------------------------------------------------------------------------
  # * Select Previous Actor on Menu Screen
  #--------------------------------------------------------------------------
  def menu_actor_prev
    index = members.index(menu_actor) || 1
    index = (index + members.size - 1) % members.size
    self.menu_actor = members[index]
#   $game_variables[98] == members[index]
  end
end 

 


By setting the variable to @menu_actor_id, it eliminated the odd error. The error only occurs if there's more than a single party member though.

Share this post


Link to post
Share on other sites

To explain the issue, would require me to explain what the equip/dequip events do in a great amount of detail.

I can do that.

I have conditional branches containing long strings of Ruby eval code, that if they return true, remove or assign certain attack skills, based on what, if any, weapons are equipped, and if hand-held shields are also equipped. The equip/dequip events call other common events based on how many party members there are, and if there's only one, it runs without issue since it only calls the one common event. Thing is, if there's two or more, it runs all the common events for each member regardless of who is changing weapons/hand-held shields, and though, the logic to me just says to not change anything, the interpreter throws a fit because, reasons.

The error it throws points to 'members' being accessed from nil, which tells me that though the party members are there, something is setting their existence in that instance to nil, and so I went to figure out what. I never did figure that out, but I did manage to make a dirty hack involving $game_variables and the menu_member_index.

I also need to note that the scriptlet I made and shared here is not the final scriptlet. I shall share that now.
 

Spoiler

class Game_Party < Game_Unit

  #--------------------------------------------------------------------------
  # * Get Actor Selected on Menu Screen
  #--------------------------------------------------------------------------
  def menu_actor
    $game_actors[@menu_actor_id] || members[0]
  end
  #--------------------------------------------------------------------------
  # * Set Actor Selected on Menu Screen
  #--------------------------------------------------------------------------
  def menu_actor=(actor)
    @menu_actor_id = actor.id
#   $game_variables[98] = @menu_actor_id
  end
  #--------------------------------------------------------------------------
  # * Select Next Actor on Menu Screen
  #--------------------------------------------------------------------------
  def menu_actor_next
    index = members.index(menu_actor) || -1
    $game_variables[98] = (index + 1) % members.size
    index = (index + 1) % members.size
    self.menu_actor = members[index]
#   $game_variables[98] = members[index]
  end
  #--------------------------------------------------------------------------
  # * Select Previous Actor on Menu Screen
  #--------------------------------------------------------------------------
  def menu_actor_prev
    index = members.index(menu_actor) || 1
    $game_variables[98] = (index + members.size - 1) % members.size
    index = (index + members.size - 1) % members.size
    self.menu_actor = members[index]
#   $game_variables[98] = members[index]
  end
end 

 

...
Setting the variable to @menu_actor_id does work/no errors thrown, but it sets the variable to the database Actor ID.
Setting it to members[index] as commented out sets a weird string instead. #GameActor<randomhexstring>
Setting it to the method used to attribute the index, notes the correct member when in any part of the status screens. However, I had it wrong thinking it was 1-based and not 0-based. By using additional conditional checks for if the variable is equal to the member whose equipment is being changed, the equip/dequip events now only run for that member, no more weird errors.

If you're curious about the long eval string...
 

Spoiler

a = $game_party.members[0].equips[1] && $game_party.members[0].equips[1].wtype_id; b = $game_party.members[0].equips[1]; [1,4,5,7].include?(a) && b

 

...
Essentially, this long eval code (with help from dearest love @Kayzee), checks if the weapon type equipped is of the four noted in the array, and is in equip slot 1, which in this case is the primary weapon slot since slot 0 is relegated to a Skill Card. If true, the party leader is given the associated attack skill, which is 'Primary Bladed', for any weapon with a blade that is not a polearm/spear (axe/sword/katana/dagger). If false, the skill is removed.

Overly complicated? Yeah, sure. It ensures that every attack skill is not copying from the default, though I've found that dual-attacking enemies is harder to do.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×