Ruby/RGSSx questions that don't deserve their own thread

you can check the troop with

$game_troop.members.each do |enemy| id = enemy.enemy_idthere you can check the ID's and do your stuff. 
I know about the id but what I am asking for is not the ID of the enemy but the number. Is it the first one on the rank? the second? the third? And so on.
oh... yeah, to get the 4th member of the troop you can simply do this

enemy = $game_troop.members[3]$game_troop.members[3] is the 4th enemy since it starts counting at 0 ... 
I'm not sure what number you actually wanted, so I'd add some suggestions:

enemy.index

returns the enemies position in the troop, zero corresponds to the first position.

$game_troop.members.count { |member| member.id == 1 }

returns how many members in the troop have id 1 (including dead/hidden members).

If you want to exclude dead enemies from the count, use  $game_troop.alive_members  instead.
Ahhh that is very interesting. That is one way, hmmm. I have another question. Is there a possible way to use this as a check so whenever you select an enemy to attack, you can't select someone in the index of 4 and above?
You could, if you would modify the methods that handle the targetting. On my custom battle system I made the targetting system to be able to run RGSS3 lines to determine which battler can be targetted.
Do you just want to prevent the player to select that enemy in the action selection phase? Or do you want to prevent the enemy from getting hit by any attack?
 

In the first case, you can modify the Window_BattleEnemy class, which provides the enemy selection window:

The superclass Window_Selectable already provides a method to decide if an item shoud be selectable. You can overwrite it for this purpose:

class Window_BattleEnemy   def current_item_enabled?    not enemy.state?(18)  # Example: Selected enemy can't be chosen when inflicted with state 18  endendDifferent battle systems may implement the target selection differently though.
Thanks Another Fen. Yes, I would want to prevent the actors from killing or hitting those enemies that are under the number (or index) of 4 and above. It means I can only target 1 - 3. If they die, then I can target anyone among them who changes their index as the other ones are killed. For example, I have:

Slime A (index 1)

Slime B (index 2)

Slime C (index 3)

Slime D (index 4)

In battle, I can't target Slime D (slime D can still attack me btw)... then suddenly, I killed Slime B. Therefore:

Slime A (index 1)

Slime C (index 2)

Slime D (index 3)

So I can strike all of them now here.

How do I achieve this?
class Window_BattleEnemy   def current_item_enabled?    not enemy.state?(18)  # Example: Selected enemy can't be chosen when inflicted with state 18  endend
For some reason i really dislike the human readability of that statement.

I personally preffer this...

class Window_BattleEnemy def current_item_enabled? !enemy.state?(18) endendEven though its completely identical in terms of everything - efficiency, logic etc. to me, that just seems much nicer to look at 😀
Hmmm, thanks for the answers. So does that mean there should be a state 18 inflicted to them right at the start of battle?
@Another Fen

Yeap, the error message that showed was basically what was in the picture if I remember correctly!
For some reason i really dislike the human readability of that statement.

I personally preffer this...

class Window_BattleEnemy def current_item_enabled? !enemy.state?(18) endendEven though its completely identical in terms of everything - efficiency, logic etc. to me, that just seems much nicer to look at 😀
`not` looks much more human-readable to me than an exclamation mark.
Yeah, I'm with Dekita on that one. not might be more human-readable, but ! is more common - I had to stop and think about the not for a bit.
It works fine now. I just have a question about how sprites can be drawn in sprite battler. For once, I like the battlers of the enemies, but I also like sprites of the actors to be drawn on the right side. Now I am not looking for an sideview battler or any complex visual battler. I just want to show the sprites of the actors on the right side and if there's a way to make them in Step Animation in a certain direction (Direction Fixed).

Something like this:

AoTm4g2.jpg


They are facing the left side, on step animation and just stay there. They don't have to move and have an attack animation.
That IS a side view battle system. It doesn't have to be complicated like actors with different poses/behaviours, moving forward/backwards/to the enemies, throwing things. It can be just actor sprites on the battle field, either animating, or not.
Yes, still using not, and and or is a bit of a bad habit I think. I see less people using it either, especially since even the VXAce started using the symbols in its standard scriptset, so I have to somehow agree with Dekita/Shaz.

@Milena:

You can enable battler sprites for battlers by changing the definition of the  use_sprite?  method of Game_Actor. In addition, even if you don't plan to make your actors move across the screen, you'd still have to provide suitable methods for  screen_x, screen_y, screen_z and battler_name. If you want to animate your battler characters instead of giving them a static image, you'd have to implement that as well (unlike map characters, battlers are not constantly updated by default and use a different sprite type).

@Jestereir:
Without the exact error message I can't tell for sure which script command caused the commotion of course, but chances are its because of a command from Galv's Character Effects. While I'm still not sure why the event was executed before switching to the map, you should be careful when using those commands while calling a menu screen from another event.

If it was the fault of the Character Effects script, you could fix that issue by modifying the script a bit:
Search for this line 

SceneManager.scene.spriteset.refresh_effects

and add 

if SceneManager.scene_is?(Scene_Map)

to the end of each occurrance (three of them already end with  if refresh , you don't necessarily have to "fix" those here).
I am just curious, I implemented "Khas Awesome Lights" script and with this script I am able to make a player lantern (as mentioned in the script).

Now I wonder, can I make more than just one lantern... so my question is: is the command $game_map.lantern provided by RPG Maker or is it something Khas built in??
Khas added it, best to make a thread for it if you require further help 🙂
okay, I try it and open new thread. ^^
You don't need to open a new topic.


I can tell you that it is not possible to make more than 1 lantern effect.


Khas is working on a new script, maybe that will include that feature.

Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/