Author Topic: Some little distance and movement rate calculations and few questions about walking algorithm  (Read 393 times)

Legacy_Valgav

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0


               

I need to find out how long does it take to walk between two waypoints. I know that it could be quite complicated for non-linear paths but for keeping it simple we assume that there's clear straight path between waypoints or if waypoints are on area transition then time equals zero.


 


Can I simple measure the vector between them and divide it by 1.75(assuming that speed of running creature is 3.5 meter per second so for walk it should be divided by 2). Logic says that it should give me pretty accurate results, but is it that simple or should i just run some timer and allow the npc to walk that distance and measure it? (need few dozens of that so would be great if I can get that just by math).


 


Also I'm looking for some simple way for walking npcs algorithm, but ActionMoveToLocation is not recommended, right? But I want to avoid placing dozens of waypoints manual so i though about storing location by area name and coordinates and then force npc to walk to that point. Using that way with database I can store thousands of waypoints and easy manage them without having to edit module, just need some wand for adding point to database.


 


Is it even possible?



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0


               It would help to know why you need the timing. For example, if you just need X to happen when an actor reaches point Y, don't worry about time, just give the actor two actions, ActionMove... followed by ActionDoCommand(X).


The theoretical speed is given here:

http://nwn.wikia.com...eaturespeed.2da


but measurement is the acid test. Some of the complications are discussed here:

http://nwn.wikia.com...i/Movement_rate


If you can calculate where the waypoints should be, you can use CreateObject in a script rather than manual placement. You can capture locations in game (not in the toolset) with a unique power item or dm / player tool.


The issues with ActionMoveToLocation are discussed here:

http://www.nwnlexico...nMoveToLocation


Although ActionMoveToObject is slightly more robust, its path may be far from linear, so the timing is less predictable. The CutsceneGhost effect allows the creature to pass through others on a linear path, which players may not even notice unless the creatures are large.
               
               

               
            

Legacy_Valgav

  • Full Member
  • ***
  • Posts: 118
  • Karma: +0/-0


               

Timing is for external use to calculate where npc have to be in certain moment. Having database with this "false waypoints" i can count exact location determined by other scripts which is better than relying on ActionMoveToObject or ActionMoveToLocation. Then OnEnterArea i can spawn this guys on specific location determined by current assigned waypoint and AMTO or AMTL to simulate walking animation.


 


In theory you can force npcs to walk long way like 20 areas and still be able to spawn them when they're needed.


 


The main problems are waypoints, even if you spawn them on module load there's still like hundreds of them, won't they lag or do some other nasty staff? Using Location seams to be cleaner solution in theory or maybe I should spawn waypoints only on specific currently used location along the used npcs?



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0


               

I've created many dozens of waypoints in single player, no noticeable lag. I generally do it when a player enters an area for the first time. I'd expect it to be very quick, because a waypoint in game is a tiny amount of data (lag generally results from graphics and/or model loading). In any case, processing during module or area load isn't going to be perceived by the player. All the same, as a rule of thumb, it's good to create stuff only when you need it, and remove it afterwards.


 


If I've understood what you're trying to do, while the player is elsewhere, you keep track of where the NPCs ought to be (according to some predetermined plan of activity) and spawn them when the PC enters an area.


 


That's definitely the way to go. For example, I once made a pilgrim system, in which pilgrims walked from one end of the module to the other, while citizens milled around in their local areas. That did start to lag, owing to the unnecessary AI activity in areas the PC couldn't even see. Also, unless I set the AI level artificially high, the NPCs would go dormant or move slowly when the PC wasn't around.


 


There is some overhead to spawning a creature, so, in the toolset, you might want to put them all in a holding area that the PC can't visit. In game, jump them to the correct location when the PC enters the area, then clear all actions when the PC leaves.