My quest to fix the unintended action of consuming the player's entire inventory of holy water led me far and wide, through wikis, forum posts, and deep within the core includes of the Community Script Library, but nowhere did I find a script that would do quite what I was looking for. It seems like it should be a pretty simple and common event to want to use up a single piece of a stackable item! Am I missing something fundamental?
At any rate, the CSL scripts had some useful checks, and I found something close to what I needed -- a script that splits a stack and distributes the items between players. So I took that and tried changing it so that it would destroy one of the split stacks. I don't know why it didn't work, but I instead lost the whole stack, plus another whole stack minus one.
The fact that it had made a less-one stack was encouraging, though, so I instead set it to delay the creation of the less-one stack until the whole stack had been destroyed. This wouldn't compile. In my search for why, I learned that object functions can't be delayed, but a straight wrapper of an object function can. So I made a wrapper, and this time the script worked. Finally! Starting with a stack of 3 holy waters, after sanctifying the bowl, I'm left with 2. It works by counting the number of a particular item in the PC's inventory, keeping that number as an integer. Then it deletes the inventory supply of the item, subtracts the desired number from the integer (1 in this case), and creates new copies of the item in the PC's inventory equal to the integer with the number subtracted.
After suppressing the feedback that said "Lost Item: Holy Water (3)" followed by "Acquired Item: Holy Water (2)", and manually adding a chat window feedback saying "Lost Item: Holy Water (1)", no one should be the wiser (except for everyone reading this)! Of course, if there was an easier way of doing this, I'd like to have known.
Next, I got the wandering monster on rest system working. You may recall when I was getting started with this, that I couldn't get most of the creatures to appear, and I traced the problem to the fact that the creatures specified in the 2DA file were campaign-specific monsters that didn't exist in the default toolset. I had not yet edited any 2DA files, and was hesitant to do so at the time, but now my hak file contains a full dozen! So I looked at it again, and it made a lot more sense than it did before. I added the blueprint names of some appropriate creatures, including some custom ones, and tried it out. Success -- now I have fully functional MotB-style resting with random encounters. I suppose that does cut into my earlier statement that I wouldn't include any possibility of XP grinding in my module, but I suppose there will be that possibility after all, if anyone really wants to exploit it.
Next was fixing the death system. I found
Kaldor Silverwand's instructions on which files from SoZ need to be included for the death system to work, and also looked at his example in King's Festival. That, and the Silverwand Sample Campaign, are real treasures for a beginning modder. This was simply a matter of using the proper scripts from SoZ, though, and once I did that, the death and bleeding system worked perfectly. Party members, including the lead character, fall down bleeding after 0 HP, and lose 1 HP every tick until they acquire a deficit of half their total HP, at which point they die. Even the main PC stays dead, without prompt, until raised from the dead. Talking to other NPCs while the main character is dead works also. I haven't tried a full party wipe yet, though, to see if a prompt shows up in that event.
I'm starting to have more and more trouble loading my main town area, though. Even with everything else shut off and trying to load it first thing, it's crashing the toolset on load. I hope I can get everything hooked up before it stops loading altogether. I had to restart the computer to get it loading at all. I spent some time laying out spawn waypoints, activating doors, and dealing with more walkmesh issues -- more time than I would have otherwise, just because it's so difficult to load this one. I also set an area-specific On Client Enter script instead of the generic one I use for other areas, so that I can edit the NPCs that spawn there without having to open the area and modify the area's local variables, again for stability reasons.
Also changed a flag on a roof piece from BCK, making it so that it does not fade with the trees. The building the roof is on top of does not fade, so it was showing the normal roof underneath, which I covered with this one because the original is not tintable and I thought it would be easier than adding a tint map for it.
I tested the death system with a full party wipe, and it functions as expected. A prompt only appears upon the death of the whole party, saying "You have been defeated", and not offering any respawn. Now we're back to the superior BG/IWD system!
Next I added some more icons and created some more quest items and treasures, and edited some of the conversations to give out those items.
Modifié par Tchos, 24 juillet 2012 - 10:01 .