Exult Logo
Home | Download | Documentation | FAQ | Studio | Screen Shots
Development | Discussion | About Us | Letters | History | Links
Exult Discussion
Before posting, make sure you've read the FAQ and searched the message board for previous discussions. When reporting problems/bugs, please include details about your setup (Exult version, OS, sound and video cards).

 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 Items and stats
Author: Donfrow 
Date:   03-16-17 20:42

So it's come to my attention a bug in my mod that I'm not sure how to fix.

I have some items that give stats, for example you put on an amulet that gives + 2 dexterity. If you remove the amulet, it removes 2 dexterity. This is all well and good, until you save the game and quit and restart. What seems to be happening is on a load of a save game, the +2 is being applied again.

So, if you start with base 20 dexterity, put on the amulet, you get 22, if you take it off, you're back to 20. No harm, no foul. This is being triggered by using events readied and unreadied on the object usecode.

If you save the game with 22 dex (20 base + 2 from amulet), you save with 22 dexterity. The next time you load the game, you start with 24 dexterity. (22 from the save, +2 more from the amulet).

I suspect what's happening is when you enter back into the game world, it's re-running the readied usecode, which is in turn causing it to keep going up and up every time you exit.

Does anyone have any thoughts about how to get around this? Is it even possible?

Along the same lines, is there a way to determine the NPC that has the item equipped? Currently I have it hard coded so it only ever works on the Avatar, but it seems like it would be a good idea to work on any equipped NPC's in the party however I can't seem to locate a suitable intrinsic that would return a reference I could use to get the NPC number of the equipped user.


Reply To This Message
 Re: Items and stats
Author: Dominus 
Date:   03-16-17 21:11

without being good with usecode, my first idea is to add a global flag to check against.
For example 0xNNN wear_amulet and make this flag a condition to add dexterity. If you put the amulet on, you check whether that global flag is set, if not, add dexterity, set global flag. If you remove it, unset the global flag.
So the case on reloading the game, will check again, but the global flag is set, so no dexterity is given.
I think the original does something similar with some stuff.

There must be some code to check for the party member, maybe KC can help :)

Read the documentation and the FAQ are your friends! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!

Reply To This Message
 Re: Items and stats
Author: Knight Captain 
Date:   03-16-17 21:49

The Silver Seed uses gflags to address this. I've emailed over the Belt of Strength file that you can adapt for your needs. The other boosting items do the same, like the Gauntlets of Quickness, Erinons' Axe, etc.

When the item is READIED the gflag is set, and it checks for that NPC's stat level, and sets the boost granted as the item's quality. For example, if the Avatar has 25 strength, the boost and quality is 5.

When UNREADIED the gflag is unset, and it uses the item's quality for how much to de-boost the stat.

So to do this boost you shouldn't need to check who is wearing the item. I'm not sure how this works in relation to party member deaths. For example, if I give the Belt to Shamino and he gets killed, does that count as (event == UNREADIED) ?

As for how to tell which party member is holding a unique item, I'm not sure. It would require checking that the party has the item, then getting the party list, and checking each member individually after that. I might be able to write this as its own function so you can just do something like:
to return the NPC.

Doing that to find the right container to place an object, for example to create a designated bag-of-reagents or move Serpent Teeth into the Jawbone, is even more complex.

Reply To This Message
 Re: Items and stats
Author: Donfrow 
Date:   03-16-17 22:14

Not sure why I didn't think of that. The flag should be straight forward enough.

I imagine with the belt of strength code (so far only skimmed it) it should have something similar in it as well, as I don't believe it was limited to simply the Avatar. Looks like it uses UI_get_container to get the wearer, which is pretty simple if that's the case.

On top of that, I think it contains the logic needed as well not to go over the total stat as well, ie, if you're at 25 strength don't go to 35, go to 30.

Thanks a bunch for that usecode; I think it will be very helpful. It looks like it would work for me with very minor changes. As I fix these bugs that people find in Glimmerscape it will really help to make Glimmerscape2 not quite the mess its predecessor is!

Reply To This Message
 Go to Top  |  Go to Topic  |  Threaded View   Newer Topic  |  Older Topic 

 Reply To This Message
 Your Name:
 Your E-mail:
SourceForge   phorum.org
Problems with Exult or this webpage? Contact us.
Last modified: 24 Oct 2001(GMT)