Scriptname SS2SupplyInjectionTemplate extends Quest { RENAME this script to something unique for your mod! Used for injecting, weapons, ammo, armor, and chems into the SS2 supply system as eligible donations. } ; ------------------------------------------ ; Consts ; ------------------------------------------ int iTimerID_QuestStartupComplete = 100 Const int iTimerID_RetryInjection = 101 Const ; Stages int iStage_Started = 1 Const int iStage_StartupComplete = 2 Const ; Component types copied from SS2's InjectionManager script int Property iComponentType_Ammo_Ballistic = 1 autoReadOnly int Property iComponentType_Ammo_Energy = 2 autoReadOnly int Property iComponentType_Ammo_Explosive = 3 autoReadOnly int Property iComponentType_Armor_Makeshift = 4 autoReadOnly int Property iComponentType_Armor_Standard = 5 autoReadOnly int Property iComponentType_Armor_Heavy = 6 autoReadOnly int Property iComponentType_Armor_Power = 7 autoReadOnly int Property iComponentType_Chems_AntiRadiation = 8 autoReadOnly int Property iComponentType_Chems_Cures = 9 autoReadOnly int Property iComponentType_Chems_Stimpaks = 10 autoReadOnly int Property iComponentType_Chems_Enhancement = 11 autoReadOnly int Property iComponentType_WeaponParts_Makeshift = 12 autoReadOnly int Property iComponentType_WeaponParts_Standard = 13 autoReadOnly int Property iComponentType_WeaponParts_Heavy = 14 autoReadOnly ; ------------------------------------------ ; Editor Properties ; ------------------------------------------ Group AutofillProperties Actor Property PlayerRef Auto Const Mandatory EndGroup Group Injection_Ammo Formlist Property BallisticAmmo Auto Const { If your mod has custom ammo you would consider Ballistic, add those records to a formlist and point this property to that formlist. } Formlist Property EnergyAmmo Auto Const { If your mod has custom ammo you would consider Energy, add those records to a formlist and point this property to that formlist. } Formlist Property ExplosiveAmmo Auto Const { If your mod has custom ammo you would consider Explosive, add those records to a formlist and point this property to that formlist. } EndGroup Group Injection_Armor Formlist Property MakeshiftArmor Auto Const { If your mod has custom armor/clothing you would consider Makeshift, add those ARMO records to a formlist and point this property to that formlist. } Formlist Property StandardArmor Auto Const { If your mod has custom armor/clothing you would consider Standard, add those ARMO records to a formlist and point this property to that formlist. } Formlist Property HeavyArmor Auto Const { If your mod has custom armor/clothing you would consider Heavy, add those ARMO records to a formlist and point this property to that formlist. } Formlist Property PowerArmor Auto Const { If your mod has custom Power Armor pieces, add those ARMO records to a formlist and point this property to that formlist. } EndGroup Group Injection_Chems Formlist Property AntiRadiationChems Auto Const { If your mod has custom chems related to dealing with radiation, add those records to a formlist and point this property to that formlist. } Formlist Property CureChems Auto Const { If your mod has custom chems related to recovering from diseases or other status effects, add those records to a formlist and point this property to that formlist. } Formlist Property StimChems Auto Const { If your mod has custom chems related to recovering health, add those records to a formlist and point this property to that formlist. } Formlist Property EnhancementChems Auto Const { If your mod has custom chems that give stat boosts or other enhancements, add those records to a formlist and point this property to that formlist. } EndGroup Group Injection_Weapons Formlist Property MakeshiftWeapons Auto Const { If your mod has custom weapons you would consider Makeshift, add those records to a formlist and point this property to that formlist. } Formlist Property StandardWeapons Auto Const { If your mod has custom weapons you would consider Standard, add those records to a formlist and point this property to that formlist. } Formlist Property HeavyWeapons Auto Const { If your mod has custom weapons you would consider Heavy, add those records to a formlist and point this property to that formlist. } EndGroup ; ------------------------------------------ ; Vars ; ------------------------------------------ Bool bSS2Detected = false ; ------------------------------------------ ; Events ; ------------------------------------------ Event OnQuestInit() RegisterForRemoteEvent(PlayerRef, "OnPlayerLoadGame") EndEvent Event Actor.OnPlayerLoadGame(Actor akSender) Startup() EndEvent Event OnStageSet(Int auiStageID, Int auiItemID) HandleStageChanges(auiStageID, auiItemID) EndEvent Event OnTimer(Int aiTimerID) if(aiTimerID == iTimerID_QuestStartupComplete) if(IsRunning()) TriggerInitialStartup() else StartTimer(2.0, iTimerID_QuestStartupComplete) endif elseif(aiTimerID == iTimerID_RetryInjection) TryToTriggerInjection() endif EndEvent ; ------------------------------------------ ; Functions ; ------------------------------------------ Function TriggerInitialStartup() Startup() SetStage(iStage_StartupComplete) EndFunction Function Startup() ; Note - since we're using formlists it is safe to double-inject TryToTriggerInjection() EndFunction Function HandleStageChanges(int auiStageID, int auiItemID) if(auiStageID == iStage_Started) if(IsRunning()) TriggerInitialStartup() else StartTimer(2.0, iTimerID_QuestStartupComplete) endif elseif(auiStageID == iStage_StartupComplete) TryToTriggerInjection() endif EndFunction Function TryToTriggerInjection() bSS2Detected = Game.IsPluginInstalled("SS2.esm") if( ! bSS2Detected) return endif Form SS2InjectionManagerQuest = Game.GetFormFromFile(0x0000EB0F, "SS2.esm") if(SS2InjectionManagerQuest != None) ScriptObject CastInjectionManager = SS2InjectionManagerQuest.CastAs("SimSettlementsV2:Quests:InjectionManager") if(CastInjectionManager != None) if(CastInjectionManager.IsRunning() && (SS2InjectionManagerQuest as Quest).GetStageDone(2)) Var[] kArgs = new Var[2] if(BallisticAmmo != None) kArgs[0] = BallisticAmmo kArgs[1] = iComponentType_Ammo_Ballistic CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif if(EnergyAmmo != None) kArgs[0] = EnergyAmmo kArgs[1] = iComponentType_Ammo_Energy CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif if(ExplosiveAmmo != None) kArgs[0] = ExplosiveAmmo kArgs[1] = iComponentType_Ammo_Explosive CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif if(MakeshiftArmor != None) kArgs[0] = MakeshiftArmor kArgs[1] = iComponentType_Armor_Makeshift CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif if(StandardArmor != None) kArgs[0] = StandardArmor kArgs[1] = iComponentType_Armor_Standard CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif if(HeavyArmor != None) kArgs[0] = HeavyArmor kArgs[1] = iComponentType_Armor_Heavy CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif if(PowerArmor != None) kArgs[0] = PowerArmor kArgs[1] = iComponentType_Armor_Power CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif if(MakeshiftWeapons != None) kArgs[0] = MakeshiftWeapons kArgs[1] = iComponentType_WeaponParts_Makeshift CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif if(StandardWeapons != None) kArgs[0] = StandardWeapons kArgs[1] = iComponentType_WeaponParts_Standard CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif if(HeavyWeapons != None) kArgs[0] = HeavyWeapons kArgs[1] = iComponentType_WeaponParts_Heavy CastInjectionManager.CallFunction("InjectPluginSupplyFormlist", kArgs) endif endif endif endif EndFunction