Is Disabling Certain Keycodes With Regions Possible? [SOLVED]

Started by ma2003, Fri 20/06/2008 21:31:03

Previous topic - Next topic

ma2003

Hi Again.

I'm trying to work out if its possible to use a region to disable a keycode....or if its even possible to disable a keycode at all.

In the game I'm working on, my character has the ability to enter crawl mode by toggling the C key.



Now as you can see...the movement and crawling animation, walk behinds and key pressing is working splendidly.



However, of course, while being under the "little tunnel", I could easily STILL press the C key, and stand back up.

This is obviously a problem, I don't want my character to toggle back to standing position WHILE under the tunnel. If he stands while under the tunnel, the walk-behinds set for this "little tunnel" will disable, and the character will unfortunately appear like in the bottom picture:



My thoughts to this problem could be the use of Regions. Where, if my character were to be crawling on a region, the C Keycode would be disabled. If this command exists, then it would make things more easier. With regions, it would be helpful when my character would encounter a wall.

So, is this actually possible? Can this be done? Is my solution wrong, or is there a better way?

Thanks. I'll appreciate any comments and help.

Pumaman

Presumably you have some script in on_key_press like this:

if (keycode == 'C')
{
  // do standing up stuff
}

you can simply change it to something like:

if ((keycode == 'C') && (Region.GetAtRoomXY(player.x, player.y) == region[0]))
{
  // do standing up stuff ONLY if not on a region
}

that code will disable the C key if the player is on any region, so you'd probably want to customize it for your needs -- but hopefully that gives you the general idea.

ma2003

Wow, it works. Thanks.

I was about to post a message about why it wasn't working when I applied the code. I waited a bit, try to configure things a bit, and then it worked.

Thanks alot mate, I appreciate it.

SMF spam blocked by CleanTalk