cerebii Posted December 2, 2021 Share Posted December 2, 2021 Hey y'all, quick CK question; I'm using an Xmarker to spawn in a weapon using placeatme, but I'd like to disable havok on the spawned weapon. I've tried using the "defaultdisablehavokonload" script on the Xmarker but that doesn't seem to work for the object it spawns. Does anyone know how to do this? Many thanks! Link to comment Share on other sites More sharing options...
niston Posted December 6, 2021 Share Posted December 6, 2021 Adding the script to the marker will disable havok on the marker. Which is not what you want. After the PlaceAtMe(), try setting motiontype of the weapon to Motion_Keyframed instead: https://www.creationkit.com/fallout4/index.php?title=SetMotionType_-_ObjectReference Link to comment Share on other sites More sharing options...
cerebii Posted December 6, 2021 Author Share Posted December 6, 2021 Adding the script to the marker will disable havok on the marker. Which is not what you want. After the PlaceAtMe(), try setting motiontype of the weapon to Motion_Keyframed instead: https://www.creationkit.com/fallout4/index.php?title=SetMotionType_-_ObjectReferenceHi, thanks for the reply. First off, I'm a complete noob with CK and Papyrus, so if I misunderstand anything anyone says that's why lol The weapon in question is spawned with the "CustomItemQuestScript" script, so I don't think it technically exists as an item until the script spawns it in? Do you know of another way I could get a custom legendary item in a way where I could directly place it as an object in the world? (and therefore be able to edit the motiontype) Thanks again! Link to comment Share on other sites More sharing options...
SKKmods Posted December 6, 2021 Share Posted December 6, 2021 Several of the many possible solutions: a. Copy the core CustomItemQuestScript.SpawnCustomItem function into your own script add item.setMotionType(Motion_Keyframed, TRUE) at the end. If you dont have a script, replace your xmarker with a Default Activator and attach an OnLoad script to that. b. PlaceAtMe a disabled container, use that as the CustomItemQuestScript.ReferenceToSpawnIn, poll for the container not being empty, DropFirstObject from the container, setMotionType(Motion_Keyframed, TRUE) on the drop reference then delete container. Messy. c. something else. Link to comment Share on other sites More sharing options...
cerebii Posted December 6, 2021 Author Share Posted December 6, 2021 Several of the many possible solutions: a. Copy the core CustomItemQuestScript.SpawnCustomItem function into your own script add item.setMotionType(Motion_Keyframed, TRUE) at the end. If you dont have a script, replace your xmarker with a Default Activator and attach an OnLoad script to that. b. PlaceAtMe a disabled container, use that as the CustomItemQuestScript.ReferenceToSpawnIn, poll for the container not being empty, DropFirstObject from the container, setMotionType(Motion_Keyframed, TRUE) on the drop reference then delete container. Messy. c. something else.Ah, hello SKK, thanks for the help once again. Option a) seems promising, I assume it would look something like this: Scriptname CustomItemQuestScript extends Quest Struct ItemDatum String ID {Indentifier - used to help identify items in array. Not otherwise used.} int QuestStage {Spawn item at this quest stage} LeveledItem LeveledListToSpawnFrom {List to spawn from} Formlist ModsFormlist {List of mods to install on item ****IMPORTANT NOTE*** THIS BYPASSES ALL NORMAL ITEM INSTANTIATION RULES} ObjectReference ReferenceToSpawnIn {Where to spawn item} ReferenceAlias AliasToSpawnIn {Where to spawn in, overrides ReferenceToSpawnIn} bool PlaceAtMeInstead {Place AT instead of IN ReferenceToSpawnIn} ReferenceAlias AliasToForceItemInto {if set, item will be forced into this alias} EndStruct ItemDatum[] Property ItemData const auto Event OnStageSet(int auiStageID, int auiItemID) int foundIndex = ItemData.findStruct("QuestStage", auiStageID) ItemDatum FoundDatum if foundIndex >= 0 FoundDatum = ItemData[foundIndex] endif if FoundDatum && auiItemID == 0 ObjectReference spawnInRef if FoundDatum.AliasToSpawnIn spawnInRef = FoundDatum.AliasToSpawnIn.GetReference() elseif FoundDatum.ReferenceToSpawnIn spawnInRef = FoundDatum.ReferenceToSpawnIn else Game.Warning(Self + "OnStageSet() didn't find ReferenceToSpawnIn, using Game.GetPlayer() instead.") spawnInRef = Game.GetPlayer() endif SpawnCustomItem(FoundDatum.LeveledListToSpawnFrom, FoundDatum.ModsFormlist, spawnInRef, FoundDatum.PlaceAtMeInstead, FoundDatum.AliasToForceItemInto) endif EndEvent form Function SpawnCustomItem(LeveledItem LeveledListToSpawnFrom, Formlist ModsFormlist, ObjectReference ReferenceToSpawnIn, bool PlaceAtMeInstead = false, ReferenceAlias AliasToForceItemInto = none) global ObjectReference item = ReferenceToSpawnIn.PlaceAtMe(LeveledListToSpawnFrom, aiCount = 1, abForcePersist = false, abInitiallyDisabled = true, abDeleteWhenAble = false) debug.trace("SpawnCustomItem() creating item " + item) int i = 0 while (i < ModsFormlist.GetSize()) ObjectMod omod = ModsFormlist.GetAt(i) as ObjectMod bool success = item.AttachMod(omod) if success == false Game.Error("FAILED TO ATTACH " + omod + " to "+ item) else debug.trace("SpawnCustomItem() attaching " + omod + " to " + item) endif i += 1 endwhile item.enable() if AliasToForceItemInto AliasToForceItemInto.ForceRefTo(item) endif if PlaceAtMeInstead debug.trace("SpawnCustomItem() placed item: " + item + " at " + ReferenceToSpawnIn) else debug.trace("SpawnCustomItem() adding item: " + item + " to " + ReferenceToSpawnIn) ReferenceToSpawnIn.additem(item) endif item.setMotionType(Motion_Keyframed, TRUE) RETURN item EndFunction ? Link to comment Share on other sites More sharing options...
SKKmods Posted December 6, 2021 Share Posted December 6, 2021 Rather than copying and pasting long scripts which is painful to look at, start with simple design questions like ... (a) what are you attaching the script to and (b) when should the script activate ? Link to comment Share on other sites More sharing options...
cerebii Posted December 6, 2021 Author Share Posted December 6, 2021 Rather than copying and pasting long scripts which is painful to look at, start with simple design questions like ... (a) what are you attaching the script to and (b) when should the script activate ?Edit: Seems like I have to use this?: Function SetMotionType(int aiMotionType, bool abAllowActivate = true) native Me and my smooth brain are having a hard time lol Link to comment Share on other sites More sharing options...
SKKmods Posted December 6, 2021 Share Posted December 6, 2021 Stop with the code, you are not there yet. Are you attaching the script to a quest or an object ? Can the item be created at any time, or are there some trigger conditions ? Link to comment Share on other sites More sharing options...
cerebii Posted December 6, 2021 Author Share Posted December 6, 2021 Stop with the code, you are not there yet. Are you attaching the script to a quest or an object ? Can the item be created at any time, or are there some trigger conditions ?It's just the default CustomItemQuestScript script, attached to a quest. Spawns the item on game load-in (when the quest starts, I think). I wouldn't think it would be a good use of time to completely re-write the script if it works ok? Just need to work out how that Function fits in.... Link to comment Share on other sites More sharing options...
SKKmods Posted December 6, 2021 Share Posted December 6, 2021 Rather than hacking base game scripts which is insane, what I do is: 1. Copy Default Activator to a new form, say MyCustomItemActivator. 2. Attach a new script MyCustomItemActivatorScript. 3. Place MyCustomItemActivator where I want the thing. Scriptname MyCustomItemActivatorScript extends ObjectReference LeveledItem Property LeveledListToSpawnFrom Auto Formlist Property ModsFormlist Auto Event OnLoad() ;Dont trust OnInit to spawn stuff outside the loaded area ObjectReference item = Self.PlaceAtMe(LeveledListToSpawnFrom, aiCount = 1, abForcePersist = false, abInitiallyDisabled = true, abDeleteWhenAble = false) int i = 0 while (i < ModsFormlist.GetSize()) ObjectMod omod = ModsFormlist.GetAt(i) as ObjectMod bool success = item.AttachMod(omod) i += 1 endwhile item.setMotionType(Motion_Keyframed, TRUE) item.enable() LeveledListToSpawnFrom = None ;clean as you go ModsFormlist = None ;clean as you go Self.Disable() ;stop reruns Self.Delete() ;stop reruns EndEvent But, you do you. Link to comment Share on other sites More sharing options...
Recommended Posts