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?