@Raduziel, you must be aware that using a function to find an available specific slot is not enough. Many creature files are using "hidden" slots, I mean slots not written in specific.ids. I faced this issue when coding my "dragons collection". I had to run a function to list all specific values used in game before adding new slots and not overwriting slots that other modders might use id they identified them in vanilla cre files. If you need it, I can share it.
@Raduziel, you must be aware that using a function to find an available specific slot is not enough. Many creature files are using "hidden" slots, I mean slots not written in specific.ids. I faced this issue when coding my "dragons collection". I had to run a function to list all specific values used in game before adding new slots and not overwriting slots that other modders might use id they identified them in vanilla cre files. If you need it, I can share it.
I don't actually need it, but I'm always willing to learn something new. If you have the time, please share with me and explain how this magic works.
I'm making a more-closer-to-PnP version of the Berserker Rage and I would like to disable the access to the inventory.
Is this possible? All I know how to do now is blocking quickslot-items, but that's it. Doing so would still allow someone to go to the inventory and use the item through there. I want an effect similar to the one the happens when a party member is in panic or charmed (the greyed inventory screen).
The Disable Button [144] opcode seemingly has a disable inventory setting, but it doesn't work. I tried using it for my Minsc mod and the inventory is still accessible. Can't Use Itemtype [181] with parameter2 = 1 allows you to prevent use of items even in the inventory screen.
In the ancient mists of time, there was a "Super Happy Fun Lucky Modder Pack" component of Fixpack that, among other things, fleshed out IDS entries. Here's what it did for specifics:
@subtledoctor No, the 1 turn preparation would not be implemented. Wouldn't make it more balanced just boring IMHO. Maybe a 3 rounds only.
Is Minsc's rage party friendly? I'm 99% sure that PnP's version is.
Things I have planned so far:
1) No item usage or spellcast of any sort (by that I mean potions, scrolls, special abilities from equipment and miscelaneous) 2) No missile weapon usage (except for throwing daggers and axes because IDK how to keep those away without blocking the melee too) 3) Hide HP info (I believe that there's an Opcode that does just that) 4) Hit/Dmg/HP bonus as PnP 5) Immunity to some specific spells (listed at the Complete Fighter's Handbook) 6) Immunity to some specific effects -> actually I would like to make those effects be absorbed by the rage, prematurely ending it 7) Keep the winded mechanic 8) Keep the premature end of rage when no enemies is at the LoS.
9*) If 6 and 8 success, make it at will. 10*) If PnP makes it party unfriendly, do the same here.
I've seen several mods that dispense with the Polymorph effect, and simply use opcode 111 and add opcode 53 Animation Change to the claw .ITM. Pretty much any .CRE characteristics I like can be applied as equipping effects on the claw .ITM.
This implementation should be preferred over opcode #135 (param2 = 0) because of this nasty bug..... The only "drawback" I can think of is that the claw .ITM can become quite big (up to ~70 equipping effects if you think about the Mustard Jelly) depending on the number of immunities your creature is supposed to have....
It'd be much better if opcode #135 fully changed you into the given .CRE -----> you should receive Resistances/statistics and benefit from the equipped items of that .CRE (e.g. RING95.itm). In this way you no longer benefit from the equipped items of your human form, but this may make sense....
Separately, how can I edit what items a certain store can purchase?
Separately, how can I edit what items a certain store can purchase?
If you want to add the food category (0x000d)
COPY_EXISTING ~storename.sto~ ~override~
READ_LONG 0x2c buy_off ELSE 0
READ_LONG 0x30 buy_num ELSE 0
SET add_categ = 1
FOR (i = 0 ; i < buy_num ; ++i) BEGIN
READ_LONG (buy_off + (i * 0x04)) category
PATCH_IF (category = 13) BEGIN // Food category is already purchased
SET add_categ = 0
SET i = buy_num // kills loop
END
END
PATCH_IF (add_categ = 1) BEGIN // if Food category not found
INSERT_BYTES buy_off 0x04
WRITE_LONG buy_off 13
WRITE_LONG 0x30 (buy_num + 1)
PATCH_FOR_EACH offset IN 0x34 0x4c 0x70 BEGIN // adjust offsets if needed
READ_LONG offset off
PATCH_IF (off > buy_off) BEGIN
WRITE_LONG offset (THIS + 0x04)
END
END
END
BUT_ONLY
Several months ago I wrote a set of store-related functions for WeiDU that were aimed at replacing (or at the very least complement) the built-in WeiDU functions ADD_STORE_ITEM and REMOVE_STORE_ITEM.
The functions are already included since WeiDU v245, but public documentation is still pending.
The (patch) functions are: - ADD_STORE_ITEM_EX: Adds an item to the store. - ADD_STORE_DRINK: Adds a drink to the store. - ADD_STORE_CURE: Adds a cure to the store. - ADD_STORE_PURCHASE: Adds an item category to the store. - REMOVE_STORE_ITEM_EX: Removes an item from the store. - REMOVE_STORE_DRINK: Removes a drink from the store. - REMOVE_STORE_CURE: Removes a cure from the store. - REMOVE_STORE_PURCHASE: Removes an item category from the store.
You can find interim documentation in the script file itself: store_functions.tpa
So, the following piece of code should do the trick, shouldn't it?
COPY_EXISTING_REGEXP ~.*\.sto~ ~override~
PATCH_IF (SOURCE_SIZE > 0x9b) BEGIN
READ_LONG 0x08 type
PATCH_IF (type !=5) BEGIN
LPF REMOVE_STORE_PURCHASE
INT_VAR
category = 2
END
END
END
BUT_ONLY
Ok, I have the attached spell that is applied to a creature (a F/C) through the also attached CLAB. The creature's Constitution is 10.
The problem is: apparently doesn't work.
This spell should give 1 extra HP per cleric level. Starting BG2 I'm a F(6)/C(6) and I don't have the 6 hp what I should have (one for every level).
During the rest of the levels, the spell behaves as expected. An extra HP is given for every cleric level achieved, except for the starting 6, so I'm always with 6 HP below the right amount.
Any ideas?
Thanks.
PS: As you can see in the CLAB attached, this spell is being applied to the creature using the CLAB all the way from level 1 to level 50.
Could you do something to REPLACE_CRE_ITEM so that it works like REPLACE_STORE_ITEM? I mean, what if I'd like to edit the number of charges of a certain item regardless of its flags and its location in the Inventory?
REPLACE_CRE_ITEM is a hardcoded WeiDU function. You would have to poke Wisp for additional functionality.
A general-purpose function for altering CRE items, that emulates all functionality of REPLACE_CRE_ITEM would be rather complex.
This is a less sophisticated version, that simply alters a CRE inventory item matching a given resource name, but without taking inventory slots into account (which would be the complex part). [spoiler]
// Alters properties of all inventory items matching the resource name specified by "match_resref". DEFINE_PATCH_FUNCTION ALTER_CRE_ITEM INT_VAR duration = "-1" charges1 = "-1" charges2 = "-1" charges3 = "-1" flags = "-1" flags_mode = 0 // 0=overwrite, 1=set bits, 2=clear bits STR_VAR match_resref = ~~ resref = ~~ BEGIN PATCH_IF (NOT ~%match_resref%~ STR_EQ ~~) BEGIN READ_LONG 0x2bc ofs_items READ_LONG 0x2c0 num_items FOR (idx = 0; idx < num_items; ++idx) BEGIN SET ofs = ofs_items + idx * 0x14 READ_ASCII ofs s (8) NULL PATCH_IF (~%match_resref%~ STR_EQ ~%s%~) BEGIN PATCH_IF (NOT ~%resref%~ STR_EQ ~~) BEGIN WRITE_ASCIIE ofs ~%resref%~ (8) END PATCH_IF (duration != "-1") BEGIN WRITE_SHORT (ofs + 0x08) duration END PATCH_IF (charges1 != "-1") BEGIN WRITE_SHORT (ofs + 0x0a) charges1 END PATCH_IF (charges2 != "-1") BEGIN WRITE_SHORT (ofs + 0x0c) charges2 END PATCH_IF (charges3 != "-1") BEGIN WRITE_SHORT (ofs + 0x0e) charges3 END PATCH_IF (flags != "-1") BEGIN PATCH_IF (flags_mode = 1) BEGIN // set specific bits WRITE_LONG (ofs + 0x10) (THIS BOR flags) END ELSE PATCH_IF (flags_mode = 2) BEGIN // clear specific bits WRITE_LONG (ofs + 0x10) (THIS BAND BNOT flags) END ELSE BEGIN // default: overwrite all flags WRITE_LONG (ofs + 0x10) flags END END END END END END
Example for BG1 "Baeloth", changing his "Potion of Healing" to "Potion of Extra Healing", increasing its number to 5 and clearing the "stolen" flag.
This is a less sophisticated version, that simply alters a CRE inventory item matching a given resource name, but without taking inventory slots into account (which would be the complex part).
So, if I write something like
COPY_EXISTING_REGEXP ~.*\.cre~ ~override~
PATCH_IF (SOURCE_SIZE > 0x2d3) BEGIN
LPF ALTER_CRE_ITEM
INT_VAR
charges1 = 10
STR_VAR
match_resref = ~wand02~
resref = ~wand02~
END
END
BUT_ONLY
there exists the possibility that some wand02 will be skipped if its location is INV1.......INV16, right?
The function above will process all matching items, regardless of inventory slots they might be assigned to. (Inventory slots and their assignments are stored separately in CRE files.)
The function above will process all matching items, regardless of inventory slots they might be assigned to. (Inventory slots and their assignments are stored separately in CRE files.)
OK, so that should be exactly what I was looking for, right? (i.e., setting the number of charges of all wands attached to a .CRE to a constant value). If this is the case, I didn't understand this part ".....but without taking inventory slots into account"......
I've mentioned it in my previous comment. Inventory slot assignment is stored in a separate part of the CRE structure. The function above doesn't check for inventory slots, so the item can be assigned to anything (including magic or inaccessible weapon slots).
Should be doable if you adjust the offsets and account for differences in store or area item structures.
Could you check if there are mistakes?
// Alters properties of all store items matching the resource name specified by "match_resref".
DEFINE_PATCH_FUNCTION ALTER_STORE_ITEM
INT_VAR
duration = "-1"
charges1 = "-1"
charges2 = "-1"
charges3 = "-1"
flags = "-1"
number_in_stock = "-1"
infinite_supply = "-1"
flags_mode = 0 // 0=overwrite, 1=set bits, 2=clear bits
STR_VAR
match_resref = ~~
resref = ~~
BEGIN
PATCH_IF (NOT ~%match_resref%~ STR_EQ ~~) BEGIN
READ_LONG 0x034 ofs_items_for_sales
READ_LONG 0x038 num_items_for_sales
FOR (idx = 0; idx < num_items_for_sales; ++idx) BEGIN
SET ofs = ofs_items_for_sales + idx * 0x14
READ_ASCII ofs s (8) NULL
PATCH_IF (~%match_resref%~ STR_EQ ~%s%~) BEGIN
PATCH_IF (NOT ~%resref%~ STR_EQ ~~) BEGIN
WRITE_ASCIIE ofs ~%resref%~ (8)
END
PATCH_IF (duration != "-1") BEGIN
WRITE_SHORT (ofs + 0x08) duration
END
PATCH_IF (charges1 != "-1") BEGIN
WRITE_SHORT (ofs + 0x0a) charges1
END
PATCH_IF (charges2 != "-1") BEGIN
WRITE_SHORT (ofs + 0x0c) charges2
END
PATCH_IF (charges3 != "-1") BEGIN
WRITE_SHORT (ofs + 0x0e) charges3
END
PATCH_IF (number_in_stock != "-1") BEGIN
WRITE_LONG (ofs + 0x014) number_in_stock
END
PATCH_IF (infinite_supply != "-1") BEGIN
WRITE_LONG (ofs + 0x018) infinite_supply
END
PATCH_IF (flags != "-1") BEGIN
PATCH_IF (flags_mode = 1) BEGIN // set specific bits
WRITE_LONG (ofs + 0x10) (THIS BOR flags)
END ELSE PATCH_IF (flags_mode = 2) BEGIN // clear specific bits
WRITE_LONG (ofs + 0x10) (THIS BAND BNOT flags)
END ELSE BEGIN // default: overwrite all flags
WRITE_LONG (ofs + 0x10) flags
END
END
END
END
END
END
// Alters properties of all area items matching the resource name specified by "match_resref".
DEFINE_PATCH_FUNCTION ALTER_AREA_ITEM
INT_VAR
duration = "-1"
charges1 = "-1"
charges2 = "-1"
charges3 = "-1"
flags = "-1"
flags_mode = 0 // 0=overwrite, 1=set bits, 2=clear bits
STR_VAR
match_resref = ~~
resref = ~~
BEGIN
PATCH_IF (NOT ~%match_resref%~ STR_EQ ~~) BEGIN
READ_LONG 0x078 ofs_items
READ_SHORT 0x076 num_items
FOR (idx = 0; idx < num_items; ++idx) BEGIN
SET ofs = ofs_items + idx * 0x14
READ_ASCII ofs s (8) NULL
PATCH_IF (~%match_resref%~ STR_EQ ~%s%~) BEGIN
PATCH_IF (NOT ~%resref%~ STR_EQ ~~) BEGIN
WRITE_ASCIIE ofs ~%resref%~ (8)
END
PATCH_IF (duration != "-1") BEGIN
WRITE_SHORT (ofs + 0x08) duration
END
PATCH_IF (charges1 != "-1") BEGIN
WRITE_SHORT (ofs + 0x0a) charges1
END
PATCH_IF (charges2 != "-1") BEGIN
WRITE_SHORT (ofs + 0x0c) charges2
END
PATCH_IF (charges3 != "-1") BEGIN
WRITE_SHORT (ofs + 0x0e) charges3
END
PATCH_IF (flags != "-1") BEGIN
PATCH_IF (flags_mode = 1) BEGIN // set specific bits
WRITE_LONG (ofs + 0x10) (THIS BOR flags)
END ELSE PATCH_IF (flags_mode = 2) BEGIN // clear specific bits
WRITE_LONG (ofs + 0x10) (THIS BAND BNOT flags)
END ELSE BEGIN // default: overwrite all flags
WRITE_LONG (ofs + 0x10) flags
END
END
END
END
END
END
I've discovered the hard way that Opcode 18 is not applied during the character creation. So if you want to make a kit with an HP boost it will not be possible for up to the starting level (that varies from BG/IWD, BG2, SoD, HoW and ToB), being applied only with already-in-game level ups.
Is there a way to work around this? I've tried through Opcode 177 without success (I might have configured the spell wrongly). Maybe Opcode 146?
Thanks.
Edit: @JuliusBorisov I've opened a bug report (Bug #38417) for this one, by the way.
Comments
If you need it, I can share it.
Thanks in advance!
Is this possible? All I know how to do now is blocking quickslot-items, but that's it. Doing so would still allow someone to go to the inventory and use the item through there. I want an effect similar to the one the happens when a party member is in panic or charmed (the greyed inventory screen).
Thanks!
The Disable Button [144] opcode seemingly has a disable inventory setting, but it doesn't work. I tried using it for my Minsc mod and the inventory is still accessible. Can't Use Itemtype [181] with parameter2 = 1 allows you to prevent use of items even in the inventory screen.
I'll disable wands, scrolls, potions and miscellaneous. That should do the trick.
Is Minsc's rage party friendly? I'm 99% sure that PnP's version is.
Things I have planned so far:
1) No item usage or spellcast of any sort (by that I mean potions, scrolls, special abilities from equipment and miscelaneous)
2) No missile weapon usage (except for throwing daggers and axes because IDK how to keep those away without blocking the melee too)
3) Hide HP info (I believe that there's an Opcode that does just that)
4) Hit/Dmg/HP bonus as PnP
5) Immunity to some specific spells (listed at the Complete Fighter's Handbook)
6) Immunity to some specific effects -> actually I would like to make those effects be absorbed by the rage, prematurely ending it
7) Keep the winded mechanic
8) Keep the premature end of rage when no enemies is at the LoS.
9*) If 6 and 8 success, make it at will.
10*) If PnP makes it party unfriendly, do the same here.
say, if I want a bg1critter to be compatible with using a "all-purpose" player animation
It'd be much better if opcode #135 fully changed you into the given .CRE -----> you should receive Resistances/statistics and benefit from the equipped items of that .CRE (e.g. RING95.itm). In this way you no longer benefit from the equipped items of your human form, but this may make sense....
Separately, how can I edit what items a certain store can purchase?
I was thinking about removing a specific item category. How can I adapt your code?
The functions are already included since WeiDU v245, but public documentation is still pending.
The (patch) functions are:
- ADD_STORE_ITEM_EX: Adds an item to the store.
- ADD_STORE_DRINK: Adds a drink to the store.
- ADD_STORE_CURE: Adds a cure to the store.
- ADD_STORE_PURCHASE: Adds an item category to the store.
- REMOVE_STORE_ITEM_EX: Removes an item from the store.
- REMOVE_STORE_DRINK: Removes a drink from the store.
- REMOVE_STORE_CURE: Removes a cure from the store.
- REMOVE_STORE_PURCHASE: Removes an item category from the store.
You can find interim documentation in the script file itself: store_functions.tpa
So, the following piece of code should do the trick, shouldn't it?
The problem is: apparently doesn't work.
This spell should give 1 extra HP per cleric level. Starting BG2 I'm a F(6)/C(6) and I don't have the 6 hp what I should have (one for every level).
During the rest of the levels, the spell behaves as expected. An extra HP is given for every cleric level achieved, except for the starting 6, so I'm always with 6 HP below the right amount.
Any ideas?
Thanks.
PS: As you can see in the CLAB attached, this spell is being applied to the creature using the CLAB all the way from level 1 to level 50.
Could you do something to REPLACE_CRE_ITEM so that it works like REPLACE_STORE_ITEM? I mean, what if I'd like to edit the number of charges of a certain item regardless of its flags and its location in the Inventory?
A general-purpose function for altering CRE items, that emulates all functionality of REPLACE_CRE_ITEM would be rather complex.
This is a less sophisticated version, that simply alters a CRE inventory item matching a given resource name, but without taking inventory slots into account (which would be the complex part).
[spoiler] Example for BG1 "Baeloth", changing his "Potion of Healing" to "Potion of Extra Healing", increasing its number to 5 and clearing the "stolen" flag. [/spoiler]
Edit: The code indentation gets lost whenever I reload the page. Does it happen to you as well?
Edit2: Switched from <code> to <pre>, which seems to preserve indentation.
OK, just tested, it works fine, thanks (It's now possible to edit, e.g., charges1 and leave the other fields as they were.....)
Do you think it's possible to edit your code in order to create a sort of ALTER_STORE_ITEM and ALTER_AREA_ITEM?
Item size in ALTER_AREA_ITEM is the same as in ALTER_CRE_ITEM.
Is there a way to work around this? I've tried through Opcode 177 without success (I might have configured the spell wrongly). Maybe Opcode 146?
Thanks.
Edit: @JuliusBorisov I've opened a bug report (Bug #38417) for this one, by the way.