TotalConversion Posted May 3, 2016 Posted May 3, 2016 Good time of the day. First, I apologize if this subforum / forum-in-general isn't a right place for my question. Please, just move / remove this topic then. What I want to do.I want to create 2 single-target spells: A and B. Doesn't matter what spell A does, but spell B must inform player how many times spell A has hit targeted NPC. And suppose that I want game to never forget about amount of hits for each NPC. The way I want to achieve this is by creating a quest with two array variables ('array_var'): affectedNPCs: stores references to affected NPCs ('ref') hitAmounts: stores corresponding integers ('short') that would denote how much time NPC with the same array index was hit by spell A. Then I plan to attach two scripts to spells A and B: Spell A script: searches through array affectedNPCs to match spell's target and either increments appropriate number in hitAmounts array or adds new element to both arrays, if targeted NPC wasn't found in affectedNPCs. Spell B script: searches through array affectedNPCs and displays either appropriate number or 0, if targeted NPC wasn't found in affectedNPCs. Questions I have. 1. 'Important' and 'un-important' NPCs. Suppose we call named NPCs that, as far as player is concerned, never disappear (unless killed), - 'important'. And, in contrast, various randomly generated, generic, fodder NPCs such as bandits, marauders, conjurers, that can spawn and despawn with time, would be called 'un-important'. Is there something that allows to distinguish between 'important' and 'unimportant' NPCs? Can one say that references to NPCs in first group are always 'persistens', references to NPCs in second group are always 'non-persistent' and distinguish between them like that? 2. Reliability of references. As far as I know, references to unimportant NPCs are randomly assigned and can be reused. But what about 'important' NPCs? Can I rely on obtained reference to remain valid and pointing to the same 'important' NPC? Or can it change to something else? If I... Record, say, Thoronir reference in affectedNPCs by casting spell A. Leave his cell, travel far away from him, stay there for several in-game days, exit and start game several times. Come back and cast spell A on him again. ...will reference obtained by spell A second time be guaranteed to match with the one already recorded in array affectedNPCs? 3. Tracking reference reassignment. If I recorded reference to 'un-important' NPC that has later despawned, - can I check if it is now invalid? And if some other NPC would later receive the same exact refID, would my reference become invalid or would it point to new NPC? Can I check whether or not it is pointing to the same NPC? What if 'important' NPC died? Can his reference be reassigned? 4. Referencing far away NPCs. If I recorded Thoronir's reference in affectedNPCs and then got far enough away for him to unload, - can I still use this reference to perform actions on him or get information about him? 5. Alternative solutions. If I can't do things the way I described above, then is there some other way to do so? I tried to google and read up on the topic of references to answer these questions myself, but I'm completely new to oblivion modding and my understanding always remains too fuzzy to be sure. Also, I'm sorry if my post is hard to read, - I'm both generally bad with words and am non-native speaker.
movomo Posted May 4, 2016 Posted May 4, 2016 Whoa. At first glance I thought this post is some kind of tutorial on something. Anyways, welcome. I'll try to answer most of your questions. If you have a shorter question, this thread is a good place to throw quick questions.https://www.loverslab.com/topic/168-useful-community-scripts-to-start-mods-with/ >>> 1. 'Important' and 'un-important' NPCs I takt it in this context you're refering to persistent and non-persistent difference. You can tell the difference by calling IsPersistent on the reference. No rhyme intended. >>> 2. Reliability of references. Persistent references remain in memory forever and will be there until the end of the world. So, yes, you can reliably reference them later, no matter how may times you've restarted the game or how far you've been to away from them. Note that dead or disabled Thoronir is still a valid Thoronir, technically. With one exception though - cloned reference... as far as I can think of right now. Cloned objects created by the CreatFullActorCopy function may be destroyed later. Such dynamic references have mod index of FF. >>> 3. Tracking reference reassignment. Your ref variable will be zeroed once the reference it's pointing to gets destroyed. It won't happen that one of your npc variables suddenly points to a quiver of arrows. Instead, it will just become invalid. Use the IsFormValid function to check that. >>> 4. Referencing far away NPCs. Persistent references won't ever unload because... they're supposed to be persistent. But, persistent or not, it is a good practice to check the validity of a form before using it.
TotalConversion Posted May 4, 2016 Author Posted May 4, 2016 Many thanks! That clears up a bunch of stuff for me and means that what I want to do should work. Will take a note of the linked thread for questions.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.