Over Hotspot dilemma...

Started by Slasher, Mon 30/09/2013 07:49:41

Previous topic - Next topic

Slasher

Hi,

would you help with a problem I seem to have?

It involves 'over hotspot'

If a certain inventory item hovers over a hotspot then events run. I use a number of hotspots and each has their own events.

To stipulate what hotspot to run its events I use this in mouse over hotspot:

Code: ags
if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hTree){ //  specifies hTree hotspot


But I also want to add the condition that if player has a particular inventory Item in which case it sets a boolean true which affects when interacting with hotspot.

Code: ags

   if(cSpaceman.ActiveInventory==iGieger){

   mouse.ChangeModeView(eModeUseinv, 105);
   cSpaceman.SayBackground("Radiation is very low there but constant exposure will make you sick.");
   tree_done=true; // changes 'interact' hotspot event.


Code: ags

function hTree_Interact()
{
  if(tree_done==true){

  interact_with_2();
  }  
  else {
  interact_with();

}
}


At the moment having the correct inventory item turns all the boolean to 'true' before it's actually over hotspot hTree for example.

I have tried a couple of things but to no success yet.

Hope you understand what I mean.

cheers



Khris

Try this:

Code: ags
// in repeatedly_execute

  Hotspot *h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  InventoryItem *ai = cSpaceman.ActiveInventory;

  if (h == hTree && ai == iGieger && !tree_done) {
    mouse.ChangeModeView(eModeUseinv, 105);
    cSpaceman.SayBackground("Radiation is very low there but constant exposure will make you sick.");
    tree_done=true; // changes 'interact' hotspot event.
  }

Slasher

#2
Hi Khris,

Somehow the boolean (tree_done) still turns 'true' even when active inventory iGieger is not directly over the hotspot hTree, in fact even if miles away from it.

EDIT I think I've jumped ahead before I've added code for ALL hotspots.

Sorry Khris.

I will report later.

EDIT EDIT Still not working as it should...

I think it's because Hotspot 'mouse over' not only acts when player has active inventory item mode showing but even if a different mode is showing.

*** EDIT EDIT EDIT

Added if mouse Mode is 4

Code: ags
Hotspot *h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  InventoryItem *ai = cSpaceman.ActiveInventory;

  if (h == hSign && ai == iGieger  && !sign_done && mouse.Mode==4){
  mouse.ChangeModeView(eModeUseinv, 105);
  sign_done=true; // changes 'interact' and 'talk' hotspot events.


This seems to do the job, well until full test... (laugh)

cheers




Khris

Right, this was just mentioned in another thread, too.
You should use eModeUseinv though instead of 4, to keep the code more readable.

And btw, if you're putting that code in hSign's mouse over event, you can of course skip the hotspot check.

Slasher


SMF spam blocked by CleanTalk