maximumuseful Posted August 10, 2023 Share Posted August 10, 2023 I ned help to understnd this function fragments which i find in many existing SSE scripts, Found many function declarations like this: Function Fragment_3() [some code] Endfunction for example. But wher all this functions are called? Link to comment Share on other sites More sharing options...
scorrp10 Posted August 10, 2023 Share Posted August 10, 2023 Fragments are code set to run from specific places in various forms. The name of the script can usually tell you what type of form. I will give a couple examples. You create a quest in CK, called 'MyGreatQuest', and CK assigns it a FormID 03001C2F. In this quest, you define a few stages. I.e. stage 0 is when quest starts and initializes, stage 10 is when you have talked to quest giver, 20 is when you arrived at mentioned location. And in Quest Objectives, you define objective 10, which log entry is 'Travel to the Ominous Cave' and its target is an Ominous Cave map marker. But how do you make it so that after you talked to quest giver, that objective appears in your quest log (and quest marker on the map?) You need a fragment. In Quest stages, you select stage 10, you can see there is a window that says 'Papyrus Fragment'. You need to add some log entry text to make it active. In that window, you put in code: SetObjectiveDisplayed(10, true), hit Compile. Now if you click 'Advanced' tab, it will tell you that your quest now has a script: QF_MyGreatQuest_03001C2F, and function name is 'Fragment_0'. If you now go into Data\Source\Scripts, sure enough, there is QF_MyGreatQuest_03001C2F.psc file, and it has a 'Fragment_0' function containing the SetObjectiveDisplayed(10, true) line. Then you go into stage 20, and there you also add a fragment 'SetObjectiveCompleted(10, true)'. Hit Compile. Now since your quest already has a fragment script, it will just add the new fragment to that. If you look at QF_MyGreatQuest_03001C2F.psc now, you may see it has two functions: Fragment_0 and Fragment_1. But how do you get the quest to reach stage 10? You add some player dialogue with the questgiver, define various branches, and topics, and one of them is where you say "I will do this for you", and she says "Good luck". In Topic info window at the bottom, you can see that it can have fragments execute when NPC starts saying this topic, and when NPC finishes saying it. So in the 'End' box, you type code: GetOwningQuest().SetStage(10), hit Compile. You will see it has generated a script named something like 'TIF__030012D7'. Now a VERY VERY good practice is to rename it to something like TIF_MyGreatQuest_030012D7 from the Advanced tab. You look into Data\Source\Scripts, you see there is now a TIF_MyGreatQuest_030012D7.psc in there. Fragments can be attached this way: To Quest stages (execute when that stage is reached, QF_ files), Topic Infos (execute when this topic is said, start or end, TIF_), to AI packages (when package starts, ends or changes phase, AF_), to start and end of Quest Scenes (SF_), and potentially some others. Link to comment Share on other sites More sharing options...
maximumuseful Posted August 10, 2023 Author Share Posted August 10, 2023 Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts