Hello again. So I've started to script, thanks to the tutorials I have in my drive. Got them working just today. I have a question about assigning variables. Basically, what I want is...
I want to assign an enemy a simple level number. For example, a Basilisk is assigned a variable level 2. So to go on, for example:
Skeleton - assigned a variable named enemy level with the value of 1
Basilisk - assigned a variable named enemy level with the value of 2
How can I get this done? I made this on Game_Battler where I assigned it to an attribute accessor but I have no idea after that.
I would probably do something like this
class RPG::Enemy
def level
@level ||= case @id
when 1 then 1
when 2 then 1
when 3 then 2
when 4..10 then 3 # enemies of id 4 through 10
# and so on
end
return @level
end
end
class Game_Enemy < Game_Battler
def enemy_level
return $data_enemies[@enemy_id].level
end
end
Can be pasted anywhere above Main. Untested--solely going off intuition here.
How are the enemies being given that Level? In the Name of the Enemy itself, or Battle Script from Troops?
Name: Ghost[level=1]
Battle: $game_troop.enemies[0].level = 1
Just curious...
Quote from: KK20 on February 12, 2014, 11:29:11 am
@level |= case @id
this will throws an error, it should be "||="
Fixed. My memory sometimes fails me.
Hi again. I'll be trying the script. I was out for a while and I noticed I got help quickly. Thanks!