Skip to content

Instantly share code, notes, and snippets.

@ghosty141
Last active December 22, 2020 21:47
Show Gist options
  • Save ghosty141/d4ed179050fbaca481cbf89d2a1989df to your computer and use it in GitHub Desktop.
Save ghosty141/d4ed179050fbaca481cbf89d2a1989df to your computer and use it in GitHub Desktop.
class 'DogfightMod'
function DogfightMod:__init()
print("Initializing DogfightMod")
Events:Subscribe('Level:RegisterEntityResources', self, self.OnRegisterResources)
Events:Subscribe('Level:LoadResources', self, self.OnLoadResources)
self:RegisterEvents()
end
function DogfightMod:OnRegisterResources()
ResourceManager:AddRegistry(self.customRegistry, ResourceCompartment.ResourceCompartment_Game)
end
function DogfightMod:OnLoadResources()
self.customRegistry = RegistryContainer()
end
function DogfightMod:RegisterEvents()
Events:Subscribe('Partition:Loaded', function(partition)
for _, p_Instance in pairs(partition.instances) do
if p_Instance.typeInfo.name == "ReferenceObjectData" then
local s_Instance = ReferenceObjectData(p_Instance)
if s_Instance.instanceGuid == Guid("42FEAB7B-2F0E-4264-8C5A-3DE15D66546A") or s_Instance.instanceGuid == Guid("D94F16E5-6780-4AAE-BB03-9550681BC91A") then
local s_blueprint = SpatialPrefabBlueprint(s_Instance.blueprint)
if (s_blueprint.name == "Gameplay/Level_Setups/Dynamic_VehicleSpawners/DynamicSpawn_SU35") then
s_Instance:MakeWritable()
local bp = SpatialPrefabBlueprint(ResourceManager:SearchForDataContainer("Gameplay/Level_Setups/Dynamic_VehicleSpawners/DynamicSpawn_F18")):Clone(s_blueprint.instanceGuid)
self.customRegistry.blueprintRegistry:add(bp)
bp:MakeWritable()
local characterSpawnData = bp.objects[1]
characterSpawnData = CharacterSpawnReferenceObjectData(characterSpawnData):Clone(characterSpawnData.instanceGuid)
self.customRegistry.referenceObjectRegistry:add(characterSpawnData)
characterSpawnData:MakeWritable()
characterSpawnData.team = 2
bp.objects[1] = characterSpawnData
local vehicleSpawnData = bp.objects[4]
vehicleSpawnData = VehicleSpawnReferenceObjectData(vehicleSpawnData):Clone(vehicleSpawnData.instanceGuid)
self.customRegistry.referenceObjectRegistry:add(vehicleSpawnData)
vehicleSpawnData:MakeWritable()
vehicleSpawnData.team = 2
bp.objects[4] = vehicleSpawnData
s_Instance.blueprint = bp
end
end
end
end
end)
end
dfmod = DogfightMod()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment