function Initialise()  
    StartTimer("BridgeKit", 500)
    MyPositions = 1

	lib_SetupMultiplayer()
	SendMessage("WormManager.Reinitialise")

   SetData("Weapon.Girder.MaxDistance", 10000)

	SetData("TurnTime", 60000)
	SetData("RoundTime", 1800000)

	StartFirstTurn()

    lock, scheme = EditContainer("GM.SchemeData")
    scheme.WeaponChance = 0
    scheme.UtilityChance = 0
    scheme.MysteryChance = 0
    scheme.HealthChance = 0
    CloseContainer(lock)

    lib_SpawnCrate("Boom1")
    lib_SpawnCrate("Boom2")
    lib_SpawnCrate("Boom3")
    lib_SpawnCrate("Boom4")

	SendMessage("GameLogic.ClearInventories")
	Index = 0
	InventoryName = lib_GetAllianceInventoryName(Index)
	while InventoryName ~= "" do
	 local Lock,Container = EditContainer(InventoryName)
	 Container.Dynamite = -1
	 Container.Girder = -1
	 Container.ChangeWorm = -1
         Container.FirePunch = 6
         Container.Prod = -1
         Container.PoisonArrow = 6
         Container.Grenade = 6
         Container.ClusterGrenade = 6
         Container.NinjaRope = -1
         Container.Parachute = -1
	 CloseContainer(Lock) 
	 Index = Index + 1
	 InventoryName = lib_GetAllianceInventoryName(Index)
        end

	local ContainerLock, Container = EditContainer("kWeaponDynamite")
	Container.OrientationOption = 1
	Container.DetonateMultiEffect = 0
	Container.StartsArmed = "false"
	Container.ArmingRadius = 20000
	Container.LifeTime = 6000
	Container.RumbleLight = 10
	Container.LaunchDelay = 80
	Container.RetreatTimeOverride = -1
	Container.PostLaunchDelay = 500
	Container.ArmingCourtesyTime = 100000
	Container.DisplayInFirstPerson = "true"
	 CloseContainer(ContainerLock)

	local ContainerLock, Container = EditContainer("kWeaponGrenade")
	Container.WormDamageMagnitude = 0
	 CloseContainer(ContainerLock)
	local ContainerLock, Container = EditContainer("kWeaponFirePunch")
	Container.WormDamageMagnitude = 0
	 CloseContainer(ContainerLock)
	local ContainerLock, Container = EditContainer("kWeaponClusterGrenade")
	Container.WormDamageMagnitude = 0
	 CloseContainer(ContainerLock)
	local ContainerLock, Container = EditContainer("kWeaponShotgun")
	Container.WormDamageMagnitude = 0
	 CloseContainer(ContainerLock)

	SetData("Ninja.NumShots", -1)

end


function Crate_Destroyed()
    local CrateIndex = GetData("Crate.Index")
    if CrateIndex == 1 then
      killred = 1
    end
    if CrateIndex == 2 then
      killblue = 1
    end
    if CrateIndex == 3 then
      killgreen = 1
    end
    if CrateIndex == 4 then
      killyellow = 1
    end
end


function Crate_Sunk()
    local CrateIndex = GetData("Crate.Index")
    if CrateIndex == 1 then
      killred = 1
    end
    if CrateIndex == 2 then
      killblue = 1
    end
    if CrateIndex == 3 then
      killgreen = 1
    end
    if CrateIndex == 4 then
      killyellow = 1
    end
end


function DoOncePerTurnFunctions()
    local WormIndex
    for WormIndex=0,15 do
        local worm = QueryContainer(lib_GetWormContainerName(WormIndex))
        if worm.TeamIndex == 0 and killred == 1 then
        SendIntMessage("WXWormManager.UnspawnWorm", WormIndex)
        end
        if worm.TeamIndex == 1 and killblue == 1 then
        SendIntMessage("WXWormManager.UnspawnWorm", WormIndex)
        end
        if worm.TeamIndex == 2 and killgreen == 1 then
        SendIntMessage("WXWormManager.UnspawnWorm", WormIndex)
        end
        if worm.TeamIndex == 3 and killyellow == 1 then
        SendIntMessage("WXWormManager.UnspawnWorm", WormIndex)
        end
    end
end


function BridgeKit()

   local Delaylock, Delay = EditContainer("Inventory0.WeaponDelays") 
   Delay.Girder = 0
   CloseContainer(Delaylock)

   local Delaylock, Delay = EditContainer("Inventory1.WeaponDelays") 
   Delay.Girder = 0
   CloseContainer(Delaylock)

   local Delaylock, Delay = EditContainer("Inventory2.WeaponDelays") 
   Delay.Girder = 0
   CloseContainer(Delaylock)

   local Delaylock, Delay = EditContainer("Inventory3.WeaponDelays") 
   Delay.Girder = 0
   CloseContainer(Delaylock)

   StartTimer("BridgeKit", 500)

end