[Ace] Keeping dead characters off the map

● ARCHIVED · READ-ONLY
Started by Cutie Mark Keldeo 6 posts View original ↗
  1. I am using SoulPour777's simple player swapping system to allow the party order to be rotated on the map (eventually this will become the only way to change characters in my project but that's not important right now).  So far I have modified the script so that there is only one button that changes characters and in only one direction, as opposed to in either direction like in the default version of the script.  

    What I am trying to do next isn't nearly as simple as I thought it would be.  I would like the script to check if the next actor is downed (0 HP), and if so skip over them, and switch to the next living actor.  This is important because I am using an action battle system and can't have the player controlling a dead character.  I haven't been able to work this out myself, and have been getting all sorts of error messages in whatever I try.

    The script as I have it now (still switches to dead characters if they're next in the order) is as follows.

    Spoiler
     # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# Simple Player Swapping# Author: Soulpour777# Date Scripted: 12:18PM, April 5, 2014# Description: Allows the player to switch on to characters by pressing a left# and right button (user defined)# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= module Soulpour  module PlayerSwitch    # Which button should be pressed to switch party members from the    # formation?    # :R = W    # :L = Q    Switch_Button = :L    # What is the name of the sound effect played when you switch players?    # Sound Effect should be inside the SE folder or inside the RTP    Button_Effect = "Absorb1"  endend class Game_System  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------    attr_accessor           :leader_switch  #--------------------------------------------------------------------------  # * Alias Listings  #--------------------------------------------------------------------------    alias :soul_initialize_on_game_system         :initialize  #--------------------------------------------------------------------------  # * Object Initialization (Aliased)  #--------------------------------------------------------------------------    def initialize    soul_initialize_on_game_system    @leader_switch = 1  endend class Scene_Map < Scene_Base  #--------------------------------------------------------------------------  # * Alias Listings  #--------------------------------------------------------------------------    alias :soul_frame_update_on_scene_map         :update  #--------------------------------------------------------------------------  # * Frame Update (Aliased)  #--------------------------------------------------------------------------  def update    soul_frame_update_on_scene_map    if Input.trigger?(Soulpour::playerSwitch::Switch_Button)      RPG::SE.new(Soulpour::playerSwitch::Button_Effect, 100, 100).play      $game_party.swap_order($game_system.leader_switch, 0)      if $game_system.leader_switch == ($game_party.all_members.size) - 1        $game_system.leader_switch = 1      else        $game_system.leader_switch += 1      end    end  end  end 
    Any help on this would be amazingly appreciated. :D
  2. I don't have Ace in front of me so I can't test this, but changing that last method so it does something like this might help:

    loop $game_party.swap_order($game_system.leader_switch, 0) if $game_system.leader_switch == $game_party.all_members.size - 1 $game_system.leader_switch = 1 else $game_system.leader_switch += 1 enduntil $game_party.leader.hp > 0This will continue moving to the next person until it finds one with HP > 0.I might have the syntax a bit wrong, so you might need to look up the correct terms for looping.
  3. As you said, I did need to alter the syntax in order to match RGSS3's standards, and this is how I have it now.

    def update    soul_frame_update_on_scene_map    if Input.trigger?(Soulpour::playerSwitch::Switch_Button)      RPG::SE.new(Soulpour::playerSwitch::Button_Effect, 100, 100).play       until $game_party.members[0].hp > 0           $game_party.swap_order($game_system.leader_switch, 0)      if $game_system.leader_switch == $game_party.all_members.size - 1        $game_system.leader_switch = 1      else         $game_system.leader_switch += 1       end      end    end  endHowever this isn't appearing to do anything.  I think it's because the game is detecting that the party leader (before swapping) is still alive and thus doesn't do the swap.  On the bright side, it's free of error messages and the game isn't crashing, so it's a start!
  4. Yeah, it's because it's now checking the condition at the start of the block instead of the end, so it's looking at the hp BEFORE the swap rather than after.

    And now that I have a bit more time, I think I've found a flaw in my logic anyway. Try this instead:

    def update soul_frame_update_on_scene_map if Input.trigger?(Soulpour::playerSwitch::Switch_Button) RPG::SE.new(Soulpour::playerSwitch::Button_Effect, 100, 100).play get_next_leader get_next_leader while $game_party.leader.hp == 0 end end def get_next_leader $game_party.swap_order($game_system.leader_switch, 0) if $game_system.leader_switch == ($game_party.all_members.size) - 1 $game_system.leader_switch = 1 else $game_system.leader_switch += 1 end end I notice you also changed $game_party.leader to $game_party.members[0] - they're referring to the same actor.

    The only problem you'll have with this one is if EVERYONE in the party is dead, it'll go into an endless loop.
  5.  $game_party.leader  wasn't working for me for some reason, so I used that line (which was copied from another script), and it worked.  Actually, I'm not having issues if everyone is defeated. My script is modified so it calls a common event instead of going straight to game over, though I'm not sure if that's the reason or not.  In any sense, this is working fine for what it does. Via common events I should be able to make it so the actors automatically switch if the lead character is defeated.  Thank you for your help.  This thread can be closed.
  6. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.