Script for checking if character has SKILL ID (variable)

Discussion in 'RPG Maker MV' started by RockEsper, Nov 20, 2015.

  1. RockEsper

    RockEsper Villager Member

    Messages:
    19
    Likes Received:
    5
    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: Nov 20, 2015
    #1
  2. Ramiro

    Ramiro Now with an army of Mecha-Ralphs! Veteran

    Messages:
    860
    Likes Received:
    366
    Location:
    Argentina
    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: Nov 20, 2015
    #2
    drumblepie and jjleroy like this.
  3. RockEsper

    RockEsper Villager Member

    Messages:
    19
    Likes Received:
    5
    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.
     
    #3

Share This Page