p $game_troop
so I put this into my common event triggered by a skill, to check the data on the enemies to see if I could figure out what their enemy target number (in battle, not in the database) was, but i couldn't figure it out. i mean their hit points, name, which troop # they were, and so on all displayed, but I couldn't tell what differentiated zombie 1 from zombie 2.
Any ideas?
I'm trying to set up some custom skills that can target different enemies in battle and display the name of the enemy you are targeting in a loop, so if you had three enemies on the screen, two zombies and a lich, it would basically say something like
"zombie"
"zombie"
"lich"
zombie --> zombie --> lich
and then loop back to zombie.
If I could get it to display something like
'zombie[1]'
'zombie[2]'
'lich'
That would be even better, but I'm not picky.
$game_troop.enemies[Enemy_ID].name
Of course, you can then set that as a variable and call it at will. For example, if I was battling a troop with a Ghost and a Sahagin, $game_troop.enemies[1].name would return Ghost.
You could also modify the .name part to other things, such as .base_atk.
Quote from: cozziekuns on June 06, 2010, 04:43:47 AM
$game_troop.enemies[Enemy_ID].name
Of course, you can then set that as a variable and call it at will. For example, if I was battling a troop with a Ghost and a Sahagin, $game_troop.enemies[1].name would return Ghost.
You could also modify the .name part to other things, such as .base_atk.
your version looks better than what I've come up with, but I'm wondering,
Is this different from game_troop.member_index?
I just realized 0 = 1 in the program, so displaying different mobs 1-3 would be
p $game_troop.enemies[0].name
p $game_troop.enemies[1].name
p $game_troop.enemies[2].name
Now if I only could remember how to stick those data bits into a variable.
Quote from: shintashi on June 06, 2010, 05:01:46 AM
I just realized 0 = 1 in the program, so displaying different mobs 1-3 would be
p $game_troop.enemies[0].name
p $game_troop.enemies[1].name
p $game_troop.enemies[2].name
Now if I only could remember how to stick those data bits into a variable.
well, using ccoa's \v[variable #] thingymabob I came up with this.
$game_variables[404] = $game_troop.enemies[0].name
Text: the target is \v[404]
and it works great in battle ^^
I found out if you query the name of something that doesn't exist, the game crashes. Is there a way to check the number of monsters loaded so the loop doesn't exceed that value?
It sounds like I need a for-loop.
I tried something like this:
$game_troop.enemies[3].name.blank?
$game_variables[405] =
$game_variables[406]
else
$game_variables[405] =
$game_troop.enemies[3].name
end
but it wasn't as functional as
if $game_troop.enemies[2].name != ""
$game_variables[405] =
$game_troop.enemies[2].name
end
which also doesn't work for enemies[3], and crashes just the same, but at least it sort of works. The basic problem is called
'undefined method 'name'
I'm not certain but I length monsters are loaded through an array similar to push/pop, and if I can check the game_troop.length or something similar to tell me the array length, I might be able to restrict how many monsters I can target.
Yeah, something like:
Conditonal Branch: (Script): $game_troop.enemies[0] != nil
$game_variables[1] = $game_troop.enemies[0].name
Branch End
Conditonal Branch: (Script): $game_troop.enemies[1] != nil
$game_variables[2] = $game_troop.enemies[1].name
Branch End
And just repeat until you get to the max number of enemies (10 or so).
Oh yeah, there's probably a better method if I recall correctly, but this should work all the same.
Quote from: cozziekuns on June 06, 2010, 10:26:19 PM
Yeah, something like:
Conditonal Branch: (Script): $game_troop.enemies[0] != nil
$game_variables[1] = $game_troop.enemies[0].name
Branch End
Conditonal Branch: (Script): $game_troop.enemies[1] != nil
$game_variables[2] = $game_troop.enemies[1].name
Branch End
And just repeat until you get to the max number of enemies (10 or so).
Oh yeah, there's probably a better method if I recall correctly, but this should work all the same.
yeah, like that, but sort of different. This is what I got,
[spoiler=sequential](https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg718.imageshack.us%2Fimg718%2F4489%2Ftestscript.png&hash=771b4542aaf50b942aa94955ea98aa5aed2f867d) (http://img718.imageshack.us/i/testscript.png/)[/spoiler]
haven't tested it yet, but I need to be "choosing" rather than "sorting" and right now i'm trying to figure out how to get choices to exist in a common event that isn't set to parallel or autorun. Do you know how to use label/jump to label? Because they seem like they could give me a temporary loop without having to create multiple event pages for sorting.
edit: tested what's above: strange effect, when you kill a monster on the end, like monster number 3, the game doesn't remove them from the list, so when you cast the spell after they are dead, it still detects them, even though they aren't on the screen. This is an even better reason to have select-ability.
Conditonal Branch: (Script): $game_troop.enemies[0] != nil
$game_variables[1] = $game_troop.enemies[0].name
Branch End
Conditonal Branch: (Script): $game_troop.enemies[1] != nil
$game_variables[2] = $game_troop.enemies[1].name
Branch End
You could just use this -.-, dunno why it's not working for you. But whatever, labels are labels. Jump to label means your jumping to that position.
So, something simple like:
Label: A
Text: Variable + 1
Control Variable: [0001: Label Variable] += 1
Conditional Branch: Variable [0001: Label Variable] == 3
Text: Variable equals five
else
Jump to Label: A
end
Which would repeat until the variable 1 equaled three.
thanks much on the labels. Your version of the conditional !=nil is better in retrospect. I'll be programming more on this stuff after my final tonight.