Ultimate cursor reprisal [Solved]

Started by Caracal, Thu 11/10/2012 22:04:11

Previous topic - Next topic

Caracal

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

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! ;-)

Khris

Try this:
Code: ags
  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
    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.

Caracal

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.

Khris

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?

Caracal

Well... it IS set to false. -_-
What do you mean with uploading the "source" somewhere?? How do i do that?

Khris

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.

Khris

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
  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

Caracal

#7
Well… I understand.
Thank you so much! I would have never guessed that!
Now it is the ultimate cursor!

SMF spam blocked by CleanTalk