[AGS problem] Walk function

Started by Calavera, Thu 17/02/2011 21:32:28

Previous topic - Next topic

Calavera

Hi, when i play and i click in a point like a crazy the main character hangs.
I think the problem is in the function Walk indeed when i run the command cEgo.Walk in the repeatedly execute function  my character freezes.

Can anyone help me?

Calin Leafshade

why *would* you click like crazy in a single point?

Calavera

because i think many player can do

Giowe

right. i have the same problem. anyone can solve this?

Snarky

The issue is that every time you click, the game recalculates the path for the character to walk to that spot. And the pathfinding in AGS is fairly slow, so this causes the game to hang for a moment. Apart from optimizing the A* implementation used by AGS (someone once claimed they could do it faster in an in-game script than the built-in implementation), you'd have to stick in some logic to keep multiple clicks in the same spot from doing the recalculation each time.

Khris

Hi, when I'm working on my PC and I pour a bucket of water into the case like a crazy the PC stops working.
I think the problem is in the bucket of water indeed when I pour water over other electric appliances they stop working, too.

Can anyone help me?

Giowe

Quote from: Khris on Thu 17/02/2011 21:58:50
Hi, when I'm working on my PC and I pour a bucket of water into the case like a crazy the PC stops working.
I think the problem is in the bucket of water indeed when I pour water over other electric appliances they stop working, too.

Can anyone help me?

just try to do the same in monkey island. it goes right. that was well designed. this is NOT well programmed and i want for my game the best solution possible. if in your opinion this is not important don't waste your time posting stupid things. tnx.

Calavera

So there aren't any other solution? I have to implement another computational method for the A* algorithm and overload the Walk method?

Calin Leafshade

So, you guys are repeatedly clicking in the same location over and over again?

If you really think that players will do that you could just add a timer to the click and not allow clicks within a second of each other and if the click is very close to the previous click.

But really it seems like you are inventing a problem that doesnt really exist.

Khris

#9
This should work:

Code: ags
int timeout = 10;

int timer;

void repeatedly_execute_always() {
  timer++;
  if (timer >= 10000) timer = 1;  // avoid overflow
}

int ox, oy;

void on_mouse_click(MouseButton button) {
  if (timer < timeout && mouse.x == ox && mouse.y == oy) ClaimEvent();
  else {
    timer = 0;
    ox = mouse.x;
    oy = mouse.y;
  }
}


Stick this in a script above the Global one (or incorporate it into Global.asc).

What it does is simply ignore any click at the same location as the previous one within timeout frames.

Btw, I recognize this is something people take seriously and I apologize for making fun of it. However, I personally wouldn't implement stuff that helps people with a serious personality disorder to play my game.

hedgefield

Quote from: Khris on Thu 17/02/2011 21:58:50
Hi, when I'm working on my PC and I pour a bucket of water into the case like a crazy the PC stops working.
I think the problem is in the bucket of water indeed when I pour water over other electric appliances they stop working, too.

Can anyone help me?

If this was Facebook I would have Like'd that post.

The situation you describe seems like a very OCD thing to do, I don't think you have to be afraid many people will act this way. The only time I ever did something similar was to find that óne pixel in the wheel puzzle room in Broken Sword 2 that lets you skip that whole section.
But if you're really serious about it the suggestions above should go a long way to help you with this 'problem'.

Calavera

The problem there also when i click in a different position, i would fix this because in my game there are many scene with a long backgorund and the player is forced to click at the screen side repeatedly. 

Calin Leafshade

Khris' function should probably be altered to catch mouse coords related to the *room* instead of the screen to account from scrolling rooms.

And while the pathfinding isnt perfect this is easy to script around. It's not a priority fix.

Snarky

I always do this when I need a character to walk across a scrolling room. Keep the cursor in one position and keep clicking while the room scrolls. The fact that it causes the game to stutter has long been one of my minor annoyances with AGS.

Yeppoh

It depends from the gameplay you wish, but I got around this by scripting a double click to do either:
- a jump;
- a teleport;
- running;
- any secondary action;
You choose.

For the scrolling room, I like how the Broken Sword team dealed with that, by using a special interaction to that effect when the mouse is on the scrolling part of the screen. Or you can make it Zack and Wiki style, keeping the mouse button down to control the character walk.

SMF spam blocked by CleanTalk