Rewriting BEAR mod - need some advice from other scripters

Post » Fri May 04, 2012 10:57 am

Any advice on the following questions is appreciated!

I am working on a new version of BEAR (BFG's Enhanced Armory Realism - see links in my signature). While this isn't a very popular mod, those who do use it seem to REALLY like it...so I figure it's worth the effort :smile:

Here's a brief description of the mod, so that my questions make more sense:
Spoiler
This mod aims to improve the way weapon and armor condition (health) impacts your game, increasing immersion and making the game more difficult.
  • All settings are customizable! All mod features as described below can be toggled on or off, and the strength of enchantment scaling on armor and weapons can be tailored to your tastes.
  • Broken armor and weapons can have a chance of completely disintegrating. The likelihood is dependent on the character Armorer and Heavy, Light, Blade, Blunt, or Marksman skill (whichever is applicable to that equipment), Luck, and the setting in the INI file. This is turned off by default.
  • Clothing can give a small armor bonus while it is being worn. The armor bonus given depends on how heavy it is, and what part of the body it covers.
  • Broken armor can no longer be worn. It is replaced with the highest value clothing in inventory, giving the impression that that clothing was being worn underneath.
  • Magical enchantments on armor and weapons scale according to the armor or weapon health.
  • A new weapon will automatically equip if the current one just broke, or was disarmed. Preference will be given to a high-value weapon of similar type.
  • Broken armor or weapons fall to the ground during combat.
  • All of the above applies to the player and NPCs.



Here's where I'm having trouble with the mod rewrite:

1. Applying new armor enchantments. As armor takes damage in battle, BEAR weakens its enchantments. For example, a piece of armor that gives Resist Magic 20 at 100% health might only give Resist Magic 5 when it's about to break. The problem is, I can't just change the size of the enchantment - the new size won't take effect unless the armor is unequipped and reequipped.. This always triggers the armor unequip/equip sound, as well as enchantment animations. Does anyone know any way to prevent those sounds and animations, or to get around the requirement to unequip/reequip armor?

2. Repairing to 150% health. The original design for BEAR called for allowing Master Armorers, under certain circumstances, to repair armor to 150% health. (For example, by using the Dwemer Forge in Battlehorn Castle.) Conversely, repairing to 100% or 125% health would not be possible anywhere that didn't have a forge/anvil--i.e. in the middle of a cave or Ayleid ruin. I was hoping to copy functionality in TheNiceOne's "Better Houses" mod, since it does something similar - but his scripts are too complex for me to understand, and they also require MenuQue. Does anyone have an idea of how to do something like this without using MenuQue?

3. Cleaning up old items. It's necessary to use PlaceAtMe or similar commands to create the "broken armor or weapons fall to the ground" effect. The unfortunate side effect of this is that it can contribute to savegame bloat, since those references don't get deleted when a cell resets. Does anyone have an idea of how to control this? Perhaps I could use an array to record when a given reference was created, then delete the reference after a certain time elapses if it's not in someone's inventory?

I have several other issues to work through as well, but these are the 3 biggest ones.
User avatar
OTTO
 
Posts: 3367
Joined: Thu May 17, 2007 6:22 pm

Post » Fri May 04, 2012 1:46 pm

1. Applying new armor enchantments. As armor takes damage in battle, BEAR weakens its enchantments. For example, a piece of armor that gives Resist Magic 20 at 100% health might only give Resist Magic 5 when it's about to break. The problem is, I can't just change the size of the enchantment - the new size won't take effect unless the armor is unequipped and reequipped.. This always triggers the armor unequip/equip sound, as well as enchantment animations. Does anyone know any way to prevent those sounds and animations, or to get around the requirement to unequip/reequip armor?

http://cs.elderscrolls.com/index.php/EquipItemSilent, maybe?



3. Cleaning up old items. It's necessary to use PlaceAtMe or similar commands to create the "broken armor or weapons fall to the ground" effect. The unfortunate side effect of this is that it can contribute to savegame bloat, since those references don't get deleted when a cell resets. Does anyone have an idea of how to control this? Perhaps I could use an array to record when a given reference was created, then delete the reference after a certain time elapses if it's not in someone's inventory?

PlaceAtMe items are usually deleted when cell resets, but not always. I have never been able to figure out a fool proof theory about its behavior.
My suggestion is that you determine if your particular implementation will or will not cause bloating by following these steps: (1) save the game, (2) run a script that PlaceAtMe 1,000 of your broken items and save again (this should increase your same size by 100-200 Kb) (3) leave the area and go thru several cell loads (4) keep saving the game every about 24 game hours and check if the save size dropped back to the same as in step 1, (5) if the size does not drop after 4 or 5 days, go back to the area an see if the items are still there (sometimes the engine clears the items while the cell is not loaded and sometimes the engine only clears the bloating during the cell load).

If the save size goes back without your returning to the area, you are safe to use PlaceAtMe.

Saving the references will not be of much use because dynamic references become temporarily invalid when the object is unloaded, so you cannot delete them at any time. In other words: you can only delete them if they are nearby.
User avatar
carley moss
 
Posts: 3331
Joined: Tue Jun 20, 2006 5:05 pm

Post » Fri May 04, 2012 5:59 am

Thanks for the suggestions! I didn't realize it was impossible to delete dynamic references when the PC isn't in the cell...I could still use an array as described to keep track of BEAR's items, but I'd have to have it run every time the player enters a new cell. Or I'd have to have it run as they're about to EXIT a cell. Hmm...

I've also thought about removing the enchantment from the armor, changing its strength, then adding the enchantment back. That might work better, but still wouldn't prevent the "magic effect" animation from happening every time.

The "Repairing to 150% health" idea is the one that's giving me the most fits. I can't think of any way, without MenuQue, to do it...and even with MenuQue it's extremely complex.
User avatar
carly mcdonough
 
Posts: 3402
Joined: Fri Jul 28, 2006 3:23 am

Post » Fri May 04, 2012 12:49 pm

Actually, you cannot do anything with dynamic references that are 'out-of-scope' (delete, move, get attributes etc)

When a cell is unloaded, is contents are saved somewhere and everything that is not marked "Persistent" is removed from memory. This includes dynamic references (FormID = FFxxxxxx) and non-dynamic, non persistent references.
From this point on, until the cell is loaded again, any ref var or aray element that contains the FormID of one of those unloaded objects becomes invalid (if you try to use the var while teh object is unloaded, the engine will return 00000000).

You may check for this with http://cs.elderscrolls.com/index.php/IsFormValid.

Saving the ref in an array is an option, but it is not as simple as that . . . well . . . I've been thinking about it and it is not as simple as I thought either . . . give me a couple of days to devise a comprehensive way and I will add an article to the WIKI.
Nope . . . could not find any way better than the existing Cell Reset

I have absolutely no experience with magic and actor value stuff, so I can't help you there.
User avatar
stephanie eastwood
 
Posts: 3526
Joined: Thu Jun 08, 2006 1:25 pm


Return to IV - Oblivion