kjmarket Posted June 11, 2010 Share Posted June 11, 2010 Ok, so I'm on my third day of scripting for Fallout 3 so if I have made any newbish mistakes please forgive me. What I want to do is be able to keep track of whether the player has killed certain npc's. For this example I'll use Roy Phillips, the ghoul from Warrington Station/Tenpenny Tower. I have a script checking for his death. ScriptName TestScript ref rRoyPhillips short RoyPhillipsGhoul Begin OnEquip Player set rRoyPhillips to RoyPhillipsRef if ( rRoyPhillips.GetDead != 0 ) && ( RoyPhillipsGhoul != 1 ) set RoyPhillipsGhoul to 1 if rRoyPhillips.IsKiller Player set KJSlasherKillCounter to KJSlasherKillCounter + 1 ShowMessage KJSlasherBodyCountMessage KJSlasherKillCounter endif endif end KJSlasherKillCounter is a global variable. What I want is for it to determine if the player killed the npc, add one to the counter variable, then display the message. If I put some code into an npc's script file under Begin OnDeath then I can make it work fine. The problem with doing it in a separate script is if its in an interior it does nothing until I go to an exterior, and then runs the code three times, diplaying the message three times in a row. Did I do something wrong? I really dont want to mess with the script of every npc I want to keep track of. Please tell me what I want to do is doable in it's own script. Link to comment Share on other sites More sharing options...
rickerhk Posted June 11, 2010 Share Posted June 11, 2010 Ok, so I'm on my third day of scripting for Fallout 3 so if I have made any newbish mistakes please forgive me. What I want to do is be able to keep track of whether the player has killed certain npc's. For this example I'll use Roy Phillips, the ghoul from Warrington Station/Tenpenny Tower. I have a script checking for his death. ScriptName TestScript ref rRoyPhillips short RoyPhillipsGhoul Begin OnEquip Player set rRoyPhillips to RoyPhillipsRef if ( rRoyPhillips.GetDead != 0 ) && ( RoyPhillipsGhoul != 1 ) set RoyPhillipsGhoul to 1 if rRoyPhillips.IsKiller Player set KJSlasherKillCounter to KJSlasherKillCounter + 1 ShowMessage KJSlasherBodyCountMessage KJSlasherKillCounter endif endif end KJSlasherKillCounter is a global variable. What I want is for it to determine if the player killed the npc, add one to the counter variable, then display the message. If I put some code into an npc's script file under Begin OnDeath then I can make it work fine. The problem with doing it in a separate script is if its in an interior it does nothing until I go to an exterior, and then runs the code three times, diplaying the message three times in a row. Did I do something wrong? I really dont want to mess with the script of every npc I want to keep track of. Please tell me what I want to do is doable in it's own script. If you are going to track a bunch of NPC's, put the script in a Quest script. By default, a quest script runs every 5 seconds. You also don't need to set the reference variable to Roy. Just use RoyPhillipsRef.GetDead. Then set a variable 'roydead' so that the message only plays once. ScriptName TrackDeadNpcQuestScript short RoyDead Begin GameMode if (Roydead == 0) if ( RoyPhillipsRef.GetDead == 1 ) if RoyPhillipsREF.IsKiller Player set Roydead to 1 set KJSlasherKillCounter to KJSlasherKillCounter + 1 ShowMessage KJSlasherBodyCountMessage KJSlasherKillCounter endif endif endif end Link to comment Share on other sites More sharing options...
kjmarket Posted June 12, 2010 Author Share Posted June 12, 2010 Thanks a lot. That works great. Another question though. It's easy enough to get the ref's of soem npc's, like the ones at Tenpenny Tower who have scripts or are controlled by a script, but is there a way to get the ref of an npc with no script, like a raider? Link to comment Share on other sites More sharing options...
rickerhk Posted June 12, 2010 Share Posted June 12, 2010 Thanks a lot. That works great. Another question though. It's easy enough to get the ref's of soem npc's, like the ones at Tenpenny Tower who have scripts or are controlled by a script, but is there a way to get the ref of an npc with no script, like a raider? Most raiders are spawed from templates and don't have a persistent reference, but a 'dynamic' reference. If you hit the console key and click on an NPC, you will see the Ref at the top of your screen. If it starts with 'ff', its a dynamic reference that you will only see in-game, and not the Geck. Also note that a ref id you are seeing this way is different than the Base Id of the object. But even though an npc doesn't have a script, they may still have a persistent reference, to allow another script somewhere access to the object. If you right-click on an NPC in the Geck and click 'use-info', a window pops up. From this you can see what cell they are placed in. Double click on that and you will see them in the render window. In the Cell View window, you will see the NPC listed in the objects list. Right-click on the NPC and click 'edit'. If they have a Ref ID, it will be the top line. Link to comment Share on other sites More sharing options...
kjmarket Posted June 13, 2010 Author Share Posted June 13, 2010 You have helped me a lot, man, and I really appreciate it. The quest script works great for named npc's. I wouldnt have thought of that myself, so thank you. As for raiders, I'll just have to make a script just for them and attach it to the templates and make sure all raiders except the handful that have there own scripts use my script. Link to comment Share on other sites More sharing options...
Recommended Posts