Jump to content

Communication between mods


Recommended Posts

I have a whole bunch of patches (100ish?) for player homes that add some level of auto-undressing. My current mod changes outfits according to certain conditions. I would like to add something to the scripts for the former mod (easy to do as long as there are no properties involved in the patch esps) that would somehow communicate with my newer mod (if installed) to let it know that a particular actor had entered and more importantly, exited a trigger box.

 

This is the only approach I can think of for the problem that the auto-undressing for bathing patches inc. other authors' similar, will redress followers according to game engine rules, so if they enter an undressing trigger box with an outfit my new mod has fitted, then when they exit, they will redress with their 'best' kit and not necessarily what the player has chosen with my mod.

 

If my newer mod can know that an actor has left one of my trigger boxes from my patches then I can do stuff:)

 

The patches all have a supporting esp along with the patch esps, this is the same for all the patches and I have no issue with add properties to that. Obviously any communication will only affect my patches and my newer mod, for this reason my newer mod has a manual 'reset' hotkey/:)

 

diziet

Link to comment
Share on other sites

in an ideal world I would be able to put an ability on actors affected by my newer mod that would have as a condition the magic spell effect applied by my patches; then, when the magic effect is detected, the ability waits until the effect 'goes away' and acts.

But I won't know how to address the magic effect unless I add it as a property to all 100odd patch esps. I've been searching for a way to refer to it in a script and check for its existence on an actor without properties. I thought of GetFormFromFile() as part of getting the full formid; but as far as I can see, to check for an effect I need to use the editor id and not the formid.

 

 

diziet

Link to comment
Share on other sites

no idea is this working for you.. two script, one for a new quest, and one for the ability to check older effects

 

The formIds you need to pass into array, try using TesVEdit and open all required esp-files.

 

dzQuestpatchScript

 

Scriptname dzQuestpatchScript extends Quest
; https://forums.nexusmods.com/index.php?/topic/9220193-communication-between-mods/

  FormList PROPERTY dzList auto            ; empty formlist has to be created with CK, and assigned

  Bool bInit        ; [default=false]


; -- EVENTs -- 2

EVENT OnInit()
    bInit = TRUE
    RegisterForSingleUpdate(5.0)        ; run update event in 5 sec
ENDEVENT

EVENT OnUpdate()
    actor player = Game.GetPlayer()     ; get it once before loop starts

    WHILE !player.IsWalking()           ; we are waiting until player is walking
        IF ( bInit )
            Utility.Wait(1.0)           ; wait a second and try again
        ELSE
            RETURN    ; - STOP - this mod has been removed!
        ENDIF
    ENDWHILE

    myF_Init()
ENDEVENT


; -- FUNCTION --

;------------------
FUNCTION myF_Init()
;------------------
    string[] b = new String[4]      ; give place for 4 mods
    b[0] = "dzmod.esp"              ; an older mod file, which has one or more effects to check for
    b[1] = ""
    b[2] = ""
    b[3] = ""

    i = 0
    WHILE (i < b.Length)
        string s = b[i]
        IF (s == "")
        ELSE
            gotoState("Init" +i)
            myF_Add(s)                    ; add effect(s) to formlist
        ENDIF
        i = i + 1
    ENDWHILE
ENDFUNCTION


;-------------------------------------------
FUNCTION myF_AddForm2List(Int[] a, String s)  ; angepasst am 26.10.2020
;-------------------------------------------
    int i = 0
    WHILE (i < a.Length)
        form fm = Game.GetFormFromFile(s, a[i])
        IF ( fm )
            dzList.AddForm(fm)
        ENDIF
    ENDWHILE
ENDFUNCTION


;================================
state Init0
;==========
    FUNCTION myF_Add(String s)
        int[] a = new Int[3]
        a[0] = 0x00123456                ; the formid of the effect without "leading Byte"
        a[1] = 0x00
        a[2] = 0x00
    
        myF_AddForm2List(a, s)
    ENDFUNCTION
;=======
endState

;================================
state Init1
;==========
    FUNCTION myF_Add(String s)
        int[] a = new Int[3]
        a[0] = 0x00123456                ; the formid of the effect without "leading Byte"
        a[1] = 0x00
        a[2] = 0x00
        myF_AddForm2List(a, s)
    ENDFUNCTION
;=======
endState

;================================
state Init2
;==========
    FUNCTION myF_Add(String s)
        int[] a = new Int[3]
        a[0] = 0x00
        a[1] = 0x00
        a[2] = 0x00
        myF_AddForm2List(a, s)
    ENDFUNCTION
;=======
endState

;================================
state Init3
;==========
    FUNCTION myF_Add(String s)
        int[] a = new Int[3]
        a[0] = 0x00
        a[1] = 0x00
        a[2] = 0x00
        myF_AddForm2List(a, s)
    ENDFUNCTION
;=======
endState

 

 

 

dzEffectCheckerScript

 

Scriptname dzEffectCheckerScript extends ActiveMagicEffect
; https://forums.nexusmods.com/index.php?/topic/9220193-communication-between-mods/

  Quest PROPERTy myQuest auto        ; has to be assigned by CK with quest, that has attached "dzQuestpatchScript"


; -- EVENTs -- 2

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
    formList fml = (myQuest as dzQuestpatchScript).dzList

IF ( fml )
    int i = fml.GetSize()
    WHILE (i > 0)
        i = i - 1
        form fm = fml.GetAt(i)    
        IF akTarget.HasMagicEffect(fm as MagicEffect)        ; (fm as Keyword)
            Debug.Trace("Older/special effect was found.. " +fm+ " - " +self)    ; print message to "papyrus.0.log"
            ; do something here
        ENDIF
    ENDWHILE
ENDIF
ENDEVENT


EVENT OnEffectFinish(Actor akTarget, Actor akCaster)
    Debug.Trace("OnEffectFinish() - has been reached.. " +self)
ENDEVENT

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...