SOLVED: Change cursor graphic if Player HasInventory item

Started by barefoot, Mon 29/11/2010 09:23:08

Previous topic - Next topic

barefoot

Hi

As my subject describes, rather then have an ActiveInventory graphic act as mouse curor i would like to check if player Has.Inventory item and if so change the mouse graphic to that item..

The mouse cursor graphic when used on an object/hotspot returns the cursor to normal, say interact mode and events happen.

Example: you see a screwdriver (object), you interact with it and you have it as an inventory item and the object visible=false.. The mouse cursor changes to a screwdriver.

You use the mouse graphic (screwdriver) on a particular hotspot/object and events happen and the mouse cursor returns to normal, say interact mode.

I have seen a variety of answers on this but yet to find a precise one.

I hope i have got this right. cheers for any help

barefoot










I May Not Be Perfect but I Have A Big Heart ..

Khris

I'm afraid I'm having problems understanding your post.
So as soon as you pick something up, it's supposed to become the active inventory item?
Like:
Code: ags
  player.AddInventory(iScrewdriver);
  player.ActiveInventory = iScrewdriver;

Is that it?

And after the player has successfully used an item, the mouse is supposed to turn back to interact?
Like:
Code: ags
  //  screwdriver was successfully used, animations, bla here
  player.ActiveInventory = null;
  mouse.Mode = eModeInteract;


I'm sorry if I misunderstood you, is it really that simple? Probably not.

barefoot

Hi Khris

Hope this explains better:

You Interact with an object (oscrewdriver / Object1), it is added to inventory as iscrewdriver and the object becomes visible=false (Object1)

Now, when the player HasInventory (in this case iscrewdriver), the mouse graphic turns to screwdriver graphic (Number 959). With the screwdriver Mouse graphic you click on a particular Hotspot and an object (Object2) becomes visible and events happen. Afterwhich the mouse graphic returns to normal mode eg walk and the inventory item is withdrawn from inventory.  

I don't really want this as an Active.Inventory scenerio.

Hope this explains better

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Khris

I sort of get what you mean, I'm still a bit confused about what you're asking exactly though.
So the player isn't supposed to leave the room with the screwdriver? And once they picked it up, they have to use it and can't deselect it, i.e. change the mode to walk?
Is the player tied to chair or something like that?

Realizing this without player.ActiveInventory is probably more of a hassle than simply constraining the player's actions.
The code snippets I posted should more or less apply; you'll just have to add
Code: ags
  player.LoseInventory(iScrewdriver);

to the second part.

To prevent the player from doing anything else once the screwdriver is active, you need to disable the player's ways of changing the mouse.Mode.
For instance, in on_mouse_click, a right click switches to the next mode:
Code: ags
  else if (button == eMouseRight || button == eMouseWheelSouth){
    // right-click our mouse-wheel down, so cycle cursor

    if (player.ActiveInventory == iScrewdriver) return;  // don't process right-clicks, exit the function

    mouse.SelectNextMode();
  }


You also have to disable the Iconbar and eMouseWheelNorth in a similar way.

I hope this is what you're looking for.

barefoot

#4
Hi Khris

UPDATE... So far this works..

Code: ags

function oscrewdriver_Interact()
{
  
  cChris.Walk(380,384, eBlock); 
  cChris.Say("It's a screwdriver");
  Display("You decide to take it");
  object[1].Visible = false;
  cChris.AddInventory(iscrewdriver);
  cChris.Say("Well, looks like i've missed who ever did this! I think they are still in the house!!");

 if (player.HasInventory(iscrewdriver))

 
  mouse.ChangeModeGraphic(2, 959);

}


AND THIS WORKS;

Code: ags

function hHotspot2_Interact()
 {
  if (!oscrewdriver.Visible) 
  object[2].Visible = true;
}


I Just need the mouse graphic to return to normal ie say interact etc
----------------------------------------------------------------

Now, with the screwdriver mouse graphic it allows events to happen when used on a Hotspot/Object in the room and then return to normal mouse graphic mode such as interact or walk etc (of course you lose the inventory item after use (iscrewdriver).

----------------------------------------------------------------------


basically, click on iscrewdriver and the mouse graphic changes to image 959 (screwdriver), with the mouse graphic (959) you click on a hotspot and another object appears and then mouse returns to normal mode.

maybe keep Active.Inventory?

cheers Khris

barefoot
I May Not Be Perfect but I Have A Big Heart ..

Khris

You don't need "if (player.HasInventory(iscrewdriver))" in that code; you've added the item two lines ago and there's no way the player won't have it.

What you want seems to be
Mouse.GetModeGraphic(CursorMode)

You'd use it like this:

Code: ags
function Hotspot/Object_Interact() {

  if (mouse.GetModeGraphic(eModeInteract) == 959) {
    ...
  }
  else Display("That won't work.");
}


Sorry, but I still don't get why you want to do this though. I'm just curious, why not use the usual way, i.e. inside Object_UseInv, check for player.ActiveInventory == iscrewdriver?

barefoot

#6
Hi Khris

Because i want the inv object to be the mouse cursor....it saves having to open the inv window. This may be the case for a few inv objects. Your points have been noted and I thank you Khris.

UPDATE:

This seems to work for the second part so it now seems to all be solved, hard work but worth getting there:
Code: ags

{
  
  if (!oscrewdriver.Visible) 
{
  cChris.Walk(166, 450, eBlock);
  player.ActiveInventory=null;
  object[2].Visible = true;
  cChris.LoseInventory(iscrewdriver);
  mouse.UseModeGraphic(eModeWalkto);
  mouse.ChangeModeGraphic(2, 2057);
  hHotspot2.Enabled = false;
 
}
}  


cheers Khris

barefoot

I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk