share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 12953 7ea62261c481
parent 12952 eafaada79157
child 12954 50dd4f88daf4
equal deleted inserted replaced
12952:eafaada79157 12953:7ea62261c481
   128 local colorReflectorShield = 0xFFAE00FF
   128 local colorReflectorShield = 0xFFAE00FF
   129 local colorWeaponFilter =  0xA800FFFF
   129 local colorWeaponFilter =  0xA800FFFF
   130 
   130 
   131 local colorHealingStationParticle = 0x00FF00FF
   131 local colorHealingStationParticle = 0x00FF00FF
   132 
   132 
   133 local colorMessage = 0xFFBA00FF
   133 local colorMessageError = 0xFFFFFFFF
   134 
   134 
   135 -- Fake ammo types, for the overwritten weapons in Construction Mode
   135 -- Fake ammo types, for the overwritten weapons in Construction Mode
   136 local amCMStructurePlacer = amAirAttack
   136 local amCMStructurePlacer = amAirAttack
   137 local amCMCratePlacer = amNapalm
   137 local amCMCratePlacer = amNapalm
   138 local amCMObjectPlacer = amDrillStrike
   138 local amCMObjectPlacer = amDrillStrike
   637 
   637 
   638 
   638 
   639 	end
   639 	end
   640 
   640 
   641 	if ((teleportDestinationSuccessful == false) or (teleportOriginSuccessful == false)) then
   641 	if ((teleportDestinationSuccessful == false) or (teleportOriginSuccessful == false)) then
   642 		AddCaption(loc("Teleport Unsuccessful. Please teleport within a clan teleporter's sphere of influence."))
   642 		AddCaption(loc("Teleport unsuccessful. Please teleport within a clan teleporter's sphere of influence."), colorMessageError, capgrpMessage)
   643 		SetGearTarget(gear, GetX(CurrentHedgehog), GetY(CurrentHedgehog))
   643 		SetGearTarget(gear, GetX(CurrentHedgehog), GetY(CurrentHedgehog))
   644 	end
   644 	end
   645 
   645 
   646 end
   646 end
   647 
   647 
   952 -- essentially called when user clicks the mouse
   952 -- essentially called when user clicks the mouse
   953 -- with girders or an airattack
   953 -- with girders or an airattack
   954 function PlaceObject(x,y)
   954 function PlaceObject(x,y)
   955 
   955 
   956 	if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then
   956 	if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then
   957 		AddCaption(loc("You may only place 1 Extra Time crate per turn."),colorMessage,capgrpVolume)
   957 		AddCaption(loc("You may only place 1 Extra Time crate per turn."), colorMessageError, capgrpVolume)
   958 		PlaySound(sndDenied)
   958 		PlaySound(sndDenied)
   959 	elseif (conf_cratesPerRound ~= "inf" and clanCratesSpawned[GetHogClan(CurrentHedgehog)] >= conf_cratesPerRound) and ( (cat[cIndex] == "Health Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") or (cat[cIndex] == "Weapon Crate Placement Mode")  )  then
   959 	elseif (conf_cratesPerRound ~= "inf" and clanCratesSpawned[GetHogClan(CurrentHedgehog)] >= conf_cratesPerRound) and ( (cat[cIndex] == "Health Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") or (cat[cIndex] == "Weapon Crate Placement Mode")  )  then
   960 		AddCaption(string.format(loc("You may only place %d crates per round."), conf_cratesPerRound),colorMessage,capgrpVolume)
   960 		AddCaption(string.format(loc("You may only place %d crates per round."), conf_cratesPerRound), colorMessageError, capgrpVolume)
   961 		PlaySound(sndDenied)
   961 		PlaySound(sndDenied)
   962 	elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true)
   962 	elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true)
   963 	and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense)
   963 	and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense)
   964 	then
   964 	then
   965 		-- For checking if the actual placement succeeded
   965 		-- For checking if the actual placement succeeded
  1012 		end
  1012 		end
  1013 
  1013 
  1014 		if placed then
  1014 		if placed then
  1015 			clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
  1015 			clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
  1016 		else
  1016 		else
  1017 			AddCaption(loc("Invalid Placement"),colorMessage,capgrpVolume)
  1017 			AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume)
  1018 			PlaySound(sndDenied)
  1018 			PlaySound(sndDenied)
  1019 		end
  1019 		end
  1020 
  1020 
  1021 	else
  1021 	else
  1022 		if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then
  1022 		if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then
  1023 			AddCaption(loc("Invalid Placement"),colorMessage,capgrpVolume)
  1023 			AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume)
  1024 		else
  1024 		else
  1025 			AddCaption(loc("Insufficient Power"),colorMessage,capgrpVolume)
  1025 			AddCaption(loc("Insufficient Power"), colorMessageError, capgrpVolume)
  1026 		end
  1026 		end
  1027 		PlaySound(sndDenied)
  1027 		PlaySound(sndDenied)
  1028 	end
  1028 	end
  1029 
  1029 
  1030 end
  1030 end
  1136 			updateCost()
  1136 			updateCost()
  1137 			updated = true
  1137 			updated = true
  1138 		end
  1138 		end
  1139 
  1139 
  1140 		if updated then
  1140 		if updated then
  1141 			AddCaption(loc(cat[cIndex]), colorMessage, capgrpMessage)
  1141 			AddCaption(loc(cat[cIndex]), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage)
  1142 			showModeMessage()
  1142 			showModeMessage()
  1143 			wallsVisible = true
  1143 			wallsVisible = true
  1144 		else
  1144 		else
  1145 			wallsVisible = false
  1145 			wallsVisible = false
  1146 		end
  1146 		end
  1248 		placedExpense = atkArray[pIndex][2]
  1248 		placedExpense = atkArray[pIndex][2]
  1249 	elseif cat[cIndex] == "Utility Crate Placement Mode" then
  1249 	elseif cat[cIndex] == "Utility Crate Placement Mode" then
  1250 		placedExpense = utilArray[pIndex][2]
  1250 		placedExpense = utilArray[pIndex][2]
  1251 	end
  1251 	end
  1252 
  1252 
  1253 	AddCaption(string.format(loc("Cost: %d"), placedExpense), colorMessage, capgrpAmmostate)
  1253 	AddCaption(string.format(loc("Cost: %d"), placedExpense), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmostate)
  1254 
  1254 
  1255 end
  1255 end
  1256 
  1256 
  1257 -- Should be called when the index of the mode was changed by the player.
  1257 -- Should be called when the index of the mode was changed by the player.
  1258 -- E.g. new weapon crate contents or structure type
  1258 -- E.g. new weapon crate contents or structure type
  1295 	or cat[cIndex] == "Sticky Mine Placement Mode" then
  1295 	or cat[cIndex] == "Sticky Mine Placement Mode" then
  1296 		str = GetAmmoName(val)
  1296 		str = GetAmmoName(val)
  1297 	else
  1297 	else
  1298 		str = tostring(val)
  1298 		str = tostring(val)
  1299 	end
  1299 	end
  1300 	AddCaption(str, colorMessage, capgrpMessage2)
  1300 	AddCaption(str, GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2)
  1301 end
  1301 end
  1302 
  1302 
  1303 function rotateMode(pDir)
  1303 function rotateMode(pDir)
  1304 	curWep = GetCurAmmoType()
  1304 	curWep = GetCurAmmoType()
  1305 	local foundMatch = false
  1305 	local foundMatch = false