share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
changeset 15488 04b63bcdb2ab
parent 15485 91c972f126b7
child 15489 3c0a3c824c49
equal deleted inserted replaced
15487:91f0c5ec37b5 15488:04b63bcdb2ab
    52 local currCount = 0
    52 local currCount = 0
    53 
    53 
    54 local specialPointsX = {}
    54 local specialPointsX = {}
    55 local specialPointsY = {}
    55 local specialPointsY = {}
    56 local specialPointsCount = 0
    56 local specialPointsCount = 0
       
    57 
       
    58 local landObjectPoints = {}
       
    59 local landObjects = {}
    57 
    60 
    58 local TeamRope = false
    61 local TeamRope = false
    59 
    62 
    60 local waypointCursor = false
    63 local waypointCursor = false
    61 local waypointPreview = nil
    64 local waypointPreview = nil
   654 		SendRankingStatsOff()
   657 		SendRankingStatsOff()
   655         	SendHealthStatsOff()
   658         	SendHealthStatsOff()
   656 		SendAchievementsStatsOff()
   659 		SendAchievementsStatsOff()
   657 	end
   660 	end
   658 
   661 
       
   662         -- Keep track of land objects that got placed by the scheme (mines, air mines, barrels)
       
   663         for id, _ in pairs(landObjects) do
       
   664                 table.insert(landObjectPoints, { type = GetGearType(id), x = GetX(id), y = GetY(id) })
       
   665         end
       
   666 
   659         SetSoundMask(sndIncoming, true)
   667         SetSoundMask(sndIncoming, true)
   660         SetSoundMask(sndMissed, true)
   668         SetSoundMask(sndMissed, true)
   661 
   669 
   662         roundN = 0
   670         roundN = 0
   663         lastRound = TotalRounds
   671         lastRound = TotalRounds
   845                                 SkipTurn()
   853                                 SkipTurn()
   846                         end
   854                         end
   847                 end
   855                 end
   848         end
   856         end
   849 
   857 
   850         -- Set the waypoints to unactive on new round
       
   851         if gameBegun and not gameOver then
   858         if gameBegun and not gameOver then
       
   859 
       
   860                 -- Reset land objects so each player starts with same racing conditions
       
   861                 for id,_ in pairs(landObjects) do
       
   862                         DeleteGear(id)
       
   863                 end
       
   864                 for i=1, #landObjectPoints do
       
   865                         AddGear(landObjectPoints[i].x, landObjectPoints[i].y, landObjectPoints[i].type, 0, 0, 0, 0)
       
   866                 end
       
   867 
       
   868                 -- Set the waypoints to unactive
   852                 for i = 0,(wpCount-1) do
   869                 for i = 0,(wpCount-1) do
   853                         wpActive[i] = false
   870                         wpActive[i] = false
   854                         wpCol[i] = waypointColour
   871                         wpCol[i] = waypointColour
   855                         local flashing, minO, maxO
   872                         local flashing, minO, maxO
   856                         if i == 0 then
   873                         if i == 0 then
  1034         end
  1051         end
  1035 
  1052 
  1036 end
  1053 end
  1037 
  1054 
  1038 function onGearAdd(gear)
  1055 function onGearAdd(gear)
  1039 
  1056         local gt = GetGearType(gear)
  1040         if GetGearType(gear) == gtHedgehog then
  1057         if gt == gtHedgehog then
  1041                 hhs[numhhs] = gear
  1058                 hhs[numhhs] = gear
  1042                 numhhs = numhhs + 1
  1059                 numhhs = numhhs + 1
  1043                 SetEffect(gear, heResurrectable, 1)
  1060                 SetEffect(gear, heResurrectable, 1)
  1044         elseif GetGearType(gear) == gtAirAttack then
  1061         elseif gt == gtAirAttack then
  1045                 cGear = gear
  1062                 cGear = gear
  1046 		local x,y = GetGearPosition(cGear)
  1063 		local x,y = GetGearPosition(cGear)
  1047         	SetGearPosition(cGear, 10000, y)
  1064         	SetGearPosition(cGear, 10000, y)
  1048         elseif (not gameBegun) and GetGearType(gear) == gtAirBomb then
  1065         elseif (gt == gtMine or gt == gtAirMine or gt == gtExplosives) then
       
  1066                 landObjects[gear] = true
       
  1067         elseif (not gameBegun) and gt == gtAirBomb then
  1049 		DeleteGear(gear)
  1068 		DeleteGear(gear)
  1050         elseif GetGearType(gear) == gtRope and TeamRope then
  1069         elseif gt == gtRope and TeamRope then
  1051             SetTag(gear,1)
  1070             SetTag(gear,1)
  1052             SetGearValues(gear,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,GetClanColor(GetHogClan(CurrentHedgehog)))
  1071             SetGearValues(gear,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,GetClanColor(GetHogClan(CurrentHedgehog)))
  1053         end
  1072         end
  1054 end
  1073 end
  1055 
  1074 
  1056 function onGearDelete(gear)
  1075 function onGearDelete(gear)
  1057 
  1076 
  1058         if GetGearType(gear) == gtAirAttack then
  1077         if GetGearType(gear) == gtAirAttack then
  1059                 cGear = nil
  1078                 cGear = nil
       
  1079         elseif landObjects[gear] == true then
       
  1080                 landObjects[gear] = nil
  1060         elseif gear == cameraGear then
  1081         elseif gear == cameraGear then
  1061                 cameraGear = nil
  1082                 cameraGear = nil
  1062         end
  1083         end
  1063 
  1084 
  1064 end
  1085 end