Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Nickydude on Tue 23/12/2008 23:50:15

Title: eBlock / eNoBlock and looking at an object
Post by: Nickydude on Tue 23/12/2008 23:50:15
Hi folks, brand spanking newbie here trying to figure AGS out  :=

I'm wondering if anyone can point me in the right direction with the following:

I have an object that the character walks to to 'look' and see what it is and I use the following code

function hPillow_Look()
{
  cEgo.Walk(104, 160, eBlock, eWalkableAreas);
  cEgo.Say("Looks like a comfy pillow to me.");
}

This works fine, he walks to the object to see what it is. At the moment the player can't do anything with the character till he's gone over to the object and looked at it, I'd like to be able to have the character change direction if the player clicks somewhere else, on the way to the object. I changed eBlock to eNoBlock but then the character doesn't walk to the object and just says what it is from where ever position he is in the room.

Basically I'd like the character to walk to an object if it's to be looked at, but be able to divert him somewhere else if need be as he's going towards the object. Any help would be appreciated. :)
Title: Re: eBlock / eNoBlock and looking at an object
Post by: Dualnames on Wed 24/12/2008 00:23:57
Ok, well there's a module for that called noblock but well, you need to do that.
I'm assuming your using sierra style interface. Find a line like this(on the global script):

ProcessClick(mouse.x,mouse.y,emodewalkto);

and replace it with this:

player.Walk(mouse.x,mouse.y,eNoBlock,eWalkableAreas);

Also remove that walk line from the object interaction.

or alternatively you can:
function hPillow_Look(){
  cEgo.Walk(104, 160, eNoBlock, eWalkableAreas);
if ((cEgo.x==104)  && (cEgo.y==160) {
cEgo.Say("Looks like a comfy pillow to me.");
}
}

I think what I've provided might not really do the trick. So in case a guy called Khris posts follow his advice.
Title: Re: eBlock / eNoBlock and looking at an object
Post by: Nickydude on Wed 24/12/2008 02:37:20
Thanks Dualnames, I'll look into that.
Title: Re: eBlock / eNoBlock and looking at an object
Post by: Khris on Wed 24/12/2008 03:40:09
EDIT: Do not use the download link or example code below! Current version and example code can be found in the linked post.
https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/graphicalfunctional-questions-for-cmi-style-guiinventorymenus/msg636639852/#msg636639852

Here's the module I coded some time ago: GotThere.scm (https://www.dropbox.com/s/pus9de69jlanm71/GotThere.scm?dl=1) (right-click, save as...)

Import it into AGS, then use it as follows:


Code (ags) Select
function x() {

  if (!GotThere()) GoFace(90, 130, eUp);  // example coords
  else {
    // actual interaction code
  }
}

GoFace(x,y,d) makes the player character walk non-blocking to coords x,y; as soon as they got there without an intermittent click, they'll face direction d, then the interaction is called again, with GotThere() being true now.
Title: Re: eBlock / eNoBlock and looking at an object
Post by: maximusfink on Wed 04/07/2012 23:16:36
whoops replied to wrong thread sorry.