Help for a script for actor NPC

Hello! Good morning / Afternoon / Evening
I need a script for convert an actor into a NPC, in other words, a character that appears in the group, you can give him equipment and is visible in the map but it doesn't appear like a playable character in battles, just like Futaba/Rise in Persona 5/4. If its possible it would be amazing if it can gain exp but that's optional.

I was using Non Kombat Ace from Kyonides but the script doesn't have the things i'm searching for

Thank you a lot.
Why doesn't the script work?
What you need is exactly that kind of script.
I also have my own version of that.
Yeah, i know, but the script of Kyonides give a lot of bugs, like the NPC sometimes follow the team and sometimes no, when you save the game the character wasn't visible in the game screen but when you load it becomes visible.

Maybe its because is incompatible with the Yanfly - Save Engine

Your script actually doesn't have those bugs, but do you think its possible to add the option to the non combat actor to be visible in the map? Following the characters basically. Or if it can gain EXP

Anyways, thank you a lot man
Hello! Good morning / Afternoon / Evening
I need a script for convert an actor into a NPC, in other words, a character that appears in the group, you can give him equipment and is visible in the map but it doesn't appear like a playable character in battles, just like Futaba/Rise in Persona 5/4. If its possible it would be amazing if it can gain exp but that's not neccesary.

I was using Non Kombat Ace from Kyonides but the script doesn't work pretty well.

Thank you a lot.
Well, I would dare to say that you didn't learn how to use Non Kombatant ACE properly.
Actually, it's pretty straight forward BUT I never promised the forumer that there would be a visible NPC on the map at all. Only as a follower if the followers are visible and that would be all. Yet, it never makes anything visible or invisible. My script simply excludes certain actors from battles. That's it.

Anyway, I've updated the script just in case it badly needed a tweak to let the game dev change an actor's state at any given point.
Well, I would dare to say that you didn't learn how to use Non Kombatant ACE properly.
Actually, it's pretty straight forward BUT I never promised the forumer that there would be a visible NPC on the map at all. Only as a follower if the followers are visible and that would be all. Yet, it never makes anything visible or invisible. My script simply excludes certain actors from battles. That's it.

Anyway, I've updated the script just in case it badly needed a tweak to let the game dev change an actor's state at any given point.
Oh yeah, sorry for that. It's just that i need a script that does exactly that but let the characters appear in the map following the leader. Maybe because the order of commands, when a character is added using Non Kombatant ACE the character appears like a follower but after certains events disappear.
bump
I haven't coded in a long time, please be patient with me.
If there's an error, let me know what it says specifically.

Ruby:
class Game_Actor
  # Alias the original initialize method to extend its functionality
  alias non_battle_actor_initialize initialize
  def initialize(actor_id)
    non_battle_actor_initialize(actor_id) # Call the original method
    @non_battle_actor = false # Add a new instance variable to track non-battle actor status
  end

  # Check if the actor is a non-battle actor
  def non_battle_actor?
    @non_battle_actor
  end

  # Set the actor as a non-battle actor or revert to a regular actor
  def set_non_battle_actor(flag)
    @non_battle_actor = flag
  end
end

class Game_Party < Game_Unit
  # Alias the original battle_members method to filter out non-battle actors
  alias non_battle_actor_battle_members battle_members
  def battle_members
    # Return only actors who are not marked as non-battle actors
    non_battle_actor_battle_members.select { |actor| !actor.non_battle_actor? }
  end
end

class Scene_Map < Scene_Base
  # Alias the update method to include non-battle actor position updates
  alias non_battle_actor_update update
  def update
    non_battle_actor_update # Call the original update method
    update_non_battle_actor_positions # Update the map positions of non-battle actors
  end

  # Update the character graphics for non-battle actors on the map
  def update_non_battle_actor_positions
    $game_party.members.each_with_index do |actor, index|
      next if actor.non_battle_actor? # Skip non-battle actors
      next unless $game_player.followers[index - 1] # Skip if follower does not exist
      follower = $game_player.followers[index - 1]
      # Set the follower's character graphics to match the actor's
      follower.character_name = actor.character_name
      follower.character_index = actor.character_index
    end
  end
end

class Scene_Battle < Scene_Base
  # Alias the process_victory method to include XP distribution for non-battle actors
  alias non_battle_actor_process_victory process_victory
  def process_victory
    non_battle_actor_process_victory # Call the original victory processing method
    distribute_xp_to_non_battle_actors # Distribute XP to non-battle actors
  end

  # Grant XP to non-battle actors after a battle
  def distribute_xp_to_non_battle_actors
    total_exp = $game_troop.exp_total # Get total XP from the defeated troop
    $game_party.members.each do |actor|
      next unless actor.non_battle_actor? # Skip regular actors
      actor.gain_exp(total_exp) # Grant XP to the non-battle actor
    end
  end
end

# Example of setting up a non-battle actor:
# In your game setup or event, you can use the following:
# $game_actors[ID].set_non_battle_actor(true)
# Replace ID with the actor's ID in the database.
If there's an error, let me know what it says specifically.
There are a few errors with that version.
process_victory is not in Class Scene_Battle, it's in module BattleManager
Which needs you to do the class << self as well, and the def self.process_victory

After that there is an error for follower.character_name = actor.character_name
undefined method `character_name=' for #<Game_Follower:0xf824948>
There are a few errors with that version.
process_victory is not in Class Scene_Battle, it's in module BattleManager
Which needs you to do the class << self as well, and the def self.process_victory

After that there is an error for follower.character_name = actor.character_name
undefined method `character_name=' for #<Game_Follower:0xf824948>
Sorry. I promise I'm doing my best.
Maybe this version? I'm willing to keep working until someone smarter points out that I'm not skilled enough.

Ruby:
class Game_Actor
  # Alias the original initialize method to extend its functionality
  alias non_battle_actor_initialize initialize
  def initialize(actor_id)
    non_battle_actor_initialize(actor_id) # Call the original method
    @non_battle_actor = false # Add a new instance variable to track non-battle actor status
  end

  # Check if the actor is a non-battle actor
  def non_battle_actor?
    @non_battle_actor
  end

  # Set the actor as a non-battle actor or revert to a regular actor
  def set_non_battle_actor(flag)
    @non_battle_actor = flag
  end
end

class Game_Party < Game_Unit
  # Alias the original battle_members method to filter out non-battle actors
  alias non_battle_actor_battle_members battle_members
  def battle_members
    # Return only actors who are not marked as non-battle actors
    non_battle_actor_battle_members.select { |actor| !actor.non_battle_actor? }
  end
end

class Scene_Map < Scene_Base
  # Alias the update method to include non-battle actor position updates
  alias non_battle_actor_update update
  def update
    non_battle_actor_update # Call the original update method
    update_non_battle_actor_positions # Update the map positions of non-battle actors
  end

  # Update the character graphics for non-battle actors on the map
  def update_non_battle_actor_positions
    $game_party.members.each_with_index do |actor, index|
      next unless actor.non_battle_actor? # Skip regular actors
      follower = $game_player.followers[index - 1]
      next unless follower # Skip if follower does not exist
      # Set the follower's character graphics to match the actor's
      follower.set_character(actor.character_name, actor.character_index)
    end
  end
end

module BattleManager
  class << self
    # Alias the process_victory method to include XP distribution for non-battle actors
    alias non_battle_actor_process_victory process_victory
    def process_victory
      non_battle_actor_process_victory # Call the original victory processing method
      distribute_xp_to_non_battle_actors # Distribute XP to non-battle actors
    end

    # Grant XP to non-battle actors after a battle
    def distribute_xp_to_non_battle_actors
      total_exp = $game_troop.exp_total # Get total XP from the defeated troop
      $game_party.members.each do |actor|
        next unless actor.non_battle_actor? # Skip regular actors
        actor.gain_exp(total_exp) # Grant XP to the non-battle actor
      end
    end
  end
end

class Game_Follower
  # Add a method to set the character graphics for a follower
  def set_character(character_name, character_index)
    @character_name = character_name
    @character_index = character_index
  end
end

# Example of setting up a non-battle actor:
# In your game setup or event, you can use the following:
# $game_actors[ID].set_non_battle_actor(true)
# Replace ID with the actor's ID in the database.
No man, thank you a lot, i really appreciate your efforts, after all this is just a request and your help is pretty welcome!

Anyways, the script works pretty well, but there is a minor problem, if you change some actor graphics in middle of a battle, when te battle ends, the non battle actor disappears for a second.

And that would be the only bug i found


Sorry. I promise I'm doing my best.
Maybe this version? I'm willing to keep working until someone smarter points out that I'm not skilled enough.

Ruby:
class Game_Actor
  # Alias the original initialize method to extend its functionality
  alias non_battle_actor_initialize initialize
  def initialize(actor_id)
    non_battle_actor_initialize(actor_id) # Call the original method
    @non_battle_actor = false # Add a new instance variable to track non-battle actor status
  end

  # Check if the actor is a non-battle actor
  def non_battle_actor?
    @non_battle_actor
  end

  # Set the actor as a non-battle actor or revert to a regular actor
  def set_non_battle_actor(flag)
    @non_battle_actor = flag
  end
end

class Game_Party < Game_Unit
  # Alias the original battle_members method to filter out non-battle actors
  alias non_battle_actor_battle_members battle_members
  def battle_members
    # Return only actors who are not marked as non-battle actors
    non_battle_actor_battle_members.select { |actor| !actor.non_battle_actor? }
  end
end

class Scene_Map < Scene_Base
  # Alias the update method to include non-battle actor position updates
  alias non_battle_actor_update update
  def update
    non_battle_actor_update # Call the original update method
    update_non_battle_actor_positions # Update the map positions of non-battle actors
  end

  # Update the character graphics for non-battle actors on the map
  def update_non_battle_actor_positions
    $game_party.members.each_with_index do |actor, index|
      next unless actor.non_battle_actor? # Skip regular actors
      follower = $game_player.followers[index - 1]
      next unless follower # Skip if follower does not exist
      # Set the follower's character graphics to match the actor's
      follower.set_character(actor.character_name, actor.character_index)
    end
  end
end

module BattleManager
  class << self
    # Alias the process_victory method to include XP distribution for non-battle actors
    alias non_battle_actor_process_victory process_victory
    def process_victory
      non_battle_actor_process_victory # Call the original victory processing method
      distribute_xp_to_non_battle_actors # Distribute XP to non-battle actors
    end

    # Grant XP to non-battle actors after a battle
    def distribute_xp_to_non_battle_actors
      total_exp = $game_troop.exp_total # Get total XP from the defeated troop
      $game_party.members.each do |actor|
        next unless actor.non_battle_actor? # Skip regular actors
        actor.gain_exp(total_exp) # Grant XP to the non-battle actor
      end
    end
  end
end

class Game_Follower
  # Add a method to set the character graphics for a follower
  def set_character(character_name, character_index)
    @character_name = character_name
    @character_index = character_index
  end
end

# Example of setting up a non-battle actor:
# In your game setup or event, you can use the following:
# $game_actors[ID].set_non_battle_actor(true)
# Replace ID with the actor's ID in the database.
Maybe this version?
Thanks I was struggling to understand how to get the graphics to show up.
Using a bit of what you wrote I was able to make my version work as intended.
Thank you.

*update - almost. There's just one small glitch I have to work out.
Oh also, do you think that it's possible to do it compatible with the MogHunter - Battle Result script? Because experience is gained after the battle, the script gives some bugs.
Here the link (By Roninator of course xD): https://www.mediafire.com/file/hrt0l2ae820c5cj/Master_11_3.zip/file
Thanks I was struggling to understand how to get the graphics to show up.
Using a bit of what you wrote I was able to make my version work as intended.
Thank you.

*update - almost. There's just one small glitch I have to work out.
I'm happy that it worked out for the most part!
Oh also, do you think that it's possible to do it compatible with the MogHunter - Battle Result script? Because experience is gained after the battle, the script gives some bugs.
Here the link (By Roninator of course xD): https://www.mediafire.com/file/hrt0l2ae820c5cj/Master_11_3.zip/file
Sorry, I don't download links from Mediafire. However, he's in this thread and said that he's working things out with his own code! I'm sure he wouldn't mind helping you. Sorry for the trouble!
compatible with the MogHunter
Script is finished and updated. Tested with Moghunter demo, works fine.
I don't download links from Mediafire.
Sorry to hear that. You must not have sufficient protection on your computer.
he's in this thread and said that he's working things out with his own code!
It's finished and working. Thanks for the guidance. I generally good at modifying code, not making it up.
Why doesn't the script work?
What you need is exactly that kind of script.
I also have my own version of that.

Hey man, i was testing and there are still some bugs.

Like i said to CrushedCentipede there is a bug when you change graphics to actors in middle of a battle (Even if the change isn't for the non combat actor), at the end of the battle for a second the character becomes invisible and after that becomes visible again.

Also the option of "Disable following" doesn't work anymore, when you try it, the following characters dissapear for an instant and appear again.

And finally, i tested with moghunter demo and the non combat actor still doesn't win exp. This is not a serious problem but if its possible to fix it i would appreciate it a lot.
Hey man, i was testing and there are still some bugs.

Like i said to CrushedCentipede there is a bug when you change graphics to actors in middle of a battle (Even if the change isn't for the non combat actor), at the end of the battle for a second the character becomes invisible and after that becomes visible again.

Also the option of "Disable following" doesn't work anymore, when you try it, the following characters dissapear for an instant and appear again.

And finally, i tested with moghunter demo and the non combat actor still doesn't win exp. This is not a serious problem but if its possible to fix it i would appreciate it a lot.
I can only extend my support so far.
Changing graphics is something that I don't know how you're doing it. so for me to even contemplate what is happening, I need to know what you are doing that accomplishes this.
But it is also an minor annoyance.

I will work on the disable followers thing.

I tested for bug crashes with moghunter demo. I'll look at the exp thing, but no promises.
I can only extend my support so far.
Changing graphics is something that I don't know how you're doing it. so for me to even contemplate what is happening, I need to know what you are doing that accomplishes this.
But it is also an minor annoyance.

I will work on the disable followers thing.

I tested for bug crashes with moghunter demo. I'll look at the exp thing, but no promises.
Oh with changing grapichs i mean the command default of rpg maker, you know, you can change the character and face of an actor. I use it before and after a fight for only change faces, but even if you change the face of an actor that isn't the non combat actor gives the error that i told you
if you change the face of an actor that isn't the non combat actor gives the error
That's not an error, it's a graphical glitch. The scene battle does not have the function to show the graphics, when the map scene takes over it processes the function. This is unavoidable in my opinion.

I updated to allow the followers to hide. (added one thing to one line)

as for mog hunter exp thing, it's proving to be an issue. I just found out that my script is not doing the exp properly. Unless the reserve member exp option is checked only battle members get exp.
I'll work on that.

I also cleaned up a lot of code as I discovered that after getting it working I had a lot that was not needed.

I'll update again when I got this done.

*Update, try again @ElHielo7
Hey man, the script isn't working anymore, i think i put the notetags well but now the actor appears always in battle. @Roninator2

Ah, and if its possible, there is a bug with the yanfly save engine where if you load the file from the menu with the non actor in the team its vissible but if you save the actor is not visible (In the file)

And one final thing, is that the Yanfly Battle Engine gives a visual glitch that the bars are stretched in the battle when there are less than 4 members in battle
That's not an error, it's a graphical glitch. The scene battle does not have the function to show the graphics, when the map scene takes over it processes the function. This is unavoidable in my opinion.

I updated to allow the followers to hide. (added one thing to one line)

as for mog hunter exp thing, it's proving to be an issue. I just found out that my script is not doing the exp properly. Unless the reserve member exp option is checked only battle members get exp.
I'll work on that.

I also cleaned up a lot of code as I discovered that after getting it working I had a lot that was not needed.

I'll update again when I got this done.

*Update, try again @ElHielo7[/USER
[/QUOTE]
now the actor appears always in battle
They don't for me.

there is a bug with the yanfly save engine where if you load the file from the menu with the non actor in the team its vissible but if you save the actor is not visible (In the file)
Then you need a yanfly save file patch. That may very well be a side script. So you want the non battle actor to show in the save file? By default it uses the battle members, that's all it shows for me.
Spoiler: save
Ruby:
class Window_FileStatus < Window_Base
  #--------------------------------------------------------------------------
  # draw_save_characters
  #--------------------------------------------------------------------------
  def draw_save_characters(dx, dy)
    return if @header[:party].nil?
    reset_font_settings
    make_font_smaller
    dw = (contents.width - dx) / @header[:party].battle_members.size
    dx += dw/2
    count = 1
    for member in @header[:party].members
      next if member.nil?
      next if count > 4
      member = @header[:actors][member.id]
      change_color(normal_color)
      draw_actor_graphic(member, dx, dy)
      text = member.name
      draw_text(dx-dw/2, dy, dw, line_height, text, 1)
      text = member.level.group
      draw_text(dx-dw/2, dy-line_height, dw-4, line_height, text, 2)
      cx = text_size(text).width
      change_color(system_color)
      text = Vocab::level_a
      draw_text(dx-dw/2, dy-line_height, dw-cx-4, line_height, text, 2)
      dx += dw
      count += 1
    end
  end
end
Yanfly Battle Engine gives a visual glitch that the bars are stretched in the battle when there are less than 4 members in battle
I think you're confusing intended result for a glitch. I do not see any issue.


I did find a bug though it seems a previous version worked better for one part so I reverted some of the code and from my end all is working.

Original thread: https://forums.rpgmakerweb.com/threads/help-for-a-script-for-actor-npc.174256/