100% Stationary Guards

Post » Thu Dec 02, 2010 8:31 pm

This is in relation to my mod, Wasteland Defense...

Basically Wasteland Defense is a mod similar to RTS for Fallout 3, but with an emphasis on forts and defending raiders. Objects are placed by the players (eventually placed with the placeatme function) after which they will remain there indefinitely. I am also working on this system to apply it to placeable guards. And this is where my issue starts

So far over the past week or so I have tried various methods to get an NPC Guard to remain 100% stationary and hold position at a single location (meaning returning to that spot after battle). Currently, I have that all working with the NPCs teleporting themselves back to their starting location after a battle, and all is well. That is, until guards start to be placed on top of other objects. Currently, when guards are placed on another object, they successfully stand and guard the right spot. However, once you leave the cell and return, the guards are being reset to ground level for some reason.

Below is the current relevant parts of the script that is running on every guard:

scn aaaSettlementStationaryGuardScriptREF	thisguardFLOAT	posxFLOAT	posyFLOAT	poszbegin onload		Set thisguard to GetSelf		Set posx to thisguard.GetPos x		Set posy to thisguard.GetPos y		Set posz to thisguard.GetPos zend

This is establishing the original position to return the guard to (based on when the guards 3D geometry loads)

begin gamemode		if posx != 0 && posy != 0 && posz != 0		Set thisguard to GetSelf		if (thisguard.GetPos x != posx || thisguard.GetPos y != posy || thisguard.GetPos z != posz) && thisguard.isincombat == 0			thisguard.SetPos x posx			thisguard.SetPos y posy			thisguard.SetPos z posz		endif	endifend

This checks every frame to see if the current guards position has changed at all, and if it has (and the guard isn't in combat), it will reset the guard to the proper location

begin onCombatEnd	if posx != 0 && posy != 0 && posz != 0		Set thisguard to GetSelf		if thisguard.GetHealth > 0			thisguard.SetPos x posx			thisguard.SetPos y posy			thisguard.SetPos z posz		endif	endifend

This code is basically redundant, but I left it in to see if it would make a difference. It basically resets the guards position as soon as it exits combat

Now, all this code works perfectly fine as long as the player doesn't leave the cell. However, as soon as the player fast travels and returns, or otherwise exits the cell, the guards reset themselves to the floor. I believe this is due to these NPCs being placed on top of objects that are added via placeatme, and are not originally navmeshed. Now, my question is: Is there a way to force the guard's absolute location, regardless of if the area is deemed safe to place by the engine? I'd like the guards to retain their vertical positioning if its at all possible. You can download the mod and give it a go yourself if you need to see what is happening (can be found http://www.newvegasnexus.com/downloads/file.php?id=38049)

Any ideas?
User avatar
sw1ss
 
Posts: 3461
Joined: Wed Nov 28, 2007 8:02 pm

Post » Thu Dec 02, 2010 8:14 am

Did you try simply giving the guard a sandbox package, with the location as 'near editor position' and radius of 0, with Wandering, Idle markers, and all those flags turned off? That does it in Fo3.
User avatar
Natasha Biss
 
Posts: 3491
Joined: Mon Jul 10, 2006 8:47 am

Post » Thu Dec 02, 2010 3:11 pm

That doesn't solve the issue I'm having though. I can get the guards to stand still perfectly fine. Its just a matter of forcing them to stay hovered in the air (on a guard tower that was placed via placeatme) after the cell resets and not having them end up in a new location
User avatar
Jade Muggeridge
 
Posts: 3439
Joined: Mon Nov 20, 2006 6:51 pm

Post » Thu Dec 02, 2010 7:31 am

@Elderwind
Your guardtower has no navmesh because it was brought in the world with placeatme. The NPC AI can't keep them there without navmesh.
User avatar
Rodney C
 
Posts: 3520
Joined: Sat Aug 18, 2007 12:54 am

Post » Thu Dec 02, 2010 9:43 am

That's what I figured

So, my next question would be:
Using setpos or MoveTo, is there a way to force the location of the NPC

I know for a fact that MoveTo would work just fine if I had a marker in the right location, however I'm wondering how it would be possible to do with only one marker and multiple guards
User avatar
Motionsharp
 
Posts: 3437
Joined: Sun Aug 06, 2006 1:33 am

Post » Thu Dec 02, 2010 9:15 pm

@Elderwind
Surely. You can use moveto on several NPCs to one xmarker location. It looks a bit strange if you do it at the same time and the NPC is standing still there but havok and the collision divides them up again. So it would be best to do it if the player isn't looking. I wouldn't recommend Setpos for such things because the NPC AI deals easier with moveto.
User avatar
Lew.p
 
Posts: 3430
Joined: Thu Jun 07, 2007 5:31 pm

Post » Thu Dec 02, 2010 4:03 pm

Yea, but the issue is I need NPCs to be moved to their own respective location. Essentially I let the player place several Stationary Guards around their fort, and I'd like them to retain their locations (up in guard towers) even when the cell resets. However I would like them to take advantage of the MoveTo command using only one xmarker. It's just a matter of moving the guards one by one as best as possible
User avatar
Mistress trades Melissa
 
Posts: 3464
Joined: Mon Jun 19, 2006 9:28 pm

Post » Thu Dec 02, 2010 11:56 am

I don't really get what you mean.

The easiest way to keep guards at their location is to give them a travel/guard package with their personal xmarker as target if it needs to be changeable with moveto or a 'at current location' as target if the place where they should be never changes.

You can't use the same xmarker as package target for different NPCs if they should be at different locations.

The package of the NPC finally decides where your NPC is placed in the game after a cell reload.

And don't forget a navmesh is needed.
User avatar
Bryanna Vacchiano
 
Posts: 3425
Joined: Wed Jan 31, 2007 9:54 pm

Post » Thu Dec 02, 2010 3:04 pm

Yea, this is the part that is the hardest to explain :)
So thanks for your patience

Players have the ability to place their own guards at their own locations via the mod (which places them via placeatme). However, due to the player being able to place an "infinite" amount of guards, I have no way to making an xmarker ref for each guard. So I am looking for a method that only requires on marker

I am currently looking into an idea that just came into my head as well, so we shall see how that ends up as well
User avatar
Alycia Leann grace
 
Posts: 3539
Joined: Tue Jun 26, 2007 10:07 pm

Post » Thu Dec 02, 2010 8:45 am

That's why there is a package target called 'current location'. If the player and the guard are at the right postion where the guard should be and the player for example tells the guard to stay here simply switch to the travel/guard package with the target 'at current location'. If a navmesh is there the NPC stays at this position and doesn't move.
User avatar
Roberta Obrien
 
Posts: 3499
Joined: Tue Oct 23, 2007 1:43 pm

Post » Thu Dec 02, 2010 3:52 pm

No. I have the ability for guards to stand still already. There is no navmesh. That is my issue. I can get guards to stay in their hovered location without a navmesh perfectly fine, until the cell resets
User avatar
No Name
 
Posts: 3456
Joined: Mon Dec 03, 2007 2:30 am

Post » Fri Dec 03, 2010 12:12 am

I actually did solve the issue just now I believe. Thanks for the help! I think all it took was just me explaining my issue to somebody for my mind to work out the solution
User avatar
Epul Kedah
 
Posts: 3545
Joined: Tue Oct 09, 2007 3:35 am


Return to Fallout: New Vegas

cron