Random Item health/durability

Post » Sat Oct 15, 2011 6:58 pm

You might know I have been cooking up a small Roguelike using Oblivion as a base for fun.

Currently I have been playing around with the idea of making all armor and weapons have random durability. So finding a new cool dagger in a chest it would have 34 durability and require you to repair it before using it at full potential. I dislike finding almost completely new armor and weapons off of skeletons. I have been playing around with the idea but I am finding this fairly simple concept a bit harder to do than I am expecting.

Does anyone here know the simplest way to go about doing this?

So far I have not been able to get this to work.

ref itemRefshort doOnceshort equipOnceshort randValCondMinshort randValCondMaxshort randValCondshort randValEnchbegin OnLoad	if doOnce == 0		set doOnce to 1		set itemRef to GetSelf		set randValCondMin to 1		set randValCondMax to 60		set randValCond to randValCondMin + GetRandomPercent * (randValCondMin - randValCondMax+1) / 100		ModObjectHealth randValCond itemRef	endifendbegin OnAdd	if doOnce == 0		set doOnce to 1		set itemRef to GetSelf		set randValCondMin to 1		set randValCondMax to 60		set randValCond to randValCondMin + GetRandomPercent * (randValCondMin - randValCondMax+1) / 100		ModObjectHealth randValCond itemRef	endifendbegin OnEquip	if equipOnce == 0		set equipOnce to 1		set randValEnch to GetRandomPercent		if randValEnch <= 2			Message "This item has a deadly curse..."					endif	endifend

User avatar
Killah Bee
 
Posts: 3484
Joined: Sat Oct 06, 2007 12:23 pm

Post » Sat Oct 15, 2011 4:39 pm

Others know the OnLoad, etc. blocks better than me, so I leave that to others. but I can tell you that the part where you actually change the item heatlt doesn't do what you think. ModObjectHealth changes the base object health. E.g. if you find a sword whose base health is 200 and you call ModObjectHealth -50 on that, what you do, is to reduce the durability of all swords in the game of that type from 200 to 150 - without changing the current health of the sword you found.

To do what you want, you need to use SetCurrentHealth instead. E.g. something like:

let currentHealth :=  itemRef.GetCurrentHealth * GetRandomPercent  / 100itemRef.SetCurrentHealth currentHealth 

This will randomize the current health, with the avarage half of what it was.
User avatar
hannah sillery
 
Posts: 3354
Joined: Sun Nov 26, 2006 3:13 pm

Post » Sat Oct 15, 2011 11:48 am

Thank you TheNiceOne :)

However, I tried your suggestion and it seems like the item still has 100% health no matter what... :/
This is really strange...
User avatar
maria Dwyer
 
Posts: 3422
Joined: Sat Jan 27, 2007 11:24 am

Post » Sat Oct 15, 2011 8:25 pm

I know absolutely nothing about scripting, but this is the internet, so I get an opinion!

Is it possible to use OBSE to directly inflict wear damage on the item(s)? That, from the outside, would seem to be the ideal case, since items have varying health levels. x% damage will knock off x% health no matter what it's base health.

Using (somehow) the Disintegrate Armor or Weapon spell effects for example when an item spawns?
User avatar
Racheal Robertson
 
Posts: 3370
Joined: Thu Aug 16, 2007 6:03 pm


Return to IV - Oblivion