1005 -- essentially called when user clicks the mouse |
1007 -- essentially called when user clicks the mouse |
1006 -- with girders or an airattack |
1008 -- with girders or an airattack |
1007 function PlaceObject(x,y) |
1009 function PlaceObject(x,y) |
1008 |
1010 |
1009 if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then |
1011 if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then |
1010 AddCaption(loc("You may only place 1 Extra Time crate per turn."), colorMessageError, capgrpVolume) |
1012 if IsHogLocal(CurrentHedgehog) then |
|
1013 AddCaption(loc("You may only place 1 Extra Time crate per turn."), colorMessageError, capgrpVolume) |
|
1014 end |
1011 PlaySound(sndDenied) |
1015 PlaySound(sndDenied) |
1012 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 |
1016 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 |
1013 AddCaption(string.format(loc("You may only place %d crates per round."), conf_cratesPerRound), colorMessageError, capgrpVolume) |
1017 if IsHogLocal(CurrentHedgehog) then |
|
1018 AddCaption(string.format(loc("You may only place %d crates per round."), conf_cratesPerRound), colorMessageError, capgrpVolume) |
|
1019 end |
1014 PlaySound(sndDenied) |
1020 PlaySound(sndDenied) |
1015 elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true) |
1021 elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true) |
1016 and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) |
1022 and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) |
1017 then |
1023 then |
1018 -- For checking if the actual placement succeeded |
1024 -- For checking if the actual placement succeeded |
1067 if placed then |
1073 if placed then |
1068 -- Pay the price |
1074 -- Pay the price |
1069 clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense |
1075 clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense |
1070 DrawClanPowerTag() |
1076 DrawClanPowerTag() |
1071 else |
1077 else |
1072 AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume) |
1078 if IsHogLocal(CurrentHedgehog) then |
|
1079 AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume) |
|
1080 end |
1073 PlaySound(sndDenied) |
1081 PlaySound(sndDenied) |
1074 end |
1082 end |
1075 |
1083 |
1076 else |
1084 else |
1077 if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then |
1085 if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then |
1078 AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume) |
1086 if IsHogLocal(CurrentHedgehog) then |
|
1087 AddCaption(loc("Invalid Placement"), colorMessageError, capgrpVolume) |
|
1088 end |
1079 else |
1089 else |
1080 AddCaption(loc("Insufficient Power"), colorMessageError, capgrpVolume) |
1090 if IsHogLocal(CurrentHedgehog) then |
|
1091 AddCaption(loc("Insufficient Power"), colorMessageError, capgrpVolume) |
|
1092 end |
1081 end |
1093 end |
1082 PlaySound(sndDenied) |
1094 PlaySound(sndDenied) |
1083 end |
1095 end |
1084 |
1096 |
1085 end |
1097 end |
1103 pIndex = currentGirderRotation |
1114 pIndex = currentGirderRotation |
1104 pMode = {amGirder} |
1115 pMode = {amGirder} |
1105 elseif cat[cIndex] == "Rubber Placement Mode" then |
1116 elseif cat[cIndex] == "Rubber Placement Mode" then |
1106 pIndex = currentGirderRotation |
1117 pIndex = currentGirderRotation |
1107 pMode = {amRubber} |
1118 pMode = {amRubber} |
1108 placedExpense = 3 |
|
1109 elseif cat[cIndex] == "Barrel Placement Mode" then |
1119 elseif cat[cIndex] == "Barrel Placement Mode" then |
1110 pMode = {60} |
1120 pMode = {60} |
1111 placedExpense = 10 |
|
1112 teamLObjectMode[team] = cat[cIndex] |
1121 teamLObjectMode[team] = cat[cIndex] |
1113 elseif cat[cIndex] == "Health Crate Placement Mode" then |
1122 elseif cat[cIndex] == "Health Crate Placement Mode" then |
1114 pMode = {HealthCaseAmount} |
1123 pMode = {HealthCaseAmount} |
1115 placedExpense = 5 |
|
1116 teamLCrateMode[team] = cat[cIndex] |
1124 teamLCrateMode[team] = cat[cIndex] |
1117 elseif cat[cIndex] == "Weapon Crate Placement Mode" then |
1125 elseif cat[cIndex] == "Weapon Crate Placement Mode" then |
1118 for i = 1, #atkArray do |
1126 for i = 1, #atkArray do |
1119 pMode[i] = atkArray[i][1] |
1127 pMode[i] = atkArray[i][1] |
1120 end |
1128 end |
1121 placedExpense = atkArray[pIndex][2] |
|
1122 teamLCrateMode[team] = cat[cIndex] |
1129 teamLCrateMode[team] = cat[cIndex] |
1123 pIndex = teamLWeapIndex[team] |
1130 pIndex = teamLWeapIndex[team] |
1124 elseif cat[cIndex] == "Utility Crate Placement Mode" then |
1131 elseif cat[cIndex] == "Utility Crate Placement Mode" then |
1125 for i = 1, #utilArray do |
1132 for i = 1, #utilArray do |
1126 pMode[i] = utilArray[i][1] |
1133 pMode[i] = utilArray[i][1] |
1127 end |
1134 end |
1128 placedExpense = utilArray[pIndex][2] |
|
1129 teamLCrateMode[team] = cat[cIndex] |
1135 teamLCrateMode[team] = cat[cIndex] |
1130 pIndex = teamLUtilIndex[team] |
1136 pIndex = teamLUtilIndex[team] |
1131 elseif cat[cIndex] == "Mine Placement Mode" then |
1137 elseif cat[cIndex] == "Mine Placement Mode" then |
1132 pMode = {0,1000,2000,3000,4000,5000} |
1138 pMode = {0,1000,2000,3000,4000,5000} |
1133 placedExpense = 15 |
|
1134 teamLObjectMode[team] = cat[cIndex] |
1139 teamLObjectMode[team] = cat[cIndex] |
1135 pIndex = teamLMineIndex[team] |
1140 pIndex = teamLMineIndex[team] |
1136 elseif cat[cIndex] == "Sticky Mine Placement Mode" then |
1141 elseif cat[cIndex] == "Sticky Mine Placement Mode" then |
1137 pMode = {amSMine} |
1142 pMode = {amSMine} |
1138 placedExpense = 20 |
|
1139 teamLObjectMode[team] = cat[cIndex] |
1143 teamLObjectMode[team] = cat[cIndex] |
1140 elseif cat[cIndex] == "Structure Placement Mode" then |
1144 elseif cat[cIndex] == "Structure Placement Mode" then |
1141 pMode = { |
1145 pMode = { |
1142 loc_noop("Support Station"), |
1146 loc_noop("Support Station"), |
1143 loc_noop("Construction Station"), |
1147 loc_noop("Construction Station"), |
1231 dSprite = sprUtility |
1236 dSprite = sprUtility |
1232 else |
1237 else |
1233 dSprite = sprArrow |
1238 dSprite = sprArrow |
1234 end |
1239 end |
1235 |
1240 |
|
1241 -- Display the gear to be spawned under the cursor |
1236 if not cursorIcon then |
1242 if not cursorIcon then |
1237 cursorIcon = AddVisualGear(CursorX, CursorY, vgtStraightShot, dSprite, false, 3) |
1243 cursorIcon = AddVisualGear(CursorX, CursorY, vgtStraightShot, dSprite, true, 3) |
1238 end |
1244 end |
1239 SetVisualGearValues(cursorIcon, CursorX, CursorY, 0, 0, 0, dFrame, 1000, dSprite, 1000) |
1245 SetVisualGearValues(cursorIcon, CursorX, CursorY, 0, 0, 0, dFrame, 1000, dSprite, 1000) |
1240 |
1246 |
1241 -- Render ammo icon for weapon and utility crate |
1247 -- Render ammo icon for weapon and utility crate. |
1242 local ammoFrame |
1248 -- But hide this from prying eyes of your enemies online! |
1243 if (cat[cIndex] == "Weapon Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") then |
1249 if IsHogLocal(CurrentHedgehog) then |
1244 local tArr |
1250 local ammoFrame |
1245 if (cat[cIndex] == "Weapon Crate Placement Mode") then |
1251 if (cat[cIndex] == "Weapon Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") then |
1246 tArr = atkArray |
1252 local tArr |
|
1253 if (cat[cIndex] == "Weapon Crate Placement Mode") then |
|
1254 tArr = atkArray |
|
1255 else |
|
1256 tArr = utilArray |
|
1257 end |
|
1258 |
|
1259 -- Get ammo icon |
|
1260 ammoFrame = tArr[pIndex][1] - 1 |
|
1261 end |
|
1262 if ammoFrame then |
|
1263 local xDisplacement = 42 |
|
1264 local yDisplacement = 42 |
|
1265 local x = CursorX + yDisplacement |
|
1266 local y = CursorY + yDisplacement |
|
1267 |
|
1268 -- Border around ammo icon |
|
1269 if not ammoIconBorder then |
|
1270 ammoIconBorder = AddVisualGear(x, y, vgtStraightShot, sprCustom1, true, 3) |
|
1271 end |
|
1272 SetVisualGearValues(ammoIconBorder, x, y, 0, 0, 0, 0, 1000, nil, 1000) |
|
1273 |
|
1274 -- Ammo icon |
|
1275 if not ammoIcon then |
|
1276 ammoIcon = AddVisualGear(x, y, vgtStraightShot, sprAMAmmos, true, 3) |
|
1277 end |
|
1278 SetVisualGearValues(ammoIcon, x, y, 0, 0, 0, ammoFrame, 1000, nil, 1000) |
|
1279 |
1247 else |
1280 else |
1248 tArr = utilArray |
1281 -- Cleanup vgears if not placing ammo crates |
1249 end |
1282 if ammoIcon then |
1250 |
1283 DeleteVisualGear(ammoIcon) |
1251 -- Get ammo icon |
1284 end |
1252 ammoFrame = tArr[pIndex][1] - 1 |
1285 if ammoIconBorder then |
1253 end |
1286 DeleteVisualGear(ammoIconBorder) |
1254 if ammoFrame then |
1287 end |
1255 local xDisplacement = 42 |
|
1256 local yDisplacement = 42 |
|
1257 local x = CursorX + yDisplacement |
|
1258 local y = CursorY + yDisplacement |
|
1259 |
|
1260 -- Border around ammo icon |
|
1261 if not ammoIconBorder then |
|
1262 ammoIconBorder = AddVisualGear(x, y, vgtStraightShot, sprCustom1, false, 3) |
|
1263 end |
|
1264 SetVisualGearValues(ammoIconBorder, x, y, 0, 0, 0, 0, 1000, nil, 1000) |
|
1265 |
|
1266 -- Ammo icon |
|
1267 if not ammoIcon then |
|
1268 ammoIcon = AddVisualGear(x, y, vgtStraightShot, sprAMAmmos, false, 3) |
|
1269 end |
|
1270 SetVisualGearValues(ammoIcon, x, y, 0, 0, 0, ammoFrame, 1000, nil, 1000) |
|
1271 |
|
1272 else |
|
1273 -- Cleanup vgears if not placing ammo crates |
|
1274 if ammoIcon then |
|
1275 DeleteVisualGear(ammoIcon) |
|
1276 end |
|
1277 if ammoIconBorder then |
|
1278 DeleteVisualGear(ammoIconBorder) |
|
1279 end |
1288 end |
1280 end |
1289 end |
1281 end |
1290 end |
1282 end |
1291 end |
1283 |
1292 |
1379 placedExpense = 200 |
1390 placedExpense = 200 |
1380 elseif cat[cIndex] == "Weapon Crate Placement Mode" then |
1391 elseif cat[cIndex] == "Weapon Crate Placement Mode" then |
1381 placedExpense = atkArray[pIndex][2] |
1392 placedExpense = atkArray[pIndex][2] |
1382 elseif cat[cIndex] == "Utility Crate Placement Mode" then |
1393 elseif cat[cIndex] == "Utility Crate Placement Mode" then |
1383 placedExpense = utilArray[pIndex][2] |
1394 placedExpense = utilArray[pIndex][2] |
1384 end |
1395 elseif cat[cIndex] == "Health Crate Placement Mode" then |
1385 |
1396 placedExpense = 5 |
1386 AddCaption(string.format(loc("Cost: %d"), placedExpense), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmostate) |
1397 elseif cat[cIndex] == "Mine Placement Mode" then |
|
1398 placedExpense = 15 |
|
1399 elseif cat[cIndex] == "Sticky Mine Placement Mode" then |
|
1400 placedExpense = 20 |
|
1401 elseif cat[cIndex] == "Barrel Placement Mode" then |
|
1402 placedExpense = 10 |
|
1403 elseif cat[cIndex] == "Girder Placement Mode" then |
|
1404 placedExpense = 1 |
|
1405 elseif cat[cIndex] == "Rubber Placement Mode" then |
|
1406 placedExpense = 3 |
|
1407 end |
|
1408 |
|
1409 -- Hide cost from spectators. |
|
1410 -- Also, this information is hidden cuz it could be used to infer e.g. crate contents. |
|
1411 if IsHogLocal(CurrentHedgehog) then |
|
1412 AddCaption(string.format(loc("Cost: %d"), placedExpense), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmostate) |
|
1413 end |
1387 |
1414 |
1388 end |
1415 end |
1389 |
1416 |
1390 -- Should be called when the index of the mode was changed by the player. |
1417 -- Should be called when the index of the mode was changed by the player. |
1391 -- E.g. new weapon crate contents or structure type |
1418 -- E.g. new weapon crate contents or structure type |
1421 str = loc(val) |
1448 str = loc(val) |
1422 elseif cat[cIndex] == "Girder Placement Mode" then |
1449 elseif cat[cIndex] == "Girder Placement Mode" then |
1423 str = GetAmmoName(amGirder) |
1450 str = GetAmmoName(amGirder) |
1424 elseif cat[cIndex] == "Rubber Placement Mode" then |
1451 elseif cat[cIndex] == "Rubber Placement Mode" then |
1425 str = GetAmmoName(amRubber) |
1452 str = GetAmmoName(amRubber) |
|
1453 elseif cat[cIndex] == "Sticky Mine Placement Mode" then |
|
1454 str = GetAmmoName(amSMine) |
1426 elseif cat[cIndex] == "Weapon Crate Placement Mode" |
1455 elseif cat[cIndex] == "Weapon Crate Placement Mode" |
1427 or cat[cIndex] == "Utility Crate Placement Mode" |
1456 or cat[cIndex] == "Utility Crate Placement Mode" then |
1428 or cat[cIndex] == "Sticky Mine Placement Mode" then |
|
1429 str = GetAmmoName(val) |
1457 str = GetAmmoName(val) |
|
1458 elseif cat[cIndex] == "Health Crate Placement Mode" then |
|
1459 str = tostring(val) |
1430 else |
1460 else |
1431 str = tostring(val) |
1461 str = tostring(val) |
1432 end |
1462 end |
1433 AddCaption(str, GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2) |
1463 -- Hide the mode message from prying enemy eyes except for the structure placer. |
|
1464 -- So stuff like crate contents or mine timers are secret. |
|
1465 if cat[cIndex] == "Structure Placement Mode" or IsHogLocal(CurrentHedgehog) then |
|
1466 AddCaption(str, GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2) |
|
1467 end |
1434 end |
1468 end |
1435 |
1469 |
1436 function rotateMode(pDir) |
1470 function rotateMode(pDir) |
1437 curWep = GetCurAmmoType() |
1471 curWep = GetCurAmmoType() |
1438 local foundMatch = false |
1472 local foundMatch = false |