Find out if current Destination.X is a (exit) Hotspot

Started by TheVolumeRemote, Tue 03/05/2022 23:34:15

Previous topic - Next topic

TheVolumeRemote

Hey mates, I hope you're all well.

Is there a reasonably simple way to find out if the players current Destination is going to land them on a Hotspot?

I'd like to send the player to the character they're about to talk to, without room-specific coordinates with the caveat being, if the player has landed on (or their DestinationX being) a hotspot- in this case a hotspot with a ChangeRoom command. 160 of them actually, so ideal solutions I'll happily note for next time but for now if I can avoid going through 80 rooms with 2 "stands on hotspot" exits in each, that would be mega. I have a few ideas that would probably get it done but they involve going back through every room and I'd love to handle this globally.

I kinda feel like #define is my answer here but honestly I'm struggling. If I can find out  1)  Is the Destination a hotspot and 2) what is that hotspot's ID, I can handle it on on_mouse_click.

I should mention that my game has rooms with varying widths (scrolling), which is the main thing that's outsmarting me so far. I'd imagine something like below would work if each room was a predictable 320 x 200 but alas. Anyway this might be drifting from the point but I feel weird asking for help without showing some code  ;)
Code: ags

function cChar_Talk()
{
  player.Walk(cChar.x + 40, PrevY, eBlock, eWalkableAreas);
  faceChar();
  facePlayer();
  dDialog.Start();
}

function on_mouse_click(MouseButton button)
{
  if (button == eMouseLeft)
  {
    if (mouse.Mode == eModeTalkto)
    {
      if (player.DesinationX <= 10 || player.DesinationX >= 310)
      {
          player.StopMoving();
          player.Walk(cChar.x - 40, PrevY, eBlock, eWalkableAreas);
      }    
    }
  }
}


Wouldn't work easily, if I go and tag the previous 80 rooms with i

Pax Animo

As a wild guess because I have similar questions my self, possibly make a function which can be called easily without repeating unessary code.
Misunderstood

Khris

You can use
Code: ags
  Hotspot* dest = Hotspot.GetAtRoomXY(player.DestinationX, player.DestinationY);


However I don't know of a way to then check whether the hotspot's stand on event is going to run a ChangeRoom command.

You should've approached this very differently from the start:
1. use Regions instead, and their "steps onto" event
2. use custom properties to state a room number and coordinates, which allows you to write global ChangeRoom code

Anyway, I guess you can simply disable all hotspots while your player is approaching a character. Iterate over all of them using the  hotspot[]  array, store the enabled ones, disabled them, then reenable them after the dialog.

SMF spam blocked by CleanTalk