Jump to content

Patching SecType.IDS and MSecType.2DA


jastey

Recommended Posts

I want to add the "secondary type" (named in NI) of a spell: AgingEffects. (So far, the mod uses "24" but I don't know whether this is compatible.)

How would I patch the SecType.ids (which I don't even see in my unmodded BGII) and how would I add the string "Aging Effects Removed" and patch the res-ref to the MSecType.2DA - in a compatible way? If someone could give me the tp2 code, I would be very thankful.

Link to comment

You can write the string in the spell, via applied patched effect.

COPY ~spell.spl~ ~override~

LPF ~ADD_SPELL_EFFECT~ INT_VAR opcode = 139 target = x timing = x resist_dispel = x probability1 = 100 parameter1 = EVAL "%Aging Effects Removed%" END

 

The x'es you need to find yourself. Could do the trick.

Edited by Jarno Mikkola
Link to comment

That's the way I handle the food poisoning in my food component:

ADD_SECTYPE GW_Intox @7100951    // ~Intoxication alimentaire soignée.~ (Food poisoning cured)

Then, for each spell using it:

COPY mymod/spells/myspell.spl override
    WRITE_BYTE 0x27 GW_Intox    // Secondary Type

If you want to use it in a #205 effect (Spell: Protection from Spell (Secondary Type) [205]):

COPY ~%MOD_FOLDER%/Kits/Chevalier/GWDgRo30.spl~    ~override/GWDgRo30.spl~                      // Rust Immunity
    LPF ALTER_EFFECT INT_VAR match_opcode = 139 parameter1 = RESOLVE_STR_REF (@7140131) END     // ~Protégé contre les effets de la rouille.~ = Protected against Rust effects
    INNER_ACTION BEGIN LAF ~GW_FIND_SECONDARY_TYPE~ STR_VAR GW_sectype_to_find = "GW_Rust" RET GW_sectype_found GW_sectype_value END END
    PATCH_IF "%GW_sectype_found%" STR_CMP "no" BEGIN
        LPF ALTER_EFFECT INT_VAR match_opcode = 205 parameter2 = EVAL "%GW_sectype_value%" END  // Spell: Protection from Spell (Secondary Type) [205]
    END
BUT_ONLY

Using this homemade function:

DEFINE_ACTION_FUNCTION ~GW_FIND_SECONDARY_TYPE~
    STR_VAR GW_sectype_to_find = ""  // École secondaire à trouver dans le fichier msectype.2da = secondary school to find
                                     // Secondary school to find in msectype.2da
    RET     GW_sectype_found         // Y = École secondaire trouvée  -  no = École secondaire absente
                                     // Y = Secondary school found    -  no = Secondary school not found
            GW_sectype_value         // Valeur de l'École secondaire trouvée dans le fichier msectype.2da
                                     // Secondary school value found in msectype.2da
BEGIN

    OUTER_SPRINT GW_sectype_found "no"
    OUTER_SET GW_sectype_value = "-99"
    ACTION_IF "%GW_sectype_to_find%" STR_CMP "" BEGIN
        ACTION_IF (FILE_CONTAINS_EVALUATED (msectype.2da "%GW_sectype_to_find%")) BEGIN
            ACTION_IF NOT VARIABLE_IS_SET $GW_sectype(~msectype~ ~%GW_sectype_to_find%~) BEGIN
                COPY_EXISTING - ~msectype.2da~ ~override~
                    READ_2DA_ENTRIES_NOW r2da_msectype 2
                    FOR (i = 1 ; i < r2da_msectype ; ++i) BEGIN
                        READ_2DA_ENTRY_FORMER r2da_msectype i 0 sectype
                        PATCH_IF ("%sectype%" STRING_EQUAL_CASE "%GW_sectype_to_find%") BEGIN
                            SET $GW_sectype(~msectype~ ~%GW_sectype_to_find%~) = i - 1
                            SET GW_sectype_value = $GW_sectype(~msectype~ ~%GW_sectype_to_find%~)
                            SPRINT GW_sectype_found "Y"
                        END
                    END
                BUT_ONLY
            END ELSE BEGIN
                OUTER_SPRINT GW_sectype_found "Y"
                OUTER_SET GW_sectype_value = $GW_sectype(~msectype~ ~%GW_sectype_to_find%~)
            END
        END
    END
END    // of DEFINE_ACTION_FUNCTION

Hoping it might help you. ;)

Edited by Gwendolyne
Link to comment

Thank you very much!

Wisp: where do you mean ADD_SECTYPE could be called again? (I need examples to be able to work with these kind of tp2 functions.)

Two more questions:

 

-if two mods might add the same entry, should I use something like this?

 

ADD_SECTYPE AgingEffects ~text~ UNLESS AgingEffects

 

And, if I have an itm that is supposed to remove these effects, currently the itm (a potion) has the ability "Remove Spell Type Protections (211)" where the spell type should be "AgingEffects". Would I do something like this?

 

COPY ~RRS_Grabmal/ITM/RRSPOT01.itm~ ~override/RRSPOT01.itm~
WRITE_BYTE 0xb2 AgingEffects

 

Link to comment

I don't know how to call ADD_SECTYPE again. So I use my function.

 

I guess you are speaking of Removal: Remove Secondary Type [221]. If yes, I use the same function:

COPY ~%MOD_FOLDER%/Kits/Chevalier/GWCD222.spl~    ~override/GWCD222.spl~
    // Atweaks stuff
    INNER_ACTION BEGIN LAF ~GW_FIND_SECONDARY_TYPE~ STR_VAR GW_sectype_to_find = "fl#Fear" RET GW_sectype_found GW_sectype_value END END
    PATCH_IF "%GW_sectype_found%" STR_CMP "no" BEGIN    // Removal: Remove Secondary Type [221]
        LPF CLONE_EFFECT INT_VAR check_globals = 0 multi_match = 1 match_opcode = 161 opcode = 221 parameter1 = 9 parameter2 = EVAL "%GW_sectype_value%" resist_dispel = 0 END
    END // of Atweaks stuff

Or
            LPF ADD_SPELL_EFFECT INT_VAR opcode = 221 target = 2 timing = 1 parameter1 = 9 parameter2 = EVAL "%GW_sectype_value%" END    // Removal: Remove Secondary Type [221]

or

COPY ~%MOD_FOLDER%/Kits/Chevaucheuse/GWLi607.spl~    ~override/GWLi607.spl~
    INNER_ACTION BEGIN LAF ~GW_FIND_SECONDARY_TYPE~ STR_VAR GW_sectype_to_find = "fl#Disease" RET GW_sectype_found GW_sectype_value END END
    PATCH_IF "%GW_sectype_found%" STR_CMP "no" BEGIN
        LPF ALTER_SPELL_EFFECT INT_VAR match_opcode = 221 parameter2 = EVAL "%GW_sectype_value%" END    // Removal: Remove Secondary Type [221]
    END
Link to comment

From the WeiDU readme:

Creates a new (guaranteed-unique) spell secondary type (as per msectype.2da), associate removalString (can be a tra reference) to its removal, and sets the sectypeName variable to the sectype identifier.

If msectype.2da already contains sectypeName, the variable is set to the sectype’s current identifier and no other operation is performed.


So jastey's code here:

ADD_SECTYPE AgingEffects ~text~

... will also create a variable, AgingEffects, that is set to its new value in SECTYPE so you can turn around and use it in effects, etc. If AgingEffects is already in SECTYPE, then using this code will just set the AgingEffects variable to the existing value without doing anything else--so you shouldn't use the UNLESS clause, because it's perfectly OK if AgingEffects is already present.

Edited by CamDawg
Link to comment

I guess you are speaking of Removal: Remove Secondary Type [221].

I don't know - I am working with existent spell and item, so I am trying to update the tp2 code. Maybe the "Remove Spell Type Protections (211)" is because the original spell also granted protection against iteself to prevent stacking).

Would the item need a "Remove Secondary Type [221]", too, to strip the cre from the spell effects?

 

Thank you all very much for the help and explanations!

Link to comment

#211 is "Spell Effect: Imprisonment". If you are modding EE games, you should use #321 (#206 equivalent) to avoid spells/items stacking:

 

 

#321 (0x141) Removal: Effects specified by Resource
Parameter #1: Irrelevant
Parameter #2: Type

Description: Removes effects from the resource specified by the resource key, in the style specified by the 'Type' field.
Known values for 'Type' are:
0 Default
1 Equipped effects list only
2 Timed effects list only
If used with a timing mode other than Duration (0) the effect behaves as per effect 206.

 

#221 is mostly used to allow cure spells or potion to erase specific effects or magic attack spells to remove specific protection effects.
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...