Save-Point
Non Kombatant - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+--- Thread: Non Kombatant (/thread-9006.html)



Non Kombatant - kyonides - 08-30-2024

Non Kombatant
XP + VX
Version 0.2.0

by Kyonides

Introduction

This scriptlet allows you to prevent a certain hero from being present during battles.

This feature can also be disabled at any given time.

There are separate calls for party members and individual heroes. This lets you include or exclude any hero no matter if he has ever joined the party or has recently left it. How convenient that is, don't you agree? Winking

RMXP Script

Code:
# * Non Kombatant XP * #
#   Scripter : Kyonides Arkanthes
#   v0.2.0 - 2024-08-30

# This scriptlet allows you to prevent a certain hero from being present during
# battles. This feature can also be disabled at any given time.

# There are separate calls for party members and individual heroes. This lets
# you include or exclude any hero no matter if he has ever joined the party or
# has recently left it.

# Warning: Game_Party#actors method has been aliased.

# * Script Calls * #
# - Set Party Member as NPC - Disabling him during battles
# $game_party.actor_as_npc(Index)

# - Set Party Single Hero as NPC - Disabling him during battles
# $game_actors[ID].is_npc = true

# - Set Party Member as Combatant - Enabling him during battles
# $game_party.npc_as_actor(Index)

# - Set Hero as Combatant - Enabling him during battles
# $game_actors[ID].is_npc = false

class Game_BattleAction
  alias :kyon_non_kombat_gm_bta_dc_rand_tgt_act :decide_random_target_for_actor
  alias :kyon_non_kombat_gm_bta_dc_rand_tgt_act :decide_random_target_for_enemy
  def decide_random_target_for_actor
    kyon_non_kombat_gm_bta_dc_rand_tgt_act
    clear unless @target_index
  end

  def decide_random_target_for_enemy
    kyon_non_kombat_gm_bta_dc_rand_tgt_act
    clear unless @target_index
  end
end

class Game_Actor
  attr_accessor :is_npc
end

class Game_Party
  alias :kyon_non_kombat_gm_pty_rand_trgt_actor :random_target_actor
  alias :kyon_non_kombat_gm_pty_actors :actors
  def npcs
    @actors.select {|actor| actor.is_npc }
  end

  def actors_without_npcs
    @actors.reject {|actor| actor.is_npc }
  end

  def actors
    $game_temp.in_battle ? actors_without_npcs : kyon_non_kombat_gm_pty_actors
  end

  def actor_as_npc(n)
    @actors[n].is_npc = true
  end

  def npc_as_actor(n)
    @actors[n].is_npc = false
  end

  def random_target_actor(hp0=false)
    actor = kyon_non_kombat_gm_pty_rand_trgt_actor(hp0)
    return if !actor or actor.is_npc
    actor
  end
end

RMVX Script

Code:
# * Non Kombatant VX * #
#   Scripter : Kyonides Arkanthes
#   v0.2.0 - 2024-08-30

# This scriptlet allows you to prevent a certain hero from being present during
# battles. This feature can also be disabled at any given time.

# There are separate calls for party members and individual heroes. This lets
# you include or exclude any hero no matter if he has ever joined the party or
# has recently left it.

# Warning: Game_Party#members method has been aliased.

# * Script Calls * #
# - Set Party Member as NPC - Disabling him during battles
# $game_party.actor_as_npc(Index)

# - Set Party Single Hero as NPC - Disabling him during battles
# $game_actors[ID].is_npc = true

# - Set Party Member as Combatant - Enabling him during battles
# $game_party.npc_as_actor(Index)

# - Set Hero as Combatant - Enabling him during battles
# $game_actors[ID].is_npc = false

class Game_BattleAction
  alias :kyon_non_kombat_gm_bta_dc_rand_tgt :decide_random_target
  alias :kyon_non_kombat_gm_bta_dc_last_tgt :decide_last_target
  def decide_random_target
    kyon_non_kombat_gm_bta_dc_rand_tgt
    clear unless @target_index
  end

  def decide_last_target
    kyon_non_kombat_gm_bta_dc_last_tgt
    clear unless @target_index
  end
end

class Game_Actor
  attr_accessor :is_npc
end

class Game_Party
  alias :kyon_non_kombat_gm_pty_rand_trgt_actor :random_target_actor
  alias :kyon_non_kombat_gm_pty_members :members
  def npcs
    members.select {|actor| actor.is_npc }
  end

  def members_without_npcs
    members.reject {|actor| actor.is_npc }
  end

  def members
    $game_temp.in_battle ? actors_without_npcs : kyon_non_kombat_gm_pty_members
  end

  def actor_as_npc(n)
    members[n].is_npc = true
  end

  def npc_as_actor(n)
    members[n].is_npc = false
  end
end


Terms & Conditions

Free Beer for use in non commercial games but you gotta own a legal copy of the engine. Tongue sticking out
Due credit is mandatory.
That's it! Tongue sticking out


RE: Non Kombatant XP - kyonides - 08-30-2024

Maintenance Update

During my playtests I noticed that there was a slight chance for the enemy troopers to make your game crash in no time. This happened whenever they had ever picked an actor that had been excluded via one of the script calls available here.

Version 0.2.0 includes:

Two methods in the Game_BattleAction class and one in the Game_Party class have been aliased.

If the enemy trooper still picks an actor that has the is_npc flag turned on, the trooper will do nothing at the end.


RE: Non Kombatant - kyonides - 08-30-2024

The Script Has Been Ported to RMVX!

Now RMVX users that might still exist Happy with a sweat can also let their heroes Slayne Ghim become lazy enough as to stay away from battle and live another day just like RMXP heroes can! Laughing