Jibble

Author Topic: Do action only if you walked to the object/hotspot  (Read 251 times)

Deabriel

  • I'm a freelance designer. I really love pixel art.
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with play testing
    • I can help with proof reading
    • I can help with web design
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

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: Do action only if you walked to the object/hotspot
« Reply #1 on: 23 May 2020, 23:55 »
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

  • I'm a freelance designer. I really love pixel art.
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with play testing
    • I can help with proof reading
    • I can help with web design
Re: Do action only if you walked to the object/hotspot
« Reply #2 on: 24 May 2020, 00:14 »
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.

Re: Do action only if you walked to the object/hotspot
« Reply #3 on: 24 May 2020, 05:02 »
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

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: Do action only if you walked to the object/hotspot
« Reply #4 on: 24 May 2020, 07:41 »
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

  • I'm a freelance designer. I really love pixel art.
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with play testing
    • I can help with proof reading
    • I can help with web design
Re: Do action only if you walked to the object/hotspot
« Reply #5 on: 24 May 2020, 09:21 »
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

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!

Deabriel

  • I'm a freelance designer. I really love pixel art.
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with play testing
    • I can help with proof reading
    • I can help with web design
Re: Do action only if you walked to the object/hotspot
« Reply #7 on: 25 May 2020, 01:14 »
Check out the Tumbleweeds documentation:
https://github.com/adventuregamestudio/ags-manual/wiki/Tumbleweed_movement

Ooooh, I'm feeling too stupid right now hahaha. Thank you so much!