irswat Posted March 11, 2014 Share Posted March 11, 2014 (edited) I'm working on a sniper mod. I am trying to get these snipers to react/detect/fire upon the player from as far away as possible. I figure this range should be about 8000-12000 units. Due to engine limitations it seems to be impossible to create a sniper that can...well....snipe!What quirky engine limitations do I need to know about Line of Sight and NPC Detection. I have a script together that should work but for some reason these snipers refuse to engage the player from a distance any further than 4000 units. Do the snipers need to be at eye level with the player to detect him/her? I read that Line of Sight is calculated from the NPC's feet. Is this true? What is the maximum number of units away an NPC can detect a player? Am I pushing it hoping for 8000? 11000? Here is my code: scn SniperModScript int hfPlayer int AlertFlag ref rSniper begin GameMode set rSniper to GetSelf set hfPlayer to 0 set AlertFlag to 0 set rSniper to 00000000 set hfPlayer to rSniper.GetDistance player if player.IsInInterior == 0 MessageEx "Sniper Mod Debug Game Mode" 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 Edited March 11, 2014 by irswat Link to comment Share on other sites More sharing options...
irswat Posted March 11, 2014 Author Share Posted March 11, 2014 In short, does UseWeapon require LineofSight? Is Line of Sight really calculated from the feet? Is there a way to force an NPC to detect a player? Link to comment Share on other sites More sharing options...
Recommended Posts