Script for checking if character has SKILL ID (variable)

RockEsper

Villager
Member
Joined
Jul 10, 2012
Messages
19
Reaction score
6
First Language
English
To make a certain routine in my game easier, I'd like to be able check if a character has a certain skill by looking it up based on a variable. For instance, I want to check if actor(5) has skill(variable50). In this case, variable 50 would be the universal skill checking variable. It being 50 is irrelevant.

Any help would be greatly appreciated. Thank you for your time.
 
Last edited by a moderator:

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
364
First Language
Spanish
TL; DR:

($gameActors.actor(/* actor id */).skills().indexOf($dataSkills[$gameVariables.value(/* variable id */)]) !== -1)In Pieces:

$gameActors.actor(/* actor id */)Gets an actor by ID.

actor.skills()Gets the actor's skills as an array.

array.indexOf( item )Gets the index of an item in an array, or -1 if not found.

$dataSkills[ id ]Gets an skill by id

$gameVariables.value( id )Gets the value of variable id.

index !== -1The returned index is not -1, so it's in the array

SO, for a plugin:

if ($gameActors.actor(/* actor id */).skills().indexOf($dataSkills[$gameVariables.value(/* variable id */)]) !== -1) { // has skill}For an event, you can use the "script call" command, and I don't remember if actually there is an:

"if actor has skill variable<id>" too in the conditional branch...
 
Last edited by a moderator:

RockEsper

Villager
Member
Joined
Jul 10, 2012
Messages
19
Reaction score
6
First Language
English
Awesome. Thanks so much. I'm just placing it in a Conditional Branch's script section.

I really appreciate you breaking it down, too. I don't know if I'll ever get full on scripting down, but I do like to understand basic syntax for simple operations like this.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Officially not a mod anymore. Thanks for the many years!
Thinking if i should post on the classifieds section...
Made another plugin showcase video! :kaojoy:
(Plugins and details inside the description of the YouTube video.) :LZScheeze:
Ami
Castle is my Biggest Fear :kaodes:. I just Managed make Part by Part (like the Entrance only),not the Entire Castle like in the RM Sample...
This video really speaks to me...

Forum statistics

Threads
104,374
Messages
1,005,910
Members
135,894
Latest member
EnriX
Top