Jump to content
Audrey

Actor Index Set?

Recommended Posts

I haven't quite found how to set the index of an actor mid-game a scipt call. I know the answer is probably something very simple that I'd be like "oh, durrr" to.

Also, if you set the index of an actor to Index #2 and there's already an actor there, then I think it might glitch the game, so yeah. I ask for the solution to these.

Share this post


Link to post
Share on other sites

If you mean the Actor ID, then actually no.

There isn't much point to do so.

If you really need to, just copy the actor data and paste it into the destined ID.

You'll have the same actor in both and be able to call it via either ID.

However changes to one actor i.e. level, equipment, skills etc. will only show on the actor which gained them.

 

However I agree with Galv.  I think you mean something completely different and we don't understand.

Please elaborate, I'd love to help.

 

If you want to switch actors out of your party, use the change party member command.

If you want to rename your actor, use the change name command.

Share this post


Link to post
Share on other sites

I'm talking about, say, wanting Eric to be in the 1st slot manually, then Terrence in 2nd, and Natalie in 4th. Using a script call. This is because when you add members, you aren't normally able to format what slot they're in.

Share this post


Link to post
Share on other sites

I think you need to explain what are you trying to achieve :)

(Do you get notifications even if I don't directly quote you?)

Share this post


Link to post
Share on other sites

Please don't double-post unless 72+ hours have passed since the most recent reply.

 

Regarding the notifications: this is different for each individual user. As you can see in My Settings -> Notification Options, there is the possibility of receiving notifications for quotes, but it could be disabled for an individual user. Anyways, back to topic.

 

There actually is a way of adding members at specific positions. It's a rather simple edit because the existing methods already do almost what we want them to.

 

 

class Game_Party < Game_Unit
 def add_actor_at(actor_id, index)
  @actors.insert(index, actor_id) unless @actors.include?(actor_id)
  $game_player.refresh
  $game_map.need_refresh = true
 end
end

class Game_Interpreter
 def add_actor(actor_id, index = $game_party.all_members.size, initialize = false)
  actor = $game_actors[actor_id]
  if actor
   if @params[2] == 1  # Initialize
    $game_actors[actor_id].setup(actor_id)
   end
    $game_party.add_actor_at(actor_id, index)
  end
 end
end 

 

 

Add your actor with the following script call:

add_actor(actor_id, index, initialize)

With actor_id being the actor's id, index being the actor's position in the group (zero-indexed: first place is 0, second is 1, etc.), and initialize being a boolean ("true" or "false" without the quotation marks). This works just like the "Change Party Members" event command, with the exception of being limited to adding members. Index and initialize are optional parameters.

 

(Edit) Also, this isn't the right subforum for this. I'm therefore moving the topic to Script Requests. Script Support is just for support with existing scripts.

Share this post


Link to post
Share on other sites

It works for a fresh project, but it clashes with Yanfly's Party System. I get the error


Script 'Yanfly Party System' line 333: NameError occurred.

undefined method 'add_actor' for class 'Game_Party'

 

It has to do with (starting at like 330)

 

 

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

 

in the Party System Script

Share this post


Link to post
Share on other sites

That's weird, my script does not reference, alias, or overwrite Game_Party#add_actor. It just creates two completely new methods.

What did you do to receive the error message?

 

Also, I just noticed a mistake in my script. It's something I copied over from a method in Game_Interpreter and then forgot to change. It is fixed in the version below.

class Game_Party < Game_Unit
 def add_actor_at(actor_id, index)
  @actors.insert(index, actor_id) unless @actors.include?(actor_id)
  $game_player.refresh
  $game_map.need_refresh = true
 end
end

class Game_Interpreter
 def add_actor(actor_id, index = $game_party.all_members.size, initialize = false)
  actor = $game_actors[actor_id]
  if actor
   if initialize
    $game_actors[actor_id].setup(actor_id)
   end
   $game_party.add_actor_at(actor_id, index)
  end
 end
end 

Share this post


Link to post
Share on other sites

I must really not know where to put these script bits.

You just gave me them, but you didn't tell what lines and what part of which script to put them in and what to replace.

 

And what I'd did was just do the script call

add_actor(5, 3, true)

 

So I think it's a matter of not knowing where to put those script bits. I don't even know if I'm supposed to keep the

class Game_Interpreter

and the last

end

 

and the

class Game_Party < Game_Unit

and its last

end

or what.

Heheh.

Share this post


Link to post
Share on other sites

Oh no, don't replace anything. Simply create a new and empty entry somewhere between "Materials" and "Main" and paste the whole thing into it.

Share this post


Link to post
Share on other sites

It works.

But due to Yanfly's Party System, the added actor becomes greyed out, essentially being "Unequipped" so to speak until

you go into the formation menu and add them.

I wouldn't know if you'd know the script to know a solution to that.

Edited by Audrey

Share this post


Link to post
Share on other sites

Fixed a bug that occurred when the index specified in the method call was higher than the amount of party members.

If an index is too high, the actor will now be inserted at the last position instead of crashing the game.

 

 

class Game_Party < Game_Unit
 def add_actor_at(actor_id, index)
  @actors.insert(index, actor_id) unless @actors.include?(actor_id)
  $game_player.refresh
  $game_map.need_refresh = true
 end
end

class Game_Interpreter
 def add_actor(actor_id, index = $game_party.all_members.size, initialize = false)
  actor = $game_actors[actor_id]
  if actor
   if initialize
    $game_actors[actor_id].setup(actor_id)
   end
   index = $game_party.all_members.size if index > $game_party.all_members.size
   $game_party.add_actor_at(actor_id, index)
  end
 end
end 

 

 

Share this post


Link to post
Share on other sites

I'm having a bit of trouble with this. Would you know how to make it so that actors added using the script call you gave me are active and not grayed out, in compatibility with Yanfly's Party System?


The reason I started this topic is because I'm trying to make a dead member switch script. When you add a member through an event call, they take the last index. So I wanted functionality to where you select a member to switch out with when an actor dies. I already have a way to choose which members in the party. It was just the indexing that I had trouble with. And now it's the fact that with that Party System script, when you script call add a member, they aren't active until you add them in the formation menu.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted