-- Toggle marking enemies script.lua (Crashing PD2 version 1.4.2)

Posts 1–6 of 6 · Page 1 of 1
-- Toggle marking enemies script.lua (Crashing PD2 version 1.4.2)
-- Toggle marking enemies script.lua (Crashing PD2 version 1.4.2)
Any help repairing and getting working again would be great.

This is the basic toggle marking enemies script, but is now crashing out in version 1.4.2 PD2. Not sure why but just letting every1 know, maybe post a reply for repair or replacement of script. Thanks for all the help and replies. I'll continue on trying to repair myself also, and post any progress I my stumble across.

Code:
-- Toggle marking enemies
function setEnemyColor(unit)
	local enemyType = unit:base()._tweak_table
	local color, target_color
	
	-- Civilians | Green
	if enemyType == "civilian" or enemyType == "civilian_female" then
		color = Vector3( 0.1687, 0.5529, 0 )
		target_color = Vector3( 0.1688, 0.5529, 0 )
	-- Taser | Blue
	elseif enemyType == "taser" then
		color = Vector3(0, 0.3804, 0.6235)
		target_color = Vector3(0.001, 0.3804, 0.6235)
	-- Shield | Orange
	elseif enemyType == "shield" then
		color = Vector3(1, 0.5, 0)
		target_color = Vector3(1.001, 0.5, 0)
	-- Tank | Yellow
	elseif enemyType == "tank" then
		color = Vector3(1, 1, 0)
		target_color = Vector3(1.001, 1, 0)
	-- Sniper | Pink
	elseif enemyType == "sniper" then
		color = Vector3(1, 0.35, 0.35)
		target_color = Vector3(1.001, 0.35, 0.35)
	-- Cop/unknown | Purple
	else
		color = Vector3(0.5216, 0, 0.5529)
		target_color = Vector3(0.5217, 0, 0.5529)
	end
	
	-- Set colors
	managers.game_play_central._enemy_contour_units[unit:key()].color = color
	managers.game_play_central._enemy_contour_units[unit:key()].target_color = target_color
end
function mark_enemies()
	local units = World:find_units_quick( "all", 3, 16, 21, managers.slot:get_mask( "enemies" ) )
	for i,unit in ipairs( units ) do
		if not unit:brain() or not unit:brain()._logic_data or
		   not unit:brain()._logic_data.objective or
		   (unit:brain()._logic_data.objective.type ~= "surrender" and 
		    unit:brain()._logic_data.objective.type ~= "follow") then
		      	if tweak_data.character[ unit:base()._tweak_table ].silent_priority_shout then
		      		managers.game_play_central:add_enemy_contour( unit, true )
		      		setEnemyColor(unit)
		      	elseif unit:character_damage().on_marked_state then
		      		managers.game_play_central:add_enemy_contour( unit, false )
		      		setEnemyColor(unit)
		      	end
		end
	end

	for u_key, unit in pairs( managers.groupai:state()._security_cameras ) do
		managers.game_play_central:add_marked_contour_unit( unit )
		end
end
function UnitNetworkHandler:mark_enemy( unit, marking_strength, sender ) end

if not _markingToggle then _markingToggle = true
else _markingToggle = nil end
if not _gameUpdate then _gameUpdate = GameSetup.update end
do
	local _gameUpdateLastMark
	function GameSetup:update( t, dt )
		_gameUpdate(self, t, dt)
	
		if _markingToggle and (not _gameUpdateLastMark or t - _gameUpdateLastMark > 4) then
			_gameUpdateLastMark = t
			mark_enemies()
		end
	end
end
I have the same problem, I haven't really learnt lua so im unable to help you mate. Im more into vb.net and c#
X-Ray Vision 2.0-By (Pirate Captain)
Thanks to Pirate Captain for releasing X-Ray Vision 2.0. This version for now is only showing guards/cops/ext. ext., No color coding, as of yet.
So hopefully this will keep everyone going for now.

Code:
-- X-RAY VISION v2.0 (post infamy edition)
-- MARKS ENEMIES ONLY
function mark_enemies()
	for u_key,u_data in pairs(managers.enemy:all_civilians()) do
		--u_data.unit:contour():add( "mark_enemy" )
	end
	for u_key,u_data in pairs(managers.enemy:all_enemies()) do
		u_data.unit:contour():add( "mark_enemy" )
	end
	for u_key, unit in pairs( managers.groupai:state()._security_cameras ) do
		--unit:contour():add( "mark_enemy" )
	end
end

function UnitNetworkHandler:mark_enemy( unit, marking_strength, sender ) 
end
if not _markingToggle then _marktoggle = nil _markingToggle = true
	else _markingToggle = nil 
end
if not _gameUpdate then _gameUpdate = GameSetup.update 
end
do
	local _gameUpdateLastMark
	function GameSetup:update( t, dt )
		_gameUpdate(self, t, dt)
		_gameUpdateLastMark = t 
		if _markingToggle then
			mark_enemies()
		else
			if not _marktoggle then
				_marktoggle = true
				for u_key,u_data in pairs(managers.enemy:all_enemies()) do
					u_data.unit:contour():remove( "mark_enemy" )
				end
			end
		end
	end
end
Code/Script (Civies) Standard Maps Only
OK, This code/script I stumbled a pawn, It's Pirate Captains x-ray v2 script, what it does, is shows civies, guards, ext. ext., No cameras, No color Codes, It only works in standard maps, including Diamond Store Heist, it does NOT function in any DLC, Go Bank, Transport Hesits, it crashes out. If I or you want to play these maps, you or I just re-enter the dash's, or re-paste the original x-ray v2 script back in, and then can at least see guards, ext. ext.. If you look at the codes side by side you'll see where the dash's are and aren't. So here it is, Enjoy.

Code:
-- X-RAY VISION v2.0 (post infamy edition)
-- MARKS ENEMIES ONLY
function mark_enemies()
	for u_key,u_data in pairs(managers.enemy:all_civilians()) do
		u_data.unit:contour():add( "mark_enemy" )
	end
	for u_key,u_data in pairs(managers.enemy:all_enemies()) do
		u_data.unit:contour():add( "mark_enemy" )
	end
	for u_key, unit in pairs( managers.groupai:state()._security_cameras ) do
		--unit:contour():add( "mark_enemy" )
	end
end

function UnitNetworkHandler:mark_enemy( unit, marking_strength, sender ) 
end
if not _markingToggle then _marktoggle = nil _markingToggle = true
	else _markingToggle = nil 
end
if not _gameUpdate then _gameUpdate = GameSetup.update 
end
do
	local _gameUpdateLastMark
	function GameSetup:update( t, dt )
		_gameUpdate(self, t, dt)
		_gameUpdateLastMark = t 
		if _markingToggle then
			mark_enemies()
		else
			if not _marktoggle then
				_marktoggle = true
				for u_key,u_data in pairs(managers.enemy:all_enemies()) do
					u_data.unit:contour():remove( "mark_enemy" )
				end
			end
		end
	end
end
Enemies, Civies, Cams (Original Maps Only)
Another big shout out to Pirate Captain, for the new hints, tips. Once again were getting closer to what we had before, slowly but surely, still only working on original maps, still no working in DLC content, and still no color codes, as of yet, Anyone feel free to drop in hints, or tips anytime, to make this script better or work as close as possible to before, your more then welcome to. Anyhow, here you all go.

Code:
-- X-RAY VISION v2.0 (post infamy edition)
-- MARKS ENEMIES,CIVIES,CAMS
function mark_enemies()     
        for u_key,u_data in pairs(managers.enemy:all_civilians()) do
		u_data.unit:contour():add( "mark_enemy" )
	end
	for u_key,u_data in pairs(managers.enemy:all_enemies()) do
		u_data.unit:contour():add( "mark_enemy" )
	end
	for u_key, unit in pairs( managers.groupai:state()._security_cameras ) do
		--unit:contour():add( "mark_enemy" )
	end
	local units = World:find_units_quick( "all" )
	for i,unit in ipairs( units ) do
		if unit:contour() then	
                        unit:contour():add( "mark_unit" )
		end
	end
end

function UnitNetworkHandler:mark_enemy( unit, marking_strength, sender ) 
end
if not _markingToggle then _marktoggle = nil _markingToggle = true
	else _markingToggle = nil 
end
if not _gameUpdate then _gameUpdate = GameSetup.update 
end
do
	local _gameUpdateLastMark
	function GameSetup:update( t, dt )
		_gameUpdate(self, t, dt)
		_gameUpdateLastMark = t 
		if _markingToggle then
			mark_enemies()
		else
			if not _marktoggle then
				_marktoggle = true
				for u_key,u_data in pairs(managers.enemy:all_enemies()) do
					u_data.unit:contour():remove( "mark_enemy" )
				end
			end
		end
	end
end
Quote Originally Posted by lacjmcc View Post
Another big shout out to Pirate Captain, for the new hints, tips. Once again were getting closer to what we had before, slowly but surely, still only working on original maps, still no working in DLC content, and still no color codes, as of yet, Anyone feel free to drop in hints, or tips anytime, to make this script better or work as close as possible to before, your more then welcome to. Anyhow, here you all go.

Code:
-- X-RAY VISION v2.0 (post infamy edition)
-- MARKS ENEMIES,CIVIES,CAMS
function mark_enemies()     
        for u_key,u_data in pairs(managers.enemy:all_civilians()) do
		u_data.unit:contour():add( "mark_enemy" )
	end
	for u_key,u_data in pairs(managers.enemy:all_enemies()) do
		u_data.unit:contour():add( "mark_enemy" )
	end
	for u_key, unit in pairs( managers.groupai:state()._security_cameras ) do
		--unit:contour():add( "mark_enemy" )
	end
	local units = World:find_units_quick( "all" )
	for i,unit in ipairs( units ) do
		if unit:contour() then	
                        unit:contour():add( "mark_unit" )
		end
	end
end

function UnitNetworkHandler:mark_enemy( unit, marking_strength, sender ) 
end
if not _markingToggle then _marktoggle = nil _markingToggle = true
	else _markingToggle = nil 
end
if not _gameUpdate then _gameUpdate = GameSetup.update 
end
do
	local _gameUpdateLastMark
	function GameSetup:update( t, dt )
		_gameUpdate(self, t, dt)
		_gameUpdateLastMark = t 
		if _markingToggle then
			mark_enemies()
		else
			if not _marktoggle then
				_marktoggle = true
				for u_key,u_data in pairs(managers.enemy:all_enemies()) do
					u_data.unit:contour():remove( "mark_enemy" )
				end
			end
		end
	end
end
Huh, since new update 1.5.0, seems to be working on DLC now, that's a good thing.
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us