Jump to content


Photo

Patching SecType.IDS and MSecType.2DA


9 replies to this topic

#1 jastey

jastey
  • Gibberlings
  • 6964 posts
  • Gender:Female

Posted 26 November 2017 - 04:57 AM

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.



#2 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6304 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 26 November 2017 - 05:19 AM

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, 26 November 2017 - 05:41 AM.

Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.

#3 Gwendolyne

Gwendolyne
  • Members
  • 156 posts
  • Gender:Male
  • Location:France

Posted 26 November 2017 - 05:53 AM

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, 26 November 2017 - 05:54 AM.

CARPE DIEM...



In progress : Menace sur le Royaume de Diamant Éternel

#4 Wisp

Wisp
  • Modders
  • 1096 posts
  • Gender:Male

Posted 26 November 2017 - 07:05 AM

To find the sectype you can just call ADD_SECTYPE again. There's no need to write new code for the task.



#5 jastey

jastey
  • Gibberlings
  • 6964 posts
  • Gender:Female

Posted 26 November 2017 - 08:36 AM

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  

 



#6 Gwendolyne

Gwendolyne
  • Members
  • 156 posts
  • Gender:Male
  • Location:France

Posted 26 November 2017 - 09:05 AM

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

CARPE DIEM...



In progress : Menace sur le Royaume de Diamant Éternel

#7 CamDawg

CamDawg

    Dreaming of a red Xmas

  • Gibberling Poobah
  • 9298 posts
  • Gender:Not Telling

Posted 26 November 2017 - 10:03 AM

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, 26 November 2017 - 10:05 AM.

I came here with a simple dream: a dream of killing all humans. And this is how it must end? Who's the real seven billion ton robot monster here? Not I. Not... I.


#8 jastey

jastey
  • Gibberlings
  • 6964 posts
  • Gender:Female

Posted 26 November 2017 - 10:47 AM

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!



#9 Gwendolyne

Gwendolyne
  • Members
  • 156 posts
  • Gender:Male
  • Location:France

Posted 26 November 2017 - 11:01 AM

#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.

CARPE DIEM...



In progress : Menace sur le Royaume de Diamant Éternel

#10 jastey

jastey
  • Gibberlings
  • 6964 posts
  • Gender:Female

Posted 26 November 2017 - 11:34 AM

I'm so sorry - of course it's 221, I mistyped and then didn't recheck. :blush:





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users