I want to check the level of an actor, but not a specific actor. I want to check the Level of an actor that is the target... I want to use it in a formula for something but it can't be actor specific.
Is there a Script Call or something for this?
I've done it in the damage formula with a.level, a the level of the attacker (or if it is the defender, b.level). Be advised though that by default, enemies don't have levels, so that might crash the game if the skill is used by enemies too.
Oh... I forgot to mention this not for a damage formula. This is for an unrelated formula. Something that doesn't use the conventional formula rules and variables.
How can you have a target if it's not a damage formula? How do you specify who the target is, because target is used in the regular battle context. Where are you planning on putting this call?
In the damage formula. it'd be "b.level" to get the level of the target. Normally enemy's don't have levels (enemy levels plugins might change that), as bgillisp mentioned, but you could do a workaround like so:
(b.level || 1)
The || means "or", so the line is "target's level OR 1". So if the target doesn't have a level, it gives 1, and if they do, you get their level. The parenthesis are to enforce order of operations so it acts like we expect it to.
||'s behavior is a bit more complicated than that, because Javascript is a very mystical and mysterious language, but for a damage formula that's sufficient.
I'm looking for a way to call the level for an actor.... Not for the damage formula but something else... an EXP Formula or a HP formula. Or a Custom Formula where the formula is generic so there's no specific actor attached to it. I want to make that generic Formula become specific to an actor.
Something like:
$gameActors.actor(actorId).level
Which doesn't work by the way.... I'm not sure if I'm explaining what I want very well.
That should work, assuming actorId is defined. What error is it giving you when you run it? Does it make the game crash? F8 will give you the developer tools, and the console tab will show you more info about the error.
To help identify the problem, can you please specify what information you have on the actor and when/where you want to use that formula?
You can't get it in a general context the way you seem to believe - something needs to identify the actor it is used on, even if that something is a loop through all actors.
Yeah, the call that you need will depend on where you will be using it since different parts of the engine have different variables for the actors, some don't have variables that pertain to actors too. So unless you can specify where you want to call the actor's level, then it's super duper hard to us to help you.
like for example as people said above, if damage formula it will be a.level or b.level, if it's the item application it will most probably be user.level or this.level and so on.. So we need to know where you want to do this.