share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
changeset 12941 ffbd31afed96
parent 12792 8fa21750470f
child 12956 89930daecaab
equal deleted inserted replaced
12940:39b7b3ed619e 12941:ffbd31afed96
   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
   256 -- experimental crap
   257 --local destroyMap = false
   257 --local destroyMap = false
       
   258 
       
   259 -- Fake ammo type for the gear placement tool
       
   260 local amCMGearPlacementTool = amAirAttack
   258 
   261 
   259 -- Special frames in Ammos.png/Ammos_bw.png
   262 -- Special frames in Ammos.png/Ammos_bw.png
   260 local ammoFrameAirAttack = 63
   263 local ammoFrameAirAttack = 63
   261 
   264 
   262 -----------------------------------------
   265 -----------------------------------------
  2454 function updateHelp(curAmmoType)
  2457 function updateHelp(curAmmoType)
  2455 	if curAmmoType == nil then
  2458 	if curAmmoType == nil then
  2456 		curAmmoType = GetCurAmmoType()
  2459 		curAmmoType = GetCurAmmoType()
  2457 	end
  2460 	end
  2458 
  2461 
  2459 	if (curAmmoType ~= amGirder) and (curAmmoType ~= amRubber) and (curAmmoType ~= amAirAttack) then
  2462 	if (curAmmoType ~= amGirder) and (curAmmoType ~= amRubber) and (curAmmoType ~= amCMGearPlacementTool) then
  2460 
  2463 
  2461 		if not hedgeEditorMissionPanelShown then
  2464 		if not hedgeEditorMissionPanelShown then
  2462 			showHedgeEditorMissionPanel()
  2465 			showHedgeEditorMissionPanel()
  2463 		end
  2466 		end
  2464 
  2467 
  2553 				loc("Toggle Placement/Deletion: [Left], [Right]") .. "|" ..
  2556 				loc("Toggle Placement/Deletion: [Left], [Right]") .. "|" ..
  2554 				" " .. "|" ..
  2557 				" " .. "|" ..
  2555 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
  2558 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
  2556 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
  2559 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
  2557 				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
  2560 				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
  2558 				"", -amAirAttack, 60000
  2561 				"", -amCMGearPlacementTool, 60000
  2559 				)
  2562 				)
  2560 		hedgeEditorMissionPanelShown = false
  2563 		hedgeEditorMissionPanelShown = false
  2561 
  2564 
  2562 	elseif cat[cIndex] == loc("Mine Placement Mode") then
  2565 	elseif cat[cIndex] == loc("Mine Placement Mode") then
  2563 
  2566 
  2673 				loc("Choose Selection/Placement/Deletion: [Left], [Right]") .. "|" ..
  2676 				loc("Choose Selection/Placement/Deletion: [Left], [Right]") .. "|" ..
  2674 				" " .. "|" ..
  2677 				" " .. "|" ..
  2675 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
  2678 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
  2676 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
  2679 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
  2677 				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
  2680 				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
  2678 				"", -amAirAttack, 60000
  2681 				"", -amCMGearPlacementTool, 60000
  2679 				)
  2682 				)
  2680 		hedgeEditorMissionPanelShown = false
  2683 		hedgeEditorMissionPanelShown = false
  2681 
  2684 
  2682 	elseif cat[cIndex] == loc("Sprite Modification Mode") then
  2685 	elseif cat[cIndex] == loc("Sprite Modification Mode") then
  2683 
  2686 
  2715 				loc("Bouncy Land: [4]") .. "|" ..
  2718 				loc("Bouncy Land: [4]") .. "|" ..
  2716 				" " .. "|" ..
  2719 				" " .. "|" ..
  2717 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
  2720 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
  2718 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
  2721 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
  2719 				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
  2722 				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
  2720 				"", -amAirAttack, 60000
  2723 				"", -amCMGearPlacementTool, 60000
  2721 				)
  2724 				)
  2722 		hedgeEditorMissionPanelShown = false
  2725 		hedgeEditorMissionPanelShown = false
  2723 
  2726 
  2724 	elseif cat[cIndex] == loc("Goal Definition Mode") then
  2727 	elseif cat[cIndex] == loc("Goal Definition Mode") then
  2725 
  2728 
  2811 		tSprCol = 0x00000000
  2814 		tSprCol = 0x00000000
  2812 		tempFrame = 0
  2815 		tempFrame = 0
  2813 		xDisplacement = 42
  2816 		xDisplacement = 42
  2814 		yDisplacement = 42
  2817 		yDisplacement = 42
  2815 
  2818 
  2816 		if (curWep == amAirAttack) then
  2819 		if (curWep == amCMGearPlacementTool) then
  2817 
  2820 
  2818 			--wowaweewa, holyeeeee shite this is badly hacked (please rewrite when less lazy/morefeatures)
  2821 			--wowaweewa, holyeeeee shite this is badly hacked (please rewrite when less lazy/morefeatures)
  2819 			dCol = 0xFFFFFFFF
  2822 			dCol = 0xFFFFFFFF
  2820 			dFrame = 0
  2823 			dFrame = 0
  2821 			dAngle = 0
  2824 			dAngle = 0
  2844 				dAngle = 270
  2847 				dAngle = 270
  2845 				dSprite = sprKnife
  2848 				dSprite = sprKnife
  2846 			elseif (cat[cIndex] == loc("Sprite Placement Mode")) then
  2849 			elseif (cat[cIndex] == loc("Sprite Placement Mode")) then
  2847 				dSprite = reducedSpriteIDArray[pIndex]
  2850 				dSprite = reducedSpriteIDArray[pIndex]
  2848 				dFrame = sFrame
  2851 				dFrame = sFrame
  2849 				if ((dSprite == sprAMAmmos) or (dSprite == sprAMAmmosBW)) and (dFrame == (amAirAttack - 1)) then
  2852 				if ((dSprite == sprAMAmmos) or (dSprite == sprAMAmmosBW)) and (dFrame == (amCMGearPlacementTool - 1)) then
  2850 					-- Special case: Air attack icon of ammos sprite needs to be fixed (since this icon is overwritten)
  2853 					-- Special case: Air attack icon of ammos sprite needs to be fixed (since this icon is overwritten)
  2851 					dFrame = ammoFrameAirAttack
  2854 					dFrame = ammoFrameAirAttack
  2852 				end
  2855 				end
  2853 			else
  2856 			else
  2854 				dCol = 0xFFFFFF00
  2857 				dCol = 0xFFFFFF00
  2927 				cIndex = 3 --new
  2930 				cIndex = 3 --new
  2928 				RedefineSubset()
  2931 				RedefineSubset()
  2929 			end
  2932 			end
  2930 
  2933 
  2931 			-- update display selection criteria
  2934 			-- update display selection criteria
  2932 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amAirAttack) then
  2935 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMGearPlacementTool) then
  2933 				AddCaption(cat[cIndex],0xffba00ff,capgrpMessage)
  2936 				AddCaption(cat[cIndex],0xffba00ff,capgrpMessage)
  2934 				showSecondaryMessage()
  2937 				showSecondaryMessage()
  2935 				if superDelete == true then
  2938 				if superDelete == true then
  2936 					AddCaption(loc("Deletition Mode"),0xffba00ff,capgrpAmmoinfo)
  2939 					AddCaption(loc("Deletition Mode"),0xffba00ff,capgrpAmmoinfo)
  2937 				end
  2940 				end
  2976 	-- some kind of target detected, tell me your story
  2979 	-- some kind of target detected, tell me your story
  2977 	if cGear ~= nil then
  2980 	if cGear ~= nil then
  2978 
  2981 
  2979 		x,y = GetGearTarget(cGear)
  2982 		x,y = GetGearTarget(cGear)
  2980 
  2983 
  2981 		if GetGearType(cGear) == gtAirAttack and GetCurAmmoType() == amAirAttack then
  2984 		if GetGearType(cGear) == gtAirAttack and GetCurAmmoType() == amCMGearPlacementTool then
  2982 			DeleteGear(cGear)
  2985 			DeleteGear(cGear)
  2983 			PlaceObject(x, y)
  2986 			PlaceObject(x, y)
  2984 		elseif GetGearType(cGear) == gtGirder then
  2987 		elseif GetGearType(cGear) == gtGirder then
  2985 
  2988 
  2986 			CGR = GetState(cGear)
  2989 			CGR = GetState(cGear)
  3122 
  3125 
  3123 	superDelete = false
  3126 	superDelete = false
  3124 	if (commandMode() == true) and (s == 4) then
  3127 	if (commandMode() == true) and (s == 4) then
  3125 		SaveLevelData() -- positions of crates, etc
  3128 		SaveLevelData() -- positions of crates, etc
  3126 	elseif (commandMode() == true) and (s == 2) then
  3129 	elseif (commandMode() == true) and (s == 2) then
  3127 		if GetAmmoCount(CurrentHedgehog, amAirAttack) == 100 then
  3130 		if GetAmmoCount(CurrentHedgehog, amCMGearPlacementTool) == 100 then
  3128 			SetEditingWeps(0)
  3131 			SetEditingWeps(0)
  3129 			AddCaption(loc("The editor weapons and tools have been removed!"))
  3132 			AddCaption(loc("The editor weapons and tools have been removed!"))
  3130 		else
  3133 		else
  3131 			SetEditingWeps(100)
  3134 			SetEditingWeps(100)
  3132 			AddCaption(loc("The editor weapons and tools have been added!"))
  3135 			AddCaption(loc("The editor weapons and tools have been added!"))
  3227 --		timer of mines
  3230 --		timer of mines
  3228 --		contents of crates etc.
  3231 --		contents of crates etc.
  3229 ---------------------------------------------------------------
  3232 ---------------------------------------------------------------
  3230 function onLeft()
  3233 function onLeft()
  3231 
  3234 
  3232 	if (curWep == amAirAttack) then
  3235 	if (curWep == amCMGearPlacementTool) then
  3233 		leftHeld = true
  3236 		leftHeld = true
  3234 		rightHeld = false
  3237 		rightHeld = false
  3235 
  3238 
  3236 		if preciseOn then
  3239 		if preciseOn then
  3237 			if cat[cIndex] == loc("Sprite Placement Mode") then
  3240 			if cat[cIndex] == loc("Sprite Placement Mode") then
  3247 			end
  3250 			end
  3248 			if cat[cIndex] == loc("Sprite Placement Mode") then
  3251 			if cat[cIndex] == loc("Sprite Placement Mode") then
  3249 				sFrame = math.min(sFrame, reducedSpriteIDArrayFrames[pIndex] - 1)
  3252 				sFrame = math.min(sFrame, reducedSpriteIDArrayFrames[pIndex] - 1)
  3250 			end
  3253 			end
  3251 
  3254 
  3252 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amAirAttack) then
  3255 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMGearPlacementTool) then
  3253 				showSecondaryMessage()
  3256 				showSecondaryMessage()
  3254 			end
  3257 			end
  3255 		end
  3258 		end
  3256 	end
  3259 	end
  3257 
  3260 
  3258 end
  3261 end
  3259 
  3262 
  3260 function onRight()
  3263 function onRight()
  3261 
  3264 
  3262 	if (curWep == amAirAttack) then
  3265 	if (curWep == amCMGearPlacementTool) then
  3263 		leftHeld = false
  3266 		leftHeld = false
  3264 		rightHeld = true
  3267 		rightHeld = true
  3265 
  3268 
  3266 		if preciseOn then
  3269 		if preciseOn then
  3267 			if cat[cIndex] == loc("Sprite Placement Mode") then
  3270 			if cat[cIndex] == loc("Sprite Placement Mode") then
  3277 			end
  3280 			end
  3278 			if cat[cIndex] == loc("Sprite Placement Mode") then
  3281 			if cat[cIndex] == loc("Sprite Placement Mode") then
  3279 				sFrame = math.min(sFrame, reducedSpriteIDArrayFrames[pIndex] - 1)
  3282 				sFrame = math.min(sFrame, reducedSpriteIDArrayFrames[pIndex] - 1)
  3280 			end
  3283 			end
  3281 
  3284 
  3282 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amAirAttack) then
  3285 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMGearPlacementTool) then
  3283 				showSecondaryMessage()
  3286 				showSecondaryMessage()
  3284 			end
  3287 			end
  3285 		end
  3288 		end
  3286 	end
  3289 	end
  3287 
  3290 
  3292 -- i.e 	mine, sticky mine, barrels
  3295 -- i.e 	mine, sticky mine, barrels
  3293 --		health/weapon/utility crate, placement of gears
  3296 --		health/weapon/utility crate, placement of gears
  3294 ---------------------------------------------------------
  3297 ---------------------------------------------------------
  3295 function onUp()
  3298 function onUp()
  3296 
  3299 
  3297 	if (curWep == amAirAttack) then
  3300 	if (curWep == amCMGearPlacementTool) then
  3298 		cIndex = cIndex - 1
  3301 		cIndex = cIndex - 1
  3299 		if (cIndex == 1) or (cIndex == 2) then --1	--we no longer hit girder by normal means
  3302 		if (cIndex == 1) or (cIndex == 2) then --1	--we no longer hit girder by normal means
  3300 			cIndex = #cat
  3303 			cIndex = #cat
  3301 		end
  3304 		end
  3302 
  3305 
  3307 
  3310 
  3308 end
  3311 end
  3309 
  3312 
  3310 function onDown()
  3313 function onDown()
  3311 
  3314 
  3312 	if (curWep == amAirAttack) then
  3315 	if (curWep == amCMGearPlacementTool) then
  3313 		cIndex = cIndex + 1
  3316 		cIndex = cIndex + 1
  3314 		if cIndex > #cat then
  3317 		if cIndex > #cat then
  3315 			cIndex = 3	 -- 2 ----we no longer hit girder by normal means
  3318 			cIndex = 3	 -- 2 ----we no longer hit girder by normal means
  3316 		end
  3319 		end
  3317 
  3320 
  3401 		loc("Save Level: [Precise]+[4]") .. "|" ..
  3404 		loc("Save Level: [Precise]+[4]") .. "|" ..
  3402 		loc("Toggle Editing Weapons and Tools: [Precise]+[2]")
  3405 		loc("Toggle Editing Weapons and Tools: [Precise]+[2]")
  3403 		, 4, 5000
  3406 		, 4, 5000
  3404 		)
  3407 		)
  3405 
  3408 
  3406 	SetAmmoTexts(amAirAttack,
  3409 	SetAmmoTexts(amCMGearPlacementTool,
  3407 		loc("Gear Placement Tool"),
  3410 		loc("Gear Placement Tool"),
  3408 		loc("HedgeEditor tool"),
  3411 		loc("HedgeEditor tool"),
  3409 		loc("Place, modify and delete gears (e.g. objects)|and waypoints, edit hedgehog settings, values,|victory conditions, and more.") .. "|" ..
  3412 		loc("Place, modify and delete gears (e.g. objects)|and waypoints, edit hedgehog settings, values,|victory conditions, and more.") .. "|" ..
  3410 		loc("Select a placement mode and read the infos|in the mission panel to learn how to use it.") .. "|" ..
  3413 		loc("Select a placement mode and read the infos|in the mission panel to learn how to use it.") .. "|" ..
  3411 		loc("Up/Down: Change placement mode") .. "|" ..
  3414 		loc("Up/Down: Change placement mode") .. "|" ..
  3434 	frameID = 1
  3437 	frameID = 1
  3435 	visualSprite = sprAmGirder
  3438 	visualSprite = sprAmGirder
  3436 	sSprite = AddVisualGear(0, 0, vgtStraightShot, 0, true,1)
  3439 	sSprite = AddVisualGear(0, 0, vgtStraightShot, 0, true,1)
  3437 	SetVisualGearValues(sSprite, 1, 1, 0, 0, nil, frameID, 20000, visualSprite, 20000, 0 )
  3440 	SetVisualGearValues(sSprite, 1, 1, 0, 0, nil, frameID, 20000, visualSprite, 20000, 0 )
  3438 
  3441 
  3439 	SetAmmoDelay(amAirAttack,0)
  3442 	SetAmmoDelay(amCMGearPlacementTool,0)
  3440 	SetAmmoDelay(amGirder,0)
  3443 	SetAmmoDelay(amGirder,0)
  3441 	SetAmmoDelay(amRubber,0)
  3444 	SetAmmoDelay(amRubber,0)
  3442 
  3445 
  3443 end
  3446 end
  3444 
  3447 
  3445 function SetEditingWeps(ammoCount)
  3448 function SetEditingWeps(ammoCount)
  3446 
  3449 
  3447 	AddAmmo(CurrentHedgehog, amAirAttack, ammoCount)
  3450 	AddAmmo(CurrentHedgehog, amCMGearPlacementTool, ammoCount)
  3448 	AddAmmo(CurrentHedgehog, amGirder, ammoCount)
  3451 	AddAmmo(CurrentHedgehog, amGirder, ammoCount)
  3449 	AddAmmo(CurrentHedgehog, amRubber, ammoCount)
  3452 	AddAmmo(CurrentHedgehog, amRubber, ammoCount)
  3450 	AddAmmo(CurrentHedgehog, amTeleport, ammoCount)
  3453 	AddAmmo(CurrentHedgehog, amTeleport, ammoCount)
  3451 	AddAmmo(CurrentHedgehog, amRope, ammoCount)
  3454 	AddAmmo(CurrentHedgehog, amRope, ammoCount)
  3452 	AddAmmo(CurrentHedgehog, amSwitch, 100)
  3455 	AddAmmo(CurrentHedgehog, amSwitch, 100)
  3723 		if (ufoFuel ~= 0) then
  3726 		if (ufoFuel ~= 0) then
  3724 			SetHealth(ufoGear, ufoFuel)
  3727 			SetHealth(ufoGear, ufoFuel)
  3725 		end
  3728 		end
  3726 	end
  3729 	end
  3727 
  3730 
  3728 	if (GetGearType(gear) == gtAirAttack and GetCurAmmoType() == amAirAttack) or (GetGearType(gear) == gtGirder) then
  3731 	if (GetGearType(gear) == gtAirAttack and GetCurAmmoType() == amCMGearPlacementTool) or (GetGearType(gear) == gtGirder) then
  3729 		cGear = gear
  3732 		cGear = gear
  3730 	end
  3733 	end
  3731 
  3734 
  3732 	local tagTint
  3735 	local tagTint
  3733 	if showGearTags then
  3736 	if showGearTags then