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.

way or script call to check actors in party?

i don't know if this is the right section to post this if its not i apologize. I also feel like an idiot posting basically the last 3 topics here and am sorry. I'm using tomoakys tactical battle system and it has me tell it what actors to use for battles via events. I specify actors with a script call like this :$game_system.srpg_member = [0, 1, 2, 3]. I'm wondering if there's a way to have it check what actors are in my party and place them. Any help would be appreciated.
 
I'm a little rusty with RPG Maker, but it would be something like this:

if $game_party.actors.include?($game_actors[1])

$game_party.actors should be an array, so include? can be used to see if the array contains a certain thing. I'm assuming these things are $game_actors. I may be wrong.

You'd use this in a conditional branch, using the "script" condition. So it would be something like:

conditional branch
script


$game_party.actors.include?($game_actors[1]) == 1


Where it will equal 1 if true, 0 if false. (You don't need the "== 1" but I've put it there for readability.)

Hopefully somebody else can elaborate if that's right or not, as I don't have RM in front of me.
 
sorry if i dont follow the only reason i even knew that line of script was cause the tbs demo used it. I'm guessing what you said checks for one actor. what im hoping to get it it to do is just place whatever actors are in my party. this way though it seems to require the actors specified and that number of actors. sorry for not being clearer
 
Ah, I get you.

I think that would have to be done in a script, as you'd have to work out how many members are in the party, too.

Something like this. Create a new script in the script editor.

Code:
class Interpreter

  def battle_members

    # new array to replace [1, 2, 3, 4]

    actors = Array.new

    # for each member in the party

    for i in 0..$game_party.actors.size-1

      # add their id to the array

      actors.push($game_party.actors[i].actor_id)

    end

    # call the original line but with our array instead of [1, 2, 3, 4]

    $game_system.srpg_member = array

  end

end

Then call battle_members instead of $game_system.srpg_member = [0, 1, 2, 3].

There's a chance I've got the actor_id bit wrong (the longest line), it might just be .id not .actor_id.

I think that should work.
 
Will do when i get home. I'll let you know if there's any problems. Thanks so much. Gonna see if i can see avengers 2 in the mean time.
EDIT:
i pasted the script and in the event called battle_members as you said. it gave this error.

Namerror occurred while running script.
undefined local variable or method 'battle_members' for #<Gamezz_Interpreter:0x298b550>
 
Ah, sorry. If it's VX Ace it will be:

Code:
 

class Game_Actor

  attr_accessor :actor_id

end

 

class Game_Interpreter

  def battle_members

    # new array to replace [1, 2, 3, 4]

    actors = Array.new

    # for each member in the party

    for i in 0..$game_party.actors.size-1

      # add their id to the array

      actors.push($game_party.actors[i].actor_id)

    end

    # call the original line but with our array instead of [1, 2, 3, 4]

    $game_system.srpg_member = array

  end

end

They renamed Interpreter to Game_Interpreter.

I have RM in front of me so I'll check the rest now.
 
I'm not using vx ace just vx. i did try that though and got this error at line 11 of what you posted.

script ' ' line 11:no method error occurred.
undefined 'method actors' for #<game_party:0x29aace0>
 
Right, think I'm there now.

Code:
    class Game_Party

      attr_accessor :actors

    end

 

    class Game_Interpreter

      def battle_members

        # new array to replace [1, 2, 3, 4]

        actors = Array.new

        # for each member in the party

        for i in 0..$game_party.actors.size-1

          # add their id to the array

          actors.push($game_party.actors[i])

        end

        # call the original line but with our array instead of [1, 2, 3, 4]

        $game_system.srpg_member = actors

      end

    end

Have tested properly this time. Assuming the line you're using is correct, this will work.
 
no errors from what you coded anymore but getting this error unfortunately in the tbs script. his translated demo can be found below after clicking on srpg2. very sorry about this.

script 'game_srpgevent' line 97 no method error occurred
undefined method 'set_tile_effect' for nil:nilclass

https://momorpg2012.wordpress.com/download/

edit: sorry had the wrong link up for a bit the one above is correct
 
Use THREE dots instead of TWO:

for i in 0..$game_party.actors.size - 1 (two dots in the i in 0..range)

That will increment i to 5 even if the actors.size is 4, which is why -1 is needed. The ruby guys already saw this and use an additional period in the range specification.

for i in 0...$game_party.actors.size (three dots in the i in 0...range)
end

Also a brief note, $game_actors works a bit different. $game_actors[0] is always nil, so your first Actor starts at $game_actors[1]. At least in XP, not sure about VX series. That can cause some crashes where it says "no method error for nil class". Its also most likely what caused your error above. Amy gets slack due to her rust, but was very very close.
 
Thank you. I'm thoroughly embarrassed now :robot:

Let's try again.

Code:
class Game_Party

   attr_accessor :actors

end

     

class Game_Interpreter

  def battle_members

    # new array to replace [1, 2, 3, 4]

    actors = Array.new

    # for each member in the party

    for i in 1..$game_party.actors.size

      # add their id to the array

      actors.push($game_party.actors[i])

    end

    # call the original line but with our array instead of [1, 2, 3, 4]

    $game_system.srpg_member = actors

  end

end

1..$game_party.actors.size because it's incrementing from 1 to 4 now instead of 0 to 3.
 

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