anchor.diff:  	return
   
   /obj/machinery/porta_turret/Topic(href, href_list)
  -	if (..())
  +	if(..())
   		return
   	usr.set_machine(src)
  -	src.add_fingerprint(usr)
  -	if ((href_list["power"]) && (src.allowed(usr)))
  -		if(anchored) // you can't turn a turret on/off if it's not anchored/secured
  -			on = !on // toggle on/off
  +	add_fingerprint(usr)
  +	if(href_list["power"] && !locked)
  +		if(anchored)	//you can't turn a turret on/off if it's not anchored/secured
  +			on = !on	//toggle on/off
   		else
  -			usr << "\red It has to be secured first!"
  +			usr << "<span class='notice'>It has to be secured first!</span>"
   
   		updateUsrDialog()
   		return
   
  -	switch(href_list["operation"])
  -		// toggles customizable behavioural protocols
  -
  -		if ("authweapon")
  -			src.auth_weapons = !src.auth_weapons
  -		if ("checkrecords")
  -			src.check_records = !src.check_records
  -		if ("shootcrooks")
  -			src.criminals = !src.criminals
  +	switch(href_list["operation"])	//toggles customizable behavioural protocols
  +		if("authweapon")
  +			auth_weapons = !auth_weapons
  +		if("checkrecords")
  +			check_records = !check_records
  +		if("shootcrooks")
  +			criminals = !criminals
   		if("shootall")
   			stun_all = !stun_all
   	updateUsrDialog()
  
positive.code: 		..()
  
  
  
  /obj/machinery/porta_turret/bullet_act(var/obj/item/projectile/Proj)
  	if(on)
  		if(!attacked && !emagged)
  			attacked = 1
  
negative.code: 	icon_state = "grey_target_prism"
  	anchored = 1
  	layer = 3
  	invisibility = INVISIBILITY_LEVEL_TWO	//the turret is invisible if it's inside its cover
  	density = 1
  	use_power = 1				//this turret uses and requires power
  	idle_power_usage = 50		//when inactive, this turret takes up constant 50 Equipment power
  	active_power_usage = 300	//when active, this turret takes up constant 300 Equipment power
  	req_access = list(access_security)
  	power_channel = EQUIP	//drains power from the EQUIPMENT channel
  
  	var/lasercolor = ""		//Something to do with lasertag turrets, blame Sieve for not adding a comment.
  	var/raised = 0			//if the turret cover is "open" and the turret is raised
  	var/raising= 0			//if the turret is currently opening or closing its cover
  	var/health = 80			//the turret's health
  	var/locked = 1			//if the turret's behaviour control access is locked
  
  	var/installation		//the type of weapon installed
  	var/gun_charge = 0		//the charge of the gun inserted
  	var/projectile = null	//holder for bullettype
  	var/eprojectile = null	//holder for the shot when emagged
  	var/reqpower = 500		//holder for power needed
  	var/sound = null		//So the taser can have sound
  	var/iconholder = null	//holder for the icon_state. 1 for orange sprite, null for blue.
  	var/egun = null			//holder to handle certain guns switching bullettypes
  
  	var/obj/machinery/porta_turret_cover/cover = null	//the cover that is covering this turret
  	var/last_fired = 0		//1: if the turret is cooling down from a shot, 0: turret is ready to fire
  	var/shot_delay = 15		//1.5 seconds between each shot
  
  	var/check_records = 1	//checks if it can use the security records
  	var/criminals = 1		//checks if it can shoot people on arrest
  	var/auth_weapons = 0	//checks if it can shoot people that have a weapon they aren't authorized to have
  	var/stun_all = 0		//if this is active, the turret shoots everything that isn't security or head of staff
  	var/check_anomalies = 1	//checks if it can shoot at unidentified lifeforms (ie xenos)
  	var/ai		 = 0 		//if active, will shoot at anything not an AI or cyborg
  
  	var/attacked = 0		//if set to 1, the turret gets pissed off and shoots at people nearby (unless they have sec access!)
  
  	var/on = 1				//determines if the turret is on
  	var/disabled = 0
  
  	var/datum/effect/effect/system/spark_spread/spark_system	//the spark system, used for generating... sparks?
  
  /obj/machinery/porta_turret/New()
  	..()
  	icon_state = "[lasercolor]grey_target_prism"
  	//Sets up a spark system
  	spark_system = new /datum/effect/effect/system/spark_spread
  	spark_system.set_up(5, 0, src)
  	spark_system.attach(src)
  	sleep(10)
  	if(!installation)	//if for some reason the turret has no gun (ie, admin spawned) it resorts to basic taser shots
  		projectile = /obj/item/projectile/energy/electrode	//holder for the projectile, here it is being set
  		eprojectile = /obj/item/projectile/beam				//holder for the projectile when emagged, if it is different
  		sound = 1
  	else
  		var/obj/item/weapon/gun/energy/E=new installation	//All energy-based weapons are applicable
  		projectile = E.projectile_type
  		eprojectile = projectile
  
  		switch(E.type)
  			if(/obj/item/weapon/gun/energy/laser/bluetag)
  				eprojectile = /obj/item/projectile/omnitag	//This bolt will stun ERRYONE with a vest
  				lasercolor = "b"
  				req_access = list(access_maint_tunnels,access_clown,access_mime)
  				check_records = 0
  				criminals = 0
  				auth_weapons = 1
  				stun_all = 0
  				check_anomalies = 0
  				shot_delay = 30
  
  			if(/obj/item/weapon/gun/energy/laser/redtag)
  				eprojectile = /obj/item/projectile/omnitag
  				lasercolor = "r"
  				req_access = list(access_maint_tunnels,access_clown,access_mime)
  				check_records = 0
  				criminals = 0
  				auth_weapons = 1
  				stun_all = 0
  				check_anomalies = 0
  				shot_delay = 30
  				iconholder = 1
  
  			if(/obj/item/weapon/gun/energy/laser/practice)
  				iconholder = 1
  				eprojectile = /obj/item/projectile/beam
  
  			if(/obj/item/weapon/gun/energy/laser/practice/sc_laser)
  				iconholder = 1
  				eprojectile = /obj/item/projectile/beam
  
  			if(/obj/item/weapon/gun/energy/laser/retro)
  				iconholder = 1
  
  			if(/obj/item/weapon/gun/energy/laser/retro/sc_retro)
  				iconholder = 1
  
  			if(/obj/item/weapon/gun/energy/laser/captain)
  				iconholder = 1
  
  			if(/obj/item/weapon/gun/energy/lasercannon)
  				iconholder = 1
  
  			if(/obj/item/weapon/gun/energy/taser)
  				eprojectile = /obj/item/projectile/beam
  
  			if(/obj/item/weapon/gun/energy/stunrevolver)
  				eprojectile = /obj/item/projectile/beam
  
  			if(/obj/item/weapon/gun/energy/gun)
  				eprojectile = /obj/item/projectile/beam	//If it has, going to kill mode
  				egun = 1
  
  			if(/obj/item/weapon/gun/energy/gun/nuclear)
  				eprojectile = /obj/item/projectile/beam	//If it has, going to kill mode
  				egun = 1
  
  
  /obj/machinery/porta_turret/Del()
  	//deletes its own cover with it
  	del(cover)
  	..()
  
  
  /obj/machinery/porta_turret/attack_ai(mob/user)
  	return attack_hand(user)
  
  
  /obj/machinery/porta_turret/attack_hand(mob/user)
  	. = ..()
  	if(.)
  		return
  	var/dat
  
  	//The browse() text, similar to ED-209s and beepskies.
  	if(!lasercolor)	//Lasertag turrets have less options
  		dat += text({"
  					<TT><B>Automatic Portable Turret Installation</B></TT><BR><BR>
  					Status: []<BR>
  					Behaviour controls are [locked ? "locked" : "unlocked"]"},
  
  					"<A href='?src=\ref[src];power=1'>[on ? "On" : "Off"]</A>" )
  
  		if(!locked)
  			dat += text({"<BR>
  						Check for Weapon Authorization: []<BR>
  						Check Security Records: []<BR>
  						Neutralize Identified Criminals: []<BR>
  						Neutralize All Non-Security and Non-Command Personnel: []<BR>
  						Neutralize All Unidentified Life Signs: []<BR>"},
  
  						"<A href='?src=\ref[src];operation=authweapon'>[auth_weapons ? "Yes" : "No"]</A>",
  						"<A href='?src=\ref[src];operation=checkrecords'>[check_records ? "Yes" : "No"]</A>",
  						"<A href='?src=\ref[src];operation=shootcrooks'>[criminals ? "Yes" : "No"]</A>",
  						"<A href='?src=\ref[src];operation=shootall'>[stun_all ? "Yes" : "No"]</A>",
  						"<A href='?src=\ref[src];operation=checkxenos'>[check_anomalies ? "Yes" : "No"]</A>" )
  	else
  		if(istype(user,/mob/living/carbon/human))
  			var/mob/living/carbon/human/H = user
  			if(lasercolor == "b" && istype(H.wear_suit, /obj/item/clothing/suit/redtag))
  				return
  			if(lasercolor == "r" && istype(H.wear_suit, /obj/item/clothing/suit/bluetag))
  				return
  		dat += text({"
  					<TT><B>Automatic Portable Turret Installation</B></TT><BR><BR>
  					Status: []<BR>"},
  
  					"<A href='?src=\ref[src];power=1'>[on ? "On" : "Off"]</A>" )
  
  
  	user << browse("<HEAD><TITLE>Automatic Portable Turret Installation</TITLE></HEAD>[dat]", "window=autosec")
  