Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: LucasFan on Mon 12/05/2003 22:50:52

Title: "Walk to"-interaction
Post by: LucasFan on Mon 12/05/2003 22:50:52
Hello.

Maybe a stupid question, but does anyone know how to script a "Walk to"-interaction?
Title: Re:"Walk to"-interaction
Post by: Proskrito on Tue 13/05/2003 13:00:32
i had the same problem. I think i read somewhere that the "any click" interaction worked for every cursor mode but 'walk to' mode.
I think it would be useful, but maybe there was a reason for chris for making that.
Or maybe there is another way...
Title: Re:"Walk to"-interaction
Post by: LucasFan on Tue 13/05/2003 13:31:49
I think it's quite important to have such a Walkto-interaction-mode. It would spare a lot of time. Why for example should I always draw a hotspot I have to stand on, to enter an open door? It's much better to have a simple interaction for that.
Title: Re:"Walk to"-interaction
Post by: Ishmael on Tue 13/05/2003 16:10:18
I have a script for it in here (http://www.agsforums.com/yabb/index.php?board=2;action=display;threadid=5873). The part CJ quoted, and the operator fixed

Just you maybe need to tweak it a bit...
Title: Re:"Walk to"-interaction
Post by: LucasFan on Tue 13/05/2003 17:33:05
QuoteI have a script for it…

Could you please explain which part of your code you mean?  ???
Title: Re:"Walk to"-interaction
Post by: Ishmael on Tue 13/05/2003 17:34:31
Quote from: TK on Tue 13/05/2003 16:10:18
The part CJ quoted, and the operator fixed

if (button==LEFT) {
 if (GetGlobalInt(1)==0 && GetCursorMode()==0) {
   MoveCharacter(EGO,mouse.x,mouse.y);
 }
 ProcessClick(mouse.x, mouse.y, GetCursorMode() );
}


And as I allready said: You need to tweak it.... so...

This is the basic:

if ((button==LEFT) && (GetCursorMode()==0)) {
 MoveCharacter(EGO,mouse.x,mouse.y);
}
Title: Re:"Walk to"-interaction
Post by: LucasFan on Tue 13/05/2003 19:05:21
Ok, with if ((button==LEFT) && (GetCursorMode()==0)) I'm able to differ between the Walk-mode and the other modes. That's a good idea, TK. But how should this help me to make an interaction with a special hotspot or object? This is a global script, not a room script. I can't turn on an object there or change a room or anything.  :'(
Title: Re:"Walk to"-interaction
Post by: Pumaman on Tue 13/05/2003 19:44:29
I have to confess, I really don't know quite what you mean by "a 'Walk to'-interaction". What sort of thing are you wanting?
Title: Re:"Walk to"-interaction
Post by: LucasFan on Tue 13/05/2003 20:03:44
For example: You have a room with an open door. You click at the door and the character goes to the door and leaves the room. That's all I want.  :)

PS.: But he should leave the room without stepping on a hotspot or a region! He should be able to walk on every part of the walkable area without leaving the room, as long as he doesn't click at the door. That way most LucasArts-games work.
Title: Re:"Walk to"-interaction
Post by: Spyros on Tue 13/05/2003 20:51:38
So what's the problem?
In the INTERACT WITH DOOR interaction put this code
MoveCharacterBlocking(NAME,x,y,0);
NewRoomEx(room,x,y);

Title: Re:"Walk to"-interaction
Post by: LucasFan on Tue 13/05/2003 21:43:50
*Sigh* I don't want to use the interact-mode. You don't "use" doors in SCUMM-games. Only Sierra-games work that way. I just want to click at the door in Walkto-mode and the character should leave the room.
Title: Re:"Walk to"-interaction
Post by: LucasFan on Wed 14/05/2003 00:06:36
Ok, some scripts...

Global-Script:

function on_mouse_click(int button) {
 // called when a mouse button is clicked. button is either LEFT or RIGHT
 if (IsGamePaused() == 1) {
   // Game is paused, so do nothing (ie. don't allow mouse click)
   }
 else if (button==LEFT) {
   ProcessClick(mouse.x, mouse.y, GetCursorMode() );
   SetCursorMode(MODE_WALK);
 
   }
  else if (button==RIGHT) {
   if (GetLocationType(mouse.x, mouse.y)==2)
       { SetGlobalInt(80,9);
         ProcessClick(mouse.x, mouse.y, MODE_TALK);
         SetGlobalInt(80,0); }
   else
        { FaceLocation(GetPlayerCharacter(), mouse.x, mouse.y );
          ProcessClick(mouse.x, mouse.y, MODE_LOOK);
          SetCursorMode(MODE_WALK);
          }
   }
 }

Hotspot-Script: (door)

 // script for hotspot5: Any click on hotspot

if (GetGlobalInt(80)==0) NewRoom(1);    // walk to
else if (GetGlobalInt(80)==1) Display("That doesn't seem to work.");    // close
else if (GetGlobalInt(80)==2) Display("I can't pick that up.");      // give
else if (GetGlobalInt(80)==3) Display("It doesn't seem to open.");  // open
else if (GetGlobalInt(80)==4) Display("I can't move it."); // push
else if (GetGlobalInt(80)==5) Display("I can't move it.");  // pull
else if (GetGlobalInt(80)==6) Display("I can't pick that up.");  // pick up
else if (GetGlobalInt(80)==7) Display("That doesn't seem to work.");// use
else if (GetGlobalInt(80)==10) Display("That doesn't seem to work."); // turn on
else if (GetGlobalInt(80)==11) Display("That doesn't seem to work."); // turn off
else Display("There's nothing to read on it."); // look
SetGlobalInt(80,0);

----

The if (GetGlobalInt(80)==0) doesn't seem to work and I don't understand why.  :-[
Title: Re:"Walk to"-interaction
Post by: Ishmael on Wed 14/05/2003 06:40:51
Ýes, right, sorry. I thought that you just want to make a walk-to command, like the Sierra games...

In the room rep_ex:

if ((GetHotspotAt(mouse.x,mouse.y)==DoorHotspotNumber) || (GetCursorMode()==0)) {
 MoveCharacterBlocking(CHARID,x,y,0);
 NewRoomEx(CHARID,x,y);
}
Title: Re:"Walk to"-interaction
Post by: LucasFan on Wed 14/05/2003 08:52:15
Call me stupid, but with (GetHotspotAt(mouse.x,mouse.y)==DoorHotspotNumber) the interaction always happens when the cursor moves over the hotspot. But I want to click at the hotspot. You understand me?  :-\
Title: Re:"Walk to"-interaction
Post by: Ishmael on Wed 14/05/2003 11:26:20
Oops..... I understand.... My bad, sorry....

if ((GetHotspotAt(mouse.x,mouse.y)==DoorHotspotNumber) && (GetCursorMode()==0) && (IsButtonDown(LEFT)==1)) {
 MoveCharacterBlocking(CHARID,x,y,0);
 NewRoomEx(CHARID,x,y);
}

This Should work
Title: Re:"Walk to"-interaction
Post by: LucasFan on Wed 14/05/2003 12:19:14
YOU ARE MY HERO!

Thank you.  Thank you.  Thank you.   :D