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.

Check the actors position in party and its state

I don't know if this topic belongs here because it's somewhat related to events.
If not, then someone please move it.

What I'm trying to do is to check if an actor in a certain position in the party (index) has a certain state inflicted. But I want to use this in a conditional branch in the event editor.

I tried to use this code:
Code:
$game_party.actors[0].state == "Knockout"
but it gives me an error in Game_Actor script...

Is there some kind of code that can do this? Or it needs an edit or new script for this to work?
 
Trickster is correct, but just to elaborate (in case you don't know much about scripting... although it seems you do), the state_id refers to the state's position/order within the database. "Knockout" would be 1 by default.

You receive an error because the code is trying to compare a number to a string (a word). You might be able to use the following code instead, if you prefer:
Code:
$game_party.actors[0].state[b].name[/b] == 'Knockout'
Although I haven't tried it, so I'm not sure if it will allow that.
 
Thanks to both of you for your help.

Retlaf, your code didn't work but thanks anyway.

Trickster, it worked perfectly. But I have another question:
How can I say if an actor has a different state then the one typed?
 
Oh, sorry about that. My code didn't work because characters can have many different states on them at a given time. Therefore, asking for just one will not do; how does the game know which one is being asked for? (this was the initial error to begin with)

Anyway, to answer your new question, use:

Code:
$game_party.actors[0].state?(state_id) [b]and/or[/b] $game_party.actors[0].state?(state_id) [b]and/or[/b] [i](etc.) (and/or are interchangeable)[/i]

This solution is rather messy, but I don't know of another way which is condensible to one line (which I believe is necessary in order to use within conditional branch events). Trickster will likely know of one, but if the messiness doesn't bother you, the above will work.
 

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