drakeelvin Posted May 23, 2011 Share Posted May 23, 2011 Hi, I have this NPC called Alice. In NVGECK under Actors -> NPC, Alice's object ID is "AliceNPC" I want to create a reference "AliceREF" and set it to refer to AliceNPC when the game loads, and I want AliceREF to be persistent and globally available in all scripts and dialogs. In particular, I need to be able to monitor the presence or absence of certain items in Alice's inventory throughout the game, and having the item appear or disappear would trigger an event. (Just like giving Veronica her dress.) Example: if (AliceREF.GetItemCount AliceItem == 0) ; Do some stuff endif The problem is I can't setup AliceREF as a global that works. I've tried declaring AliceREF in the Quest script, but it is not visible elsewhere (such as in Dialog scripts). The only place I got it to work was in the companion script: scn AliceScript Ref AliceREF Begin OnLoad set AliceREF to GetSelf End I read that the place to put globals like this is in the Quest script, but I'm a little stumped as to how to declare and set the reference, and the syntax get it to refer to the proper NPC. None of the eight standard NPC's seem to declare or initialize references (e.g. VeronicaREF gets used a lot but I never see where or how it first gets initialized) The Quest script lets me declare: ref AliceREF But I'm not clear on how to properly initialize it to refer to AliceNPC. Any help will be greatly appreciated! Link to comment Share on other sites More sharing options...
rickerhk Posted May 23, 2011 Share Posted May 23, 2011 When you place the NPC into the editor, you can then edit the properties of that instance and give it the reference AliceREF. Make sure to mark the 'persistent' box. Then you will be able to use the reference in scripts.Dialog conditions use the base object for GetIsID, but you can also have conditions that check for a reference if you have more than one instance of the base object placed in the world and you want different dialog for each. Link to comment Share on other sites More sharing options...
drakeelvin Posted May 23, 2011 Author Share Posted May 23, 2011 (edited) When you place the NPC into the editor, you can then edit the properties of that instance and give it the reference AliceREF. Make sure to mark the 'persistent' box. Then you will be able to use the reference in scripts.Dialog conditions use the base object for GetIsID, but you can also have conditions that check for a reference if you have more than one instance of the base object placed in the world and you want different dialog for each. @Rickerhk I owe you another one. I didn't think to look in the Cell View/Render Window but I understand now that if I edit the object in there its a specific instance, and also there is the field to put in a persistent reference to it. Voila, everything works now. Thank you! Hypothetically speaking, if I wanted to have twins (2 instances of an NPC) I believe from what you are saying that I would give the first instance Alice1REF, and the second instance Alice2REF? Did I understand that correctly? Or Can I use AliceREF for both and use a function to distinguish between the two instances? This could be useful in a Farscape John/Aeryn type of scenario :D (If you are not familiar with Farscape, at one point John gets cloned and both clones are in love with Aeryn and fighting with each other over her.) Edited May 23, 2011 by drakeelvin Link to comment Share on other sites More sharing options...
rickerhk Posted May 24, 2011 Share Posted May 24, 2011 Each reference name can only apply to one instance in the editor. So you'll need Alice1REF and Alice2REF. So Aeryn isn't going to be fooled one bit ;) You could use just one reference name for Alice1REF, then another instance could be a linked ref that you could get in scripting, but I don't think it would make anything simpler - probably more confusing. Both NPCs will have the same name in-game as the base object, though. Link to comment Share on other sites More sharing options...
drakeelvin Posted May 24, 2011 Author Share Posted May 24, 2011 (edited) Well I'm definitely going to play around with this a bit. It nicely connects two dots in the GECK puzzle that was not entirely clear to me until now, but now it makes perfect sense. Obviously for objects in GECK, unless they actually have instances placed in the game then a lot of functions don't apply. That explains why some functions only work for reference variables outside of the NPC object/script, but inside the NPC object/script you can use the base object name. I am very glad to have made this connection clear now, its something I've read about in snippets here and there but how it was actually implemented was a bit of a mystery. I only really wanted to find out this weekend to solve a particular problem and now its solved: my companions can now repair and upgrade their current weapons automatically all through the game, and they can also react to the player when they get a certain item given to them, if I want to add some personal qeusts later. And one always understands stuff better after having struggled with it first which is why I waited to ask. Being stumped for awhile makes things a lot clearer when the solution comes around. Edited May 24, 2011 by drakeelvin Link to comment Share on other sites More sharing options...
drakeelvin Posted May 24, 2011 Author Share Posted May 24, 2011 @RickerHK Just FYI here are the initial results of your help to me: Companion Kayenta I managed to put the finishing touches on the companion wheel so it remembers settings, and in addition I added the ability of this companion to monitor weapon and ammo state, do repairs, recover lost ammo/weapons if the game glitches, and even upgrade weapons throughout the game to better ones at later levels. Maybe after the first kudos subsequent ones should be wortth 0.01 or something, I'd give you more if I could, because Kayenta is rocking now! :D Thanks again! Link to comment Share on other sites More sharing options...
rickerhk Posted May 25, 2011 Share Posted May 25, 2011 @RickerHK Just FYI here are the initial results of your help to me: Companion Kayenta I managed to put the finishing touches on the companion wheel so it remembers settings, and in addition I added the ability of this companion to monitor weapon and ammo state, do repairs, recover lost ammo/weapons if the game glitches, and even upgrade weapons throughout the game to better ones at later levels. Maybe after the first kudos subsequent ones should be wortth 0.01 or something, I'd give you more if I could, because Kayenta is rocking now! :D Thanks again! Glad to help ;) Link to comment Share on other sites More sharing options...
Recommended Posts