scripting help with actors, skills and items

Started by Memor-X, February 16, 2011, 06:44:10 pm

Previous topic - Next topic

Memor-X

i need some help with making a couple of scripts, my RGSS skills are basic and though i know the logic, i'm not sure of the methods (i would be if the classes was constructed using arrays of classes), anyway, here's what i need to know how to do,


  • How to check if an actor knows a skill or not (eg. check to see if Actor 1 knows Skill 547)

  • How to check if an actor is inflicted with a certain state (eg. Actor 3 is inflicted with State 14)

  • How to add and remove skills like the event command

  • How to check if an item is in the inventory

  • How to check if every index in an array is True without having to use a loop (cause the array i want to check would have over 500 indexes, something is bound to stuff up if i have a running loop)


Wizered67

Here are the ones I'm pretty sure on, although I didn't test.

1. if $game_actor[1].skills.include?(547)
3.$game_actor[1].learn_skill(547) / $game_actor[1].forget_skill(547)
4. $game_party.item_number(547)

Ryex

February 16, 2011, 06:51:52 pm #2 Last Edit: February 16, 2011, 07:02:16 pm by Ryex
Quote from: Memor-X on February 16, 2011, 06:44:10 pm


  • How to check if an actor knows a skill or not (eg. check to see if Actor 1 knows Skill 547)

  • How to check if an actor is inflicted with a certain state (eg. Actor 3 is inflicted with State 14)

  • How to add and remove skills like the event command

  • How to check if an item is in the inventory

  • How to check if every index in an array is True without having to use a loop (cause the array i want to check would have over 500 indexes, something is bound to stuff up if i have a running loop)





  • the include? method of arrays can test if an array contains a value

  • same as above

  • look at the Game_Actor class for the right method

  • look at the Game_Party class

if !array.include?(false) && !array.include?(nil)
or if your array is going to include values other than true, false, and nil
ary.uniq.size == 1 && ary[0] == true

I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ForeverZer0

In order: 
$game_party.actors[INDEX].skill_learn?(SKILL_ID)
 
Actor at INDEX learns the skill with SKILL_ID

$game_party.actors[INDEX].state?(STATE_ID)
 
Returns true/false if actor at INDEX is inflicted with the state with STATE_ID


$game_party.actors[INDEX].learn_skill(SKILL_ID)
$game_party.actors[INDEX].forget_skill(SKILL_ID)
 
Actor at INDEX learns/forgets skill with SKILL_ID

$game_party.item_number(ITEM_ID) > 0
 
Returns true/false if party has item in inventory with quantity greater than 0

array.all?

If you are simply checking for all "true" you can simply do that. A block has to be supplied if you are checking conditions with this method.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ryex

... I though there was an all? method but when I went looking for it to make sure I couldn't find it.... then I looked at the enumerable module ?*facepalm*
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />