Jump to content

how to check if an NPC is loaded?


irswat

Recommended Posts

I added some debug messages to see if these functions were working as they were supposed to. I didn't get one message saying snipers were being added or removed from the form list. I'm about to give up on modding this game. Lol. Please keep in mind this script is attached to the NPC Base Object.

Yeah that's weird :sad:

 

I didn't get a chance to do much of anything over the weekend, but I did think of something that might be of use. Essentially it's a spell with a script effect that is used quite a few times on the final battle of hoover. It's called VEvaluatePackagePulseSpell in geck (DisguiseFactionPulseActorEffect, used for faction disguise also has a similar means of delivery). It's a script effect so it's a way to deliver a script to a actor within a certain range. On hoover it's used to cause actors to reevaluate their ai packages, but it should be possible to use it do deliver any code.

 

This is still a pretty rough, preliminary idea, as I don't even know how well it will function at the distances you'd like to use. But a simple quest script could fire off the pulse (via CIOS), to deliver a script payload. The script would need to filter out anything not an instance of the base obj sniper (which is exactly what getIsID does) so the pulse doesn't affect every actor in it's area. But you should be able to attach the code you'v written to the script for the script effect (explicit so you still need to set a ref to getself). There may be other hurdles and challenges, but I think it could be a useful line to pursue. I think the most important aspect is what can and can't be included in a effect script.

 

You can punch up VEvaluatePackagePulseSpell and it's chained forms (enchantment, magic effect) for more detail and fine tuning (bump up the area, untick area effect ignores LOS, etc).

Link to comment
Share on other sites

the script has really evolved. at this point I have it narrowed down to a limitation in the engines detection code. I think it is a LOS issue as we had discussed.

 

https://www.dropbox.com/s/w08sxdbyytfr7qu/SniperModWIP.esp

scn SniperModScript

float hfPlayer=0
int AlertFlag=0
ref rSniper=00000000

begin GameMode


	
	if player.IsInInterior == 0
		MessageEx "Sniper Mod Debug Game Mode"
		set rSniper to GetSelf
		set hfPlayer to rSniper.GetDistance player
		if rSniper.GetDead
			MessageEx "Sniper %i is dead" rSniper
			set hfPlayer to -72
		endif
	
		if hfPlayer <= 8000 
			if (hfPlayer != -72)
				MessageEx "Sniper %i is %g units away" rSniper hfPlayer
				set AlertFlag to 1
			endif
		elseif hfPlayer > 8000
			set AlertFlag to 0
			MessageEx "Player out of range by %g units." (hfPlayer-8000)
		endif
	
		if AlertFlag == 1
			if player.GetDead == 0
				Look rSniper
				rSniper.Look player
				MessageEx "Player within range."
				if (rSniper.GetDetected player)
					MessageEx "Player detected. Firing!"
					rSniper.UseWeapon WeapNVGhillieSniperRifle rSniper player 6 0 0 1 0 
				elseif (rSniper.GetDetected player == 0)
					MessageEx "%i unable to detect player. Unable to fire" rSniper
				endif
			endif
			if player.GetDead == 1
				set AlertFlag to 0
			endif
		endif
	endif
end


Link to comment
Share on other sites

as youll see the snipers are not able to detect the player, and it must be an LOS issue. I'm going to test this theory by removing the rock ledges on the sniper tower and placing the snipers at the very edge. If they engage from 11000 units then I'll know I'll need to come up with some sort of creative solution to this problem.

Edited by irswat
Link to comment
Share on other sites

:laugh:

not what i had hoped for. If I cant figure this out tomorrow I may give up on the tower concept. When I place the snipers on ledges and stuff they react exactly how I want them too. I really want to get these sniper towers working. lol I'm persistent. Good night

 

it's so wierd because the npcs will engage the other npcs from much further then they will attack me. I don't get it.

Edited by irswat
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...