Mimick pathfinding?
#1
Posté 02 janvier 2013 - 07:55
#2
Posté 02 janvier 2013 - 07:26
I have not found an elegant way to do this. I did write a jumping AI however which is able to determine when an NPC is in combat and stuck. If they are stuck they are given the option to initiate another mode of movement (jumping, teleporting, fly, spider climb) and thereby cross whatever impassable terrain is in the way.
This is a very small piece of what you are trying to do. I don't have the answer for your pathfinding problem. I'll be watching to see what you come up with.
#3
Posté 02 janvier 2013 - 07:51
#4
Posté 02 janvier 2013 - 08:45
It effectively creates a series of line segments that you can designate as roads or paths that NPC will follow. And is very efficient, as pathing between two unobstructed points is quite easy for the engine. If you message me I can share what I have so far, it's a small module.
You can create a webwork of paths in your module and the scripting PK created will plot the course automatically. I'm hoping to create a multi-area module to illustrate this technology.
You can check out a small discussion on my form: http://qlippoth.dynd....php?f=18&t=195
You don't need to use it in every area; you can designate a creature to use Pathways, or an area where the creatures should use Pathways. It is VERY helpful for getting PCs to walk around tight obstacled areas, but does NOT function while PCs are in combat. So there are limits, since Pathways (or pathing, for that matter) is a non-combat mode of movement.
PK did a ton of cool things for NPC Activities and it's a shame it wasn't a clearly marketed update o NC Activities 6.1. PK wanted to do more, but then he fell off the face of the earth... I will likely add Lairs to that module example as well. That was something Deva wrote for me years back before PK took it onward.
- Qlippoth
Modifié par QlippothVI, 02 janvier 2013 - 08:49 .
#5
Posté 03 janvier 2013 - 12:29
#6
Posté 03 janvier 2013 - 02:13
I don't think they ever did a function to pathfind specifically or determine whether a point was actually get too able. (Though your horse just shows up if it's nearby and can't get to you, i.e. it can't figure out how to get to you. The default is for it to just jump to where you are).
The function: // FILE: x3_inc_horse FUNCTION: HorseForceJump()
// This is used to make sure oJumper makes it to withing fRange of oDestination.
// The nTimeOut is used to set a maximum number of attempts that will be made.
void HorseForceJump(object oJumper,object oDestination,float fRange=4.0,int nTimeOut=10);
I know there is onblocked, and I use that for things like flyers who could fly over a bridge door or up to a higher level without using a ramp or some such method to arrive, though that does not address your question.
#7
Posté 03 janvier 2013 - 03:30
Highv Priest wrote...
Wait so I'm actually touching on a ground no one has touched on before? Awesome! That's so rare in a game like nwn.
Not even remotely. Download the Omnibus and run some searches. This one is as old as NWN. Long story short, you need engine-level access to do anything other than jump-style solutions. See, e.g.:
NWN Omnibus/NWN Omnibus/data/BioWare Forums/Scripting/02601 I feel like I'm about to reinvent the wheel_ NPC Pathing & forcing 'unstick'.html
NWN Omnibus/NWN Omnibus/data/BioWare Forums/Archive Builders - NWN Custom Content/08058 More Pathnodes - Please_!.html
NWN Omnibus/NWN Omnibus/data/BioWare Forums/Scripting/07570 onblocked.html
Probably the worst part is that onblocked doesn't fire for placeables - only creatures and doors. This gave us no end of grief when trying to get critters to attack summoned-in player walls - we eventually had to resort to damaging all wall sections within a small radius of creatures onheartbeat.
Funky
#8
Posté 03 janvier 2013 - 05:00
Although the imposed system is the public release, on my mod I actually decided to store local floats/waypoints in the area data where the NPC knows the boundaries by manual insertion rather then needing to create objects to set a path for it. For example I explained where the entrance to reach that particular height is with a waypoint(RAMP, TRANS, PLACE) and I have floats stored in the area painting a boundary of the game map in places the NPC would get stuck. The NPC then reads the x/y of it's path to know it's running into a wall.. Since my mod is only 300 areas in size it's an efficient method.(not all of them have ramps or blocking points)
I'm still heavily testing a lot of the code for it as it involves a lot of vectors, but I'll have something posted soon.
EDIT = I think I'll use a blank invisible NPC with an onblocked event. This allows me to alert the NPC if the obstructing object is a door or a PC in there path and adjust as necessary.
Modifié par Highv Priest, 03 janvier 2013 - 05:05 .
#9
Posté 03 janvier 2013 - 05:02
Highv Priest wrote...
Wait so I'm actually touching on a ground no one has touched on before? Awesome! That's so rare in a game like nwn. That sounds fair to me, I'll break out the mountain dew and play my mortal kombat album and see if I can figure out how to resolve this issue.
As some have already stated... we still fight with it. Find an elegant way to deal with it, and even I will beat a path to the vault to have a look at your submission !
My own project is using two different pathfinding modes that rely on having waypoints painted down in difficult areas for my ambient npc's to use. Gets ugly, but you can burn a lot of cpu time before you start taking the hit that a single stuck npc generates.
It's real crudge, that includes taking control of the ai level of npc's away from the engine. Needed for my project where npc's start to become ambient when a PC enters a connecting area... step in the door of the bar it's in party mode when you arrive.... sleepers aren't falling onto their bed as you come though the door. It's the little things like that drive me crazy.
Highv Priest it's a rabbit hole and once you poke your head into it, it's nothing if not a challange to get npc's to do the right thing "most of the time".
Good Luck!
Modifié par CalSailX, 03 janvier 2013 - 05:03 .
#10
Posté 03 janvier 2013 - 12:52
CalSailX wrote...
As some have already stated... we still fight with it. Find an elegant way to deal with it, and even I will beat a path to the vault to have a look at your submission !
My own project is using two different pathfinding modes that rely on having waypoints painted down in difficult areas for my ambient npc's to use. Gets ugly, but you can burn a lot of cpu time before you start taking the hit that a single stuck npc generates.
It's real crudge, that includes taking control of the ai level of npc's away from the engine. Needed for my project where npc's start to become ambient when a PC enters a connecting area... step in the door of the bar it's in party mode when you arrive.... sleepers aren't falling onto their bed as you come though the door. It's the little things like that drive me crazy.
Highv Priest it's a rabbit hole and once you poke your head into it, it's nothing if not a challange to get npc's to do the right thing "most of the time".
Good Luck!
The way I'm doing it is basically like injecting code into the NPC. Using GetAttackTarget, GetAttemptedAttackTarget, GetAttemptedSpellTarget. The script reads those(using GetAttemptedAttackTarget first, GetAttackTarget second, and GetAttemptedSpellTarget last but I'm still testing this. I've had good results so far.) and then creates a path for the NPC just by creating a string of vectors checking all along the way if something obstructing is in the way(by either creating a blank invisible NPC or using my area data). It only reads as fast as the NPC is moving and when an obstruction of a permanent nature is found I have the NPC setting the data normally manually put in as a local on the area.(making it similar to Get2DAString in that it might be expensive the first time because it has to create a blank object to essentially read boundaries, but it won't have to do it multiple times unless this player is doing everything they can to get the NPC stuck somewhere in different places and in that case you might need to make a rule). So far I've round the script needs to be called recursively only every 10 seconds for a hasted normal speed NPC, even less for a slow one, even less for a very slow one. Furthermore since it's checking if one of those attack declarations above is valid it makes it VERY efficient. The script cancels so quickly it uses virtually no CPU time.
Furthermore I added heuristics(sensitivity in cases of precision), you can specify how many vector points before it creates a blank NPC in it's path. By default it only creates them 10 spaces away(which is good enough to have the NPC act pretty intelligent and avoid most times as 10 spaces is effectively the range of a whole tile), but you can specify it to be every vector point(creating 10 blank NPCs altogether which is a bit much even if they don't have any scripts but OnBlocked) which is UNBELIEVABLY intelligent. It was freaking amazing watching the NPC chasing me and I run up the ramp to confuse him and he just promptly ran right around it to me(and killed me, forgot dm_god sadly).
I'll do everything I can to make it efficient AND effective to the point it is definitely worth it.
P.S= It's amazing what 4 cans of moutain dew and the mortal kombat theme song can do.
EDIT = Can the creatures exact action be called from GetLastAttackType without the creature actually performing the action? I'm trying to consider if this would work in this circumstance.
~~~~Highv Priest
Modifié par Highv Priest, 03 janvier 2013 - 01:07 .
#11
Posté 03 janvier 2013 - 02:00
Alas, using that system, when you've got all the bugs worked out, I'll no longer be able to use some of my tricks to survival when I low-level a normally mid-level or higher adventure. Time to figure out some new tricks
Modifié par Sir Adril, 03 janvier 2013 - 02:03 .
#12
Posté 03 janvier 2013 - 09:50
My smart npc's still get utterly stupid if you trigger them into Combat Mode. Using the hooks might just give them brains enough to put up a good fight.... getting killed by something you shouldn't have picked a fight with is a plus.
I'm fair though... I sure that given enough time a member of some npc faction will decide to "Raise Dead" your looted corpse if only to exact a favor in return. Laying dead in the grass for a few minutes will give the player time to think of the errors of their ways... evil chuckle.
With the hooks in Get*Target() functions something like your work should plug right in along side the rest of the stuff currently in their AI.
Watching with interest CalSailX
#13
Posté 26 janvier 2014 - 05:08
Also, strange fact:
1. If you try to path your PC to a location (clicking on the spot of ground as your destination) that is too far or too complex to get to, your character won't try to walk there (pathing failure in the engine after X segments or some multistep algo?).
2. Attempting to reach a creature will sometimes succeed, but not always. And never if you're attempting to talk to the creature. This is why your PC won't walk around the darned counter to talk to the shop keeper 5 meters away, but the engine simpy tells you they are too far away to talk to.
3. BUT, if you click on a usable placeable you get crazy complex success (within limits)! WTH does that mean? I'm wondering if the walk to placeables code has a bug that doesn't cut off pathing clculations for placeables like for pathing to other objects...
Disclaimer: I have no idea what kind of strain on the CPU this method causes. I have not tested, only leveraged this fact when playing other modules when too lazy to manually click my way around.
Could this be used to fix pathing during combat for creatures? Pathways only handles pathing during non-combat mode. Also, the setup currently causes the creature to return to the last segment they were supposed to travel to instead of the next one. Maybe I need to fix it so it tries to determine which is closer, last destination, or the next one after that.
Or better yet, try to fix Pathways so it recalculates (GPS, "rerouting...") instead of going all the way out to the last destination segment end.
This would be for two reasons:
1. Returning to their last segment destination does not use pathways, if the chase or battle took the group too far away down a complex path, they don't use Pathways to get back! (Bug I guess)
2. This would cause the creature to handle 1 above, and also ensure the creatures are always moving forward (maybe, not sure) instead of walking all the way back to their last destination if it is far behind them.
I'll need to throroughly test this hypothesis.
ANYway, could you "clear all" on the creature, plot the path to a placeable (you script in), then do so again for your PC (up until the distance to the transition is too far and you PC has simply "gotten away"? If they get close enough then direct the creature to attack the PC (or whatever is there to be attacked).
I was thinking of using placeables to help the PC navigate to places that are easy to get to (they can see very clearly how to get there), but is tedious. Maybe place a bush or something in the area to help with this for ease of travel.
Of course, I'd also like to be able to script the PC to use Pathways and simply give the destination for the PC. This leaves hands free for RP while the PCs all walk together to their destination. Anyone know how to script PC movements? Just need ot know where to start.
- Qlippoth:wizard:
Modifié par QlippothVI, 26 janvier 2014 - 05:25 .





Retour en haut






