Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Iwant Kropotkin

Use item on game environment

Question

Hey!

 

I've started working on an adventure game project, using RPG Maker XP. The game system would require the following to be possible: When the player thinks he's encountered an element of the environment he can interact with, he should be able to go in its inventory and try to use an item - if that's what he's supposed to do, it works ; it it isn't, he's just told it won't do. Nothing more than that.

 

Basically, using the Red Key on the Red Door will unlock it ; but using the Banana Peel on the unrelated Traffic Light, on a non-interactive part of the environment or in thin air will just trigger a "you can't do that" bit of text. Pretty much what's used in the Pokémon series, among others.

 

Now, I searched it up, and found this. Good news: It looks exactly like what I need. Bad news: It barely works. It crashes when I'm in a "you can't do that" situation - and the more I try to fix, the worse it gets. I tried making the changes to the code as mentioned in the referenced thread, but it doesn't seem to do any good.

 

I searched for another similar script, but it seems like it's the only one that would allow me to pull that of. So, I'm kind of stuck, and this is why I made this thread. Could someone please help me making this work? That would be greatly appreciated.

 

Thanks!

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Did you think of using conditional branches? You can set up a common event in the menu and trigger it when you click the event, along with the position that the player should be facing.

 

That's a little difficult when using events, so I made it so that the player should be in a specific spot, facing one direction, when they use their item--and if the coordinates fit, it triggers the event.

 

It was for an old project, but I'll look through my screenshots and see if I can find the one that I used. Unless, of course, you want something less complicated? Like in a script?

 

The Witch's House is a very good example of what I think you're trying to do--selecting an item from the menu and using it only in a specific place, right?

 

Not sure if double posting is against the rules here, but anywho I'm adding this as an edited post: 

I attached some files below that might be helpful. Simply use the common events, set up a lot of control variables (that's a little complicated), and then set a couple of branches that make sure that the player is fulfilling those conditions. If the player is NOT, then just write in Else: "You can't use this item" or something like that.

 

The red circle in the Item window, in Database, shows where you connect the item with the common event. When you set it and click on the item, whatever is in that common event will play.

 

If you need a little detail, I could go into it, but I'd have to refresh myself with the concept of it first.

 

Hope this is something along the lines of what you hoped for!

post-24661-0-45346400-1403331196_thumb.jpg

post-24661-0-98890400-1403331241_thumb.jpg

Edited by GermanyXItaly1000

Share this post


Link to post
Share on other sites
  • 0

Thanks for your reply!

 

I'm very grateful for your answer. Your system does seem to work properly! However, having to use all of those control variables will probably prove unpractical in the long term, especially in a game that so heavily relies on that kind of interactions, which is why I'm more interested in a script to be perfectly honest. If I fail to find something that works better, I'll definitely use what you've shown me though; many thanks!

 

The thing is, I actually found (almost) exactly what I needed a few hours ago: The Chrono Cross Key Items script. It has one big problem though: Apparently it never really checks for coordinates properly, thus an item used anywhere in an area will still affect the event even if it's far away from the player.

 

Now, I've read someone say it is "easily fixed by a short conditional branch where it just tells you the item doesn't work if the variable isn't 0, and then resets it" but I'm not sure what he's talking about. By "conditional branch", did he refer to the event command in the events window or to an actual if/else condition in the script?

 

Do you think you could help me on that?

 

At least now, even if the available scripts all prove to be too flawed, I have a fallback option thanks to you!

Edited by Iwant Kropotkin

Share this post


Link to post
Share on other sites
  • 0

The Chrono Cross Key Items script. It has one big problem though: Apparently it never really checks for coordinates properly, thus an item used anywhere in an area will still affect the event even if it's far away from the player.

 

Now, I've read someone say it is "easily fixed by a short conditional branch where it just tells you the item doesn't work if the variable isn't 0, and then resets it" but I'm not sure what he's talking about. By "conditional branch", did he refer to the event command in the events window or to an actual if/else condition in the script?

 

Do you think you could help me on that?

 

Looking at the note about setting the conditional branches... I think that's scripting, which is far out of my league.

 

I downloaded the demo for the script you named, though, and it doesn't seem to give me any problems, as long as you set the item ID properly in a conditional branch.

 

If you could explain what exactly is the problem, I might be able to think of something. But in the demo I played, I can select the item far away from the player, and it doesn't appear to still affect the player. Unless I'm getting confused again. :P

Share this post


Link to post
Share on other sites
  • 0

Oops, my bad - I didn't mean "far away from the player" but "far away from the related event". Sorry about that.

 

The problem is that it never checks if the player is actually in front of the event or at least that's what I believe is wrong in the script. It basically means that the player can go to the bottom-left of the screen or anywhere else really, "use" the potion there, then go talk to the character requesting that potion and said character will react as if he was just given that potion.

 

Thanks for your help!

Share this post


Link to post
Share on other sites
  • 0

Apologies, but in the demo I couldn't find anything particularly wrong. :P Maybe it's because I haven't taken the script out and tested it myself. I will go and try to do so.

 

In the demo I used, the payer had to be standing directly on the teleporter event, which then used a conditional branch to check for the item. If you want to stand in front of an object--I guess you want to do that?--I'd used a conditional branch checking to see if the player is facing the event, than use another branch that checks for the item, if the first branch is fulfilled.

 

But otherwise, it shouldn't work in the way you said, since you need to be standing right in front of the event or it won't happen since the conditional branch hasn't been met...

 

Maybe you could upload what you made with the potion? :P But I don't see how there should be a problem, after looking at the code in the demo. I couldn't use the teleporter anywhere else.

Share this post


Link to post
Share on other sites
  • 0

The teleportation only appears to work correctly - but the problem is actually the same. If you use the Teleporter in a random area, then come back to a portal and press the button, it will warp you anyway. There really is something off with the way the script was made.

 

See for yourself with the demo: Start a new game. Speak to the man - he'll ask for a potion. Use the teleporter to get to the other side, and speak to the girl - she'll give you the potion. Now, use that potion ANYWHERE on the map, then come back to the man and speak to him - he'll answer as if he was just given that potion. Which of course is a big problem.

 

To be honest, I think I'm gonna use the event-based system you showed me earlier - in the end, it appears to be more malleable and reliable than a script. The only thing that bugs me is that it doesn't allow for a "quick inventory" that doesn't require to go into the actual menu, but it's not that much of a big deal.

Share this post


Link to post
Share on other sites
  • 0

Wow, you're right D: Yeah, looking back at the past comment, it does seem as if they're talking about scripts. I'm afraid I can't help you there. You might want to ask another user on this forum who knows how to handle RGSS (won't be too hard finding them). Only problem is, I don't know if it requires a rewrite of the script or just a few changes, an added section or something.

 

My system was very inconvenient when I started out, but that's because I was learning, and I didn't know how to the basic things in RMXP :D Now that I think about it, it's still inconvenient, seeing how many variables you have to set up for it.

 

Hopefully you have a better time with my weird variable system than I did, though.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...