Skip to content

General mod Questions thread

1303133353670

Comments

  • GwendolyneGwendolyne Member Posts: 461
    @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
  • RaduzielRaduziel Member Posts: 4,714

    @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. :)

    Thanks in advance!
  • RaduzielRaduziel Member Posts: 4,714
    edited August 2018
    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).

    Thanks!
    Post edited by Raduziel on
  •  TheArtisan TheArtisan Member Posts: 3,277
    edited August 2018
    @Raduziel

    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.
    Raduziel
  • RaduzielRaduziel Member Posts: 4,714
    Thanks @Artemius_I !

    I'll disable wands, scrolls, potions and miscellaneous. That should do the trick.
  • CamDawgCamDawg Member, Developer Posts: 3,438
    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:

    APPEND ~specific.ids~ ~0 NOTHING~ UNLESS ~^0 NOTHING~
    APPEND ~specific.ids~ ~1 NORMAL~ UNLESS ~^1 NORMAL~
    APPEND ~specific.ids~ ~2 HARPERS~ UNLESS ~^2 HARPERS~
    APPEND ~specific.ids~ ~3 KNIGHTS_OF_THE_LIGHTNING_HEART~ UNLESS ~^3 KNIGHTS_OF_THE_LIGHTNING_HEART~
    APPEND ~specific.ids~ ~4 PALADIN_GROUP_IN_UMAR_HILLS~ UNLESS ~^4 PALADIN_GROUP_IN_UMAR_HILLS~
    APPEND ~specific.ids~ ~5 FIGHTING_GROUPS--ELVES_AND_DROW~ UNLESS ~^5 FIGHTING_GROUPS--ELVES_AND_DROW~
    APPEND ~specific.ids~ ~6 ELFVES_AT_EXIT_FROM_UNDERDARK--OROGONS_IN_UMAR_HILLS~ UNLESS ~^6 ELFVES_AT_EXIT_FROM_UNDERDARK--OROGONS_IN_UMAR_HILLS~
    APPEND ~specific.ids~ ~7 SAHUAGIN_FROM_THE_KING~ UNLESS ~^7 SAHUAGIN_FROM_THE_KING~
    APPEND ~specific.ids~ ~8 HAUPTMANN_ERELON_AND_SOLDIERS~ UNLESS ~^8 HAUPTMANN_ERELON_AND_SOLDIERS~
    APPEND ~specific.ids~ ~10 MONKS_SMUGGLERPLOT--DROW_GROUP_IN_UNDERDARK~ UNLESS ~^10 MONKS_SMUGGLERPLOT--DROW_GROUP_IN_UNDERDARK~
    APPEND ~specific.ids~ ~11 THUGS~ UNLESS ~^11 THUGS~
    APPEND ~specific.ids~ ~12 NOBLEPEOPLE_WITH_GUARDS_IN_TH_BRIDGE_DISTRICT--TOMBELTHEN~ UNLESS ~^12 NOBLEPEOPLE_WITH_GUARDS_IN_TH_BRIDGE_DISTRICT--TOMBELTHEN~
    APPEND ~specific.ids~ ~13 KNIGHTS_IN_OBSIDIAN_SPHERE--KOBOLDS~ UNLESS ~^13 KNIGHTS_IN_OBSIDIAN_SPHERE--KOBOLDS~
    APPEND ~specific.ids~ ~14 THUGS_GROUP_IN_BUILDING_IN_TEMPLE_DISTRICT~ UNLESS ~^14 THUGS_GROUP_IN_BUILDING_IN_TEMPLE_DISTRICT~
    APPEND ~specific.ids~ ~15 NIGHT_DAGGERS_WITH_AMA~ UNLESS ~^15 NIGHT_DAGGERS_WITH_AMA~
    APPEND ~specific.ids~ ~18 GOLBINS--ORCS~ UNLESS ~^18 GOLBINS--ORCS~
    APPEND ~specific.ids~ ~20 SAHUAGIN_REBELS--TETHYRIAN_CLERICS--YAGA_SHURAS_SOLDIERS~ UNLESS ~^20 SAHUAGIN_REBELS--TETHYRIAN_CLERICS--YAGA_SHURAS_SOLDIERS~
    APPEND ~specific.ids~ ~22 RAKSHASAS_IN_DRUID_HAIN~ UNLESS ~^22 RAKSHASAS_IN_DRUID_HAIN~
    APPEND ~specific.ids~ ~28 PEOPLE_AT_VICONIAS_STAKE~ UNLESS ~^28 PEOPLE_AT_VICONIAS_STAKE~
    APPEND ~specific.ids~ ~30 SAHUAGIN_KING_GUARDS~ UNLESS ~^30 SAHUAGIN_KING_GUARDS~
    APPEND ~specific.ids~ ~33 ROBBERS~ UNLESS ~^33 ROBBERS~
    APPEND ~specific.ids~ ~40 METRICHS_SOLDIERS~ UNLESS ~^40 METRICHS_SOLDIERS~
    APPEND ~specific.ids~ ~42 PEOPLE_AT_NALIAS_FUNERAL_PLOT~ UNLESS ~^42 PEOPLE_AT_NALIAS_FUNERAL_PLOT~
    APPEND ~specific.ids~ ~43 RAKSHASA_IN_SULDANESSALAR~ UNLESS ~^43 RAKSHASA_IN_SULDANESSALAR~
    APPEND ~specific.ids~ ~44 RAKSHASAS~ UNLESS ~^44 RAKSHASAS~
    APPEND ~specific.ids~ ~50 SLAYSHADOW~ UNLESS ~^50 SLAYSHADOW~
    APPEND ~specific.ids~ ~51 DROW_IN_DROW_ELFEN_FIGHT_IN_AREA_2500~ UNLESS ~^51 DROW_IN_DROW_ELFEN_FIGHT_IN_AREA_2500~
    APPEND ~specific.ids~ ~52 THUGS_IN_THE_SLUMS~ UNLESS ~^52 THUGS_IN_THE_SLUMS~
    APPEND ~specific.ids~ ~55 ZAKEE--LEILA--BOYS--GIRLS~ UNLESS ~^55 ZAKEE--LEILA--BOYS--GIRLS~
    APPEND ~specific.ids~ ~60 DEMOGORGONS_AND_MELISSANS_SUMMONED_CREATURES~ UNLESS ~^60 DEMOGORGONS_AND_MELISSANS_SUMMONED_CREATURES~
    APPEND ~specific.ids~ ~66 SOLDIERS_IN_AMKETHRAN--THUGS~ UNLESS ~^66 SOLDIERS_IN_AMKETHRAN--THUGS~
    APPEND ~specific.ids~ ~77 NOBLE_ORDER~ UNLESS ~^77 NOBLE_ORDER~
    APPEND ~specific.ids~ ~80 TROLLS_IN_ASYLUM--WOMEN_MONSTERS_IN_WATCHING_TOWER~ UNLESS ~^80 TROLLS_IN_ASYLUM--WOMEN_MONSTERS_IN_WATCHING_TOWER~
    APPEND ~specific.ids~ ~88 MAGE_APPRENTIS--YAGA_SHURAS_GUARDS~ UNLESS ~^88 MAGE_APPRENTIS--YAGA_SHURAS_GUARDS~
    APPEND ~specific.ids~ ~90 MDK_GROUP~ UNLESS ~^90 MDK_GROUP~
    APPEND ~specific.ids~ ~97 GROUP_AT_GRAVE_IN_AREA_1800~ UNLESS ~^97 GROUP_AT_GRAVE_IN_AREA_1800~
    APPEND ~specific.ids~ ~98 HENDAKS_GROUP~ UNLESS ~^98 HENDAKS_GROUP~
    APPEND ~specific.ids~ ~99 MELISSAN--SLAVES_IN_PLANAR_PRISON~ UNLESS ~^99 MELISSAN--SLAVES_IN_PLANAR_PRISON~
    APPEND ~specific.ids~ ~100 DEMOGORGON_GUARDS~ UNLESS ~^100 DEMOGORGON_GUARDS~
    APPEND ~specific.ids~ ~101 MAGIC~ UNLESS ~^101 MAGIC~
    APPEND ~specific.ids~ ~102 NO_MAGIC~ UNLESS ~^102 NO_MAGIC~
    APPEND ~specific.ids~ ~105 ACTOR_GROUP_WITH_RAELIS~ UNLESS ~^105 ACTOR_GROUP_WITH_RAELIS~
    APPEND ~specific.ids~ ~110 ROENALS_GUARDS~ UNLESS ~^110 ROENALS_GUARDS~
    APPEND ~specific.ids~ ~111 SAMIA_AND_FRIENDS~ UNLESS ~^111 SAMIA_AND_FRIENDS~
    APPEND ~specific.ids~ ~112 SHADOW_PATRICK--DARK_MASTER_IN_SENDAIS_LAIR~ UNLESS ~^112 SHADOW_PATRICK--DARK_MASTER_IN_SENDAIS_LAIR~
    APPEND ~specific.ids~ ~115 SHADOWDRUIDS~ UNLESS ~^115 SHADOWDRUIDS~
    APPEND ~specific.ids~ ~116 SHADOWDRUIDS_BY_FALDORN~ UNLESS ~^116 SHADOWDRUIDS_BY_FALDORN~
    APPEND ~specific.ids~ ~117 KYLAND_LINDS_GROUP~ UNLESS ~^117 KYLAND_LINDS_GROUP~
    APPEND ~specific.ids~ ~120 THUG_GROUP_IN_UNDERDARK_WITH_CHALINDRA~ UNLESS ~^120 THUG_GROUP_IN_UNDERDARK_WITH_CHALINDRA~
    APPEND ~specific.ids~ ~121 THUGS_IN_WAUKEENS_PROMENADE~ UNLESS ~^121 THUGS_IN_WAUKEENS_PROMENADE~
    APPEND ~specific.ids~ ~122 MAGE_ASSASSINEN~ UNLESS ~^122 MAGE_ASSASSINEN~
    APPEND ~specific.ids~ ~125 THIEFS~ UNLESS ~^125 THIEFS~
    APPEND ~specific.ids~ ~126 SAHUAGIN_REBELS~ UNLESS ~^126 SAHUAGIN_REBELS~
    APPEND ~specific.ids~ ~127 MAE_VAR_AND_HIS_GUARDS~ UNLESS ~^127 MAE_VAR_AND_HIS_GUARDS~
    APPEND ~specific.ids~ ~128 ADVENTURER_ROBBERS~ UNLESS ~^128 ADVENTURER_ROBBERS~
    APPEND ~specific.ids~ ~129 DROW_TORWAECHTER_IN_UNDERDARK~ UNLESS ~^129 DROW_TORWAECHTER_IN_UNDERDARK~
    APPEND ~specific.ids~ ~130 VAMPIRES_IN_ASYLUM~ UNLESS ~^130 VAMPIRES_IN_ASYLUM~
    APPEND ~specific.ids~ ~140 PATIENTS_IN_ASYLUM~ UNLESS ~^140 PATIENTS_IN_ASYLUM~
    APPEND ~specific.ids~ ~141 GUARDS_CALLED_FROM_GAAL~ UNLESS ~^141 GUARDS_CALLED_FROM_GAAL~
    APPEND ~specific.ids~ ~150 GITHIANKY_IN_UNDERDARK~ UNLESS ~^150 GITHIANKY_IN_UNDERDARK~
    APPEND ~specific.ids~ ~151 SAHUAGIN~ UNLESS ~^151 SAHUAGIN~
    APPEND ~specific.ids~ ~200 ODRENS_GROUP_AT_WATCHING_TOWER~ UNLESS ~^200 ODRENS_GROUP_AT_WATCHING_TOWER~
    APPEND ~specific.ids~ ~201 INVISIBLE_STATUES_IN_WATCHING_TOWER--SLAVE_GUARDS_IN_COPPER_CROWN_SEWERS~ UNLESS ~^201 INVISIBLE_STATUES_IN_WATCHING_TOWER--SLAVE_GUARDS_IN_COPPER_CROWN_SEWERS~
    APPEND ~specific.ids~ ~202 INVISIBLE_STATUES_IN_WATCHING_TOWER--HALFLINGS_IN_OBSIDIAN_SPHERE~ UNLESS ~^202 INVISIBLE_STATUES_IN_WATCHING_TOWER--HALFLINGS_IN_OBSIDIAN_SPHERE~
    APPEND ~specific.ids~ ~203 BOUNTY_HUNTER_IN_PLANAR_PRISON--GLABREZU--BALOR~ UNLESS ~^203 BOUNTY_HUNTER_IN_PLANAR_PRISON--GLABREZU--BALOR~
    APPEND ~specific.ids~ ~204 TEUFELCHEN--RANGER_IN_UMAR_HILLS~ UNLESS ~^204 TEUFELCHEN--RANGER_IN_UMAR_HILLS~
    APPEND ~specific.ids~ ~205 SHADOW_THIEF_THUGS_AND_ARCHERS~ UNLESS ~^205 SHADOW_THIEF_THUGS_AND_ARCHERS~
    APPEND ~specific.ids~ ~206 ADVENTURERS_IN_THE_SEWERS_TEMPEL_AREA~ UNLESS ~^206 ADVENTURERS_IN_THE_SEWERS_TEMPEL_AREA~
    APPEND ~specific.ids~ ~207 BLIND_PRIESTS_IN_BEHOLDER_LAIR~ UNLESS ~^207 BLIND_PRIESTS_IN_BEHOLDER_LAIR~
    APPEND ~specific.ids~ ~208 GROMNIRS_SOLDIERS~ UNLESS ~^208 GROMNIRS_SOLDIERS~
    APPEND ~specific.ids~ ~209 SKELETT_WARRIORS_AND_PRIESTERS_NEAR_NYALEE~ UNLESS ~^209 SKELETT_WARRIORS_AND_PRIESTERS_NEAR_NYALEE~
    APPEND ~specific.ids~ ~210 YAGA_SHURAS_SOLDIERS~ UNLESS ~^210 YAGA_SHURAS_SOLDIERS~
    APPEND ~specific.ids~ ~211 AMKETHRAN_SOLDIERS_BY_ASANA~ UNLESS ~^211 AMKETHRAN_SOLDIERS_BY_ASANA~
    APPEND ~specific.ids~ ~212 ALU_SCHEUSAL--SUKKUBUS~ UNLESS ~^212 ALU_SCHEUSAL--SUKKUBUS~
    APPEND ~specific.ids~ ~213 DROW_IN_SENDAIS_LAIR~ UNLESS ~^213 DROW_IN_SENDAIS_LAIR~
    APPEND ~specific.ids~ ~215 GUARDS_IN_SARADUSH~ UNLESS ~^215 GUARDS_IN_SARADUSH~
    APPEND ~specific.ids~ ~216 SHAMANES_BY_ABAZIGAL~ UNLESS ~^216 SHAMANES_BY_ABAZIGAL~
    APPEND ~specific.ids~ ~217 KUO_TOA~ UNLESS ~^217 KUO_TOA~
    APPEND ~specific.ids~ ~218 DWARFS_IN_SARADUSH~ UNLESS ~^218 DWARFS_IN_SARADUSH~
    APPEND ~specific.ids~ ~219 THUGS_IN_SARADUSH~ UNLESS ~^219 THUGS_IN_SARADUSH~
    APPEND ~specific.ids~ ~220 CULTISTS_IN_SARADUSH~ UNLESS ~^220 CULTISTS_IN_SARADUSH~
    APPEND ~specific.ids~ ~221 GROMNIRS_GUARDS_IN_SARADUSH~ UNLESS ~^221 GROMNIRS_GUARDS_IN_SARADUSH~
    APPEND ~specific.ids~ ~222 THUGS_IN_SARADUSH~ UNLESS ~^222 THUGS_IN_SARADUSH~
    APPEND ~specific.ids~ ~223 SENDAIS_GUARDS~ UNLESS ~^223 SENDAIS_GUARDS~
    APPEND ~specific.ids~ ~224 ELVES_IN_SARADUSH~ UNLESS ~^224 ELVES_IN_SARADUSH~
    APPEND ~specific.ids~ ~225 CUTSCENE_SPAWNS_BY_SAEMON_IN_AMKETHRAN~ UNLESS ~^225 CUTSCENE_SPAWNS_BY_SAEMON_IN_AMKETHRAN~
    APPEND ~specific.ids~ ~227 TETHYRIAN_TRUPS~ UNLESS ~^227 TETHYRIAN_TRUPS~
    APPEND ~specific.ids~ ~228 ADVENTURERS_NEAR_ABAZIGALS_LAIR~ UNLESS ~^228 ADVENTURERS_NEAR_ABAZIGALS_LAIR~
    APPEND ~specific.ids~ ~229 CURTISANE_IN_SARADUSH~ UNLESS ~^229 CURTISANE_IN_SARADUSH~
    APPEND ~specific.ids~ ~230 BANDITS~ UNLESS ~^230 BANDITS~
    APPEND ~specific.ids~ ~231 GITHIANKY_IN_WATCHING_TOWER~ UNLESS ~^231 GITHIANKY_IN_WATCHING_TOWER~
    APPEND ~specific.ids~ ~232 THUG_GROUP_IN_BRIDGE_DISTRICT--DWARFS_IN_SARADUSH~ UNLESS ~^232 THUG_GROUP_IN_BRIDGE_DISTRICT--DWARFS_IN_SARADUSH~
    APPEND ~specific.ids~ ~233 ELVES_IN_SARADUSH~ UNLESS ~^233 ELVES_IN_SARADUSH~
    APPEND ~specific.ids~ ~234 ORC_ARCHERS~ UNLESS ~^234 ORC_ARCHERS~
    APPEND ~specific.ids~ ~255 FAHEED_AND_MAJIRA--GROUP_IN_YAGA_SHURAS_TEMPLE~ UNLESS ~^255 FAHEED_AND_MAJIRA--GROUP_IN_YAGA_SHURAS_TEMPLE~
    APPEND ~specific.ids~ ~2001 FINAL_IRENICUS~ UNLESS ~^2001 FINAL_IRENICUS~
    Raduziel
  • RaduzielRaduziel Member Posts: 4,714
    There are some very specific entries in there. Now I know why it was named that way.
  • The user and all related content has been deleted.
  • RaduzielRaduziel Member Posts: 4,714
    @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.
  • SirBatinceSirBatince Member Posts: 882
    how can I change animation types?

    say, if I want a bg1critter to be compatible with using a "all-purpose" player animation
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited August 2018

    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?
    Post edited by _Luke_ on
  • GwendolyneGwendolyne Member Posts: 461
    edited August 2018
    Luke93 said:

    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
    
    I did not test it, but is should work.
    _Luke_
  • RaduzielRaduziel Member Posts: 4,714

    I did not test it, but is should work.

    Someday I'll have this confidence about modding. I can't even trust in the things that I test.
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    @Gwendolyne

    I was thinking about removing a specific item category. How can I adapt your code?
  • argent77argent77 Member Posts: 3,431
    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
    _Luke_
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited August 2018
    @argent77

    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
    Post edited by _Luke_ on
  • argent77argent77 Member Posts: 3,431
    Yes, that's correct syntax. (Minor nitpick: source_size -> SOURCE_SIZE)
    _Luke_
  • GwendolyneGwendolyne Member Posts: 461
    Raduziel said:

    I did not test it, but is should work.

    Someday I'll have this confidence about modding. I can't even trust in the things that I test.
    I only adapted a function I wrote to add new cure spells in temples. But Argent77 seems to have lightened my code with his new WeiDU functions. ;)
  • RaduzielRaduziel Member Posts: 4,714
    edited August 2018
    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.
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    @argent77

    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?
  • argent77argent77 Member Posts: 3,431
    edited August 2018
    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.
    COPY_EXISTING ~a.cre~ ~override~
    LPF ALTER_CRE_ITEM
    INT_VAR
    charges1 = 5
    flags = BIT2 // "Stolen"
    flags_mode = 2 // clear bits
    STR_VAR
    match_resref = ~potn25~
    resref = ~potn52~
    END
    BUT_ONLY
    [/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.
    Post edited by argent77 on
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited August 2018
    argent77 said:


    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?
  • argent77argent77 Member Posts: 3,431
    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.)
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited August 2018
    argent77 said:

    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"......
  • argent77argent77 Member Posts: 3,431
    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).
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    @argent77

    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?
  • argent77argent77 Member Posts: 3,431
    edited August 2018
    Should be doable if you adjust the offsets and account for differences in store or area item structures.
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited August 2018
    argent77 said:

    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
  • argent77argent77 Member Posts: 3,431
    Almost. You forgot to update item structure size in ALTER_STORE_ITEM. In line "SET ofs = ofs_items_for_sales + idx * 0x14" replace 0x14 by 0x1c.

    Item size in ALTER_AREA_ITEM is the same as in ALTER_CRE_ITEM.
    _Luke_
  • RaduzielRaduziel Member Posts: 4,714
    edited August 2018
    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.
Sign In or Register to comment.