Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Dervish on Tue 03/03/2009 03:52:41

Title: Using an Hotspot like a Region?
Post by: Dervish on Tue 03/03/2009 03:52:41
Right now I have a part in my game that I want the player to walk over a certain area and when he walks on it the floor boards creak and he backs up saying something about the floor being squeaky then the player can use an inventory item say like grease to turn off the effect of the squeeky floor is there an easy way to do this without using very much code or none at all?
Title: Re: Using an Hotspot like a Region?
Post by: Trent R on Tue 03/03/2009 04:00:45
Well, there is a event for standing on a hotspot. Why can't you just use that?

~Trent
Title: Re: Using an Hotspot like a Region?
Post by: Dervish on Tue 03/03/2009 04:29:06
That works somewhat but if you walk to another point bu just say using something on the other side of the room it does not stop the player it allows them to go right over it.
Title: Re: Using an Hotspot like a Region?
Post by: Trent R on Tue 03/03/2009 04:40:41
Perhaps something like

//room_rep_exec
Hotspot *hotty=Hotspot.GetAtScreenXY(player.x, player.y);
bool greasedfloor;

if (hotty==hCreakyFloor && !greasedfloor) {
  //Can't step there!
}

But, Khris or someone else will probably soon come by and give you something better. := Cause they're cool like that.

~Trent
Title: Re: Using an Hotspot like a Region?
Post by: Khris on Tue 03/03/2009 10:39:00
Unfortunately, blocking walks won't trigger region events until after the player has stopped moving, correct.

It's possible to do a rep_ex check, but it's even better to send the player off non-blocking.
I've written a module called GotThere to achieve this.

Here's the link & short explanation:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36383.msg477380#msg477380
(The downside: if you want the game to work consistent, you'll have to adjust all your existing interaction funtions)
Title: Re: Using an Hotspot like a Region?
Post by: thezombiecow on Tue 03/03/2009 13:35:42
Quotewithout using very much code

As a workaround, using lots of code, could you add in a condition to the Interact function for each object on the other side of the room that requires a walk-up-and-interact animation??


if (bOiledFloorboards)
{
  // walk across, you're fine
  // interact with the whatnot on the other side as intended
}
else
{
   if (bTestedFloorboard)
   {
   cChar.Say("If I walk over there, that damned floorboard'll start squeaking again.");
   }
   else
   {
    // engineer a walk just as far as the floorboard
    // play squeak effect
    // back off
    bTestedFloorboard = true;
    }
}


??

Depends on how many objects you've got on the other side of the room, I  suppose.

Title: Re: Using an Hotspot like a Region?
Post by: Vince Twelve on Tue 03/03/2009 19:05:57
I did the very thing thezombiecow is suggesting in the game I'm making. 

I had a section of the floor that could not be walked over until certain conditions were met.  I put the proper code into the playerWalksOntoRegion function ("Oh no I can't walk here!" etc), and then for each hotspot on the other side of that region, I checked if the conditions had been met, and if not, had the player only walk just as far as the edge of the region and stop.  That would trigger the playerWalksOntoRegion function.

Since I had only four interactable items beyond that region of the floor, this was a simple and effective solution.
Title: Re: Using an Hotspot like a Region?
Post by: thezombiecow on Wed 04/03/2009 09:36:00
QuoteI did the very thing thezombiecow is suggesting in the game I'm making. 

Awesome. Hope it works out for you ;)
Title: Re: Using an Hotspot like a Region?
Post by: Vince Twelve on Wed 04/03/2009 14:39:52
Well, I did it several months ago, so it is working out for me just fine.  Thanks.  ;)
Title: Re: Using an Hotspot like a Region?
Post by: thezombiecow on Wed 04/03/2009 15:30:28
Aaaaaaah.
Title: Re: Using an Hotspot like a Region?
Post by: Vince Twelve on Wed 04/03/2009 15:40:22
Then again, I am a time traveler...
Title: Re: Using an Hotspot like a Region?
Post by: Shane 'ProgZmax' Stevens on Thu 05/03/2009 04:15:29
He came from the past to save the future...


Seriously though, you could just not have any walk-to interactions beyond the board (ie, the player must manually walk to within a certain distance for take/interact stuff to occur).  This easily resolves the issue of blocked walk because you won't have any (except for walking away from the board, obviously).