share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 12946 ffbd31afed96
parent 12945 39b7b3ed619e
child 12947 ca23981ec219
equal deleted inserted replaced
12945:39b7b3ed619e 12946:ffbd31afed96
   198 
   198 
   199 clanPowerTag = nil
   199 clanPowerTag = nil
   200 lastWep = nil
   200 lastWep = nil
   201 
   201 
   202 checkForSpecialWeaponsIn = -1
   202 checkForSpecialWeaponsIn = -1
       
   203 
       
   204 -- Fake ammo types, for the overwritten weapons in Construction Mode
       
   205 amCMStructurePlacer = amAirAttack
       
   206 amCMCratePlacer = amNapalm
       
   207 amCMObjectPlacer = amDrillStrike
   203 
   208 
   204 -- Config variables (script parameter)
   209 -- Config variables (script parameter)
   205 conf_initialEnergy = 550
   210 conf_initialEnergy = 550
   206 conf_energyPerRound = 50
   211 conf_energyPerRound = 50
   207 conf_maxEnergy = 1000
   212 conf_maxEnergy = 1000
   664 
   669 
   665 					for wpnIndex = 1, #utilArray do
   670 					for wpnIndex = 1, #utilArray do
   666 						AddAmmo(gear, utilArray[wpnIndex][1], 0)
   671 						AddAmmo(gear, utilArray[wpnIndex][1], 0)
   667 					end
   672 					end
   668 
   673 
   669 					AddAmmo(gear, amAirAttack, 100)
   674 					AddAmmo(gear, amCMStructurePlacer, 100)
   670 					AddAmmo(gear, amSwitch, 100)
   675 					AddAmmo(gear, amSwitch, 100)
   671 					AddAmmo(gear, amSkip, 100)
   676 					AddAmmo(gear, amSkip, 100)
   672 
   677 
   673 				end
   678 				end
   674 			end
   679 			end
   868 
   873 
   869 			if sProx[i][1] == loc("Girder Placement Mode") then
   874 			if sProx[i][1] == loc("Girder Placement Mode") then
   870 				if sProx[i][2] == true then
   875 				if sProx[i][2] == true then
   871 					AddAmmo(CurrentHedgehog, amGirder, 100)
   876 					AddAmmo(CurrentHedgehog, amGirder, 100)
   872 					AddAmmo(CurrentHedgehog, amRubber, 100)
   877 					AddAmmo(CurrentHedgehog, amRubber, 100)
   873 					AddAmmo(CurrentHedgehog, amDrillStrike, 100)
   878 					AddAmmo(CurrentHedgehog, amCMObjectPlacer, 100)
   874 				else
   879 				else
   875 					AddAmmo(CurrentHedgehog, amGirder, 0)
   880 					AddAmmo(CurrentHedgehog, amGirder, 0)
   876 					AddAmmo(CurrentHedgehog, amRubber, 0)
   881 					AddAmmo(CurrentHedgehog, amRubber, 0)
   877 					AddAmmo(CurrentHedgehog, amDrillStrike, 0) -- new
   882 					AddAmmo(CurrentHedgehog, amCMObjectPlacer, 0) -- new
   878 				end
   883 				end
   879 			elseif sProx[i][1] == loc("Teleportation Mode") then
   884 			elseif sProx[i][1] == loc("Teleportation Mode") then
   880 				if sProx[i][2] == true then
   885 				if sProx[i][2] == true then
   881 					AddAmmo(CurrentHedgehog, amTeleport, 100)
   886 					AddAmmo(CurrentHedgehog, amTeleport, 100)
   882 				else
   887 				else
   883 					AddAmmo(CurrentHedgehog, amTeleport, 0)
   888 					AddAmmo(CurrentHedgehog, amTeleport, 0)
   884 				end
   889 				end
   885 			elseif sProx[i][1] == loc("Weapon Crate Placement Mode") then
   890 			elseif sProx[i][1] == loc("Weapon Crate Placement Mode") then
   886 				-- this is new stuff
   891 				-- this is new stuff
   887 				if sProx[i][2] == true then
   892 				if sProx[i][2] == true then
   888 					AddAmmo(CurrentHedgehog, amNapalm, 100)
   893 					AddAmmo(CurrentHedgehog, amCMCratePlacer, 100)
   889 				else
   894 				else
   890 					AddAmmo(CurrentHedgehog, amNapalm, 0)
   895 					AddAmmo(CurrentHedgehog, amCMCratePlacer, 0)
   891 				end
   896 				end
   892 			end
   897 			end
   893 
   898 
   894 			if (sProx[i][2] == true) then
   899 			if (sProx[i][2] == true) then
   895 				anyUIProx = true
   900 				anyUIProx = true
   901 end
   906 end
   902 
   907 
   903 
   908 
   904 function checkForSpecialWeapons()
   909 function checkForSpecialWeapons()
   905 
   910 
   906 	if (GetCurAmmoType() == amDrillStrike) then
   911 	if (GetCurAmmoType() == amCMObjectPlacer) then
   907 		AddCaption(loc("Object Placer"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
   912 		AddCaption(loc("Object Placer"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
   908 	end
   913 	end
   909 
   914 
   910 	lastWep = GetCurAmmoType()
   915 	lastWep = GetCurAmmoType()
   911 
   916 
   960 				{amDynamite, 	"amDynamite",		0, 9*placeholder},
   965 				{amDynamite, 	"amDynamite",		0, 9*placeholder},
   961 				{amCake, 		"amCake",			0, 25*placeholder},
   966 				{amCake, 		"amCake",			0, 25*placeholder},
   962 				{amBallgun, 	"amBallgun",		0, 40*placeholder},
   967 				{amBallgun, 	"amBallgun",		0, 40*placeholder},
   963 				--{amRCPlane,		"amRCPlane",		0, loc("RC Plane"), 	25*placeholder},
   968 				--{amRCPlane,		"amRCPlane",		0, loc("RC Plane"), 	25*placeholder},
   964 				{amSMine,		"amSMine",			0, 5*placeholder},
   969 				{amSMine,		"amSMine",			0, 5*placeholder},
       
   970 
       
   971 				-- Careful! Some airborne attacks are overwritten by the special Construction Mode tools
   965 
   972 
   966 				--{amAirAttack,	"amAirAttack",		0, loc("Air Attack"), 		10*placeholder},
   973 				--{amAirAttack,	"amAirAttack",		0, loc("Air Attack"), 		10*placeholder},
   967 				--{amMineStrike,	"amMineStrike",		0, loc("Mine Strike"), 		15*placeholder},
   974 				--{amMineStrike,	"amMineStrike",		0, loc("Mine Strike"), 		15*placeholder},
   968 				--{amNapalm, 		"amNapalm",			0, loc("Napalm"), 		15*placeholder},
   975 				--{amNapalm, 		"amNapalm",			0, loc("Napalm"), 		15*placeholder},
   969 				--{amPiano,		"amPiano",			0, loc("Piano Strike"), 	40*placeholder},
   976 				--{amPiano,		"amPiano",			0, loc("Piano Strike"), 	40*placeholder},
  1279 				RedefineSubset()
  1286 				RedefineSubset()
  1280 
  1287 
  1281 			end
  1288 			end
  1282 
  1289 
  1283 			-- update display selection criteria
  1290 			-- update display selection criteria
  1284 			if ((curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) or (curWep == amRubber))
  1291 			if ((curWep == amGirder) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) or (curWep == amRubber))
  1285 				and (CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0) then
  1292 				and (CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0) then
  1286 
  1293 
  1287 				---------------hooolllllyyyy fucking shit this
  1294 				---------------hooolllllyyyy fucking shit this
  1288 				-- code is a broken mess now
  1295 				-- code is a broken mess now
  1289 				-- it was redesigned and compromised three times
  1296 				-- it was redesigned and compromised three times
  1290 				-- so now it is a mess trying to do what it was
  1297 				-- so now it is a mess trying to do what it was
  1291 				-- never designed to do
  1298 				-- never designed to do
  1292 				-- needs to be rewritten badly sadface
  1299 				-- needs to be rewritten badly sadface
  1293 				-- this bit here catches the new 3 types of weapons
  1300 				-- this bit here catches the new 3 types of weapons
  1294 				if ((sProx[cIndex][1] == loc("Structure Placement Mode") and (curWep ~= amAirAttack))) then
  1301 				if ((sProx[cIndex][1] == loc("Structure Placement Mode") and (curWep ~= amCMStructurePlacer))) then
  1295 					updatePlacementDisplay(1)
  1302 					updatePlacementDisplay(1)
  1296 				elseif (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
  1303 				elseif (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
  1297 							(sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
  1304 							(sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
  1298 							(sProx[cIndex][1] == loc("Utility Crate Placement Mode")) then
  1305 							(sProx[cIndex][1] == loc("Utility Crate Placement Mode")) then
  1299 								if curWep ~= amNapalm then
  1306 								if curWep ~= amCMCratePlacer then
  1300 									updatePlacementDisplay(1)
  1307 									updatePlacementDisplay(1)
  1301 								end
  1308 								end
  1302 
  1309 
  1303 				elseif (sProx[cIndex][1] == loc("Mine Placement Mode")) or
  1310 				elseif (sProx[cIndex][1] == loc("Mine Placement Mode")) or
  1304 							(sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
  1311 							(sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
  1305 							(sProx[cIndex][1] == loc("Barrel Placement Mode")) then
  1312 							(sProx[cIndex][1] == loc("Barrel Placement Mode")) then
  1306 								if curWep ~= amDrillStrike then
  1313 								if curWep ~= amCMObjectPlacer then
  1307 									updatePlacementDisplay(1)
  1314 									updatePlacementDisplay(1)
  1308 								end
  1315 								end
  1309 
  1316 
  1310 				end
  1317 				end
  1311 
  1318 
  1407 	pIndex = pIndex - 1
  1414 	pIndex = pIndex - 1
  1408 	if pIndex == 0 then
  1415 	if pIndex == 0 then
  1409 		pIndex = #pMode
  1416 		pIndex = #pMode
  1410 	end
  1417 	end
  1411 
  1418 
  1412 	if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then
  1419 	if (curWep == amGirder) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
  1413 		showModeMessage()
  1420 		showModeMessage()
  1414 		updateCost()
  1421 		updateCost()
  1415 	end
  1422 	end
  1416 
  1423 
  1417 
  1424 
  1422 	pIndex = pIndex + 1
  1429 	pIndex = pIndex + 1
  1423 	if pIndex > #pMode then
  1430 	if pIndex > #pMode then
  1424 		pIndex = 1
  1431 		pIndex = 1
  1425 	end
  1432 	end
  1426 
  1433 
  1427 	if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then
  1434 	if (curWep == amGirder) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
  1428 		showModeMessage()
  1435 		showModeMessage()
  1429 		updateCost()
  1436 		updateCost()
  1430 	end
  1437 	end
  1431 
  1438 
  1432 end
  1439 end
  1459 		elseif cIndex > #cat then
  1466 		elseif cIndex > #cat then
  1460 			cIndex = 3	 -- 2 ----we no longer hit girder by normal means
  1467 			cIndex = 3	 -- 2 ----we no longer hit girder by normal means
  1461 		end
  1468 		end
  1462 
  1469 
  1463 		if sProx[cIndex][2] == true then
  1470 		if sProx[cIndex][2] == true then
  1464 			if (GetCurAmmoType() == amNapalm) then
  1471 			if (GetCurAmmoType() == amCMCratePlacer) then
  1465 				if (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
  1472 				if (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
  1466 					(sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
  1473 					(sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
  1467 					(sProx[cIndex][1] == loc("Utility Crate Placement Mode"))
  1474 					(sProx[cIndex][1] == loc("Utility Crate Placement Mode"))
  1468 					then
  1475 					then
  1469 						foundMatch = true
  1476 						foundMatch = true
  1470 					end
  1477 					end
  1471 			elseif (GetCurAmmoType() == amDrillStrike) then
  1478 			elseif (GetCurAmmoType() == amCMObjectPlacer) then
  1472 				if (sProx[cIndex][1] == loc("Mine Placement Mode")) or
  1479 				if (sProx[cIndex][1] == loc("Mine Placement Mode")) or
  1473 					(sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
  1480 					(sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
  1474 					(sProx[cIndex][1] == loc("Barrel Placement Mode"))
  1481 					(sProx[cIndex][1] == loc("Barrel Placement Mode"))
  1475 					then
  1482 					then
  1476 						foundMatch = true
  1483 						foundMatch = true
  1477 					end
  1484 					end
  1478 			elseif (GetCurAmmoType() == amAirAttack) then
  1485 			elseif (GetCurAmmoType() == amCMStructurePlacer) then
  1479 				if sProx[cIndex][1] == loc("Structure Placement Mode") then
  1486 				if sProx[cIndex][1] == loc("Structure Placement Mode") then
  1480 					foundMatch = true
  1487 					foundMatch = true
  1481 				end
  1488 				end
  1482 			end
  1489 			end
  1483 		end
  1490 		end
  1497 -- i.e 	mine, sticky mine, barrels
  1504 -- i.e 	mine, sticky mine, barrels
  1498 --		health/weapon/utility crate, placement of gears
  1505 --		health/weapon/utility crate, placement of gears
  1499 ---------------------------------------------------------
  1506 ---------------------------------------------------------
  1500 function onUp()
  1507 function onUp()
  1501 
  1508 
  1502 	if ( (curWep == amNapalm) or (curWep == amDrillStrike) ) then
  1509 	if ( (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) ) then
  1503 		if CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
  1510 		if CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
  1504 			updatePlacementDisplay(-1)
  1511 			updatePlacementDisplay(-1)
  1505 		end
  1512 		end
  1506 	end
  1513 	end
  1507 
  1514 
  1508 end
  1515 end
  1509 
  1516 
  1510 function onDown()
  1517 function onDown()
  1511 
  1518 
  1512 	if ( (curWep == amNapalm) or (curWep == amDrillStrike) ) then
  1519 	if ( (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) ) then
  1513 		if CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
  1520 		if CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
  1514 			updatePlacementDisplay(1)
  1521 			updatePlacementDisplay(1)
  1515 		end
  1522 		end
  1516 	end
  1523 	end
  1517 
  1524 
  1570 	if not fortMode then
  1577 	if not fortMode then
  1571 		FindPlace(gear, false, clanBoundsSX[GetHogClan(gear)], clanBoundsEX[GetHogClan(gear)],true)
  1578 		FindPlace(gear, false, clanBoundsSX[GetHogClan(gear)], clanBoundsEX[GetHogClan(gear)],true)
  1572 	end
  1579 	end
  1573 
  1580 
  1574 	-- for now, everyone should have this stuff
  1581 	-- for now, everyone should have this stuff
  1575 	AddAmmo(gear, amAirAttack, 100)
  1582 	AddAmmo(gear, amCMStructurePlacer, 100)
  1576 	AddAmmo(gear, amSwitch, 100)
  1583 	AddAmmo(gear, amSwitch, 100)
  1577 	AddAmmo(gear, amSkip, 100)
  1584 	AddAmmo(gear, amSkip, 100)
  1578 
  1585 
  1579 end
  1586 end
  1580 
  1587 
  1589 				loc("There are a variety of structures available to aid you.") .. "|" ..
  1596 				loc("There are a variety of structures available to aid you.") .. "|" ..
  1590 				loc("Use the structure placer to place structures.")
  1597 				loc("Use the structure placer to place structures.")
  1591 				, 4, 5000
  1598 				, 4, 5000
  1592 				)
  1599 				)
  1593 
  1600 
  1594 	SetAmmoTexts(amAirAttack, loc("Structure Placer"), loc("Construction Mode tool"), loc("Build one of multiple different structures|to aid you in victory, at the cost of energy.") .. "| |" ..
  1601 	SetAmmoTexts(amCMStructurePlacer, loc("Structure Placer"), loc("Construction Mode tool"), loc("Build one of multiple different structures|to aid you in victory, at the cost of energy.") .. "| |" ..
  1595 	loc("Healing Station: Heals nearby hogs.")  .. "|" ..
  1602 	loc("Healing Station: Heals nearby hogs.")  .. "|" ..
  1596 	loc("Bio-Filter: Aggressively removes enemies.")  .. "|" ..
  1603 	loc("Bio-Filter: Aggressively removes enemies.")  .. "|" ..
  1597 	loc("Weapon Filter: Dematerializes all ammo|    carried by enemies entering it.")  .. "|" ..
  1604 	loc("Weapon Filter: Dematerializes all ammo|    carried by enemies entering it.")  .. "|" ..
  1598 	loc("Reflector Shield: Reflects enemy projectiles.")  .. "|" ..
  1605 	loc("Reflector Shield: Reflects enemy projectiles.")  .. "|" ..
  1599 	loc("Generator: Generates energy.")  .. "|" ..
  1606 	loc("Generator: Generates energy.")  .. "|" ..
  1607 	local txt_crateLimit = ""
  1614 	local txt_crateLimit = ""
  1608 	if conf_cratesPerRound ~= "inf" then
  1615 	if conf_cratesPerRound ~= "inf" then
  1609 		txt_crateLimit = string.format(loc("You may only place %d crates per round."), conf_cratesPerRound) .. "|"
  1616 		txt_crateLimit = string.format(loc("You may only place %d crates per round."), conf_cratesPerRound) .. "|"
  1610 	end
  1617 	end
  1611 
  1618 
  1612 	SetAmmoTexts(amNapalm, loc("Crate Placer"), loc("Construction Mode tool"),
  1619 	SetAmmoTexts(amCMCratePlacer, loc("Crate Placer"), loc("Construction Mode tool"),
  1613 		loc("This allows you to create a crate anywhere|within your clan's area of influence,|at the cost of energy.") .. "|" ..
  1620 		loc("This allows you to create a crate anywhere|within your clan's area of influence,|at the cost of energy.") .. "|" ..
  1614 		txt_crateLimit ..
  1621 		txt_crateLimit ..
  1615 		loc("Up/down: Choose crate type") .. "|" .. 
  1622 		loc("Up/down: Choose crate type") .. "|" .. 
  1616 		loc("Left/right: Choose crate contents") .. "|" ..
  1623 		loc("Left/right: Choose crate contents") .. "|" ..
  1617 		loc("|Cursor: Place crate"))
  1624 		loc("|Cursor: Place crate"))
  1618 	SetAmmoTexts(amDrillStrike, loc("Object Placer"), loc("Construction Mode tool"), loc("This allows you to create and place mines,|sticky mines and barrels anywhere within your|clan's area of influence at the cost of energy.|Up/down: Choose object type|Left/right: Choose timer (for mines)|Cursor: Place object"))
  1625 	SetAmmoTexts(amCMObjectPlacer, loc("Object Placer"), loc("Construction Mode tool"), loc("This allows you to create and place mines,|sticky mines and barrels anywhere within your|clan's area of influence at the cost of energy.|Up/down: Choose object type|Left/right: Choose timer (for mines)|Cursor: Place object"))
  1619 
  1626 
  1620 	SetAmmoDescriptionAppendix(amTeleport, loc("It only works in teleportation nodes of your own clan."))
  1627 	SetAmmoDescriptionAppendix(amTeleport, loc("It only works in teleportation nodes of your own clan."))
  1621 	
  1628 	
  1622 	sCirc = AddVisualGear(0,0,vgtCircle,0,true)
  1629 	sCirc = AddVisualGear(0,0,vgtCircle,0,true)
  1623 	SetVisualGearValues(sCirc, 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x00000000)
  1630 	SetVisualGearValues(sCirc, 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x00000000)