The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => Topic started by: onfurom on February 06, 2012, 09:52:36 AM

Title: Tutrial Help [XP]
Post by: onfurom on February 06, 2012, 09:52:36 AM
Hi! Again Sorry for many Help i Post I just need help with Tutrial
Here is it there a NPC who say:Go to that chest then equip that old armor then ask me again if u finish Equiped The Old Armor
Then i dont equip the armor and  i talk to the npc and said:okay fight my pet Then i fight
i want that the player must equip the armor before fight i already try the variables and its just nothing
variable is only need item okay tnx P.S  :blizj:
Title: Re: Tutrial Help [XP]
Post by: AbsoluteIce on February 06, 2012, 11:16:06 AM
Hi! Again Sorry for many Help i Post I just need help with Tutrial
Here is it there a NPC who say:Go to that chest then equip that old armor then ask me again if u finish Equiped The Old Armor
Then i dont equip the armor and  i talk to the npc and said:okay fight my pet Then i fight
i want that the player must equip the armor before fight i already try the variables and its just nothing
variable is only need item okay tnx P.S  :blizj:

Right click in event mode > quick event creation > treasure chest > choose which armor you want.
Make a new event which is the NPC, just a blank one with your NPC graphic > Conditional branch  > 4th Tab > Armor
Title: Re: Tutrial Help [XP]
Post by: LoganF on February 06, 2012, 11:56:53 AM
Quote from: AbsoluteIce
Right click in event mode > quick event creation > treasure chest > choose which armor you want.
Make a new event which is the NPC, just a blank one with your NPC graphic > Conditional branch  > 4th Tab > Armor

The 4th tab only checks for having the item in the inventory.

In order to check that the armor is equipped first, you need to use the options on Conditional Branch > Tab 2. Choose the actor who must be wearing this armor, and select the desired armor from the drop menu next to "Armor".

If, however, you are wanting to check if any actor is wearing the armor, you'll have to do a little more work. You can create a common event that does this check for all actors and set a switch to ON (or a variable to a number like 1) that you can check for in the NPC event.

Alternatively, you can use this script that I just cooked up that will do the exact same thing with less work for you:

Code: [Select]
class Game_Actor
 
  #get array of all armors equipped
  def armors
    [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
  end
 
end


class Game_Actors
 
  def actors
    temp = Array.new
    for d in @data
      next if d == nil
      temp.push(d)
    end
    temp
  end
 
end


class Interpreter
 
  #armor_id : id of the armor to be checked for
  #all_actors : true - all known actors checked; false - party only checked
  def check_for_armor(armor_id, all_actors=false)
    armors = Array.new
    #get appropriate actor ids
    actors = all_actors ? $game_actors.actors : $game_party.actors
    #add armor ids of each actor in actors
    for actor in actors
      armors += actor.armors
    end
    #return appropriate value
    return true if armors.include?(armor_id)
    return false
  end
 
end

Just copy and paste the code into a space in the Script Editor (F11), making sure it is above "Main" but below "Scene_Debug".

Then, in an event where you want to check for the armor being equipped by an actor, create a Conditional Branch > Tab 4. Check the radio button for Script and in the empty box use either:

check_for_armor(id) - replace ID with the ID number of the Armor you want to check for. You can get this value from the database. This will check for the armor id being equipped by an actor in the current party only.

or

check_for_armor(id, true) - replace ID as above, except this time it will check for all actors you've encountered. This will let the player equip an item and change that party member and still be able to trigger the event.

This will definitely save a lot of hassle with Common Events if you have a lot of actors. Even only a handful will take up some time that can be saved with this little snippet of code.

Hope it works like you want.
Title: Re: Tutrial Help [XP]
Post by: onfurom on February 08, 2012, 05:10:46 AM
Ohh yah could u help me with the (@armor_id) what i well put there the name of item?  :o
Title: Re: Tutrial Help [XP]
Post by: LoganF on February 08, 2012, 06:22:57 AM
You don't need to change anything in the script itself. Those are just there to give me a way to retrieve the IDs of the armors that an actor is wearing. So, nothing you need to worry about, it just makes the script work.

All you need to do is follow this information:

Spoiler for Info:
Quote
Then, in an event where you want to check for the armor being equipped by an actor, create a Conditional Branch > Tab 4. Check the radio button for Script and in the empty box use either:

check_for_armor(id) - replace ID with the ID number of the Armor you want to check for. You can get this value from the database. This will check for the armor id being equipped by an actor in the current party only.

or

check_for_armor(id, true) - replace ID as above, except this time it will check for all actors you've encountered. This will let the player equip an item and change that party member and still be able to trigger the event.

I've included an image to show you how it should look (with the extra game related stuff added by you later):

Spoiler for:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi671.photobucket.com%2Falbums%2Fvv73%2FTohme_Rhiazanho%2FCheckForArmorScriptScreenShot.png&hash=14874dbbce2355a9cc16f14410cc0337a4eb2f88)
Title: Re: Tutrial Help [XP]
Post by: onfurom on February 08, 2012, 09:57:50 AM
Ohhh okay i Understand but where well put it in the above of the KILL MY PET?
i really confuse  :(
Title: Re: Tutrial Help [XP]
Post by: LoganF on February 08, 2012, 12:02:22 PM
I think the AHA would be happy to confirm that my script did not cause any harm to animals, and it sure shouldn't lead to any harm to them either.

Random comment aside (and after I read the OP):

It should go before you fight the pet, and only fight the pet if the conditional branch succeed.

It should go something like this:

Talk to NPC
NPC says "Go find this Armor"
{Player goes off to find Armor somewhere here - nothing to do with the event}
Check if the Player is wearing the Armor like in the screenshot I gave you
If Player is wearing armor, then Fight Pet
If Not then tell them to find the armor/remind them to wear the armor.

I made a quick screenshot example to help make sense.

Spoiler for:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi671.photobucket.com%2Falbums%2Fvv73%2FTohme_Rhiazanho%2FCheckForArmorScriptScreenShot2.png&hash=2440935b05eaac472ee180706a97e925ad3d4baa)

I hope that helps.
Title: Re: Tutrial Help [XP]
Post by: onfurom on February 08, 2012, 09:58:05 PM
Lol Dude its wrong but i solved my problem tnx bro it just easy the topic of control branch is Actor:Equipped:MagicArmor
Then put Now Kill My Pt its easy lol but tnx dude! it help btw.. ^-^ 
Title: Re: Tutrial Help [XP]
Post by: LoganF on February 09, 2012, 12:58:24 AM
The difference between the script and the conditional branch options is that for a conditional branch you have to specify the actor who is wearing the armor. If you wanted to make a check for every actor individually, then that way will work. But if you have a lot of actors, maybe 6 or more, you'll have to make a single check for each of those 6+ actors. The script takes care of that, and lets you check every actor's armor for the equipped armor at the same time and it only takes up 1 conditional branch to do it in.

Whilst you can set up a common event that will have the same effect, this simply takes far less time to do (it took me less than 2 minutes to write the script) and doesn't require setting up variables or switches in a common event - thus no additional resources at your expense.

Either way, though, at least your problem is solved. So that's a bonus anyway.