Do action only if you walked to the object/hotspot

Started by Deabriel, Sat 23/05/2020 23:21:23

Previous topic - Next topic

Deabriel

Hi, I want to make my character do something only if he get to the object/hotspot first. If I use the eBlock walk function, this works perfect, the character goes to the object/hotspot and when he reach the point he do the next action. But I want the walk action can be cancelled (eNoBlock) but when I use the eNoBlock walk the character automatically do the rest of the actions without walking before.

How can I make my character walk without blocking and only do the certain things if he get to the point?

Cassiebsg

when the player interacts with the object tell him to walk there, and then in rep_exe check if the player is at the x,y coords, if he is, then do the interaction.  ;)
There are those who believe that life here began out there...

Deabriel

Quote from: Cassiebsg on Sat 23/05/2020 23:55:17
when the player interacts with the object tell him to walk there, and then in rep_exe check if the player is at the x,y coords, if he is, then do the interaction.  ;)

I already tried and that will make my character always do that action always if a walk over the coords.

kaizen101

do you think something like this might work?

if( character on hotspot =true)
{
  if (character already done action = false)
{
    do action
  }
  else
{
    dont do action
}
}


Snarky

Is this the only place in the game you want to be able to cancel an action during the walk there? Because if you want to be able to do this more generally you'd probably want to make a dedicated system for it. (The LucasArts/9-verbs/Tumbleweed templates should already have such a system included.)

Basically, when you start the walk you need to put the action you're going to do in a buffer, and then when you arrive you check the buffer and do it, and whenever you click on something else first you empty the buffer without doing it. In practice, you need to use some sort of identifying key (a string or enum value; or if you only ever need one action per location you could use the coordinates, though I wouldn't recommend it) to store in the buffer (which is just a variable), and then in repeatedly_execute() you compare the buffer value to the master list of actions.

Note also that depending on your AGS version (and of course the walkable areas), the character may not stop at precisely the coordinates you specify.

Deabriel

Quote from: Snarky on Sun 24/05/2020 07:41:23
Is this the only place in the game you want to be able to cancel an action during the walk there? Because if you want to be able to do this more generally you'd probably want to make a dedicated system for it. (The LucasArts/9-verbs/Tumbleweed templates should already have such a system included.)

Basically, when you start the walk you need to put the action you're going to do in a buffer, and then when you arrive you check the buffer and do it, and whenever you click on something else first you empty the buffer without doing it. In practice, you need to use some sort of identifying key (a string or enum value; or if you only ever need one action per location you could use the coordinates, though I wouldn't recommend it) to store in the buffer (which is just a variable), and then in repeatedly_execute() you compare the buffer value to the master list of actions.

Note also that depending on your AGS version (and of course the walkable areas), the character may not stop at precisely the coordinates you specify.
I'm using the thumbleweed template, but I didn't find anything about doing something only if you reach the walk point. I use the last version of AGS. I will try to do the buffer thing, I hope it works.

Snarky


Deabriel


SMF spam blocked by CleanTalk