Morrowind Mod talk:Storing NPC related data

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

Workaround script[edit]

For the workaround script, why not simply use the HasItemEquipped function? You could have a much simpler script that doesn't even have to require MWSE, and it will even be more robust, too (will work if NPC somehow decides to equip the light for some other reason). You also don't need the script to run every frame (with either solution). I'd run it every 2 seconds or so. Also, maybe there's a way to make NPCs not want to equip the light item? Like giving it certain properties (black light? zero or negative light strength?) that will make the AI count it as useless? Or -- how does the AI choose what to equip if an NPC has multiple light items? Could you ensure an NPC equips a different light instead? I take it that whether an NPC has an active Light or NightEye effect on it also doesn't affect this... If all of the above fails, is there perhaps a different item type that could be made invisible in inventories under certain circumstances? Golken (talk) 23:12, 1 June 2015 (UTC)

The script uses xRemoveItem and xAddItem, so there is no way to remove MWSE requirement. I tried make NPCs not equip lights but nothing worked. qqqbbb (talk) 12:57, 6 June 2015 (UTC)

Wrapper MWSE functions that allow count vars in place of hardcoded counts could be simulated in vanilla by simply looping with hardcoded count of 1 (e.g. RemoveItem item 1), either with one iteration per frame or instantly via while(). Though this is mostly academic, as nowadays, indeed, I don't too much merit in caring about your mod requiring MWSE. Thanks for sharing your results, if so it would seem that a MCP fix is in order (if it's still being worked on...) to prevent NPCs from trying to equip noncarriable lights, and until then we have to workaround this by handling any NPC that equips a non-carriable light. This handling should probably look to see if they have a normal light in their inventory and equip it if so, otherwise NPCs that have "stored data" on them might not use their torches (because they went for the invisible light first and then a script killed it). This could even be done with a periodical MWSE loop through NPCs in the current cell, and it could check for any lights flagged by a specific word in id or name, and make sure they're not equipped (and normal lights are equipped instead, if present), using xStringMatch, xHasItemEquipped and xEquip. So it will automatically take care of this problem for all scripts/mods installed that comply. By the way, you can sign your edits by writing ~~~~, to make the page flow better and easier to follow. I manually added a sign for your previous edit. Golken (talk) 00:41, 11 June 2015 (UTC)

Other methods of storing data on an NPC[edit]

Other than writing data to file using MWSE, which isn't a particularly good method in itself, data can also be stored on an NPC with the following methods. They spell ones aren't as flexible as storing an item, however, and the rest aren't as repeatable and will conflict between mods that use the same method. Some of those may even have rare effects on gameplay.

  • Get/SetReputation (no gameplay effect AFAIK. can also be accessed from dialog conditions.)
  • Get/SetResistBlight
  • Get/SetResistCorprus (no meaningful gameplay effect)
  • Get/SetResistDisease
  • Get/SetScale??? (haven't tested, scale change might not be noticeable if small decimals are used)
  • Get/AddSpell (make sure you setup the spell so NPC won't try to cast it, this can be used to store unlimited boolean data perfectly, but it will affect all references of the same id)
  • anyobject->Cast touch_spell npc, npc->GetSpellEffects touch_spell (this should work to mark only individual references, and can automatically expire after amount of seconds you decide. may have activation sfx on NPC depending on spell effect used; can probably choose one with no sfx (no effect, or EXTRA SPELL effect?))
  • can also use ExplodeSpell instead of Cast, with above.

^Golken (talk) 23:12, 1 June 2015 (UTC)