share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
changeset 12976 4772eb3c9929
parent 12962 52c12029c7bd
child 13033 a823de31240e
equal deleted inserted replaced
12975:6d328f116044 12976:4772eb3c9929
   251 HedgewarsScriptLoad("/Scripts/Locale.lua")
   251 HedgewarsScriptLoad("/Scripts/Locale.lua")
   252 HedgewarsScriptLoad("/Scripts/Tracker.lua")
   252 HedgewarsScriptLoad("/Scripts/Tracker.lua")
   253 HedgewarsScriptLoad("/Scripts/Params.lua")
   253 HedgewarsScriptLoad("/Scripts/Params.lua")
   254 HedgewarsScriptLoad("/Scripts/TechMaps.lua")
   254 HedgewarsScriptLoad("/Scripts/TechMaps.lua")
   255 
   255 
   256 -- experimental crap
       
   257 --local destroyMap = false
       
   258 
       
   259 -- Fake ammo type for the gear placement tool
   256 -- Fake ammo type for the gear placement tool
   260 local amCMGearPlacementTool = amAirAttack
   257 local amCMGearPlacementTool = amAirAttack
   261 
   258 
   262 -- Special frames in Ammos.png/Ammos_bw.png
   259 -- Special frames in Ammos.png/Ammos_bw.png
   263 local ammoFrameAirAttack = 63
   260 local ammoFrameAirAttack = 63
       
   261 
       
   262 -- Caption colors
       
   263 local colorErrorMessage = 0xFFFFFFFF
       
   264 local colorInfoMessage = 0xFFFFFFFF
       
   265 local colorPlaceMode1 = 0xFFBA00FF -- Main placement mode
       
   266 local colorPlaceMode2 = 0xFFDE85FF -- Secondary mode
   264 
   267 
   265 -----------------------------------------
   268 -----------------------------------------
   266 -- tracking vars for save/load purposes
   269 -- tracking vars for save/load purposes
   267 -----------------------------------------
   270 -----------------------------------------
   268 
   271 
  1184 				SetGearPosition(sGear, x, y)
  1187 				SetGearPosition(sGear, x, y)
  1185 			end
  1188 			end
  1186 		elseif pMode[pIndex] == loc("Deletion Mode") then
  1189 		elseif pMode[pIndex] == loc("Deletion Mode") then
  1187 			sGear = GetClosestGear()
  1190 			sGear = GetClosestGear()
  1188 			if (sGear == nil) then
  1191 			if (sGear == nil) then
  1189 				AddCaption(loc("Please click on a gear."),0xffba00ff,capgrpVolume)
  1192 				AddCaption(loc("Please click on a gear."), colorErrorMessage, capgrpVolume)
  1190 			elseif (GetGearType(sGear) == gtHedgehog) then
  1193 			elseif (GetGearType(sGear) == gtHedgehog) then
  1191 				AddCaption(loc("Hedgehogs can not be deleted."),0xffba00ff,capgrpVolume)
  1194 				AddCaption(loc("Hedgehogs can not be deleted."), colorErrorMessage, capgrpVolume)
  1192 			else
  1195 			else
  1193 				DeleteGear(sGear)
  1196 				DeleteGear(sGear)
  1194 			end
  1197 			end
  1195 			sGear = nil
  1198 			sGear = nil
  1196 		end
  1199 		end
  1203 				SetHogProfile(sGear, pMode[pIndex])
  1206 				SetHogProfile(sGear, pMode[pIndex])
  1204 			else -- set for the whole team
  1207 			else -- set for the whole team
  1205 				SetTeamIdentity(sGear)
  1208 				SetTeamIdentity(sGear)
  1206 			end
  1209 			end
  1207 		else
  1210 		else
  1208 			AddCaption(loc("Please click on a hedgehog."),0xffba00ff,capgrpVolume)
  1211 			AddCaption(loc("Please click on a hedgehog."), colorErrorMessage, capgrpVolume)
  1209 		end
  1212 		end
  1210 
  1213 
  1211 
  1214 
  1212 
  1215 
  1213 	elseif cat[cIndex] == loc("Health Modification Mode") then
  1216 	elseif cat[cIndex] == loc("Health Modification Mode") then
  1235 			end
  1238 			end
  1236 			if newHealth ~= nil then
  1239 			if newHealth ~= nil then
  1237 				SetGearValues(sGear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 36 - newHealth)
  1240 				SetGearValues(sGear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 36 - newHealth)
  1238 			end
  1241 			end
  1239 		else
  1242 		else
  1240 			AddCaption(loc("Please click on a hedgehog, barrel, health crate or dud mine."),0xffba00ff,capgrpVolume)
  1243 			AddCaption(loc("Please click on a hedgehog, barrel, health crate or dud mine."), colorErrorMessage, capgrpVolume)
  1241 		end
  1244 		end
  1242 
  1245 
  1243 	elseif cat[cIndex] == loc("Sprite Modification Mode") then
  1246 	elseif cat[cIndex] == loc("Sprite Modification Mode") then
  1244 
  1247 
  1245 		SelectClosestSprite()
  1248 		SelectClosestSprite()
  1269 
  1272 
  1270 				if pMode[pIndex] == loc("Victory Condition: Collect") then
  1273 				if pMode[pIndex] == loc("Victory Condition: Collect") then
  1271 					if GetGearType(sGear) == gtCase then
  1274 					if GetGearType(sGear) == gtCase then
  1272 						setGearValue(sGear, "tag","collection")
  1275 						setGearValue(sGear, "tag","collection")
  1273 					else
  1276 					else
  1274 						AddCaption(loc("Please click on a crate."),0xffba00ff,capgrpVolume)
  1277 						AddCaption(loc("Please click on a crate."), colorErrorMessage, capgrpVolume)
  1275 					end
  1278 					end
  1276 				else
  1279 				else
  1277 					if pMode[pIndex] == loc("Victory Condition: Destroy") then
  1280 					if pMode[pIndex] == loc("Victory Condition: Destroy") then
  1278 						setGearValue(sGear, "tag","victory")
  1281 						setGearValue(sGear, "tag","victory")
  1279 					elseif pMode[pIndex] == loc("Losing Condition: Destroy") then
  1282 					elseif pMode[pIndex] == loc("Losing Condition: Destroy") then
  2351 
  2354 
  2352 	ConvertGearDataToHWPText()
  2355 	ConvertGearDataToHWPText()
  2353 
  2356 
  2354 	WriteLnToConsole("------ END GENERATED SCRIPT ------")
  2357 	WriteLnToConsole("------ END GENERATED SCRIPT ------")
  2355 
  2358 
  2356 	AddCaption(loc("Level Data Saved!"))
  2359 	AddCaption(loc("Level Data Saved!"), colorInfoMessage, capgrpGameState)
  2357 
  2360 
  2358 end
  2361 end
  2359 
  2362 
  2360 ----------------------------------
  2363 ----------------------------------
  2361 -- some special effects handling
  2364 -- some special effects handling
  2932 				RedefineSubset()
  2935 				RedefineSubset()
  2933 			end
  2936 			end
  2934 
  2937 
  2935 			-- update display selection criteria
  2938 			-- update display selection criteria
  2936 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMGearPlacementTool) then
  2939 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMGearPlacementTool) then
  2937 				AddCaption(cat[cIndex],0xffba00ff,capgrpMessage)
  2940 				AddCaption(cat[cIndex], colorPlaceMode1, capgrpMessage)
  2938 				showSecondaryMessage()
  2941 				showSecondaryMessage()
  2939 				if superDelete == true then
  2942 				if superDelete == true then
  2940 					AddCaption(loc("Deletition Mode"),0xffba00ff,capgrpAmmoinfo)
  2943 					AddCaption(loc("Deletition Mode"), colorPlaceMode1, capgrpAmmoinfo)
  2941 				end
  2944 				end
  2942 			end
  2945 			end
  2943 
  2946 
  2944 
  2947 
  2945 			if sSprite ~= nil then
  2948 			if sSprite ~= nil then
  3128 	if (commandMode() == true) and (s == 4) then
  3131 	if (commandMode() == true) and (s == 4) then
  3129 		SaveLevelData() -- positions of crates, etc
  3132 		SaveLevelData() -- positions of crates, etc
  3130 	elseif (commandMode() == true) and (s == 2) then
  3133 	elseif (commandMode() == true) and (s == 2) then
  3131 		if GetAmmoCount(CurrentHedgehog, amCMGearPlacementTool) == 100 then
  3134 		if GetAmmoCount(CurrentHedgehog, amCMGearPlacementTool) == 100 then
  3132 			SetEditingWeps(0)
  3135 			SetEditingWeps(0)
  3133 			AddCaption(loc("The editor weapons and tools have been removed!"))
  3136 			AddCaption(loc("The editor weapons and tools have been removed!"), colorInfoMessage, capgrpGameState)
  3134 		else
  3137 		else
  3135 			SetEditingWeps(100)
  3138 			SetEditingWeps(100)
  3136 			AddCaption(loc("The editor weapons and tools have been added!"))
  3139 			AddCaption(loc("The editor weapons and tools have been added!"), colorInfoMessage, capgrpGameState)
  3137 		end
  3140 		end
  3138 	elseif (preciseOn == true) and (s == 1) then
  3141 	elseif (preciseOn == true) and (s == 1) then
  3139 		helpDisabled = not(helpDisabled)
  3142 		helpDisabled = not(helpDisabled)
  3140 		if helpDisabled then
  3143 		if helpDisabled then
  3141 			AddCaption(loc("Help Disabled"),0xffba00ff,capgrpVolume)
  3144 			AddCaption(loc("Help Disabled"), colorInfoMessage, capgrpVolume)
  3142 		else
  3145 		else
  3143 			AddCaption(loc("Help Enabled"),0xffba00ff,capgrpVolume)
  3146 			AddCaption(loc("Help Enabled"), colorInfoMessage, capgrpVolume)
  3144 		end
  3147 		end
  3145 		updateHelp()
  3148 		updateHelp()
  3146 	elseif (preciseOn == true) and (s == 3) then
  3149 	elseif (preciseOn == true) and (s == 3) then
  3147 		showGearTags = not(showGearTags)
  3150 		showGearTags = not(showGearTags)
  3148 		if showGearTags then
  3151 		if showGearTags then
  3149 			AddCaption(loc("Gear information shown"),0xffba00ff,capgrpVolume)
  3152 			AddCaption(loc("Gear information shown"), colorInfoMessage, capgrpVolume)
  3150 		else
  3153 		else
  3151 			AddCaption(loc("Gear information hidden"),0xffba00ff,capgrpVolume)
  3154 			AddCaption(loc("Gear information hidden"), colorInfoMessage, capgrpVolume)
  3152 		end
  3155 		end
  3153 
  3156 
  3154 	elseif (cat[cIndex] == loc("Sprite Placement Mode")) or (cat[cIndex] == loc("Girder Placement Mode")) or (cat[cIndex] == loc("Rubber Placement Mode")) or (cat[cIndex] == loc("Sprite Modification Mode")) then
  3157 	elseif (cat[cIndex] == loc("Sprite Placement Mode")) or (cat[cIndex] == loc("Girder Placement Mode")) or (cat[cIndex] == loc("Rubber Placement Mode")) or (cat[cIndex] == loc("Sprite Modification Mode")) then
  3155 
  3158 
  3156 		if (cat[cIndex] == loc("Rubber Placement Mode")) then
  3159 		if (cat[cIndex] == loc("Rubber Placement Mode")) then
  3157 			if s == 1 then
  3160 			if s == 1 then
  3158 				landType = lfBouncy
  3161 				landType = lfBouncy
  3159 				AddCaption(loc("Bouncy Land"),0xffba00ff,capgrpAmmoinfo)
  3162 				AddCaption(loc("Bouncy Land"), colorPlaceMode1, capgrpAmmoinfo)
  3160 			elseif s == 5 then
  3163 			elseif s == 5 then
  3161 				superDelete = true
  3164 				superDelete = true
  3162 			end
  3165 			end
  3163 		elseif s == 1 then
  3166 		elseif s == 1 then
  3164 			landType = 0
  3167 			landType = 0
  3165 			AddCaption(loc("Normal Land"),0xffba00ff,capgrpAmmoinfo)
  3168 			AddCaption(loc("Normal Land"), colorPlaceMode1, capgrpAmmoinfo)
  3166 		elseif s == 2 then
  3169 		elseif s == 2 then
  3167 			landType = lfIndestructible
  3170 			landType = lfIndestructible
  3168 			AddCaption(loc("Indestructible Land"),0xffba00ff,capgrpAmmoinfo)
  3171 			AddCaption(loc("Indestructible Land"), colorPlaceMode1, capgrpAmmoinfo)
  3169 		elseif s == 3 then
  3172 		elseif s == 3 then
  3170 			landType = lfIce
  3173 			landType = lfIce
  3171 			AddCaption(loc("Icy Land"),0xffba00ff,capgrpAmmoinfo)
  3174 			AddCaption(loc("Icy Land"), colorPlaceMode1, capgrpAmmoinfo)
  3172 		elseif (s == 4) then
  3175 		elseif (s == 4) then
  3173 			landType = lfBouncy
  3176 			landType = lfBouncy
  3174 			AddCaption(loc("Bouncy Land"),0xffba00ff,capgrpAmmoinfo)
  3177 			AddCaption(loc("Bouncy Land"), colorPlaceMode1, capgrpAmmoinfo)
  3175 		elseif (s == 5) and (cat[cIndex] ~= loc("Sprite Modification Mode")) and (cat[cIndex] ~= loc("Sprite Placement Mode")) then
  3178 		elseif (s == 5) and (cat[cIndex] ~= loc("Sprite Modification Mode")) and (cat[cIndex] ~= loc("Sprite Placement Mode")) then
  3176 			superDelete = true
  3179 			superDelete = true
  3177 		end
  3180 		end
  3178 	elseif pMode[pIndex] == loc("Selection Mode") then
  3181 	elseif pMode[pIndex] == loc("Selection Mode") then
  3179 		if sGear ~= nil and GetGearType(sGear) == gtHedgehog then
  3182 		if sGear ~= nil and GetGearType(sGear) == gtHedgehog then
  3220 	elseif type(pMode[pIndex]) == "table" then
  3223 	elseif type(pMode[pIndex]) == "table" then
  3221 		caption2 = tostring(pMode[pIndex][1])
  3224 		caption2 = tostring(pMode[pIndex][1])
  3222 	else
  3225 	else
  3223 		caption2 = tostring(pMode[pIndex])
  3226 		caption2 = tostring(pMode[pIndex])
  3224 	end
  3227 	end
  3225 	AddCaption(caption2, 0xffba00ff, capgrpMessage2)
  3228 	AddCaption(caption2, colorPlaceMode2, capgrpMessage2)
  3226 end
  3229 end
  3227 
  3230 
  3228 ---------------------------------------------------------------
  3231 ---------------------------------------------------------------
  3229 -- Cycle through selection subsets (by changing pIndex, pMode)
  3232 -- Cycle through selection subsets (by changing pIndex, pMode)
  3230 -- i.e 	health of barrels, medikits,
  3233 -- i.e 	health of barrels, medikits,