Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
Hi guys, I'm hoping to design a system for reusable spellbooks for Epic Encounters and I wanted to get some insight on how some of you might implement this particular idea. Of course, similar ideas that you think might just be better are welcome smile The only restriction here (it's a big restriction) is that story scripting cannot be used, because I need to maintain the integrity of player saved games, so item/character scripting only.

So, set all spellbooks to no longer consume themselves on use; that's easy, no problem. The catch is that I'd like players to pay for the book again each time the book is used after the first. My thought is to attach an itemscript to each of these books (since they need to offer one free use) which will act as the vehicle for the system.

The mock-up script I had written did this: Check if the book was already used once, if it has been, check to see if the user learned the skill (via a timer-delayed check of CharacterCanCast()). If the user did learn the skill, check if they have enough gold to learn it, if they did not, remove the skill. If they did, remove the gold.

The major problem here is gold--there's no way, to my knowledge, to easily understand how much gold the player has--since I both cannot get nor manipulate the gold amount directly and I have no function to iterate through stacks of gold in the inventory. My idea to handle this problem is to use ItemGetFromInventory(..., ..., "Small_Gold") to find the first stack of gold, use ItemGetStat() to find the stack's value, add it to a variable, then delete the stack. This process is repeated until the player has no more gold, but I have obtained their original gold amount. Next, I can use this value to check if they have enough gold, subtract the amount to pay, then create stacks of gold along with setting their stacksize to give them the appropriate gold amount back.

My worry with this particular implementation is whether or not this will work the way I expect it to, but also whether or not it will rapidly contribute toward the "Out of Handles" crash.

Last edited by Ameranth; 24/01/17 06:56 PM.
Joined: Jun 2015
F
enthusiast
Offline
enthusiast
F
Joined: Jun 2015
Gold is always one or more stack(s) of the root template:
'LOOT_Gold_Big_A_1c3c9c74-34a1-4685-989e-410dc080be6f'.

Be careful not to do too much deleting and creating, I've already mentioned the danger of too much item creation ;-)

Edit:
- with every book use, you use up at least one new handle - no matter if you need to remove gold or not.
- you cannot control which slot the new stack is put into. So the gold might happily 'jump around' inside the char's inventory if there were empty slots before the old slot.
- you also might change the amount of stacks inside the inventory. (e.g. if someone has 5 stacks of 10k and you charge 6k gold, the char will end up with 1 stack of 44k.)
- you attach the script and it can not know, how often it has been used before. There *will* be a balancing complainer, because they can use an existing book for free at least one time. You've had enough complaints about things that are not even your fault.
- if you implement such a system, there's no need anymore to have skill trainers restock the books. So remove the skillbooks from the TreasureTable.txt entry. But they need an initial stock, hard to do with object scripts. If they don't restock books any longer, that's very positive for the handle balance.
- if any existing skillbook has a script with paramters attached, e.g. HiddenPerception, it will not pick up the script from the template --> next rant.

Are you sure you really want to implement this for running games too ?


... since I'm an object script noob, I can only imagine that you register a gold stack's info (amount), then delete it and afterwards use CharacterAddToInventory() to re-add the remaining gold. I might be wrong though.


All apart, it should be possible to increase the max stack size of the above template even for running games if you haven't already done it.

Last edited by FrauBlake; 24/01/17 10:01 PM.
Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
The item handle crash is probably the biggest concern of mine. I assumed that deleting the gold items would free-up the used item handle, if that isn't the case then this system could potentially create that crash quite quickly. Also, if that's the case, then every game is doomed to find this crash eventually regardless of any clean-up done by modders...

Books in existing games would still get a "free" use, yes, but they've already either paid for the book initially or found it as a drop, so it's not actually free. I really hope no one would complain about balance with this system, it would only be the difference that players do not need to go to each vendor to buy the separate books anymore--if they've already bought/found it once.

For the vendor skillbook stock, I think that, given this system, I would ideally either have books as only drops, or vendors would have a few random books from a pool at a time. Perhaps a mixture of both. Of course, this may be strange to implement in the middle of saved games, etc.

I would need to go find pre-placed scripted books, you're right. That shouldn't be too painful though.

I only want to implement this for running games insofar as I don't want players using the mod to lose their saves. It's possible to do a "re-release" of the mod at some point, with story scripting updates, but I'm not certain about this. I did have an idea for a standalone Epic Encounters release, but this would be something for the future and DoS 2 will be out soon.

I haven't tried raising the max stack size of the gold template. Even if I raised it so high that players could never fill a stack, it's possible that players could create separate stacks themselves, causing the system to misread gold (I'm not sure if I would care about this though).

Last edited by Ameranth; 25/01/17 02:23 AM.
Joined: Jun 2015
F
enthusiast
Offline
enthusiast
F
Joined: Jun 2015
Originally Posted by Ameranth
The item handle crash is probably the biggest concern of mine. I assumed that deleting the gold items would free-up the used item handle, if that isn't the case then this system could potentially create that crash quite quickly. Also, if that's the case, then every game is doomed to find this crash eventually regardless of any clean-up done by modders...

The handle might be freed but it is never usable again. The reason for that is the way the handle generator works.

All you can do is change things in a way that not too many handles get created. I changed my Field Bed skills for example to achieve this. Originally it was done with SpawnItem(), but when I learned about the handle thing, I changed that. Also, the TreasureTable cleanup was done because of handles. (e.g. I removed all lockpicks and disarm kits from traders because I introduced the 'unbreakable' versions. One wasted handle less is one less.)

What you can not control is if players craft a lot or split stacks a lot, so it's always a good idea to do as few creations in a mod as really necessary to minimize handle waste from the mod's side.
(You also cannot control how often players learn the spell even if short of money.)

Originally Posted by Ameranth
Books in existing games would still get a "free" use, yes, but they've already either paid for the book initially or found it as a drop, so it's not actually free. I really hope no one would complain about balance with this system, it would only be the difference that players do not need to go to each vendor to buy the separate books anymore--if they've already bought/found it once.

For the vendor skillbook stock, I think that, given this system, I would ideally either have books as only drops, or vendors would have a few random books from a pool at a time. Perhaps a mixture of both. Of course, this may be strange to implement in the middle of saved games, etc.

You love to forget crafting ...

From a pool at a time is exactly how it is now, even if the pool might be too big for your taste. This pool is recreated in certain intervals or on levelup, a big pool uses more handles, a small pool less.

Originally Posted by Ameranth
I would need to go find pre-placed scripted books, you're right. That shouldn't be too painful though.

It's not, but changing pre-placed items (the objects themselves, not the root templates) once they're initialized has a good chance to render a savegame unusable. Not saying it will, only that there's a chance.

Originally Posted by Ameranth
I only want to implement this for running games insofar as I don't want players using the mod to lose their saves. It's possible to do a "re-release" of the mod at some point, with story scripting updates, but I'm not certain about this. I did have an idea for a standalone Epic Encounters release, but this would be something for the future and DoS 2 will be out soon.

I haven't tried raising the max stack size of the good template. Even if I raised it so high that players could never fill a stack, it's possible that players could create separate stacks themselves, causing the system to misread gold (I'm not sure if I would care about this though).

This is an independent problem.

Increasing stack sizes is one of the measures to push the inevitable out-of-handles crash further away.


Anyway, if you want to do it the way you suggested, do it.
The original question was if it could become a problem and I'd say it can, but it depends on player's playstyle. Although you unnecessarily pull the ooh crash closer, it's of course not guaranteed to happen.

And don't forget that you have a complete new area with a lot of objects using handles, the free pool is already reduced compared to standard Enhanced Edition ...


Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5