Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Sneaking up on characters

Hi all,

I'm in the process of making a game where the main character has to run up to town's people and steal their wallets, however i'm having a problem with getting the functionlity right.

Basically I want the character to only be able to successfull steal their wallet if the town's person is facing away from them. If not they will be caught and arrested.

I started by creating an event system that used conditional branches so that:

If the main character is facing towards the towns person
and if the towns person is facing towards the character
then they would shout out "Thief!!"
else they would steal their wallet

The problem is, when you apprach the towns person and press the action key they automatically turn round to face you. This means they always catch you. The town's people are wandering aroud the town so I cannot fix the initial direction they are facing.

Does anyone have any ideas of how I can either stop them from turning around?
or
Have a better idea of how I can implement the system so that you can only activate the stealing event if they attack a towns person from behind?

I'm an artist and not a coder and this is the first time i've used RPG Maker XP so please break any responses down into simple language for me :thumb:

Many thanks in advance

Yogi
 
Ok, sounds like that might work... so how do I do that? I couldnt find an event that had the variable for facing away from the character or turning on directional fix automatically.

Any change you could tell me where they can be set?

Thanks
Yogi
 
Cant find MOVE EVENT under the events list. Is it on page 1 2 or 3?

I know Direction Fix is under Options on the right hand side of the New Events screen, but that is not what im looking for.

If you can be a little clearer with your instructions I would appreciate it.

Thanks
Yogi
 
Ok let me break this down again just incase i'm not being clear

What i'm trying to achieve is a system where the player has to steal another characters wallet without being seen.

At the moment when my player approaches a character (from any angle) and presses the action key, the character turns to face them. This seems to be an automatic process. Obviously if they are looking right at you they would see you taking their wallet.

What I would like to know is:

1. Is it possible to stop a character from turning to face you when you press the action button?

2. Is there a function or event that allows you to set something like:

If the character is facing away from the player you can steal their wallet.
If not then they will shout thief!

Hope some one can help me with this.

Thanks
Yogi
 
On the bottom left corner of the main event page screen, there are a few checkmarks labeled "Move Animation", "Stop Animation" etc. Direction Fix should be one of those check marks!

-Syv
 
The "Set Move Route" button is on page 2 of the events box, but try as I might, I can't get it to work using that method. If you make the very first command "Set Move Route: This Event - Direction Fix" it's already too late and they'll turn to face you anyway. Then, I thought about setting a custom movement route for the NPC that would turn Direction Fix off, take a random step, and then turn it back on, but I couldn't get it to turn Direction Fix back on after the first step it took for some reason. You might have to resort to static NPCs, unless someone knows a workaround.
 
Hi Deltree,

Thanks for taking a stab at it. Seems you ran into the same problems as me. No matter what I try the event character always turns to face you.

I tired to use the Set Move Route command (move in a direction then turn direction fix on, wait 20 frames, turn direction fix off, move in a direction etc) to see if that would allow me to quickly nip in and get it too work, but it just ignores the rest of the script :(

I'm not sure if there is a way round it. Perhaps a script might be the only way, but thats not my area of expertise.

Quess I will have to use static characters.

Thanks again for your help

Yogi
 
I dug through the scripts a bit, and it seems like the 'turn towards player' method gets executed before 'Interpreter' (which reads the event commands.) So, the direction fix won't do it.

I think the 'turn_towards_player' method would need to be modified.
Do you have a way to indicate that 'pickpocketing' is enabled?
Or should it just work all of the time?

Maybe one of our 'scripting wizards' will peek in & offer some wisdom.

Here's an odd afterthought. Edit all of the townspeople sprites so the animations go "up, right, left, down", and make them all walk backwards. :) this won't work either, they'd always turn away from the player. But you gotta admit it's a clever thought!

BE Well
 
Hi Brewmeister,

Thanks for the reply.

My pickpocketing skill is set as a variable that increases as you learn to pickpocket over time. If you try to take someones wallet without first learning the skill it will deny you.

The idea is to make taking someones wallet easier as your skill increases.

Hopefully one of them scripting wizards will come by and take pity on me :D

Thanks again

Yogi
 
No worries.

What I'm struggling with is the logic. (and the correct script to edit).

If I say:

If variable[1] > 0 (your pickpocket variable)
Don't turn around when I hit action​
Otherwise
Do turn around when I hit action​


All events won't turn around once you learn the skill. Then it will look bad when you just try to talk to someone.

Now, what if you also implement a switch to turn pickpocketing on & off.
(you could even link it to a skill that the player has to use.)
Then, we can say


If ( variable[1] > 0 ) AND ( switch[1] is ON )
Don't turn around when I hit action​
Otherwise
Do turn around when I hit action​


Will that do the trick?

<EDIT>

Holy Crap, it works!!!!
Replace the "Lock" method in "Game_Character_1" with
Code:
  #--------------------------------------------------------------------------
  # * Lock
  #--------------------------------------------------------------------------
  def lock
    # If already locked
    if @locked
      # End method
      return
    end
    if ($game_variables[10] > 0) && ($game_switches[10])
      #don't do anything
    else
      # Save prelock direction
      @prelock_direction = @direction
      # Turn toward player
      turn_toward_player
      # Set locked flag
      @locked = true
    end
  end

I'm using variable[10] and switch[10]. Change these to the correct values for your game.

Note: this only stops the event from turning around. You still need to process the pickpocket.

Be Well
 
Great! thanks Brewmeister!!!

I'm working right now, but I will try this out ASAP and report pack with how it works. Sounds to me like this will do what I want though.

I'm thinking that the pickpocket could be like a stealth mode you turn on, maybe even change the players opacity so you knwo when its on or off. :) Just need to work out how to turn it on via a keyboard button now :D

Out of interest what does the Lock script do normally? will it affect anything else in my game?

Cheers
Yogi
 
I had a think and I'm not sure this will work exactley they way I want.

Basically this script will check to see if the pickpocket ability is >0 and then it will check to see if it is ON

If it is then the character being mugged will not turn and face the character.

That's fine, but that means that if I pickpocket them from the side or the front, they will still be facing the same way.

What we need is some way of only allowing this new script to run if we attack them from behind.

This is the logic:

If variable[1] == direction away from player (direction of character)

Don't turn around when I hit action

Otherwise

Do turn around when I hit action and shout Thief!!!

Hope that makes sense :)

I will have another go later.

Yogi
 
I think I got it. If "pickpocket" mode is on, it only works from behind.
Otherwise, he gets busted.
To Talk to someone, he needs to turn "Pickpocket" mode off.

I think I can just use,

If "Character & Event are both facing the same way"
Don't turn around​
Otherwise
Turn around​

You can handle the rest of the logic in your events

Give me a few minutes, then I'll edit this post

Be Well

Oh yeh, the 'lock' method faces a character towards the player, and 'locks' him there until the event ends.

EDIT:

Ok, this should do it.

Code:
  #--------------------------------------------------------------------------
  # * Lock
  # modified to prevent turn_toward_player if pickpocketing. - Brew
  #--------------------------------------------------------------------------
  def lock
    # If already locked
    if @locked
      # End method
      return
    end
    if ($game_variables[COLOR=Red][10][/COLOR] > 0) && ($game_switches[COLOR=Red][10][/COLOR]) && ($game_player.direction == @direction)
      $game_switches[COLOR=Red][11][/COLOR] = false  #don't do anything
    else
      $game_switches[COLOR=Red][11][/COLOR] = true   #Busted
      # Save prelock direction
      @prelock_direction = @direction
      # Turn toward player
      turn_toward_player
      # Set locked flag
      @locked = true
    end
  end

Change the numbers in Red to match the variable & switches you use in your game.
$game_variables[10] #Pickpocket skill level
$game_switches[10] #Pickpocketing mode
$game_switches[11] #Busted

Here's the event

View attachment 2958
Page 1 is just the normal talking text

This should get you going.

Be Well
 
Words cannot express how much you ROCK!!!! :D

Nice work my friend! :thumb: you got it working exactley the way I wanted.

Thanks alot for spending your time on work this out for me. As soon as I have the rest of the sections together I will post a demo of the mini game working for all too see.

I'm off to get this new bit of code into my game ^_^

Oh btw, if I compile the game with that new bit of script will it save it all together so that anyone can use it?

Thanks again
Yogi
 
:D <chuckle>. You're quite welcome.

Yes, your compressed game will include your edited scripts, and everything else in your game folder. Along with any extra junk you've piled up in there. (I did this ;) ) Best to keep all the extra junk in a separate, or parent folder.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top