kungfubellydancer Posted March 5, 2011 Share Posted March 5, 2011 I have plans of making a small mod in which a character will show up at various, undisclosed places and perform an action, much like a random event. However, these events are not literally random as they have a 100% chance of occurring. As for the character's actions, they will only initiate under two conditions: 1), that the player is far enough away, so that the character can do his thing and leave before the player can get to him, if even possible, because he might be somewhere such as a building rooftop 2) that the player looks directly at him. Until then, this character will stand idly until the player looks at him, then he will perform his action. Is there a good script out there that can make this work, providing I make the changes appropriate for the mod, and is there some good reading for scripted events? Link to comment Share on other sites More sharing options...
davidlallen Posted March 5, 2011 Share Posted March 5, 2011 I have found this kind of complex behavior to be very frustrating. Perhaps I don't quite have the "hang" of it yet. But, there are probably three parts to what you want. 1. A continuously running quest script which, every once in a while, teleports the character to some distance away from the player. Rather than trying to guess which locations may be safe landing spots, just try "myref.moveto player 1024" 2. Once the character arrives, the quest script should monitor the player's direction and facing to see if the player is facing the character at a reasonable distance. I don't know how to tell if the character is actually spotted. It could be that there is a wall in between. This may result in the character performing the action when in fact he can't be seen. 3. When step 2 triggers, then you need a timer script to sequence whatever actions you want the character to do. I like using quest stages for these things, because while debugging, I can use the console "setstage" command to force something to happen. Regarding tutorials, depending on what level you're starting at, the geck.bethsoft tutorials show some examples, and cipscis.com has some good starters. Reading the game code is probably one of the best ways to learn. Once you get started you can certainly post here with questions. Link to comment Share on other sites More sharing options...
Quetzlsacatanango Posted March 5, 2011 Share Posted March 5, 2011 (edited) That seems a bit overly complicated to me...Try GetDetectedhttp://geck.bethsoft.com/index.php/GetDetected and GetDistancehttp://geck.bethsoft.com/index.php/GetDistance Something like Begin GameMode if mynpcref.getdetected player if player.getdistance mynpcre >= 1024 dostuff endif endif End Getdetected the way I used it here will tell if your npc can detect the player, not the other way around. I don't know if it can be used the other way (player.getdetected mynpcref). Maybe. If that's not good enough, you could try GetLOS which I have also never tried.http://cs.elderscrolls.com/constwiki/index.php/GetLOSAlso, 1024 may or may not be far enough if you don't want the PC to be able to shoot the NPC. You'll have to play with that. Edited March 5, 2011 by Quetzlsacatanango Link to comment Share on other sites More sharing options...
ecksile Posted March 5, 2011 Share Posted March 5, 2011 There has to be some line of sight command. something with how it shows health only when the player is looking/aiming at an NPC. Idk what command that might be though but it should be possible as you cant view health through objects I don't think. Link to comment Share on other sites More sharing options...
llamaRCA Posted March 5, 2011 Share Posted March 5, 2011 You can't get player line of sight but you can get the line of sight for an NPC. Or you could in FO3; I used it there quite reliably. I've noticed, though, when trying to do it here in NV that it seems a little squirrely. But you could try it to see if it did what you wanted. Link to comment Share on other sites More sharing options...
rickerhk Posted March 5, 2011 Share Posted March 5, 2011 I've used GetLos just once, and on the player and it worked in FO3.if (Player.GetLOS RHKBrisaREF) ;look for a moveto opportunity. should lose LOS when Overseer interupts. One thing with GetLos is that it's line of sight from the FEET. So, from what i've read, standing in front of a small rock could block LOS. Another way to see if the player is looking in the direction of a specific reference is GetHeadingAngle http://geck.bethsoft.com/index.php/GetHeadingAngle Using the example on the wiki page, and depending on how far away the actor is, you could have your quest script assume that any value from -10 to 10 was a trigger, for example. Or use both tests. Test the distance and angle, then start checking LOS. Link to comment Share on other sites More sharing options...
ecksile Posted March 5, 2011 Share Posted March 5, 2011 What is the command/function thingy for when you aim at something (creature or NPC) and the crosshair goes red or green and displays the health? There has to be a command for that action. Link to comment Share on other sites More sharing options...
davidlallen Posted March 5, 2011 Share Posted March 5, 2011 There doesn't have to be a "command" that the modder can execute for that. Lots of things are done internally to the game engine and the modder cannot get access. Link to comment Share on other sites More sharing options...
llamaRCA Posted March 5, 2011 Share Posted March 5, 2011 I've used GetLos just once, and on the player and it worked in FO3.if (Player.GetLOS RHKBrisaREF) ;look for a moveto opportunity. should lose LOS when Overseer interupts. Oops. :blush: I was thinking about something else that you can't get on the player. Link to comment Share on other sites More sharing options...
rickerhk Posted March 5, 2011 Share Posted March 5, 2011 What is the command/function thingy for when you aim at something (creature or NPC) and the crosshair goes red or green and displays the health? There has to be a command for that action. GetCombatTarget does that, and it's very unreliable on the player because mods that turn off autoaim pretty much make it always return zero (on the player). When it does work, it's after you have fired a shot and you captured the event in an object script. A quest script is too slow unless you run it every frame. Link to comment Share on other sites More sharing options...
Recommended Posts