Unwanted mouse mode processing at end of speech

Started by Sughly, Tue 08/05/2012 08:54:05

Previous topic - Next topic

Sughly

Alright, can't seem to find anyone who's had the same issue exactly so here goes - I'm getting stuck in an endless loop. I have the mouse mode changing to an exit arrow over the hotspot for a room exit, and if the player hasn't met certain conditions, clicking on it triggers a scene where the player talks about why they cant use the exit yet. BUT at the end of this, the player keeps walking back to the hotspot and triggering the same scene over and over! I figure it's because the game is told to process the attempted exit when the mouse is in that particular mode, but I can't figure out a work around. I tried this at the end of the scene...

Code: ags
Mouse.Mode = eModeWalkto;
overhotspot.Text = "@OVERHOTSPOT@";
overhotspot.Visible = true;
player.StopMoving();


...in order to set the mouse mode back to normal, but nope, didn't help. As you can tell I'm just trying to throw whatever I can at the game to get it to not process the click at the end of this scene, but it's determined to ignore me and keep the loop going :(
I also have this code in repeatedly execute since I was having the mouse mode hanging in exit mode sometimes...

Code: ags
if (mouse.Mode == (eModeExitDown || eModeExitRight || eModeExitUp || eModeUsermode1)){
  if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hAttToRoof || Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hWeakSpot || Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hAtticToBed){
    //do nothing
  } else {
    if (cAnna.ActiveInventory == null){
      Mouse.Mode = eModeWalkto;
    } else {
      Mouse.Mode = eModeUseinv;
    }
  }
}


buuuut that doesnt help in this situation for some reason, even if I move it to repeatedly execute always. Anyone...?

EDIT: Ahhhh, okay, looking at that second code I realise its useless in this situation - the hotspot in question is hWeakSpot, and since the game still thinks the mouse is over the hotspot I suppose its just not doing anything and leaving it. I still need that code though to prevent the mouse from hanging in exit mode sometimes though... any suggestions?

Khris

Minor suggestion: store Hotspot.GetAtScreenXY(mouse.x, mouse.y) in a pointer, then do the check:
Code: ags
  Hotspot*h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  if (h == hAttToRoof || h == hWeakSpot || h == hAtticToBed) {
    ...


But, more importantly, the first condition is flawed. You can't group multiple checks like that. What you have there is essentially
Code: ags
  if (mouse.Mode)

When AGS encounters that line, the first thing it does is calculate the right part. All mouse cursor enums are ints, and any int other than 0 amounts to true. Thus you're basically having (true || true || true || true) which is of course true. Then AGS does if (mouse.Mode == true) which is true for every mode except 0 (eModeWalkto).

So you need something similar to the other piece:
Code: ags
  int mm = mouse.Mode;
  if (mm == eModeExitDown || mm == eModeExitUp || mm == eModeUsermode1) ...

Sughly

Ahhhhh ok, that makes sense. Yeah making those adjustments was enough to stop the loop at least, so thanks a heap Khris! It still processes a click if clicking through what the player character says about not being able to go through the exit, which the game doesnt normally do except at this one particular point, but that's not a huge issue anyway. Again, thanks a heap Khris! Lifesaver!

SMF spam blocked by CleanTalk