-- Bridge Build game for Innovation modification


function Initialise()


  StartTimer("Gir", -1)        
  ActRR = 0                     
  ActRast = 1                  
   StartedSuddenDeath = false   
   SetData("Weapon.Girder.MaxDistance", 50)




   SetupScheme()
    SetData("Worm.FallDamageRatio", 0) 
    SendMessage("GameLogic.SetNoFallDamage")
   lib_SetupMultiplayerWormsAndTeams()
   SendMessage("WormManager.Reinitialise")
    lib_SpawnCrate("crate")




   for NumberTeam = 0, 3 do
     local lock, inventory = EditContainer("Inventory.Alliance0" .. (NumberTeam)) 
       inventory.Airstrike = 0
       inventory.Shotgun = 0
       inventory.HomingMissile = 0
       inventory.Sheep = 0
       inventory.ConcreteDonkey = 0
       inventory.SuperSheep = 0
       inventory.BridgeKit = 0
       inventory.NinjaRope = 0
       inventory.Parachute = 0
       inventory.Jetpack = 1
       inventory.Starburst = 0
       inventory.Redbull = 0
       inventory.AlienAbduction = 0
       inventory.Fatkins = 0
       inventory.Scouser = 0
       inventory.NoMoreNails = 0
       inventory.SentryGun = 0
       inventory.SniperRifle = 0
       inventory.SuperAirstrike = 0
     CloseContainer(lock)
   end







   local scheme = QueryContainer("GM.SchemeData")
   if scheme.RoundTime == 0 then
      StartSuddenDeath() -- do this after worms are set up to readjust health
      local GameOver = GetData("FCS.GameOver")
      -- do no further processing if sudden death drew the game
      if GameOver ~= 0 then
         return 
      end
   end
   

   
   if scheme.TelepadsOn == true then
       SendMessage("GameLogic.PlaceTelepads")       
   end
   
   SetData("Camera.StartOfTurnCamera","Default")
   
   SetWormpotModes()
   

   WaitingForStartFirstTurn = false
   StartFirstTurn()
--   Activity = GetData("ObjectCount.Active")
--   if Activity == 0 then
--		WaitingForStartFirstTurn = false
--        StartFirstTurn()
--	else
--		WaitingForStartFirstTurn = true
--	end
end




function Crate_Collected()

    
  SendMessage("GameLogic.Draw")
  SetData("Text.TestComment",'You Win!!!')
  lib_Comment("Text.TestComment")

  local CurrentWorm = GetData("ActiveWormIndex")
  local wormdataname = lib_GetWormContainerName(CurrentWorm)

  local lock, worm = EditContainer(wormdataname) 
    TimIndx = worm.TeamIndex  
  CloseContainer(lock) 

  WinningTeam = TimIndx
  SendIntMessage("GameLogic.Win", WinningTeam)
        
end


function DoOncePerTurnFunctions()

end

function TurnEnded()
   local RoundTimeRemaining = GetData("RoundTimeRemaining")
   if RoundTimeRemaining == 0 then
      SendMessage("GameLogic.Draw")
SetData("Text.TestComment",'Nothing')
lib_Comment("Text.TestComment")


   else
      CheckOneTeamVictory()      
   end
end











