Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Caracal on Thu 11/10/2012 22:04:11

Title: Ultimate cursor reprisal [Solved]
Post by: Caracal on Thu 11/10/2012 22:04:11
Hello everyone after a long time I come up with another issue.
This time it has to do (so I think) with the extra fancy kings-quest cursor like in this topic:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=46368.0;prev_next=prev#new
I have the following code:
Code (AGS) Select

function repeatedly_execute() {
  int mm = mouse.Mode;   
  int lt = GetLocationType(mouse.x, mouse.y);
  int nm;
  if (lt == eLocationHotspot || lt == eLocationObject) nm = eModeInteract;
  else if (lt == eLocationCharacter) nm = eModeTalkto;
  else nm = eModeWalkto;
  if (nm != mm) mouse.Mode = nm;

This cursor-equation is really amazing and works perfectly fine.
But after continuing to develop my game I run into the following problem: I can not use Inventory Items.
Everything works perfect, the player clicks on an object and it is added to the inventory as the appropriate inventory item… But when I want to click on an inventory item, in order to use it. The cursor just wont change. It is as if I cant click inventory items at all.
My guess is now that it’s the cursors “fault”. But the cursor is besides that perfect I don’t want to have to change it.

Thanks in advance for any participation in finding a solution! ;-)
Title: Re: Ultimate cursor reprisal
Post by: Khris on Fri 12/10/2012 02:01:47
Try this:
Code (ags) Select
  if (nm != mm && player.ActiveInventory == null) mouse.Mode = nm;

Then go to on_mouse_click, and in the button == eMouseRight block, instead of mouse.SelectNextMode(); call this:
Code (ags) Select
    if (player.ActiveInventory != null) player.ActiveInventory = null;

That should fix it.

You'll probably also want to remove the eMouseWheelNorth/South parts.

Btw, I saw that you posted this question in the other thread back when it was current, sorry for never getting back to you; must've missed it.
Title: Re: Ultimate cursor reprisal
Post by: Caracal on Fri 12/10/2012 20:01:08
Well its not really doing anything.
Nothing has changed. Only one question, do i remove the original "if (nm...)" function and replace it with the other or do i leave it untouched? Either way i do it, the cursor is still not reacting to the inventory items.
Title: Re: Ultimate cursor reprisal
Post by: Khris on Fri 12/10/2012 20:10:26
The line is supposed to replace line 8 in the code you posted.

One other thing that could be the cause here:
Go to General settings -> Inventory and check the option "Override built-in inventory click handling".
It should be set to false.

If it is set to true, AGS calls on_mouse_click(eMouseLeftInv) if you left-click on an inventory item and this case isn't handled in a default game's on_mouse_click.

If it IS set to false in your game, could you upload the source somewhere so I can take a look at it?
Title: Re: Ultimate cursor reprisal
Post by: Caracal on Fri 12/10/2012 20:18:47
Well... it IS set to false. -_-
What do you mean with uploading the "source" somewhere?? How do i do that?
Title: Re: Ultimate cursor reprisal
Post by: Khris on Fri 12/10/2012 20:44:06
Save your game, quit AGSEditor, then delete all exe files in the _Debug and Compiled folder (this is fine, AGS will recreate all of them the next time you save the game).
Now pack the game folder into an archive using WinRAR or 7zip or WinZip.
Upload the result to mediafire or another one-click host and PM me the link you get.
Title: Re: Ultimate cursor reprisal
Post by: Khris on Mon 15/10/2012 21:25:14
I feel bad... :P

What happened is that my cursor code set the cursor to eModeWalkto whenever it was over the inventory GUI.
The standard inventory click handling expects eModeInteract though.

Neither of us noticed this because you have imported the same cursor image for every cursor mode; but when I put in code that would display the mode whenever I pressed space, it became apparent.

Amended rep_exe code:
Code (ags) Select
  int mm = mouse.Mode;                                                                          // Ultimate Cursor code from Krhis!!!
  int lt = GetLocationType(mouse.x, mouse.y);
  int nm;
  if (lt == eLocationHotspot || lt == eLocationObject) nm = eModeInteract;
  else if (lt == eLocationCharacter) nm = eModeTalkto;
  else nm = eModeWalkto;
  if (GUI.GetAtScreenXY(mouse.x, mouse.y) == gInventory) nm = eModeInteract;         // <--- added this line
  if (nm != mm && player.ActiveInventory == null) mouse.Mode = nm;

Not so ultimate after all I guess :-D
Title: Re: Ultimate cursor reprisal
Post by: Caracal on Tue 16/10/2012 10:11:29
Well… I understand.
Thank you so much! I would have never guessed that!
Now it is the ultimate cursor!