I want to read the first feature value of an enemy that exists. Can someone tell me what I'm doing wrong? Also is there a way to read the note field of the enemy?
$game_enemies[a.enemy_id].features[0].value
a.enemy_id is defined as 1 in the case I'm testing.
$game_enemies is only accessible in battles by default, I think, and lacks some info that $data_enemies has.
Try to use $data_enemies instead.
$data_enemies[id].note will return the contents of the note-box of the enemy.
Thank you. I'm in Battles when using that variable. I'll try $data_enemies anyway when I get home. Is there nothing wrong with the rest of the line?
What happens when you did it? and how exactly are you testing it?
Nothing wrong with the rest of your line.
Exactly where are you calling this line, and why do you need the 1st feature value? What will you do after you get the value?
If you are in battle and if the troop doesn't have the enemy with the ID of 1 in it, it will throw a NoMethod error.
You will need to extract the enemies' ID based on what kind of enemies you have in the troop.
$data_troop[troop_id].members[index] will get you the whole $game_enemies[enemy_id] variable, so you can read the first feature value from that.
$data_troop[troop_id].members[index].features[0].value should never throw an error if you get the correct IDs for the troop and the member index, assuming that $game_enemies does got the feature values accessible. If not, just extract the ID of the returned troop member, and use that for the id in $data_enemies[id].
But again, depending on where you call your line, there might be an easier solution.
It's $game_troop not $game_enemies
$game_troop.members[0] returns the first enemy.
I'm doing this as a custom formula. In the skill() method I currently now have:
This formula is used when a database "enemy" is doing a skill because they don't have a level, otherwise the variable would be a.level.
damageMod = lowDamage + ((highDamage - lowDamage) * (($data_enemies[a.enemy_id].note).to_i - 1) / 98)where $data_enemies[a.enemy_id].note is the npc level.
returns 0 at the end of the method when it should return a different number.
I know something is throwing an error because a msgbox() isn't showing up in a non-conditional part of the method after that code piece.
EDIT: I edited the code to have variable.to_i and it works now. Yeh! Yea idk what I did wrong originally. I was almost sure I tried the code above. :/