Total newb needs help with notetags

Hello everyone, I'm new to the community, just picked up VX Ace during the recent Steam sale.

Let me start by explaining what I'm trying to do.  I assume once I get this figured out, I can generalize that knowledge to more advanced notetagging.

So, anyone who's played Final Fantasy VI knows that leveling up doesn't increase a character's attributes, rather, a character's level seems to figure directly into various calculations, like damage.  Now, I can actually already plug in a battler's level into the damage formula for skills, including the base attack, and it works just fine for heroes, as Actors have a "level" variable.  However, this results in monsters doing NULL damage, as Enemies don't have a "level" variable.  I imagine all I really need to do is add a class variable @level to Game_Enemy, and notetags seem like the ideal way to assign a value to that variable.

I understand notetags on a conceptual level: they add metadata to objects that can be read and interpretted by scripts.  What I'm having trouble with is how to go about applying this.  I did a bit of searching, and my first few attempts threw an error stating that there was no known method "note".  Now it doesn't appear that my script is doing anything at all.  I've checked the script for various objects, including Game_BaseItem, and I don't see anything in the code about notes, so I'm somewhat at a loss as to how to get the data I need from the notes.

Here's what my script currently looks like:

class Game_Enemy < Game_Battler  attr_accessor :level   # Add levels to monsters  alias monster_initialize initialize  def monster_initialize(index, enemy_id)    # Call the original initialize method    monster_initialized(index, enemy_id)    # Check notetags to get the monster's level    if @note =~ /<level:\s*(\d*)>/i      @level = $1.to_i    else      @level = 1 # The default if no notetag is present    end    p @level # Print level to see if it's working  endendThis post helped (in fact, I modified some of the example code here), but I still can't seem to get it working: http://forums.rpgmakerweb.com/index.php?/topic/1686-a-guide-to-notetagging/
class Game_Enemy < Game_Battler  attr_accessor :level   # Add levels to monsters  alias monster_initialize initialize  def monster_initialize(index, enemy_id)    # Call the original initialize method    monster_initialized(index, enemy_id)    # Check notetags to get the monster's level    if @note =~ /<level:\s*(\d*)>/i      @level = $1.to_i    else      @level = 1 # The default if no notetag is present    end    p @level # Print level to see if it's working  endend
When you alias a method, the first name is the copy, the second name is the original. What you're doing here is making a copy, and then deleting the copy entirely. Your method should be 'def initialize', not 'def monster_initialize'. Also, you call monster_initialized(index, enemy_id) before you check your code, but monster_initialized is not defined (from what you show us). I believe you intended monster_initialize, but again, you're currently throwing that method out the window.

try fixing that ans see if it changes anything.
also you called @note inside Game_Enemy. it's variable inside RPG::Enemy. not Game_Enemy.

you could change

@note

to

enemy.note

it will read the note you write in the enemy database entry.
Thanks, that kind of worked.  Monsters aren't doing NULL damage anymore, but adding the relevant tag to bump them up to level 99 (specifically, "<level: 99>") doesn't seem to affect damage output.  At least it seems to be defaulting to level 1 if they don't have a level (changing the default level to 99 drastically increased damage, so that part is confirmed working), but it still doesn't seem to be reading the note.

I could theoretically bump up the attack of more powerful monsters to compensate, or create an array to assign levels by enemy_id, but there are other things I'd like to use notetags for, too, so I might as well figure out what I'm doing wrong.

I've seen a few scripts designed for reading notes.  Do I possibly need one of those?  I wouldn't think so.

Maybe if I sleep on it, it will make more sense in the morning.

EDIT:

also you called @note inside Game_Enemy. it's variable inside RPG::Enemy. not Game_Enemy.

you could change

@note

to

enemy.note

it will read the note you write in the enemy database entry.
That worked!  So what is the difference then between RPG::Enemy and Game_Enemy?  Clearly I need to spend more time learning Ruby and the infrastructure that VX Ace has in place.

Thank you both for your help.
So what is the difference then between RPG::Enemy and Game_Enemy?  Clearly I need to spend more time learning Ruby and the infrastructure that VX Ace has in place.
Game_Enemy is the class that represents an instance of an enemy in-game. RPG::Enemy is the basic data structure that VX Ace uses to store information about enemies (essentially, what you enter into the database). The two are closely related, which is probably the source of your confusion.


As has already been said, the RPG::Enemy data structure is actually what uses the note tags, not the Game_Enemy instance which is created when you encounter an enemy. You can find more information about RPG::Enemy in the Ace help file.

Original thread: https://forums.rpgmakerweb.com/threads/total-newb-needs-help-with-notetags.15632/