[FIXED] CVS 3.4r: Healing Error.

Here we stuff all the bugs we've managed to squash/squish/squelch.
Locked
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

CVS 3.4r: Healing Error.

Post by stranf »

Looks like the Tempeffects changes effected the healing switch.

If I'm damaged, and I use bandages nothing happens. I get an error in UOx3 that says:

Code: Select all

Fallout of switch statment 22 Uox3.cpp tempeffects 
Thanks.[/code]
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

Bandages are now handled by JS and work here. Make shure your JS scripts, jse_fileassociations.scp, jse_objectassociations.scp, jse_typeassociations.scp and DFNs are all up-to-date.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Healing is entirely handled in JS now, so those switch entries no longer exist. :P

As Grimson said, sounds like your JS files are not up to date. Specifically healing.js
Scott
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Changed the script and now I can apply bandages!

Imagine my surprise when I suddenly died of heart failure after my first bandage use! I was curious. So I met a wandering healer that ressed me, and I applied bandages again.....and BAM sure enough I died!

I wish I had my scripts with me, but the error seemed to be in the statement at the bottom where the health was calulated:

Code: Select all

mChar.heal(anatomy/50 + heal(3 10)+ healing/50.....etc
I changed that line to : mChar.heal(3 10); and it works now, it's just not as robust as your original formula.[/code]
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Changed the script and now I can apply bandages!

Imagine my surprise when I suddenly died of heart failure after my first bandage use! I was curious. So I met a wandering healer that ressed me, and I applied bandages again.....and BAM sure enough I died!

I wish I had my scripts with me, but the error seemed to be in the statement at the bottom where the health was calulated:

Code: Select all

mChar.heal(anatomy/50 + heal(3 10)+ healing/50.....etc
I changed that line to : mChar.heal(3 10); and it works now, it's just not as robust as your original formula.[/code]
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Hmm...

There's pretty much no logical way that statement could return a negative value....
Scott
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

We could put in a "failsave" into the heal and damage functions, so that they do nothing when you give a negative number.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Technically Heal() should only be a positive, however that would me most easily done with using a UI16 instead of SI16. But Maarc may have wanted it to be possible to pass a negative value, so best to check with him first.

As for the problem you got, stranf, it looks like what was happening is the number was too large (due to bad math by the JS Engine) and it was rolling that over into a negative when passed to the Heal() function.

Try replacing what you have with this

Code: Select all

				ourObj.Heal( (RandomNumber( 3, 10 ) + parseInt(mChar.skills.anatomy / 50) + RandomNumber( parseInt(healSkill / 50), parseInt(healSkill / 20) )), mChar );
Scott
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Two words: Evil Healer.

While I anticipate that most calls to these functions will be positive, not negative, it doesn't imply that it should always be so. I'm sure people can envisage a time where they might want to do negative healing or damage (creatures of fire attacked with fire, in most RPGs, tend to be healed, or negative damage inflicted).

giwo's other idea is quite possible, too large causing a rollover ... but if that's the case, I'd have to wonder how it got so high. It would essentially have to rollover 32767! Given that the skills themselves probably can't go that high (unless Stranf had a char with > 2000.0 of helaing and anatomy?), I'd have to wonder why the numbers aren't coming out right.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

As I noted, bad math by the JS Engine. Without telling it to parse to an int, it was (aparrantly) using a float, which for some reason was getting to 100,000 and even higher when I spit it to the Console. Notably this was with a character who had 0 healing, 0 anatomy.

I'm thinking maybe something due to converting float values to integers for the RandomNumber() call.

[EDIT]

RandomNumber() a Candidate for JSEncaps usage, anyone? :)
Scott
Locked