irswat Posted March 4, 2014 Author Share Posted March 4, 2014 It depends on what your purpose is. You can create a form list of all refIDs and in many cases it can be passed to a function just like any other var. You can also check out the "reference walking" functions of NVSE, but those are used (IIRC) in a cell as opposed to many cells in a worldspace. is there a way to do this procedurally? e.g. to fill the form list of any/all instances of an NPC? Link to comment Share on other sites More sharing options...
irswat Posted March 4, 2014 Author Share Posted March 4, 2014 Here is my script. Not sure if it works set. Sniper1 is the RefID ScriptName SMSniperAlertScript float hfPlayer int AlertFlag=0 begin GameMode label 1 set hfPlayer to player.GetDistance Sniper1 if hfPlayer <= 20000 set AlertFlag to 1 Look Sniper1 Sniper1.Look player endif if AlertFlag if (player.GetDead == 0) Sniper1.UseWeapon WeapNVGhillieSniperRifle Sniper1 player 6 0 0 0 0 endif endif if AlertFlag if player.GetDead set AlertFlag to 0 endif elseif (player.GetDead == 0) set hfPlayer to player.GetDistance Sniper1 if hfPlayer<=20000 goto 1 endif elseif (player.GetDead == 0) set hfPlayer to player.GetDistance Sniper1 if hfPlayer>=20000 set AlertFlag to 0 endif endif endif end How can I make this work for all instances of NPC Class SMSniper? (e.g.Sniper1,Sniper2,Sniper3) without having to create a unique script for each sniper? Link to comment Share on other sites More sharing options...
devinpatterson Posted March 5, 2014 Share Posted March 5, 2014 is there a way to do this procedurally? e.g. to fill the form list of any/all instances of an NPC? You can look up NVSE's reference walking info and pair it with AddFormToFormList. But with the caveat I stated earlier (I don't think it's made for more than 1 cell). Here is my script. Not sure if it works set. Sniper1 is the RefID if your going to use the useWeapon function you need to put a condition on that via the getLOS function. If you don't It will seem as if the sniper magically knows where the player is even if s/he has kept completely under cover. And even worse the sniper will just shoot into whatever is inbetween. Even if you use the flag for useWeapon to prevent fire when blocked getLOS still should determine whether you flip the bit on your alertFlag var, there is no reason to have it run. If on the other hand you want it to fire whether blocked or not, you should be careful not to have large objects about to hide behind. It won't seem realistic if How can I make this work for all instances of NPC Class SMSniper? (e.g.Sniper1,Sniper2,Sniper3) without having to create a unique script for each sniper? Since your using explicit referencing I'm guessing that is a quest script? Your snipers are all a refs of your base NPC. A baseobj can have it's own script (object script). Refs will inherent it, and it will have implicit referencing (ie no need to include sniper1). But it won't have the flexibility of a quest script (especially and most importantly being able to set how often it runs, which means it could eat up serious cpu cycles if there are hundreds across the wasteland). I think you'd have to do a quest and it's associated script for each. Link to comment Share on other sites More sharing options...
irswat Posted March 5, 2014 Author Share Posted March 5, 2014 that's great news. I couldn't find any information about the purpose of GetLOS. Does it just return a 1 if the actor is in the line of sight of the target? I wonder if there is a command I can issue the NPS if !GetLOS==0 it will move to a position where it has LOS. Also do you think height will affect LOS? Do you know if distance is triangulated from Sniper to base to target using Pythagoras' theorum? Thanks for taking the time to help me. Link to comment Share on other sites More sharing options...
irswat Posted March 5, 2014 Author Share Posted March 5, 2014 (edited) ScriptName SMSniperAlertScript float hfPlayer int AlertFlag=0 ref rSniper begin GameMode set rSniper to SMSniper01.GetSelf label 1 set hfPlayer to player.GetDistance rSniper if hfPlayer <= 20000 set AlertFlag to 1 Look rSniper rSniper.Look player endif if AlertFlag if (player.GetDead == 0) if ((rSniper.GetLOS + 128) player) rSniper.UseWeapon WeapNVGhillieSniperRifle rSniper player 6 0 0 0 0 endif endif endif if AlertFlag if player.GetDead set AlertFlag to 0 endif elseif (player.GetDead == 0) set hfPlayer to player.GetDistance rSniper if hfPlayer<=20000 goto 1 endif elseif (player.GetDead == 0) set hfPlayer to player.GetDistance rSniper if hfPlayer>=20000 set AlertFlag to 0 endif endif endif end I included the getLOS but the problem is it checks from the feet. e.g. if ((rSniper.GetLOS + 128) player) will not compile. So I want to do this: if ((rSniper.GetLOS + 128) player) == 0//calculate the nearest position where ((rSniper.GetLOS + 128) player) == 1//rSniper.MoveTo this position what would you suggest? Edited March 5, 2014 by irswat Link to comment Share on other sites More sharing options...
devinpatterson Posted March 5, 2014 Share Posted March 5, 2014 that's great news. I couldn't find any information about the purpose of GetLOS. Does it just return a 1 if the actor is in the line of sight of the target?Yeah 1/true I wonder if there is a command I can issue the NPS if !GetLOS==0 it will move to a position where it has LOS. Also do you think height will affect LOS?Probably more than a few ways to do that. You could do a if/else block and send the sniper to some x markers. But honestly if your in a sniper tower how big can it be? It's only really going to be useful for field of vision. Moving 4 or 5 feet to the side probably isn't going to give the sniper an angle on the player when he/she is 2000 game units away. But hitting all the compass points for a 360, on the other hand, *is* going to be useful. getLOS is +/- 95 degrees from where the sniper is facing so you could put an xmarker in each corner or face of a square tower (just an example since I have no idea how the snipers field of veiw is in relation to teh landscape etc, s/he might only have a 180 degree feild of view and be up against a canyon wall) and move the sniper from one xmarker to another via a patrol, until getLOS returns true. You might even be able to get an idle on each xmarker where the sniper looks though binoculars, which would make it seem very realistic. Maybe make him/her walk to an xmarker and idle 4 or 5 seconds, then move on. Excluding any xmarkers sides or corner that the sniper doesnt have a FOV from. Another could be a if/else block that adds a simple script package (just move to the next xmarker, ie simple travel package) if the getLOS fails. short Corner ;xmarker1 through xmarker4 short doOnce if (doOnce == 0) set doOnce to 1 endIf if (sniper.getLOS rplayer == 1 ; useWeapon ;bang elseIf (sniper.getLOS replayer != 1) && (corner <= 3) set corner to (corner +1) ;next corner addScriptPackage X ; your travel package to move to corner X elseIf (sniper.getLOS replayer != 1) && (corner == 4) set corner to 1 ; at last corner, back to first addScriptPackage X ; your travel package to move to corner 1 endIf That's 4 script packages (travel) for each sniper and probably not practical, where as the patrol is pretty simple but still setting one up for each sniper.But there are probably better ways to do it, that a a script guy (which I'm not) could suggest. Do you know if distance is triangulated from Sniper to base to target using Pythagoras' theorum? Thanks for taking the time to help me.I wouldn't worry about it. Even if the Z axis isn't included in the calculation for total distance, the effect is minimal even on a high tower like 40'+ feet, when your dealing with these long range sniping distances. I included the getLOS but the problem is it checks from the feet. e.g. if ((rSniper.GetLOS + 128) player) will not compile.From the feet huh? OK that's a PITA and kind of odd. Even moderately rough terrain would block LOS even through you could clearly see an actor, making this function useless in many terrains. Are you sure? So I want to do this: if ((rSniper.GetLOS + 128) player) == 0//calculate the nearest position where ((rSniper.GetLOS + 128) player) == 1//rSniper.MoveTo this position what would you suggest?No I can't think of a way to calculate what spot would give you a line of sight, and I wouldn't think you'd want that anyway. The fun for the player will partly be evading the snipers attention. If you can automatically just plug the player when s/he is within a set distance there is no reward for chance, skill or caution for the player. And by moving the player to a point where there is LOS automatically that's essentially what you'd be doing. Another possible suggestion is to have different behavior at different distances. If you in an area that has little cover you could include getLOS as a condition if the player is >= 2000 && <= 1000. But if the player is < 1000 just have the useWeapon function and forget the getLOS. That way it would simulate a relatively low cover area, and a greater chance of hte sniper spotting the pc when s/he is close. Link to comment Share on other sites More sharing options...
irswat Posted March 5, 2014 Author Share Posted March 5, 2014 Well the script works. Unfortunately the snipers are still not reacting to the player as aggressively and as far away as I would like. I will play with these primitives tomorrow. I want these snipers to be really challenging. I want them to be able to spot the player before the player can spot them (some will be hidden on high peaks, in nooks, and crevices overlooking valleys), or at least right around the same time (approx max sniper rifle scope distance). If the player can just pick these snipers off from a distance before the sniper even reacts to the player the mod is pointless.I have not been able to achieve this effect using aggro radius, guard/patrol radius, or this script. I will try using a primitive tomorrow to trigger this alert script. Someone explained that the engine has a built in limitation that anything more than 2 cells away 'doesn't exist'. If this is true I may have to abandon the tower idea and just place these snipers all around the wasteland. That is if the primitive idea doesn't work. They are quite challenging. Once they spot the player and start shooting the player only has a couple seconds to take them out before they get a headshot in. Good news is this is giving me a great opportunity to learn the various functions, syntax, capabilities of the engine and GECK. It's been a while since I was passionate about coding. :-) thanks for taking the time to help me out sir. Someone should buy this man a drink! Link to comment Share on other sites More sharing options...
irswat Posted March 5, 2014 Author Share Posted March 5, 2014 p.s. if I make these primitives nearly 2D will it take less processing power? Im thinking something like a relatively thin two dimensional fence made of four rectangles around every one of the towers. The problem is this: All the towers have 2 or more snipers. I'm not sure how to go about using the primitive as a trigger for multiple snipers/multiple towers (if the player us standing in an area of overlapping tower coverage for example.) I'll play around with this a bit to see what I can achieve. Thanks again Link to comment Share on other sites More sharing options...
irswat Posted March 5, 2014 Author Share Posted March 5, 2014 http://i61.tinypic.com/efgfeq.jpgI had great success with the script but the script doesn't seem to be firing when the player enters the prim. Wierd thing is one of the tower snipers wandered to the front of the saloon and started a shootout between the snipers in the tower and other NPCs near the saloon so I know the sniper can shoot that far. I will not give up. Just sharing progress. Once I get this one instance working every other instance will be very easy. Link to comment Share on other sites More sharing options...
irswat Posted March 6, 2014 Author Share Posted March 6, 2014 not sure how to use this prim as a trigger for the script. All progress on this is halted until Sunday or Monday. I will include a download link for anyone who wants to mess with it. I take no credit for the SniperTowers, SniperRifle, or SniperArmor. There are bugs (sometimes snipers wander away from their towers, changing sniper armor textures depending on angles, sometimes the snipers do not spawn with a rifle, and the snipers do not engage from as far away as they should.) PM me if interested in helping me with this. Link to comment Share on other sites More sharing options...
Recommended Posts