share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 12091 db5e12d623cc
parent 11982 6f4b96669f9d
child 12092 9fe7eb1f7df2
equal deleted inserted replaced
12090:fac17dd2bc2f 12091:db5e12d623cc
  1113 		AddCaption(loc("You may only spawn 5 crates per turn."),0xffba00ff,capgrpVolume)
  1113 		AddCaption(loc("You may only spawn 5 crates per turn."),0xffba00ff,capgrpVolume)
  1114 		PlaySound(sndDenied)
  1114 		PlaySound(sndDenied)
  1115 	elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true)
  1115 	elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true)
  1116 	and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense)
  1116 	and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense)
  1117 	then
  1117 	then
  1118 
  1118 		-- For checking if the actual placement succeeded
  1119 
  1119 		local placed = false
  1120 
       
  1121 		if cat[cIndex] == "Girder Placement Mode" then
  1120 		if cat[cIndex] == "Girder Placement Mode" then
  1122 			PlaceGirder(x, y, CGR)
  1121 			placed = PlaceGirder(x, y, CGR)
  1123 			placedSpec[placedCount] = CGR
  1122 			placedSpec[placedCount] = CGR
  1124 		elseif cat[cIndex] == "Rubber Placement Mode" then
  1123 		elseif cat[cIndex] == "Rubber Placement Mode" then
  1125 			PlaceSprite(x,y, sprAmRubber, CGR, nil, nil, nil, nil, lfBouncy)
  1124 			placed = PlaceRubber(x, y, CGR)
  1126 			placedSpec[placedCount] = CGR
  1125 			placedSpec[placedCount] = CGR
  1127 		elseif cat[cIndex] == "Health Crate Placement Mode" then
  1126 		elseif cat[cIndex] == "Health Crate Placement Mode" then
  1128 			gear = SpawnHealthCrate(x,y)
  1127 			gear = SpawnHealthCrate(x,y)
  1129 			SetHealth(gear, pMode[pIndex])
  1128 			if gear ~= nil then
  1130 			setGearValue(gear,"caseType","med")
  1129 				placed = true
  1131 			clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
  1130 				SetHealth(gear, pMode[pIndex])
       
  1131 				setGearValue(gear,"caseType","med")
       
  1132 				clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
       
  1133 			end
  1132 		elseif cat[cIndex] == "Weapon Crate Placement Mode" then
  1134 		elseif cat[cIndex] == "Weapon Crate Placement Mode" then
  1133 			gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1])
  1135 			gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1])
  1134 			placedSpec[placedCount] = atkArray[pIndex][2]
  1136 			if gear ~= nil then
  1135 			setGearValue(gear,"caseType","ammo")
  1137 				placed = true
  1136 			setGearValue(gear,"contents",atkArray[pIndex][2])
  1138 				placedSpec[placedCount] = atkArray[pIndex][2]
  1137 			clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
  1139 				setGearValue(gear,"caseType","ammo")
       
  1140 				setGearValue(gear,"contents",atkArray[pIndex][2])
       
  1141 				clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
       
  1142 			end
  1138 		elseif cat[cIndex] == "Utility Crate Placement Mode" then
  1143 		elseif cat[cIndex] == "Utility Crate Placement Mode" then
  1139 			gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1])
  1144 			gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1])
  1140 			placedSpec[placedCount] = utilArray[pIndex][2]
  1145 			if gear ~= nil then
  1141 			setGearValue(gear,"caseType","util")
  1146 				placed = true
  1142 			setGearValue(gear,"contents",utilArray[pIndex][2])
  1147 				placedSpec[placedCount] = utilArray[pIndex][2]
  1143 			if utilArray[pIndex][1] == amExtraTime then
  1148 				setGearValue(gear,"caseType","util")
  1144 				clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = true
  1149 				setGearValue(gear,"contents",utilArray[pIndex][2])
  1145 			end
  1150 				if utilArray[pIndex][1] == amExtraTime then
  1146 			clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
  1151 					clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = true
       
  1152 				end
       
  1153 				clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
       
  1154 			end
  1147 		elseif cat[cIndex] == "Barrel Placement Mode" then
  1155 		elseif cat[cIndex] == "Barrel Placement Mode" then
  1148 			gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0)
  1156 			gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0)
  1149 			SetHealth(gear, pMode[pIndex])
  1157 			if gear ~= nil then
       
  1158 				placed = true
       
  1159 				SetHealth(gear, pMode[pIndex])
       
  1160 			end
  1150 		elseif cat[cIndex] == "Mine Placement Mode" then
  1161 		elseif cat[cIndex] == "Mine Placement Mode" then
  1151 			gear = AddGear(x, y, gtMine, 0, 0, 0, 0)
  1162 			gear = AddGear(x, y, gtMine, 0, 0, 0, 0)
  1152 			SetTimer(gear, pMode[pIndex])
  1163 			if gear ~= nil then
       
  1164 				placed = true
       
  1165 				SetTimer(gear, pMode[pIndex])
       
  1166 			end
  1153 		elseif cat[cIndex] == "Sticky Mine Placement Mode" then
  1167 		elseif cat[cIndex] == "Sticky Mine Placement Mode" then
  1154 			gear = AddGear(x, y, gtSMine, 0, 0, 0, 0)
  1168 			gear = AddGear(x, y, gtSMine, 0, 0, 0, 0)
  1155 
  1169 			placed = gear ~= nil
  1156 		elseif cat[cIndex] == "Structure Placement Mode" then
  1170 		elseif cat[cIndex] == "Structure Placement Mode" then
  1157 
       
  1158 			AddStruc(x,y, pMode[pIndex],GetHogClan(CurrentHedgehog))
  1171 			AddStruc(x,y, pMode[pIndex],GetHogClan(CurrentHedgehog))
  1159 
  1172 			placed = true
  1160 		end
  1173 		end
  1161 
  1174 
  1162 		clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
  1175 		if placed then
  1163 		placedCount = placedCount + 1
  1176 			clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
       
  1177 			placedCount = placedCount + 1
       
  1178 		else
       
  1179 			AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
       
  1180 			PlaySound(sndDenied)
       
  1181 		end
  1164 
  1182 
  1165 	else
  1183 	else
  1166 	    if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then
  1184 	    if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then
  1167             AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
  1185             AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
  1168         else
  1186         else