[SOLVED] Remove walkable areas for certain characters?

Started by Paul Franzen, Sat 23/07/2016 01:44:54

Previous topic - Next topic

Paul Franzen

Okay, so here's the situation:

- In this part of the game, you're in a dungeon. If you walk in front of one of the cells, someone reaches out and kills you.
- Concurrently, you have an NPC following you around (using the Character.FollowCharacter function).
- If she walks in front of the jail cell, nobody kills her. This is good! I don't want anybody to kill her!
- However, this feels weird, story-wise. Either she should get killed, or she should be smart enough not to walk in front of the cell. It doesn't make sense that she's able to wander in front of the cell unscathed.

...So what I'd like to do is prevent her from wandering in front of the cell. My gut instinct was to define a new walkable area in front of the cell, one that she can't walk through. But there doesn't seem to be a way to define a walkable area that only specific characters can access.

My next attempt was to make an invisible object that, if the NPC randomly collides with it, she immediately walks away. Like so:

Code: ags

function room_RepExec(){
    if (cLily.IsCollidingWithObject(oLilyBarrier)){ // 
        cLilyWalk((cLily.x), ((cLily.y)+10), eNoBlock);
     }
}


....Unfortunately, this just causes her to get stuck on the object. She touches it, and she tries to walk away, but because she's still touching it, the game just runs the Walk command over and over again. So it's a no-go. (I tried the same idea with a regionâ€"she walks into the region, she's supposed to immediately walk awayâ€"with the same non-result.)

tl;dr Is there a simple way to define a walkable area that only the player character can access? Or otherwise, a way to define which specific characters can access a specific walkable?
The Beard in the Mirror (formerly testgame) - Out now on Steam! http://store.steampowered.com/app/385840
Other games I've worked on: http://paulmfranzen.com/games/

Crimson Wizard

Quote from: Paul Franzen on Sat 23/07/2016 01:44:54
tl;dr Is there a simple way to define a walkable area that only the player character can access? Or otherwise, a way to define which specific characters can access a specific walkable?

Argh! Sadly, still no direct way.
Thing is, your post reminded me that I saw similar problem just around the time when I started contributing to AGS project, I even made an issue in the tracker: http://www.adventuregamestudio.co.uk/forums/index.php?issue=353.0

I recall a person had a moat with crocodiles in it and wanted player to be able to get across the moat, but keep crocodiles in, or something like that.
Here is the old thread, I do not remember if they found solution, but possibly may contain some tips:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=46811.msg629893#msg629893

Slasher

#2
Hi

whilst ags may not cover every scenario there is generally a way to do most things.

Ideas

if the npc is following the character (not real close) why not have a region in front of the cell that if the player walks onto the npc stops following and when the player walks off the npc begins again to follow.

If using an object: Make sure npc moves far enough away from the object to stop collision detection
Code: ags

 // When collision with object is detected
 cLily.Walk(cLily.x,cLily.y +20, eBlock, eWalkableAreas); // Or whatever x y distance you want


I generally use the PPC module for this.

food for thought






johanvepa

Use an "if" condition.

Might be tricky because the NPC may stop-and-go, but its an option.

Jack

Since it's a dungeon I'm guessing there is only one entrance. Why not have her wait there? Even if there's another exit at the other end, you can deactivate the areas and have her walk through when the player exits.

Otherwise slasher's first idea sounds best, if you can design the areas/regions in such a way that she won't walk through them when she starts following again.

Paul Franzen

Quote from: Crimson Wizard on Sat 23/07/2016 02:14:44
I recall a person had a moat with crocodiles in it and wanted player to be able to get across the moat, but keep crocodiles in, or something like that.
Here is the old thread, I do not remember if they found solution, but possibly may contain some tips:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=46811.msg629893#msg629893

Hah! Funny thing is, I was just scouring that thread before I posted, so talking with you about it now feels a bit like reaching into the past.

Quote from: slasher on Sat 23/07/2016 06:18:34
if the npc is following the character (not real close) why not have a region in front of the cell that if the player walks onto the npc stops following and when the player walks off the npc begins again to follow.

That did it!! I tried placing the region in front of the cell, but it wasn't enough of a barrier; if I was standing just next to the region, but not on it, she could still walk past me. So I set it up about halfway across the room, and now it (mostly) keeps her from getting too close. Thanks everyone for your help!!


The Beard in the Mirror (formerly testgame) - Out now on Steam! http://store.steampowered.com/app/385840
Other games I've worked on: http://paulmfranzen.com/games/

SMF spam blocked by CleanTalk