Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Party Leader "Rotating" (with a check to see if the actor is dead) -- How?

Hi hi!

This is my last request. I really hope someone can help me, because I need it done within 4 hours or so. I'm trying to make it so that with a button you can change party leaders. I already assigned the button and got it to work with the code below, but it also switches to dead members. I want it to skip the dead members as party leader.

If someone could help me with that I will love you forever! I also kind of need a second button to scroll backwards, but it's OK if no one knows how to do that.

The code that I have atm:

Code:
(In Game Map)

 (def update)     
if Input.trigger?($PT_Rotate_Left) || Input.press?($PT_Rotate_Left) && $PT_Rotate_Left.nil?
      rotate_party_left
    end

def rotate_party_left
    leader = $game_party.actors[0]
    $game_party.actors.delete_at(0)
    $game_party.actors.push(leader)
    $game_player.refresh
  end

Thank you!!! x 500
 
Code:
class Game_Party
  def rotate_next_actor
    return if all_dead?
    @actors << @actors.shift
    @actors << @actors.shift while @actors[0].dead?
  end
  def rotate_last_actor
    return if all_dead?
    @actors.insert(0, @actors.pop)
    @actors.insert(0, @actors.pop) while @actors[0].dead?
  end
end

class Game_Player
  Rotate_Party_Next_Button = Input::L
  Rotate_Party_Last_Button = Input::R
  alias_method :seph_partyrotate_gmplyr_update, :update
  def update
    if Input.trigger?(Rotate_Party_Next_Button)
      $game_party.rotate_next_actor
      refresh
    elsif Input.trigger?(Rotate_Party_Last_Button)
      $game_party.rotate_last_actor
      refresh
    end
    seph_partyrotate_gmplyr_update
  end
end
 
Try that (not tested)
 
It didn't work. I tried it (in case it's important info, I have three actors in the party) and got this message:

Script 'SephirothSpawn - Leader Switch' line 10: NoMethodError occurred.

undefined method `dead?' for 3:Fixnum

Edit: I've discovered the problem. $actors[0] only returns the ID number of the first member of the party. To remedy the error I tried this, and it worked.
Simply replace the instances of this:
Code:
@actors[0].dead?
...With this:
Code:
members[0].dead?

Yet another problem that's presented, though, is how to automatically switch the leader to the next living member when a party member is determined to be dead.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top