share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
changeset 12356 d1448cc0b8c2
parent 12355 37ed9df448fa
child 12357 ae6503e17764
equal deleted inserted replaced
12355:37ed9df448fa 12356:d1448cc0b8c2
   765 
   765 
   766 		-- There are about 58+- weps / utils
   766 		-- There are about 58+- weps / utils
   767 		-- Weapon Crates
   767 		-- Weapon Crates
   768 		elseif (specialPointsFlag[i] >= 20) and (specialPointsFlag[i] < (#atkArray+20)) then
   768 		elseif (specialPointsFlag[i] >= 20) and (specialPointsFlag[i] < (#atkArray+20)) then
   769 			tempG = SpawnAmmoCrate(specialPointsX[i],specialPointsY[i],atkArray[specialPointsFlag[i]-19][1])
   769 			tempG = SpawnAmmoCrate(specialPointsX[i],specialPointsY[i],atkArray[specialPointsFlag[i]-19][1])
   770 			setGearValue(tempG,"caseType","ammo")
       
   771 			setGearValue(tempG,"contents",atkArray[specialPointsFlag[i]-19][2])
   770 			setGearValue(tempG,"contents",atkArray[specialPointsFlag[i]-19][2])
   772 
   771 
   773 
   772 
   774 		-- Utility Crates
   773 		-- Utility Crates
   775 		elseif (specialPointsFlag[i] >= (#atkArray+20)) and (specialPointsFlag[i] < (#atkArray+20+#utilArray)) then
   774 		elseif (specialPointsFlag[i] >= (#atkArray+20)) and (specialPointsFlag[i] < (#atkArray+20+#utilArray)) then
   776 			tempG = SpawnUtilityCrate(specialPointsX[i],specialPointsY[i],utilArray[specialPointsFlag[i]-19-#atkArray][1])
   775 			tempG = SpawnUtilityCrate(specialPointsX[i],specialPointsY[i],utilArray[specialPointsFlag[i]-19-#atkArray][1])
   777 			setGearValue(tempG,"caseType","util")
       
   778 			setGearValue(tempG,"contents",utilArray[specialPointsFlag[i]-19-#atkArray][2])
   776 			setGearValue(tempG,"contents",utilArray[specialPointsFlag[i]-19-#atkArray][2])
   779 
   777 
   780 		--79-82 (reserved for future wep crates)
   778 		--79-82 (reserved for future wep crates)
   781 		--89,88,87,86 and 85,84,83,82 (reserved for the 2 custom sprites and their landflags)
   779 		--89,88,87,86 and 85,84,83,82 (reserved for the 2 custom sprites and their landflags)
   782 
   780 
  1164 	elseif cat[cIndex] == loc("Cleaver Placement Mode") then
  1162 	elseif cat[cIndex] == loc("Cleaver Placement Mode") then
  1165 		gear = AddGear(x, y, gtKnife, 0, 0, 0, 0)
  1163 		gear = AddGear(x, y, gtKnife, 0, 0, 0, 0)
  1166 	elseif cat[cIndex] == loc("Health Crate Placement Mode") then
  1164 	elseif cat[cIndex] == loc("Health Crate Placement Mode") then
  1167 		gear = SpawnHealthCrate(x,y)
  1165 		gear = SpawnHealthCrate(x,y)
  1168 		SetHealth(gear, pMode[pIndex])
  1166 		SetHealth(gear, pMode[pIndex])
  1169 		setGearValue(gear,"caseType","med")
       
  1170 	elseif cat[cIndex] == loc("Weapon Crate Placement Mode") then
  1167 	elseif cat[cIndex] == loc("Weapon Crate Placement Mode") then
  1171 		gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1])
  1168 		gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1])
  1172 		placedSpec[placedCount] = atkArray[pIndex][2]
  1169 		placedSpec[placedCount] = atkArray[pIndex][2]
  1173 		setGearValue(gear,"caseType","ammo")
       
  1174 		setGearValue(gear,"contents",atkArray[pIndex][2])
  1170 		setGearValue(gear,"contents",atkArray[pIndex][2])
  1175 	elseif cat[cIndex] == loc("Utility Crate Placement Mode") then
  1171 	elseif cat[cIndex] == loc("Utility Crate Placement Mode") then
  1176 		gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1])
  1172 		gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1])
  1177 		placedSpec[placedCount] = utilArray[pIndex][2]
  1173 		placedSpec[placedCount] = utilArray[pIndex][2]
  1178 		setGearValue(gear,"caseType","util")
       
  1179 		setGearValue(gear,"contents",utilArray[pIndex][2])
  1174 		setGearValue(gear,"contents",utilArray[pIndex][2])
  1180 	elseif cat[cIndex] == loc("Barrel Placement Mode") then
  1175 	elseif cat[cIndex] == loc("Barrel Placement Mode") then
  1181 		gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0)
  1176 		gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0)
  1182 		SetHealth(gear, pMode[pIndex])
  1177 		SetHealth(gear, pMode[pIndex])
  1183 	elseif cat[cIndex] == loc("Mine Placement Mode") then
  1178 	elseif cat[cIndex] == loc("Mine Placement Mode") then
  1739 
  1734 
  1740 	elseif GetGearType(gear) == gtCase then
  1735 	elseif GetGearType(gear) == gtCase then
  1741 
  1736 
  1742 		table.insert(previewDataList, "	PreviewPlacedGear(" .. GetX(gear) ..", " ..	GetY(gear) .. ")")
  1737 		table.insert(previewDataList, "	PreviewPlacedGear(" .. GetX(gear) ..", " ..	GetY(gear) .. ")")
  1743 
  1738 
  1744 		if (GetHealth(gear) ~= nil) then
  1739 		-- Health crate
       
  1740 		if band(GetGearPos(gear), 0x2) ~= 0 then
  1745 
  1741 
  1746 			temp = 	"	tempG = SpawnHealthCrate(" ..
  1742 			temp = 	"	tempG = SpawnHealthCrate(" ..
  1747 				GetX(gear) ..", " ..
  1743 				GetX(gear) ..", " ..
  1748 				GetY(gear) ..", " ..
  1744 				GetY(gear) ..", " ..
  1749 				GetHealth(gear) .. ")"
  1745 				GetHealth(gear) .. ")"
  1756 			elseif	GetHealth(gear) == 50 then specialFlag = 10
  1752 			elseif	GetHealth(gear) == 50 then specialFlag = 10
  1757 			elseif	GetHealth(gear) == 75 then specialFlag = 11
  1753 			elseif	GetHealth(gear) == 75 then specialFlag = 11
  1758 			elseif	GetHealth(gear) == 100 then specialFlag = 12
  1754 			elseif	GetHealth(gear) == 100 then specialFlag = 12
  1759 			end
  1755 			end
  1760 
  1756 
  1761 		elseif getGearValue(gear,"caseType") == "ammo" then
  1757 		-- Ammo crate
       
  1758 		elseif band(GetGearPos(gear), 0x1) ~= 0 then
  1762 
  1759 
  1763 			arrayList = wepCrateList
  1760 			arrayList = wepCrateList
  1764 			temp = 	"	tempG = SpawnAmmoCrate(" ..
  1761 			temp = 	"	tempG = SpawnAmmoCrate(" ..
  1765 					GetX(gear) ..", " ..
  1762 					GetX(gear) ..", " ..
  1766 					GetY(gear) ..", " ..
  1763 					GetY(gear) ..", " ..
  1773 				if tempV == atkArray[i][2] then
  1770 				if tempV == atkArray[i][2] then
  1774 					specialFlag = i + 19
  1771 					specialFlag = i + 19
  1775 				end
  1772 				end
  1776 			end
  1773 			end
  1777 
  1774 
  1778 			--dammit, we probably need two more entries if we want to allow editing of existing maps
  1775 			--dammit, we probably need more entries if we want to allow editing of existing maps
  1779 			table.insert(wepCrateList, "	setGearValue(tempG, \"caseType\", \"" .. getGearValue(gear,"caseType") .. "\")")
       
  1780 			table.insert(wepCrateList, "	setGearValue(tempG, \"contents\", \"" .. getGearValue(gear,"contents") .. "\")")
  1776 			table.insert(wepCrateList, "	setGearValue(tempG, \"contents\", \"" .. getGearValue(gear,"contents") .. "\")")
  1781 
  1777 
  1782 
  1778 		-- Utility crate
  1783 		elseif getGearValue(gear,"caseType") == "util" then
  1779 		elseif band(GetGearPos(gear), 0x4) ~= 0 then
  1784 
  1780 
  1785 			arrayList = utilCrateList
  1781 			arrayList = utilCrateList
  1786 			temp = 	"	tempG = SpawnUtilityCrate(" ..
  1782 			temp = 	"	tempG = SpawnUtilityCrate(" ..
  1787 					GetX(gear) ..", " ..
  1783 					GetX(gear) ..", " ..
  1788 					GetY(gear) ..", " ..
  1784 					GetY(gear) ..", " ..
  1795 				if tempV == utilArray[i][2] then
  1791 				if tempV == utilArray[i][2] then
  1796 					specialFlag = i + 19 + #atkArray
  1792 					specialFlag = i + 19 + #atkArray
  1797 				end
  1793 				end
  1798 			end
  1794 			end
  1799 
  1795 
  1800 			--dammit, we probably need two more entries if we want to allow editing of existing maps
  1796 			--dammit, we probably need more entries if we want to allow editing of existing maps
  1801 			table.insert(utilCrateList, "	setGearValue(tempG, \"caseType\", \"" .. getGearValue(gear,"caseType") .. "\")")
       
  1802 			table.insert(utilCrateList, "	setGearValue(tempG, \"contents\", \"" .. getGearValue(gear,"contents") .. "\")")
  1797 			table.insert(utilCrateList, "	setGearValue(tempG, \"contents\", \"" .. getGearValue(gear,"contents") .. "\")")
  1803 
  1798 
  1804 		end
  1799 		end
  1805 
  1800 
  1806 	end
  1801 	end