Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Nahuel on Wed 12/08/2009 19:02:11

Title: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Nahuel on Wed 12/08/2009 19:02:11
Hello there! My problem is when I used the command
Character.Walk(int x, int y, optional BlockingStyle, optional WalkWhere);

the game enter in a wait mode, how can I make a function where I can stop the moving or cancel the action, when I click in other area, hotspot ANYTHING (like the lucas games) because it's too many time wasted.

I'm Trying to make a function MoveChar using "while" player.Walking
and when (Mouse.IsButtonDown(eMouseLeft) || Mouse.IsButtonDown(eMouseRight)
player.StopMoving();

but I don't undertand very well.

Thanks for your time!!

Nahuel.
Title: Re: Command Walk without eBlock no move the char
Post by: Mazoliin on Wed 12/08/2009 20:30:06
This post should be of interest:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=31597.msg406099#msg406099 (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=31597.msg406099#msg406099)
Title: Re: Command Walk without eBlock no move the char
Post by: Nahuel on Wed 12/08/2009 20:47:36
Quote from: Mazoliin on Wed 12/08/2009 20:30:06
This post should be of interest:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=31597.msg406099#msg406099 (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=31597.msg406099#msg406099)

Thanks!! but doesn't work  :P I'm trying, I'm trying!!  :=

Thanks!!
Title: Re: Command Walk without eBlock no move the char
Post by: Mazoliin on Wed 12/08/2009 21:01:44
Look's like you should place the function code after the on_mouse_click function in the global script, not inside it, after.
Title: Re: Command Walk without eBlock no move the char
Post by: Nahuel on Wed 12/08/2009 21:16:07
Quote from: Mazoliin on Wed 12/08/2009 21:01:44
Look's like you should place the function code after the on_mouse_click function in the global script, not inside it, after.

Thanks Mazoliin!! It's working now!

But it's doesn't what I need because I need some like this
this is from a SCUMM template by RULAMAN

Simple while player.Moving if Button Rigth || Left
              cancel


function MovePlayerEx (int x, int y, int direct)
{
  // Move the player character to x,y coords, waiting until he/she gets there,
  // but allowing to cancel the action by pressing a mouse button.

GUI *guiAt = GUI.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem *invAt = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);

if ( g_PlayerCanMove > 0 )
  {
    int cursorspritenumber = 16,
    blankcursorspritenumber = 26;
GScancelable = 0;

Mouse.ChangeModeGraphic(eModeWait, cursorspritenumber);

if (direct == 0)
player.Walk(x, y);

    else
player.Walk(x, y, eNoBlock, eAnywhere);

// wait for release of mouse button
    while (player.Moving && (Mouse.IsButtonDown(eMouseLeft) || Mouse.IsButtonDown(eMouseRight) ))
    {
      Wait (1);
      Mouse.Update();
      CheckDefaultAction ();
    }
    // abort moving on new mouse down

    while (player.Moving)
    {
      if ( Mouse.IsButtonDown (eMouseLeft) && ( null == guiAt || null != invAt ))
      {
        player.StopMoving();
        GScancelable = 1;
      }
      else if ( Mouse.IsButtonDown(eMouseRight) && (null == guiAt || null != invAt ))
      {
        player.StopMoving();
        GScancelable = 2;
}
      else
      {
        Wait (1);
        Mouse.Update();
        CheckDefaultAction();
      }
    }
    mouse.ChangeModeGraphic(eModeWait, blankcursorspritenumber);

if ( GScancelable == 0 && player.x == x && player.y == y )
{
return 2;
}
    else if ( GScancelable == 0 )
{
return 1;
}
    else
{
return 0;
}
  }
  else return 0;
}



Thanks!!!!!
Title: Re: Command Walk without eBlock no move the char
Post by: Khris on Wed 12/08/2009 21:33:14
I've written a module to do that, based on the code in the other thread.

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36383.msg477380#msg477380

Please don't say "it doesn't what I need", tell us what you need it to do.
Title: Re: Command Walk without eBlock no move the char
Post by: Nahuel on Wed 12/08/2009 21:45:20
Quote from: KhrisMUC on Wed 12/08/2009 21:33:14
I've written a module to do that, based on the code in the other thread.

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36383.msg477380#msg477380

Please don't say "it doesn't what I need", tell us what you need it to do.

oh, I'm sorry KhrisMUC. Sometimes I write with mixing two languajes (English and Spanish) I apologize.

Thanks for the information, and sorry again.

Nahuel.
Title: Re: Command Walk without eBlock no move the char
Post by: Khris on Wed 12/08/2009 22:17:24
There's no need to apologize, I was just interested in why the other method failed to do what you wanted it to.
Title: Re: Command Walk without eBlock no move the char
Post by: Nahuel on Thu 13/08/2009 15:11:36
Quote from: KhrisMUC on Wed 12/08/2009 22:17:24
There's no need to apologize, I was just interested in why the other method failed to do what you wanted it to.



KhrisMUC,
         
          Unfortunately yesterday I could not answer.
          I'm going to expain as best I can (obviously for my English).

I need a method to walk to the hotspot or object, and when use the funcion (for example) PickUp, the player continue walk without a wait time and cancel the action with one click in other part of the room (like Indiana Jones), but these methods doesn't work with my game (I realy don't know) becuse I put the functions in the rigth place.

The character must cancel their action when with the mouse touch in other

It's like SCUMM. Or Indiana Jones or Maniac Mansion.

Thank You.

Nahuel.
Title: Re: Command Walk without eBlock no move the char
Post by: Khris on Thu 13/08/2009 17:01:35
Did you try the module I linked you to? It does exactly what you want.
Title: Re: Command Walk without eBlock no move the char
Post by: Nahuel on Thu 13/08/2009 17:09:33
Quote from: KhrisMUC on Thu 13/08/2009 17:01:35
Did you try the module I linked you to? It does exactly what you want.

Yes KhrisMUC but doesn't work.
Probably some in my script make conflicts, I still working with your module:-\

Thanks for help me. KhrisMUC!

Nahuel.
Title: Re: Command Walk without eBlock no move the char
Post by: Nahuel on Thu 13/08/2009 17:18:15
Quote from: peillat.nahuel on Thu 13/08/2009 17:09:33
Quote from: KhrisMUC on Thu 13/08/2009 17:01:35
Did you try the module I linked you to? It does exactly what you want.

Yes KhrisMUC but doesn't work.
Probably some in my script make conflicts, I still working with your module:-\

Thanks for help me. KhrisMUC!

Nahuel.

KhrisMUC ! It's WORK!!! I has a problem with the direction and coordenades!! Now I can use it to perfection!!!!

Thanks for your script!! I appreciate you very much

Nahuel.
Title: Re: Command Walk without eBlock no move the char (SOLVED)
Post by: Khris on Thu 13/08/2009 17:37:48
You're welcome! :)
Title: Re: Command Walk without eBlock no move the char [OK] but....
Post by: Nahuel on Thu 13/08/2009 19:27:59
KhrisMUC,
               exist any way that, during the time that the character walks to the object or hotspot, return to eModeWalkTo by default?? Because my char still with the action I select... understand what I mean??
   
I understand if it is difficult to understand.  :=

Thanks.

Nahuel.
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Khris on Thu 13/08/2009 20:05:16
When exactly do you want the mouse mode to switch back to eModeWalkto?
After the player interrupted the action by clicking on nothing?
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Nahuel on Thu 13/08/2009 20:10:15
Quote from: KhrisMUC on Thu 13/08/2009 20:05:16
When exactly do you want the mouse mode to switch back to eModeWalkto?
After the player interrupted the action by clicking on nothing?

Exactly, do you play some game like indiana jones or monkey island or the dig?? like this when you touch in nothing, the char cancel de action and automaticly the mouse.Mode is WalkTo.

Thanks

Nahuel.
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Khris on Thu 13/08/2009 23:02:05
If you look at the on_mouse_click function in GlobalScript.asc, it should say in there:
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }


Replace that with
  else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick(mouse.x, mouse.y, eModeWalkto);
    else ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Nahuel on Fri 14/08/2009 01:13:02
Quote from: KhrisMUC on Thu 13/08/2009 23:02:05
If you look at the on_mouse_click function in GlobalScript.asc, it should say in there:
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }


Replace that with
  else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick(mouse.x, mouse.y, eModeWalkto);
    else ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }


KhrisMUC,
              I appreciate all your help.
              Thank you very very much!
              Any problems I have, I will notify you.
              As soon as possible I will make the changes!!!

Thanks KhrisMUC!!! Thank you!

Nahuel.
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Nahuel on Fri 14/08/2009 14:03:18
KhrisMUC doesn't return to eModeWalkto!!  :'(  I 'm fried!! I still working on!!

Thanks!!

Nahuel.
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Matti on Fri 14/08/2009 14:58:51
Quote from: peillat.nahuel on Fri 14/08/2009 14:03:18
KhrisMUC doesn't return to eModeWalkto!!  :'(  I 'm fried!! I still working on!!

Thanks!!

Nahuel.

You're fried just because Khris doesn't return to eModeWalkto?  ;D

No, seriously, KhrisMUCs script doesn't change the cursor, but lets the character walk. Try this instead:


  else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) {
      mouse.Mode = eModeWalkto;
      ProcessClick(mouse.x, mouse.y, eModeWalkto);
    else ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }


I guess this is what you sere looking for.
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Nahuel on Fri 14/08/2009 15:15:08
Quote from: Mr Matti on Fri 14/08/2009 14:58:51
Quote from: peillat.nahuel on Fri 14/08/2009 14:03:18
KhrisMUC doesn't return to eModeWalkto!!  :'(  I 'm fried!! I still working on!!

Thanks!!

Nahuel.

You're fried just because Khris doesn't return to eModeWalkto?  ;D

No, seriously, KhrisMUCs script doesn't change the cursor, but lets the character walk. Try this instead:


  else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) {
      mouse.Mode = eModeWalkto;
      ProcessClick(mouse.x, mouse.y, eModeWalkto);
    else ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }


I guess this is what you sere looking for.

Jejeje fried becouse I coudn't make this function! It's unbelievable ! jejejeje.

by the way..  := the script don't work!  :o

Thanks Mr Matti!!

Nahuel.
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Matti on Fri 14/08/2009 15:21:28
Why doesn't the script work? What exactly happens?
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Nahuel on Fri 14/08/2009 15:28:18
Quote from: Mr Matti on Fri 14/08/2009 15:21:28
Why doesn't the script work? What exactly happens?

GlobalScript.asc(93): Error (line 93): PE04: parse error at 'else'

function on_mouse_click(MouseButton button)
{
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
  }
    else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) {
      mouse.Mode = eModeIra;
      ProcessClick(mouse.x, mouse.y, eModeIra);
    else ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight)
  {
    ProcessClick(mouse.x, mouse.y, eModeMirar);
  }
}


and I try this
function on_mouse_click(MouseButton button)
{
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
  }
  else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) {
      mouse.Mode = eModeIra;
      ProcessClick(mouse.x, mouse.y, eModeIra);
    }
    else ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight)
  {
    ProcessClick(mouse.x, mouse.y, eModeMirar);
  }
}


and this

function on_mouse_click(MouseButton button)
{
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
  }
  else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) {
      mouse.Mode = eModeIra;
      ProcessClick(mouse.x, mouse.y, eModeIra);
    }
    else ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
}

And the mouse.Mode remains the action I have and doesn't return to Walkto  :(
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Matti on Fri 14/08/2009 15:41:29
You forgot a closing bracket, it should look like this:


function on_mouse_click(MouseButton button)
{
 if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
 {
 }
 else if (button == eMouseLeft) {
   if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) {
     mouse.Mode = eModeIra;
     ProcessClick(mouse.x, mouse.y, eModeIra);
   }                                                            // <-- this bracket was missing
   else ProcessClick(mouse.x, mouse.y, mouse.Mode );
 }
 else if (button == eMouseRight)
 {
   ProcessClick(mouse.x, mouse.y, eModeMirar);
 }
}



EDIT: Sorry, in your second code, the bracket is there. I've no clue why it doesn't work, are you sure you have set the walkable areas right?
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Nahuel on Fri 14/08/2009 16:04:07
Mr Matti the function is not working.

I make a function ModeStandard()
{
       mouse.Mode = eModeIra;
}

And I call when the script finish.

I think I will delete all the scripts and make from beggining!  :'(

Have anybody any script like LucasArt Stile? My Script is a disaster!
I only want make an interface like LucasArts.

Features:

Click on object or hotspot, make action (possible cancel with click on other place) you know

Thanks!

By the way
If anybody wants my game to test why doesn't work I give you! jeje :=

Guys thanks for help me!
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Matti on Fri 14/08/2009 16:36:49
Yeah, upload it so we can have a look..
Title: Re: Command Walk without eBlock no move the char (SOLVED) - With other problem!
Post by: Nahuel on Fri 14/08/2009 16:52:01
Quote from: Mr Matti on Fri 14/08/2009 16:36:49
Yeah, upload it so we can have a look..

Ok I will upload in a minutes. Thanks for your efforts!

HAVE PROBLEM!! I can't upload it at work! In a couple of hours I will upload the file.


Pass:
ThanksForHelpMe1


Nahuel.