DavaScript Posted September 23, 2020 Share Posted September 23, 2020 I'm new to Oblivion scripting, and I would like to play a custom sound when a player activates an object from another mod. Can someone demonstrate the code? Thanks in advance. Link to comment Share on other sites More sharing options...
mixxa77 Posted September 23, 2020 Share Posted September 23, 2020 (edited) The easiest way would probably be to just edit the script of the object from the other mod directly. Else you would probably need to get a "quest/global script" to constantly check the players interactions, which sounds unnecessarily complicated. Without further details (What mod and object) it is difficult to say or demonstrate. Edited September 23, 2020 by mixxa77 Link to comment Share on other sites More sharing options...
DavaScript Posted September 23, 2020 Author Share Posted September 23, 2020 (edited) The easiest way would probably be to just edit the script of the object from the other mod directly. Else you would probably need to get a "quest/global script" to constantly check the players interactions, which sounds unnecessarily complicated. Without further details (What mod and object) it is difficult to say or demonstrate. For this mod, how would I play a custom sound when the player activates a chair to sit. Would I need to modify the existing script, or can I make a standalone esp that will overwrite the original? https://www.nexusmods.com/oblivion/mods/44877?tab=description Edited September 23, 2020 by DavidSkx Link to comment Share on other sites More sharing options...
Oblivionaddicted Posted September 23, 2020 Share Posted September 23, 2020 With the author's authorization you can make his mod as a requirement for yours using the CS Extender or import the object in your mod with a different edior ID and in both situations mention create an object script for it. Link to comment Share on other sites More sharing options...
JustChill Posted February 10, 2021 Share Posted February 10, 2021 Hey, the most fancy way would be to use a script constellation like this: scn YourPatchModQuestScript Begin GameMode ref rModReference If IsModLoaded "ExactModName.ESP" Let rModReference := GetFormFromMod "ExactModName.ESP" "2A4B" endif End "2A4B" is the FormID without the first 2 numbers, as these come from "ExactModName.ESP".You can easily build up references to world objects or even base forms from other mods, without having to add them as masters into your own mod. Link to comment Share on other sites More sharing options...
Pellape Posted February 10, 2021 Share Posted February 10, 2021 (edited) @JustChill - if we had a kodo system here, I would have given you 3 kodos. :D it is so extremely brilliant. Maskar have done this a long time with MOO as one example where he peeks in every damn mod there is - almost. The book Looting spell mod also do it. I will do it later as well when I will use the card collecting mod as one example and implement it if the player are using it. It is so damn cool to do this as it will not limit us to do anything as everything is possible and we do not need anyone's permissions to do it either and we do not rely on if the mod really exist, only if it exist at all, then we do it. Those cards are so well made so I will implement a room for them later. The author will not have any power over it or anything to say about it as I do not touch his mod. My mod will only peek in his mod, that is it. :wink: Edited February 10, 2021 by Pellape Link to comment Share on other sites More sharing options...
JustChill Posted February 11, 2021 Share Posted February 11, 2021 Why thank you. :smile: I learned this from my old mentor, even though he didn't really use this system on his own as he said "It's a LOT work to write down every reference you want to use".And I agree. Especially if you want to include DLC content. ^^ I've updated a house mod for Fallout New Vegas which was origially updated by my old mentor to have a sorting system which also includes DLC items.He used as patch ESP, but in my update I made a patch script and simply use "BuildRef" and later "GetFormFromMod". "BuildRef" seems to be a New Vegas-exclusive function but it is far worse than "GetFormFromMod" as you need to convert the FormID into a decimal value. XDDDDWhich leaves room for issues during conversion, while with "GetFormFromMod", you can simply copy the FormID out of FNVEdit when having it running in the background. ^^ This will ensure that there are no typos, as building up an invalid reference isn't that good.Although its possible to catch that with "IsFormValid": scn YourPatchModQuestScript Begin GameMode ref rModReference If IsModLoaded "ExactModName.ESP" Let rModReference := GetFormFromMod "ExactModName.ESP" "2A4B" if IsFormValid rModReference ;=> Valid reference do some stuff with it here. endif endif End Well... I've a nicer example for Oblivion... ehm... Nehrim. ^^ scn TelNetEnhNMOpatchQuestScript ref TelNetEnhNMOruneREF float fQuestDelayTime Begin MenuMode if fQuestDelayTime else Let fQuestDelayTime := 0.1 endif if GetGameLoaded if IsModLoaded "Nehrim Magic Overhaul.esp" Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8CC" ;=> Mark if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport09Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport09.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8CD" ;=> Return if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport09Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport09.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8CF" ;=> Arcane Uni if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport03Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport03.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8D1" ;=> Cahbaet if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport04Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport04.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8D2" ;=> Erothin if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport02Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport02.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8D3" ;=> Giliad if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport03Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport03.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8D0" ;=> Mountain Abbey if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport04Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport04.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8D4" ;=> Ostian if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport06Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport06.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8D5" ;=> Sarnor if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport08Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport08.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8CE" ;=> Tirin Abbey if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport03Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport03.nif" TelNetEnhNMOruneREF endif Let TelNetEnhNMOruneREF := GetFormFromMod "Nehrim Magic Overhaul.esp" "8D6" ;=> Waverock if IsFormValid TelNetEnhNMOruneREF SetIconPath "BTNehrimTweaks\BTRuneTeleport07Icon.dds" TelNetEnhNMOruneREF SetModelPath "BTNehrimTweaks\Teleporter\BTRuneTeleport07.nif" TelNetEnhNMOruneREF endif endif endif EndHere, I simply switch the meshes and icon textures of some misc items to the ones from another mod, if that mod is available. :smile:Script is from that mod:https://www.nexusmods.com/nehrim/mods/31And it points to this mod:https://www.nexusmods.com/nehrim/mods/27 This works very well and doesn't require any patch ESPs. :smile: But be sure that "GetGameLoaded" is required as these changes will be forgotten by the game if you load a different savegame. Link to comment Share on other sites More sharing options...
Pellape Posted February 11, 2021 Share Posted February 11, 2021 (edited) I will remember that. Pekka, do not forget: if GetGameLoaded Lets see... What was we talking about? :wink: With those examples, this will be a piece in the cake to implement - I hope... :smile: Edited February 11, 2021 by Pellape Link to comment Share on other sites More sharing options...
JustChill Posted February 12, 2021 Share Posted February 12, 2021 Well, GetGameLoaded ensures that this script only fires once, after you load a game. ;)Which eases the engine a lot, therefore using "GetGameLoaded" and "GetGameRestarted" is recommended for things that only need to be done at these specific occasions. I am not totally sure which functions get recognized through savegames and which not. But I am for a few...Like here: if GetGameRestarted ;=> Will be saved in the memory but not into the savegame. AddToLeveledList BuecherHaushalt NMOBuchNehrimMagieArkan 1 1 AddToLeveledList BuecherHaushalt NMOBuchNehrimMagieIllusion 1 1 AddToLeveledList BuecherHaushalt NMOBuchNehrimMagieVeranderung 1 1 AddToLeveledList BuecherHaushalt NMOBuchNehrimMagieWiederherstellung 1 1 AddToLeveledList BuecherHaushalt NMOBuchNehrimMagieZerstorung 1 1 AddToLeveledList BuchRandom NMOBuchNehrimMagieArkan 1 1 AddToLeveledList BuchRandom NMOBuchNehrimMagieIllusion 1 1 AddToLeveledList BuchRandom NMOBuchNehrimMagieVeranderung 1 1 AddToLeveledList BuchRandom NMOBuchNehrimMagieWiederherstellung 1 1 AddToLeveledList BuchRandom NMOBuchNehrimMagieZerstorung 1 1 endif This block just adds these books to the respective spawn lists upon restarting.They stay in the spawn lists even through loading a savegame.So it's not necessary to do that in GetGameLoaded and actually... might be potentially bad.As with GetGameLoaded you may add the same item multiple times to the same list. oO Even though I am not sure if AddToLeveledList works that way, as there is no such warning on the respective wiki page. Yet I still rather would recommend to use it in that way. ;) Link to comment Share on other sites More sharing options...
qwertyasdfgh Posted February 12, 2021 Share Posted February 12, 2021 GetGameLoaded returns true once after a savegame is loaded, so it's usually used to control any variables that are stored in the save game. GetGameRestarted only returns true once per game session, meaning that you'll have to exit to desktop before it runs again. It is important to note that many Obse functions work per game session and not per save game, so GetGameRestarted is preferable in these situations. Another thing is that GetGameLoaded condition can be replaced with PostLoadGame event handler, which I personally prefer to use in all my mods. Link to comment Share on other sites More sharing options...
Recommended Posts