share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
changeset 14658 93a7b78259fb
parent 14345 ef7501d9935c
child 14659 46ac6fbde6f6
equal deleted inserted replaced
14657:b390479f24c1 14658:93a7b78259fb
  3106 
  3106 
  3107 	-- Show cursor coords
  3107 	-- Show cursor coords
  3108 	updateCursorCoords()
  3108 	updateCursorCoords()
  3109 
  3109 
  3110 	-- Barrel health tags, mine timer tags and health crate health tags
  3110 	-- Barrel health tags, mine timer tags and health crate health tags
  3111 	do
  3111 	if GameTime % 20 == 0 then
  3112 		local actualValue	-- internal value
  3112 		local actualValue	-- internal value
  3113 		local printedValue	-- value exposed to HUD
  3113 		local printedValue	-- value exposed to HUD
  3114 		for g, v in pairs(tagGears) do
  3114 		for g, v in pairs(tagGears) do
  3115 			local gt = GetGearType(g)
  3115 			local gt = GetGearType(g)
  3116 			if v == -1 then
  3116 			if v == -1 then
  3117 				if gt == gtCase then
  3117 				if gt == gtCase then
  3118 					if(band(GetGearPos(g), 0x2) ~= 0) then
  3118 					if(band(GetGearPos(g), 0x2) ~= 0) and (band(GetState(g), gstFrozen) == 0) then
  3119 						v = AddVisualGear(0, 0, vgtHealthTag, GetHealth(g), true)
  3119 						v = AddVisualGear(0, 0, vgtHealthTag, GetHealth(g), true)
  3120 						SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, 0x808080FF)
  3120 						SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, 0x808080FF)
  3121 						tagGears[g] = v
  3121 						tagGears[g] = v
  3122 					else
  3122 					else
  3123 						tagGears[g] = nil
  3123 						tagGears[g] = nil
  3124 					end
  3124 					end
  3125 				else
  3125 				else
  3126 					if gt == gtMine and GetHealth(g) == 0 then
  3126 					if gt == gtMine and GetHealth(g) == 0 then
  3127 						local _, damage, health
  3127 						local _, damage, health
  3128 						_, _, _, _, _, _, _, _, _, _, _, damage = GetGearValues(g)
  3128 						_, _, _, _, _, _, _, _, _, _, _, damage = GetGearValues(g)
  3129 						health = 36 - damage
  3129 						health = 36 - damage
  3130 						v = AddVisualGear(0, 0, vgtHealthTag, health, true)
  3130 						v = AddVisualGear(0, 0, vgtHealthTag, health, true)
  3131 						SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, 0x808080FF)
  3131 						SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, 0x808080FF)
  3132 						tagGears[g] = v
  3132 						tagGears[g] = v
  3133 					end
  3133 					end
  3134 				end
  3134 				end
  3135 			end
  3135 			end
  3136 			-- Delete tag for drowning gears
  3136 			-- Delete tag for drowning gears
  3137 			if(band(GetState(g), gstDrowning) ~= 0) then
  3137 			if(band(GetState(g), gstDrowning) ~= 0) then
  3138 				DeleteVisualGear(v)
  3138 				DeleteVisualGear(v)
  3139 				tagGears[g] = nil
  3139 				tagGears[g] = nil
  3140 			-- Delete tag for frozen mines and air mines
  3140 			-- Delete tag for frozen sticky mines, air mines and crates
  3141 			elseif(band(GetState(g), gstFrozen) ~= 0 and (gt == gtAirMine or gt == gtSMine)) then
  3141 			elseif(band(GetState(g), gstFrozen) ~= 0 and (gt == gtAirMine or gt == gtSMine or gt == gtCase)) then
  3142 				DeleteVisualGear(v)
  3142 				DeleteVisualGear(v)
  3143 				tagGears[g] = nil
  3143 				tagGears[g] = nil
  3144 			elseif(tagGears[g] ~= nil and tagGears[g] ~= -1) then
  3144 			elseif(tagGears[g] ~= nil and tagGears[g] ~= -1) then
  3145 				local tag, actualvalue, offset_x, offset_y
  3145 				local tag, actualvalue, offset_x, offset_y
  3146 				tag = GetState(v)
  3146 				tag = GetState(v)
  3184 					actualValue = GetTimer(g)
  3184 					actualValue = GetTimer(g)
  3185 					printedValue = actualValue
  3185 					printedValue = actualValue
  3186 					offset_y = 28
  3186 					offset_y = 28
  3187 					offset_x = 16
  3187 					offset_x = 16
  3188 				end
  3188 				end
  3189 				--[[ The timer tag normally disappears near the water line, this is a really
       
  3190 				ugly hack to adjust the position of the tag so it is always displayed.
       
  3191 				FIXME: Find a better solution to fix this. ]]
       
  3192 				if (GetY(g) + offset_y) > WaterLine and (GetY(g) + offset_y) < WaterLine + 30 then
       
  3193 					offset_y = (WaterLine - GetY(g))
       
  3194 				end
       
  3195 				local tint
  3189 				local tint
  3196 				if(not showGearTags) then
  3190 				if(not showGearTags) then
  3197 					-- Hide the tags
  3191 					-- Hide the tags
  3198 					tint = 0x00000000
  3192 					tint = 0x00000000
  3199 				elseif(gt == gtCase) then
  3193 				elseif(gt == gtCase) then
  3212 				if(actualValue ~= tag) then
  3206 				if(actualValue ~= tag) then
  3213 					--[[ If timer/health changed, delete visual gear and add it again.
  3207 					--[[ If timer/health changed, delete visual gear and add it again.
  3214 					Changing the visual gear state does not have any effect, so we need this hack ]]
  3208 					Changing the visual gear state does not have any effect, so we need this hack ]]
  3215 					DeleteVisualGear(v)
  3209 					DeleteVisualGear(v)
  3216 					v = AddVisualGear(GetX(g)+offset_x, GetY(g)+offset_y, vgtHealthTag, printedValue, true)
  3210 					v = AddVisualGear(GetX(g)+offset_x, GetY(g)+offset_y, vgtHealthTag, printedValue, true)
  3217 					SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, tint)
  3211 					SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tint)
  3218 					tagGears[g] = v
  3212 					tagGears[g] = v
  3219 				else
  3213 				else
  3220 					-- Just update position if the health did not change
  3214 					-- Just update position if the health did not change
  3221 					SetVisualGearValues(v, GetX(g)+offset_x, GetY(g)+offset_y, 0, 0, nil, nil, nil, nil, 240000, tint)
  3215 					SetVisualGearValues(v, GetX(g)+offset_x, GetY(g)+offset_y, 0, 0, nil, 0, 1, nil, 240000, tint)
  3222 				end
  3216 				end
  3223 			end
  3217 			end
  3224 		end
  3218 		end
  3225 	end
  3219 	end
  3226 end
  3220 end
  3850 	else
  3844 	else
  3851 		tagTint = 0x00000000
  3845 		tagTint = 0x00000000
  3852 	end
  3846 	end
  3853 	if ((GetGearType(gear) == gtMine and GetHealth(gear) ~= 0) or (GetGearType(gear) == gtSMine and band(GetState(gear), gstFrozen) == 0)) then
  3847 	if ((GetGearType(gear) == gtMine and GetHealth(gear) ~= 0) or (GetGearType(gear) == gtSMine and band(GetState(gear), gstFrozen) == 0)) then
  3854 		local v = AddVisualGear(0, 0, vgtHealthTag, GetTimer(gear), true)
  3848 		local v = AddVisualGear(0, 0, vgtHealthTag, GetTimer(gear), true)
  3855 		SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, tagTint)
  3849 		SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tagTint)
  3856 		tagGears[gear] = v
  3850 		tagGears[gear] = v
  3857 	elseif ((GetGearType(gear) == gtMine and GetHealth(gear) == 0)) then
  3851 	elseif ((GetGearType(gear) == gtMine and GetHealth(gear) == 0)) then
  3858 		local _, dmg
  3852 		local _, dmg
  3859 		_, _, _, _, _, _, _, _, _, _, dmg = GetGearValues(gear)
  3853 		_, _, _, _, _, _, _, _, _, _, dmg = GetGearValues(gear)
  3860 		local v = AddVisualGear(0, 0, vgtHealthTag, 36 - dmg, true)
  3854 		local v = AddVisualGear(0, 0, vgtHealthTag, 36 - dmg, true)
  3861 		SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, tagTint)
  3855 		SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tagTint)
  3862 		tagGears[gear] = v
  3856 		tagGears[gear] = v
  3863 	elseif (GetGearType(gear) == gtAirMine and band(GetState(gear), gstFrozen) == 0) then
  3857 	elseif (GetGearType(gear) == gtAirMine and band(GetState(gear), gstFrozen) == 0) then
  3864 		local _, wdTimer
  3858 		local _, wdTimer
  3865 		_, _, wdTimer = GetGearValues(gear)
  3859 		_, _, wdTimer = GetGearValues(gear)
  3866 		local v = AddVisualGear(0, 0, vgtHealthTag, wdTimer, true)
  3860 		local v = AddVisualGear(0, 0, vgtHealthTag, wdTimer, true)
  3867 		SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, tagTint)
  3861 		SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tagTint)
  3868 		tagGears[gear] = v
  3862 		tagGears[gear] = v
  3869 	elseif (GetGearType(gear) == gtCase) then
  3863 	elseif (GetGearType(gear) == gtCase) then
  3870 		tagGears[gear] = -1
  3864 		tagGears[gear] = -1
  3871 	elseif (GetGearType(gear) == gtExplosives) then 
  3865 	elseif (GetGearType(gear) == gtExplosives) then 
  3872 		local v = AddVisualGear(0, 0, vgtHealthTag, GetHealth(gear), true)
  3866 		local v = AddVisualGear(0, 0, vgtHealthTag, GetHealth(gear), true)
  3873 		SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, tagTint)
  3867 		SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tagTint)
  3874 		tagGears[gear] = v
  3868 		tagGears[gear] = v
  3875 	end
  3869 	end
  3876 
  3870 
  3877 	if isATrackedGear(gear) then
  3871 	if isATrackedGear(gear) then
  3878 		trackGear(gear)
  3872 		trackGear(gear)