984 local actualDisplayedImage = placedFrame[pID] |
988 local actualDisplayedImage = placedFrame[pID] |
985 if (placedSprite[pID] == sprAMAmmos or placedSprite[pID] == sprAMAmmosBW) and (actualDisplayedImage == (amAirAttack - 1)) then |
989 if (placedSprite[pID] == sprAMAmmos or placedSprite[pID] == sprAMAmmosBW) and (actualDisplayedImage == (amAirAttack - 1)) then |
986 actualDisplayedImage = ammoFrameAirAttack |
990 actualDisplayedImage = ammoFrameAirAttack |
987 end |
991 end |
988 |
992 |
989 return PlaceSprite(placedX[pID], placedY[pID], placedSprite[pID], actualDisplayedImage, |
993 local success = PlaceSprite(placedX[pID], placedY[pID], placedSprite[pID], actualDisplayedImage, |
990 placedTint[pID], |
994 placedTint[pID], |
991 nil, -- overrite existing land |
995 nil, -- overrite existing land |
992 nil, nil, -- this stuff specifies flipping |
996 nil, nil, -- this stuff specifies flipping |
993 landType) |
997 landType) |
|
998 |
|
999 if not silent then |
|
1000 if success then |
|
1001 PlaySound(sndPlaced) |
|
1002 else |
|
1003 PlaySound(sndDenied) |
|
1004 end |
|
1005 end |
|
1006 |
|
1007 return success |
994 |
1008 |
995 end |
1009 end |
996 |
1010 |
997 function SelectClosestSprite() |
1011 function SelectClosestSprite() |
998 |
1012 |
1028 nil, -- only erase the provided land flags. don't touch other land flags or LandPixels |
1042 nil, -- only erase the provided land flags. don't touch other land flags or LandPixels |
1029 nil, -- flip sprite horizontally |
1043 nil, -- flip sprite horizontally |
1030 nil, -- flip sprite vertically |
1044 nil, -- flip sprite vertically |
1031 placedLandFlags[closestSpriteID]) |
1045 placedLandFlags[closestSpriteID]) |
1032 |
1046 |
|
1047 PlaySound(sndBump) |
|
1048 |
1033 placedX[closestSpriteID] = nil |
1049 placedX[closestSpriteID] = nil |
1034 placedY[closestSpriteID] = nil |
1050 placedY[closestSpriteID] = nil |
1035 placedSpec[closestSpriteID] = nil |
1051 placedSpec[closestSpriteID] = nil |
1036 placedType[closestSpriteID] = nil |
1052 placedType[closestSpriteID] = nil |
1037 placedTint[closestSpriteID] = nil |
1053 placedTint[closestSpriteID] = nil |
1038 placedSprite[closestSpriteID] = nil |
1054 placedSprite[closestSpriteID] = nil |
1039 placedFrame[closestSpriteID] = nil |
1055 placedFrame[closestSpriteID] = nil |
1040 placedLandFlags[closestSpriteID] = nil |
1056 placedLandFlags[closestSpriteID] = nil |
1041 closestSpriteID = nil |
1057 closestSpriteID = nil |
1042 SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 ) |
1058 SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 ) |
|
1059 else |
|
1060 PlaySound(sndDenied) |
1043 end |
1061 end |
1044 end |
1062 end |
1045 |
1063 |
1046 -- work this into the above two functions and edit them, later |
1064 -- work this into the above two functions and edit them, later |
1047 function EraseClosestWaypoint() |
1065 function EraseClosestWaypoint() |
1049 closestDist = 999999999 |
1067 closestDist = 999999999 |
1050 closestSpriteID = nil -- just in case |
1068 closestSpriteID = nil -- just in case |
1051 |
1069 |
1052 for i = 0, (placedCount-1) do |
1070 for i = 0, (placedCount-1) do |
1053 if (placedType[i] == loc("Waypoint Editing Mode")) then |
1071 if (placedType[i] == loc("Waypoint Editing Mode")) then |
1054 q = placedX[i] - placedX[placedCount] |
1072 local q = placedX[i] - placedX[placedCount] |
1055 w = placedY[i] - placedY[placedCount] |
1073 local w = placedY[i] - placedY[placedCount] |
1056 d = ( (q*q) + (w*w) ) |
1074 local d = ( (q*q) + (w*w) ) |
1057 if d < closestDist then |
1075 if d < closestDist then |
1058 closestDist = d |
1076 closestDist = d |
1059 closestSpriteID = i |
1077 closestSpriteID = i |
1060 |
1078 |
1061 SetVisualGearValues(sSprite, placedX[i], placedY[i], 0, 0, nil, placedFrame[i], 10000, placedSprite[i], 10000, newTint ) |
1079 SetVisualGearValues(sSprite, placedX[i], placedY[i], 0, 0, nil, placedFrame[i], 10000, placedSprite[i], 10000, newTint ) |
1062 |
1080 end |
1063 end |
|
1064 end |
1081 end |
1065 end |
1082 end |
1066 |
1083 |
1067 if closestSpriteID ~= nil then |
1084 if closestSpriteID ~= nil then |
1068 DeleteVisualGear(placedSpec[closestSpriteID]) |
1085 DeleteVisualGear(placedSpec[closestSpriteID]) |
1074 placedSprite[closestSpriteID] = nil |
1091 placedSprite[closestSpriteID] = nil |
1075 placedFrame[closestSpriteID] = nil |
1092 placedFrame[closestSpriteID] = nil |
1076 placedLandFlags[closestSpriteID] = nil |
1093 placedLandFlags[closestSpriteID] = nil |
1077 closestSpriteID = nil |
1094 closestSpriteID = nil |
1078 SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 ) |
1095 SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 ) |
|
1096 PlaySound(sndBump) |
|
1097 else |
|
1098 PlaySound(sndDenied) |
1079 end |
1099 end |
1080 end |
1100 end |
1081 |
1101 |
1082 |
1102 |
1083 -- essentially called when user clicks the mouse |
1103 -- essentially called when user clicks the mouse |
1137 if CGR == 0 then placedHWMapFlag[placedCount] = 124 |
1157 if CGR == 0 then placedHWMapFlag[placedCount] = 124 |
1138 elseif CGR == 1 then placedHWMapFlag[placedCount] = 125 |
1158 elseif CGR == 1 then placedHWMapFlag[placedCount] = 125 |
1139 elseif CGR == 2 then placedHWMapFlag[placedCount] = 126 |
1159 elseif CGR == 2 then placedHWMapFlag[placedCount] = 126 |
1140 elseif CGR == 3 then placedHWMapFlag[placedCount] = 127 |
1160 elseif CGR == 3 then placedHWMapFlag[placedCount] = 127 |
1141 end |
1161 end |
|
1162 PlaySound(sndPlaced) |
1142 else |
1163 else |
1143 placedType[placedCount] = "bogus" |
1164 placedType[placedCount] = "bogus" |
|
1165 PlaySound(sndDenied) |
1144 end |
1166 end |
1145 else |
1167 else |
1146 placedType[placedCount] = "bogus" |
1168 placedType[placedCount] = "bogus" |
1147 SelectClosestSprite() |
1169 SelectClosestSprite() |
1148 EraseClosestSprite() |
1170 EraseClosestSprite() |
1182 SetGearValues(gear, nil, nil, pMode[pIndex]) |
1204 SetGearValues(gear, nil, nil, pMode[pIndex]) |
1183 elseif cat[cIndex] == loc("Repositioning Mode") then |
1205 elseif cat[cIndex] == loc("Repositioning Mode") then |
1184 |
1206 |
1185 if pMode[pIndex] == loc("Selection Mode") then |
1207 if pMode[pIndex] == loc("Selection Mode") then |
1186 sGear = GetClosestGear() |
1208 sGear = GetClosestGear() |
|
1209 if sGear ~= nil then |
|
1210 PlaySound(sndPortalSwitch) |
|
1211 end |
1187 elseif pMode[pIndex] == loc("Placement Mode") then |
1212 elseif pMode[pIndex] == loc("Placement Mode") then |
1188 if sGear ~= nil then |
1213 if sGear ~= nil then |
1189 SetGearPosition(sGear, x, y) |
1214 SetGearPosition(sGear, x, y) |
|
1215 PlaySound(sndWarp) |
1190 end |
1216 end |
1191 elseif pMode[pIndex] == loc("Deletion Mode") then |
1217 elseif pMode[pIndex] == loc("Deletion Mode") then |
1192 sGear = GetClosestGear() |
1218 sGear = GetClosestGear() |
1193 if (sGear == nil) then |
1219 if (sGear == nil) then |
1194 AddCaption(loc("Please click on a gear."), colorErrorMessage, capgrpVolume) |
1220 AddCaption(loc("Please click on a gear."), colorErrorMessage, capgrpVolume) |
|
1221 PlaySound(sndDenied) |
1195 elseif (GetGearType(sGear) == gtHedgehog) then |
1222 elseif (GetGearType(sGear) == gtHedgehog) then |
1196 AddCaption(loc("Hedgehogs can not be deleted."), colorErrorMessage, capgrpVolume) |
1223 AddCaption(loc("Hedgehogs can not be deleted."), colorErrorMessage, capgrpVolume) |
|
1224 PlaySound(sndDenied) |
1197 else |
1225 else |
1198 DeleteGear(sGear) |
1226 DeleteGear(sGear) |
|
1227 PlaySound(sndBump) |
1199 end |
1228 end |
1200 sGear = nil |
1229 sGear = nil |
1201 end |
1230 end |
1202 |
1231 |
1203 elseif (cat[cIndex] == loc("Hog Identity Mode")) or (cat[cIndex] == loc("Team Identity Mode")) then |
1232 elseif (cat[cIndex] == loc("Hog Identity Mode")) or (cat[cIndex] == loc("Team Identity Mode")) then |
1207 if (cat[cIndex] == loc("Hog Identity Mode")) then |
1236 if (cat[cIndex] == loc("Hog Identity Mode")) then |
1208 SetHogProfile(sGear, pMode[pIndex]) |
1237 SetHogProfile(sGear, pMode[pIndex]) |
1209 else -- set for the whole team |
1238 else -- set for the whole team |
1210 SetTeamIdentity(sGear) |
1239 SetTeamIdentity(sGear) |
1211 end |
1240 end |
|
1241 PlaySound(sndHello, sGear) |
1212 else |
1242 else |
1213 AddCaption(loc("Please click on a hedgehog."), colorErrorMessage, capgrpVolume) |
1243 AddCaption(loc("Please click on a hedgehog."), colorErrorMessage, capgrpVolume) |
|
1244 PlaySound(sndDenied) |
1214 end |
1245 end |
1215 |
1246 |
1216 |
1247 |
1217 |
1248 |
1218 elseif cat[cIndex] == loc("Health Modification Mode") then |
1249 elseif cat[cIndex] == loc("Health Modification Mode") then |
1219 |
1250 |
1220 sGear = GetClosestGear() |
1251 sGear = GetClosestGear() |
1221 local gt = GetGearType(sGear) |
1252 local gt = GetGearType(sGear) |
1222 if gt == gtHedgehog or gt == gtExplosives or (gt == gtCase and GetGearPos(sGear) == 0x2) then |
1253 if gt == gtHedgehog or gt == gtExplosives or (gt == gtCase and GetGearPos(sGear) == 0x2) then |
|
1254 local oldHealth, hDiff = GetHealth(sGear) |
1223 if pMode[pIndex][2] == "set" then |
1255 if pMode[pIndex][2] == "set" then |
1224 SetHealth(sGear, pMode[pIndex][1]) |
1256 SetHealth(sGear, pMode[pIndex][1]) |
|
1257 hDiff = pMode[pIndex][1] - oldHealth |
1225 elseif pMode[pIndex][2] == "mod" then |
1258 elseif pMode[pIndex][2] == "mod" then |
1226 local min |
1259 local min |
1227 if gt == gtCase then min = 0 else min = 1 end |
1260 if gt == gtCase then min = 0 else min = 1 end |
1228 local newHealth = math.max(min, GetHealth(sGear) + tonumber(pMode[pIndex][1])) |
1261 local newHealth = math.max(min, GetHealth(sGear) + tonumber(pMode[pIndex][1])) |
1229 SetHealth(sGear, newHealth) |
1262 SetHealth(sGear, newHealth) |
|
1263 hDiff = newHealth - oldHealth |
|
1264 end |
|
1265 PlaySound(sndPortalSwitch) |
|
1266 if gt == gtHedgehog and hDiff < 0 then |
|
1267 local snd = { sndOw1, sndOw2, sndOw3 } |
|
1268 PlaySound(snd[math.random(1, #snd)], sGear) |
1230 end |
1269 end |
1231 elseif gt == gtMine and GetHealth(sGear) == 0 then |
1270 elseif gt == gtMine and GetHealth(sGear) == 0 then |
1232 local newHealth |
1271 local newHealth |
1233 if pMode[pIndex][2] == "set" then |
1272 if pMode[pIndex][2] == "set" then |
1234 newHealth = pMode[pIndex][1] |
1273 newHealth = pMode[pIndex][1] |
1238 oldHealth = 36 - oldHealth |
1277 oldHealth = 36 - oldHealth |
1239 newHealth = math.max(1, oldHealth + tonumber(pMode[pIndex][1])) |
1278 newHealth = math.max(1, oldHealth + tonumber(pMode[pIndex][1])) |
1240 end |
1279 end |
1241 if newHealth ~= nil then |
1280 if newHealth ~= nil then |
1242 SetGearValues(sGear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 36 - newHealth) |
1281 SetGearValues(sGear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 36 - newHealth) |
|
1282 PlaySound(sndPortalSwitch) |
1243 end |
1283 end |
1244 else |
1284 else |
1245 AddCaption(loc("Please click on a hedgehog, barrel, health crate or dud mine."), colorErrorMessage, capgrpVolume) |
1285 AddCaption(loc("Please click on a hedgehog, barrel, health crate or dud mine."), colorErrorMessage, capgrpVolume) |
|
1286 PlaySound(sndDenied) |
1246 end |
1287 end |
1247 |
1288 |
1248 elseif cat[cIndex] == loc("Sprite Modification Mode") then |
1289 elseif cat[cIndex] == loc("Sprite Modification Mode") then |
1249 |
1290 |
1250 SelectClosestSprite() |
1291 SelectClosestSprite() |
1251 |
1292 |
1252 if closestSpriteID ~= nil then |
1293 if closestSpriteID ~= nil then |
1253 if pMode[pIndex] == loc("LandFlag Modification Mode") then |
1294 if pMode[pIndex] == loc("LandFlag Modification Mode") then |
1254 EraseSprite(placedX[closestSpriteID], placedY[closestSpriteID], placedSprite[closestSpriteID], placedFrame[closestSpriteID], nil, nil, nil, nil, placedLandFlags[closestSpriteID]) |
1295 EraseSprite(placedX[closestSpriteID], placedY[closestSpriteID], placedSprite[closestSpriteID], placedFrame[closestSpriteID], nil, nil, nil, nil, placedLandFlags[closestSpriteID]) |
1255 placementSucceeded = CallPlaceSprite(closestSpriteID) |
1296 placementSucceeded = CallPlaceSprite(closestSpriteID, true) |
1256 if placementSucceeded then |
1297 if placementSucceeded then |
1257 closestSpriteID = nil |
1298 closestSpriteID = nil |
1258 SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 ) |
1299 SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 ) |
|
1300 PlaySound(sndPortalSwitch) |
|
1301 else |
|
1302 PlaySound(sndDenied) |
1259 end |
1303 end |
1260 elseif pMode[pIndex] == loc("Sprite Erasure Mode") then |
1304 elseif pMode[pIndex] == loc("Sprite Erasure Mode") then |
1261 |
1305 |
1262 EraseClosestSprite() |
1306 EraseClosestSprite() |
1263 |
1307 |
1264 end |
1308 end |
|
1309 else |
|
1310 PlaySound(sndDenied) |
1265 end |
1311 end |
1266 |
1312 |
1267 |
1313 |
1268 elseif cat[cIndex] == loc("Goal Definition Mode") then |
1314 elseif cat[cIndex] == loc("Goal Definition Mode") then |
1269 |
1315 |
1273 if getGearValue(sGear,"tag") == nil then |
1319 if getGearValue(sGear,"tag") == nil then |
1274 |
1320 |
1275 if pMode[pIndex] == loc("Victory Condition: Collect") then |
1321 if pMode[pIndex] == loc("Victory Condition: Collect") then |
1276 if GetGearType(sGear) == gtCase then |
1322 if GetGearType(sGear) == gtCase then |
1277 setGearValue(sGear, "tag","collection") |
1323 setGearValue(sGear, "tag","collection") |
|
1324 PlaySound(sndPortalSwitch) |
1278 else |
1325 else |
1279 AddCaption(loc("Please click on a crate."), colorErrorMessage, capgrpVolume) |
1326 AddCaption(loc("Please click on a crate."), colorErrorMessage, capgrpVolume) |
|
1327 PlaySound(sndDenied) |
1280 end |
1328 end |
1281 else |
1329 else |
1282 if pMode[pIndex] == loc("Victory Condition: Destroy") then |
1330 if pMode[pIndex] == loc("Victory Condition: Destroy") then |
1283 setGearValue(sGear, "tag","victory") |
1331 setGearValue(sGear, "tag","victory") |
|
1332 PlaySound(sndPortalSwitch) |
1284 elseif pMode[pIndex] == loc("Losing Condition: Destroy") then |
1333 elseif pMode[pIndex] == loc("Losing Condition: Destroy") then |
1285 setGearValue(sGear, "tag","failure") |
1334 setGearValue(sGear, "tag","failure") |
|
1335 PlaySound(sndPortalSwitch) |
1286 end |
1336 end |
1287 end |
1337 end |
1288 |
1338 |
1289 else |
1339 else |
1290 -- remove tag and delete circ |
1340 -- remove tag and delete circ |
1291 setGearValue(sGear, "tag", nil) |
1341 setGearValue(sGear, "tag", nil) |
1292 DeleteVisualGear(getGearValue(sGear,"tCirc")) |
1342 DeleteVisualGear(getGearValue(sGear,"tCirc")) |
1293 setGearValue(sGear, "tCirc", nil) |
1343 setGearValue(sGear, "tCirc", nil) |
|
1344 PlaySound(sndBump) |
1294 end |
1345 end |
1295 |
1346 |
1296 |
1347 |
1297 |
1348 |
1298 end |
1349 end |
1302 |
1353 |
1303 if superDelete == false then |
1354 if superDelete == false then |
1304 placedFrame[placedCount] = sFrame |
1355 placedFrame[placedCount] = sFrame |
1305 placedSprite[placedCount] = reducedSpriteIDArray[pIndex] |
1356 placedSprite[placedCount] = reducedSpriteIDArray[pIndex] |
1306 placementSucceeded = CallPlaceSprite(placedCount) |
1357 placementSucceeded = CallPlaceSprite(placedCount) |
1307 if placementSucceeded then |
|
1308 PlaySound(sndPlaced) |
|
1309 end |
|
1310 else |
1358 else |
1311 placedType[placedCount] = "bogus" |
1359 placedType[placedCount] = "bogus" |
1312 SelectClosestSprite() |
1360 SelectClosestSprite() |
1313 EraseClosestSprite() |
1361 EraseClosestSprite() |
1314 end |
1362 end |