code:
#define HEAT_DAMAGE_LEVEL_1 2 //Amount of damage applied when your body temperature just passes the 360.15k safety point
#define HEAT_DAMAGE_LEVEL_2 3 //Amount of damage applied when your body temperature passes the 400K point
#define HEAT_DAMAGE_LEVEL_3 8 //Amount of damage applied when your body temperature passes the 460K point and you are on fire

/mob/living/carbon/alien
	name = "alien"
	voice_name = "alien"
	say_message = "hisses"
	icon = 'icons/mob/alien.dmi'
	gender = NEUTER
	dna = null
	faction = list("alien")
	ventcrawler = 2
	languages = ALIEN
	var/nightvision = 1
	var/storedPlasma = 250
	var/max_plasma = 500

	var/obj/item/weapon/card/id/wear_id = null // Fix for station bounced radios -- Skie
	var/has_fine_manipulation = 0

	var/move_delay_add = 0 // movement delay to add
	type_of_meat = /obj/item/weapon/reagent_containers/food/snacks/meat/slab/xeno
	gib_type = /obj/effect/decal/cleanable/xenoblood/xgibs

	status_flags = CANPARALYSE|CANPUSH
	var/heal_rate = 5
	var/plasma_rate = 5

	var/heat_protection = 0.5
	var/leaping = 0
	var/list/obj/effect/proc_holder/alien/abilities = list()

/mob/living/carbon/alien/New()
	verbs += /mob/living/proc/mob_sleep
	verbs += /mob/living/proc/lay_down
	internal_organs += new /obj/item/organ/brain/alien
	AddAbility(new/obj/effect/proc_holder/alien/nightvisiontoggle(null))

	..()

/mob/living/carbon/alien/adjustToxLoss(amount)
	storedPlasma = min(max(storedPlasma + amount,0),max_plasma) //upper limit of max_plasma, lower limit of 0
	updatePlasmaDisplay()
	return

/mob/living/carbon/alien/adjustFireLoss(amount) // Weak to Fire
	if(amount > 0)
		..(amount * 2)
	else
		..(amount)
	return

/mob/living/carbon/alien/proc/getPlasma()
	return storedPlasma

/mob/living/carbon/alien/check_eye_prot()
	return 2

/mob/living/carbon/alien/getToxLoss()
	return 0

/mob/living/carbon/alien/handle_environment(var/datum/gas_mixture/environment)

	//If there are alien weeds on the ground then heal if needed or give some toxins
	if(locate(/obj/structure/alien/weeds) in loc)
		if(health >= maxHealth - getCloneLoss())
			adjustToxLoss(plasma_rate)
		else
			adjustBruteLoss(-heal_rate)
			adjustFireLoss(-heal_rate)
			adjustOxyLoss(-heal_rate)

	if(!environment)
		return

	var/loc_temp = get_temperature(environment)

	//world << "Loc temp: [loc_temp] - Body temp: [bodytemperature] - Fireloss: [getFireLoss()] - Fire protection: [heat_protection] - Location: [loc] - src: [src]"

	// Aliens are now weak to fire.

	//After then, it reacts to the surrounding atmosphere based on your thermal protection
	if(!on_fire) // If you're on fire, ignore local air temperature
		if(loc_temp > bodytemperature)
			//Place is hotter than we are
			var/thermal_protection = heat_protection //This returns a 0 - 1 value, which corresponds to the percentage of protection based on what you're wearing and what you're exposed to.
			if(thermal_protection < 1)
				bodytemperature += (1-thermal_protection) * ((loc_temp - bodytemperature) / BODYTEMP_HEAT_DIVISOR)
		else
			bodytemperature += 1 * ((loc_temp - bodytemperature) / BODYTEMP_HEAT_DIVISOR)
		//	bodytemperature -= max((loc_temp - bodytemperature / BODYTEMP_AUTORECOVERY_DIVISOR), BODYTEMP_AUTORECOVERY_MINIMUM)

	// +/- 50 degrees from 310.15K is the 'safe' zone, where no damage is dealt.
	if(bodytemperature > 360.15)
		//Body temperature is too hot.
		throw_alert("alien_fire")
		switch(bodytemperature)
			if(360 to 400)
				apply_damage(HEAT_DAMAGE_LEVEL_1, BURN)
			if(400 to 460)
				apply_damage(HEAT_DAMAGE_LEVEL_2, BURN)
			if(460 to INFINITY)
				if(on_fire)
					apply_damage(HEAT_DAMAGE_LEVEL_3, BURN)
				else
					apply_damage(HEAT_DAMAGE_LEVEL_2, BURN)
	else
		clear_alert("alien_fire")

/mob/living/carbon/alien/ex_act(severity, target)
	..()

	switch (severity)
		if (1.0)
			gib()
			return

		if (2.0)
			adjustBruteLoss(60)
			adjustFireLoss(60)
			adjustEarDamage(30,120)

		if(3.0)
			adjustBruteLoss(30)
			if (prob(50))
				Paralyse(1)
			adjustEarDamage(15,60)

	updatehealth()

/mob/living/carbon/alien/handle_fire()//Aliens on fire code
	if(..())
		return
	bodytemperature += BODYTEMP_HEATING_MAX //If you're on fire, you heat up!
	return

/mob/living/carbon/alien/IsAdvancedToolUser()
	return has_fine_manipulation

/mob/living/carbon/alien/SpeciesCanConsume()
	return 1 // Aliens can eat, and they can be fed food/drink

/mob/living/carbon/alien/Stat()
	..()

	if(statpanel("Status"))
		stat(null, "Intent: [a_intent]")
		stat(null, "Move Mode: [m_intent]")
		stat(null, "Plasma Stored: [getPlasma()]/[max_plasma]")

	add_abilities_to_panel()

/mob/living/carbon/alien/proc/AddAbility(var/obj/effect/proc_holder/alien/A)
	abilities.Add(A)
	A.on_gain(src)
	if(A.has_action)
		if(!A.action)
			A.action = new/datum/action/spell_action/alien
			A.action.target = A
			A.action.name = A.name
			A.action.button_icon = A.action_icon
			A.action.button_icon_state = A.action_icon_state
			A.action.background_icon_state = A.action_background_icon_state
		A.action.Grant(src)

/mob/living/carbon/alien/proc/add_abilities_to_panel()
	for(var/obj/effect/proc_holder/alien/A in abilities)
		statpanel("[A.panel]",A.plasma_cost > 0?"([A.plasma_cost])":"",A)

/mob/living/carbon/alien/Stun(amount)
	if(status_flags & CANSTUN)
		stunned = max(max(stunned,amount),0) //can't go below 0, getting a low amount of stun doesn't lower your current stun
	else
		// add some movement delay
		move_delay_add = min(move_delay_add + round(amount / 2), 10) // a maximum delay of 10
	return

/mob/living/carbon/alien/getTrail()
	return "xltrails"

/mob/living/carbon/alien/cuff_break(obj/item/I, mob/living/carbon/C)
	playsound(C, 'sound/voice/hiss5.ogg', 40, 1, 1)  //Alien roars when breaking free.
	..()

/*----------------------------------------
Proc: AddInfectionImages()
Des: Gives the client of the alien an image on each infected mob.
----------------------------------------*/
/mob/living/carbon/alien/proc/AddInfectionImages()
	if (client)
		for (var/mob/living/C in mob_list)
			if(C.status_flags & XENO_HOST)
				var/obj/item/body_egg/alien_embryo/A = locate() in C
				var/I = image('icons/mob/alien.dmi', loc = C, icon_state = "infected[A.stage]")
				client.images += I
	return

/*----------------------------------------
Proc: RemoveInfectionImages()
Des: Removes all infected images from the alien.
----------------------------------------*/
/mob/living/carbon/alien/proc/RemoveInfectionImages()
	if (client)
		for(var/image/I in client.images)
			if(dd_hasprefix_case(I.icon_state, "infected"))
				qdel(I)
	return

/mob/living/carbon/alien/canBeHandcuffed()
	return 1

#undef HEAT_DAMAGE_LEVEL_1
#undef HEAT_DAMAGE_LEVEL_2
#undef HEAT_DAMAGE_LEVEL_3


code:
/mob/living/carbon/alien/hitby(atom/movable/AM)
	..(AM, 1)

/*Code for aliens attacking aliens. Because aliens act on a hivemind, I don't see them as very aggressive with each other.
As such, they can either help or harm other aliens. Help works like the human help command while harm is a simple nibble.
In all, this is a lot like the monkey code. /N
*/
/mob/living/carbon/alien/attack_alien(mob/living/carbon/alien/M as mob)
	if (!ticker)
		M << "You cannot attack people before the game has started."
		return

	if (istype(loc, /turf) && istype(loc.loc, /area/start))
		M << "No attacking people at spawn, you jackass."
		return

	switch(M.a_intent)

		if ("help")
			sleeping = max(0,sleeping-5)
			resting = 0
			AdjustParalysis(-3)
			AdjustStunned(-3)
			AdjustWeakened(-3)
			visible_message("[M.name] nuzzles [src] trying to wake it up!")

		if ("grab")
			grabbedby(M)

		else
			if (health > 0)
				M.do_attack_animation(src)
				playsound(loc, 'sound/weapons/bite.ogg', 50, 1, -1)
				var/damage = 1
				visible_message("[M.name] bites [src]!", \
						"[M.name] bites [src]!")
				adjustBruteLoss(damage)
				add_logs(M, src, "attacked", admin=0)
				updatehealth()
			else
				M << "[name] is too injured for that."
	return

/mob/living/carbon/alien/attack_larva(mob/living/carbon/alien/larva/L as mob)
	return attack_alien(L)

/mob/living/carbon/alien/attack_hand(mob/living/carbon/human/M as mob)
	if(..())	//to allow surgery to return properly.
		return 0

	switch(M.a_intent)
		if("help")
			help_shake_act(M)
		if("grab")
			grabbedby(M)
		if ("harm", "disarm")
			M.do_attack_animation(src)
			return 1
	return 0

/mob/living/carbon/alien/attack_paw(mob/living/carbon/monkey/M as mob)
	if(..())
		if (stat != DEAD)
			adjustBruteLoss(rand(1, 3))
			updatehealth()
	return

/mob/living/carbon/alien/attack_animal(mob/living/simple_animal/M as mob)
	if(..())
		var/damage = rand(M.melee_damage_lower, M.melee_damage_upper)
		adjustBruteLoss(damage)
		updatehealth()

license: mit


code:
/mob/living/carbon/alien/spawn_gibs()
	xgibs(loc, viruses)

/mob/living/carbon/alien/gib_animation(var/animate)
	..(animate, "gibbed-a")

/mob/living/carbon/alien/spawn_dust()
	new /obj/effect/decal/remains/xeno(loc)

/mob/living/carbon/alien/spawn_dust()
	new /obj/effect/decal/remains/xeno(loc)

/mob/living/carbon/alien/dust_animation(var/animate)
	..(animate, "dust-a")

/mob/living/carbon/alien/dust(var/animation = 1)
	..()


code:
/*NOTES:
These are general powers. Specific powers are stored under the appropriate alien creature type.
*/

/*Alien spit now works like a taser shot. It won't home in on the target but will act the same once it does hit.
Doesn't work on other aliens/AI.*/
/datum/action/spell_action/alien

/datum/action/spell_action/alien/UpdateName()
	var/obj/effect/proc_holder/alien/ab = target
	return ab.name

/datum/action/spell_action/alien/IsAvailable()
	if(!target)
		return 0
	var/obj/effect/proc_holder/alien/ab = target

	if(usr)
		return ab.cost_check(ab.check_turf,usr,1)
	else
		if(owner)
			return ab.cost_check(ab.check_turf,owner,1)
	return 1

/datum/action/spell_action/alien/CheckRemoval()
	return !isalien(owner)

/obj/effect/proc_holder/alien
	name = "Alien Power"
	panel = "Alien"
	var/plasma_cost = 0
	var/check_turf = 0

	var/has_action = 1
	var/datum/action/spell_action/alien/action = null
	var/action_icon = 'icons/mob/actions.dmi'
	var/action_icon_state = "spell_default"
	var/action_background_icon_state = "bg_alien"

/obj/effect/proc_holder/alien/Click()
	if(!istype(usr,/mob/living/carbon/alien))
		return 1
	var/mob/living/carbon/alien/user = usr
	if(cost_check(check_turf,user))
		if(fire(user) && user) // Second check to prevent runtimes when evolving
			user.adjustToxLoss(-plasma_cost)
	return 1

/obj/effect/proc_holder/alien/proc/on_gain(var/mob/living/carbon/alien/user)
	return

/obj/effect/proc_holder/alien/proc/fire(var/mob/living/carbon/alien/user)
	return 1

/obj/effect/proc_holder/alien/proc/cost_check(check_turf=0,var/mob/living/carbon/alien/user,var/silent = 0)
	if(user.stat)
		if(!silent)
			user << "You must be conscious to do this."
		return 0
	if(user.getPlasma() < plasma_cost)
		if(!silent)
			user << "Not enough plasma stored."
		return 0
	if(check_turf && (!isturf(user.loc) || istype(user.loc, /turf/space)))
		if(!silent)
			user << "Bad place for a garden!"
		return 0
	return 1

/obj/effect/proc_holder/alien/plant
	name = "Plant Weeds"
	desc = "Plants some alien weeds"
	plasma_cost = 50
	check_turf = 1

	action_icon_state = "alien_plant"

/obj/effect/proc_holder/alien/plant/fire(var/mob/living/carbon/alien/user)
	if(locate(/obj/structure/alien/weeds/node) in get_turf(user))
		src << "There's already a weed node here."
		return 0
	for(var/mob/O in viewers(user, null))
		O.show_message(text("[user] has planted some alien weeds!"), 1)
	new/obj/structure/alien/weeds/node(user.loc)
	return 1

/obj/effect/proc_holder/alien/whisper
	name = "Whisper"
	desc = "Whisper to someone"
	plasma_cost = 10

	action_icon_state = "alien_whisper"

/obj/effect/proc_holder/alien/whisper/fire(var/mob/living/carbon/alien/user)
	var/mob/M = input("Select who to whisper to:","Whisper to?",null) as mob in oview(user)
	if(!M)
		return 0
	var/msg = sanitize(input("Message:", "Alien Whisper") as text|null)
	if(msg)
		log_say("AlienWhisper: [key_name(user)]->[M.key] : [msg]")
		M << "You hear a strange, alien voice in your head...[msg]"
		user << {"You said: "[msg]" to [M]"}
	else
		return 0
	return 1

/obj/effect/proc_holder/alien/transfer
	name = "Transfer Plasma"
	desc = "Transfer Plasma to another alien"
	plasma_cost = 0

	action_icon_state = "alien_transfer"

/obj/effect/proc_holder/alien/transfer/fire(var/mob/living/carbon/alien/user)
	var/list/mob/living/carbon/alien/aliens_around = list()
	for(var/mob/living/carbon/alien/A  in oview(user))
		aliens_around.Add(A)
	var/mob/living/carbon/alien/M = input("Select who to transfer to:","Transfer plasma to?",null) as mob in aliens_around
	if(!M)
		return 0
	if(isalien(M))
		var/amount = input("Amount:", "Transfer Plasma to [M]") as num
		if (amount)
			amount = abs(round(amount))
			if(user.getPlasma() > amount)
				if (get_dist(user,M) <= 1)
					M.adjustToxLoss(amount)
					user.adjustToxLoss(-amount)
					M << "[user] has transfered [amount] plasma to you."
					user << {"You trasfer [amount] plasma to [M]"}
				else
					user << "You need to be closer!"
	return

/obj/effect/proc_holder/alien/acid
	name = "Corrossive Acid"
	desc = "Drench an object in acid, destroying it over time."
	plasma_cost = 200

	action_icon_state = "alien_acid"

/obj/effect/proc_holder/alien/acid/on_gain(var/mob/living/carbon/alien/user)
	user.verbs.Add(/mob/living/carbon/alien/humanoid/proc/corrosive_acid)

/obj/effect/proc_holder/alien/acid/proc/corrode(var/target,var/mob/living/carbon/alien/user = usr)
	if(target in oview(1,user))
		// OBJ CHECK
		if(isobj(target))
			var/obj/I = target
			if(I.unacidable)	//So the aliens don't destroy energy fields/singularies/other aliens/etc with their acid.
				user << "You cannot dissolve this object."
				return 0
		// TURF CHECK
		else if(istype(target, /turf/simulated))
			var/turf/T = target
			// R WALL
			if(istype(T, /turf/simulated/wall/r_wall))
				user << "You cannot dissolve this object."
				return 0
			// R FLOOR
			if(istype(T, /turf/simulated/floor/engine))
				user << "You cannot dissolve this object."
				return 0
		else// Not a type we can acid.
			return 0
		new /obj/effect/acid(get_turf(target), target)
		user.visible_message("[user] vomits globs of vile stuff all over [target]. It begins to sizzle and melt under the bubbling mess of acid!")
		return 1
	else
		src << "Target is too far away."
		return 0

/obj/effect/proc_holder/alien/acid/fire(var/mob/living/carbon/alien/user)
	var/O = input("Select what to dissolve:","Dissolve",null) as obj|turf in oview(1,user)
	if(!O)
		return 0
	return corrode(O,user)

/mob/living/carbon/alien/humanoid/proc/corrosive_acid(O as obj|turf in oview(1)) // right click menu verb ugh
	set name = "Corrossive Acid"

	if(!isalien(usr))
		return
	var/mob/living/carbon/alien/humanoid/user = usr
	var/obj/effect/proc_holder/alien/acid/A = locate() in user.abilities
	if(!A)
		return
	if(user.getPlasma() > A.plasma_cost && A.corrode(O))
		user.adjustToxLoss(-A.plasma_cost)

/obj/effect/proc_holder/alien/neurotoxin
	name = "Spit Neurotoxin"
	desc = "Spits neurotoxin at someone, paralyzing them for a short time."
	plasma_cost = 50

	action_icon_state = "alien_neurotoxin"

/obj/effect/proc_holder/alien/neurotoxin/fire(var/mob/living/carbon/alien/user)
	user.visible_message("[user] spits neurotoxin!", "You spit neurotoxin.")

	var/turf/T = user.loc
	var/turf/U = get_step(user, user.dir) // Get the tile infront of the move, based on their direction
	if(!isturf(U) || !isturf(T))
		return 0

	var/obj/item/projectile/bullet/neurotoxin/A = new /obj/item/projectile/bullet/neurotoxin(user.loc)
	A.current = U
	A.yo = U.y - T.y
	A.xo = U.x - T.x
	A.fire()

	return 1

/obj/effect/proc_holder/alien/resin
	name = "Secrete Resin"
	desc = "Secrete tough malleable resin."
	plasma_cost = 55
	check_turf = 1

	action_icon_state = "alien_resin"

/obj/effect/proc_holder/alien/resin/fire(var/mob/living/carbon/alien/user)
	if(locate(/obj/structure/alien/resin) in user.loc.contents)
		user << "There is already a resin structure there."
		return 0
	var/choice = input("Choose what you wish to shape.","Resin building") as null|anything in list("resin wall","resin membrane","resin nest") //would do it through typesof but then the player choice would have the type path and we don't want the internal workings to be exposed ICly - Urist

	if(!choice)
		return 0

	user << "You shape a [choice]."
	user.visible_message("[user] vomits up a thick purple substance and begins to shape it.")

	switch(choice)
		if("resin wall")
			new /obj/structure/alien/resin/wall(user.loc)
		if("resin membrane")
			new /obj/structure/alien/resin/membrane(user.loc)
		if("resin nest")
			new /obj/structure/stool/bed/nest(user.loc)
	return 1

/obj/effect/proc_holder/alien/regurgitate
	name = "Regurgitate"
	desc = "Empties the contents of your stomach"
	plasma_cost = 0

	action_icon_state = "alien_barf"

/obj/effect/proc_holder/alien/regurgitate/fire(var/mob/living/carbon/alien/user)
	if(user.stomach_contents.len)
		for(var/atom/movable/A in user.stomach_contents)
			user.stomach_contents.Remove(A)
			A.loc = user.loc
		user.visible_message("[user] hurls out the contents of their stomach!")
	return

/obj/effect/proc_holder/alien/nightvisiontoggle
	name = "Toggle Night Vision"
	desc = "Toggles Night Vision"
	plasma_cost = 0

	has_action = 0 // Has dedicated GUI button already

/obj/effect/proc_holder/alien/nightvisiontoggle/fire(var/mob/living/carbon/alien/user)

	if(!user.nightvision)
		user.see_in_dark = 8
		user.see_invisible = SEE_INVISIBLE_MINIMUM
		user.nightvision = 1
		user.hud_used.nightvisionicon.icon_state = "nightvision1"
	else if(user.nightvision == 1)
		user.see_in_dark = 4
		user.see_invisible = 45
		user.nightvision = 0
		user.hud_used.nightvisionicon.icon_state = "nightvision0"

	return 1


code:
/mob/living/carbon/alien/humanoid/drone
	name = "alien drone"
	caste = "d"
	maxHealth = 100
	health = 100
	icon_state = "aliend_s"
	plasma_rate = 15

/mob/living/carbon/alien/humanoid/drone/New()
	create_reagents(100)
	if(src.name == "alien drone")
		src.name = text("alien drone ([rand(1, 1000)])")
	src.real_name = src.name

	AddAbility(new/obj/effect/proc_holder/alien/resin(null))
	AddAbility(new/obj/effect/proc_holder/alien/acid(null))
	AddAbility(new/obj/effect/proc_holder/alien/evolve(null))

	..()
//Drones use the same base as generic humanoids.

/mob/living/carbon/alien/humanoid/drone/movement_delay()
	. = ..()
	. += 1

/obj/effect/proc_holder/alien/evolve
	name = "Evolve"
	desc = "Produce an interal egg sac capable of spawning children. Only one queen can exist at a time."
	plasma_cost = 500

	action_icon_state = "alien_evolve_drone"

/obj/effect/proc_holder/alien/evolve/fire(var/mob/living/carbon/alien/user)
	var/no_queen = 1
	for(var/mob/living/carbon/alien/humanoid/queen/Q in living_mob_list)
		if(!Q.key || !Q.getorgan(/obj/item/organ/brain))
			continue
		no_queen = 0
	if(no_queen)
		user << "You begin to evolve!"
		user.visible_message("[user] begins to twist and contort!")
		var/mob/living/carbon/alien/humanoid/queen/new_xeno = new (user.loc)
		user.transfer_borer(new_xeno)
		user.mind.transfer_to(new_xeno)
		qdel(user)
		return 1
	else
		user << "We already have an alive queen."
		return 0


code:
/mob/living/carbon/alien/humanoid/hunter
	name = "alien hunter"
	caste = "h"
	maxHealth = 150
	health = 150
	storedPlasma = 100
	max_plasma = 150
	icon_state = "alienh_s"
	plasma_rate = 5

/mob/living/carbon/alien/humanoid/hunter/New()
	create_reagents(100)
	if(name == "alien hunter")
		name = text("alien hunter ([rand(1, 1000)])")
	real_name = name
	..()

/mob/living/carbon/alien/humanoid/hunter/handle_hud_icons_health()
	if (healths)
		if (stat != 2)
			switch(health)
				if(150 to INFINITY)
					healths.icon_state = "health0"
				if(120 to 150)
					healths.icon_state = "health1"
				if(90 to 120)
					healths.icon_state = "health2"
				if(60 to 90)
					healths.icon_state = "health3"
				if(30 to 60)
					healths.icon_state = "health4"
				if(0 to 30)
					healths.icon_state = "health5"
				else
					healths.icon_state = "health6"
		else
			healths.icon_state = "health7"

/mob/living/carbon/alien/humanoid/hunter/movement_delay()
	. = -1		//hunters are sanic
	. += ..()	//but they still need to slow down on stun

//Hunter verbs

/mob/living/carbon/alien/humanoid/hunter/proc/toggle_leap(var/message = 1)
	leap_on_click = !leap_on_click
	leap_icon.icon_state = "leap_[leap_on_click ? "on":"off"]"
	update_icons()
	if(message)
		src << "You will now [leap_on_click ? "leap at":"slash at"] enemies!"
	else
		return

/mob/living/carbon/alien/humanoid/hunter/ClickOn(var/atom/A, var/params)
	face_atom(A)
	if(leap_on_click)
		leap_at(A)
	else
		..()

#define MAX_ALIEN_LEAP_DIST 7

/mob/living/carbon/alien/humanoid/hunter/proc/leap_at(var/atom/A)
	if(pounce_cooldown)
		src << "You are too fatigued to pounce right now!"
		return

	if(leaping) //Leap while you leap, so you can leap while you leap
		return

	if(!has_gravity(src) || !has_gravity(A))
		src << "It is unsafe to leap without gravity!"
		//It's also extremely buggy visually, so it's balance+bugfix
		return
	if(lying)
		return

	else //Maybe uses plasma in the future, although that wouldn't make any sense...
		leaping = 1
		update_icons()
		throw_at(A,MAX_ALIEN_LEAP_DIST,1)
		leaping = 0
		update_icons()

/mob/living/carbon/alien/humanoid/hunter/throw_impact(A)

	if(!leaping)
		return ..()

	if(A)
		if(istype(A, /mob/living))
			var/mob/living/L = A
			L.visible_message("[src] pounces on [L]!", "[src] pounces on you!")
			L.Weaken(5)
			sleep(2)//Runtime prevention (infinite bump() calls on hulks)
			step_towards(src,L)

			toggle_leap(0)
			pounce_cooldown = !pounce_cooldown
			spawn(pounce_cooldown_time) //3s by default
				pounce_cooldown = !pounce_cooldown
		else
			visible_message("[src] smashes into [A]!", "[src] smashes into [A]!")
			weakened = 2

		if(leaping)
			leaping = 0
			update_canmove()

/mob/living/carbon/alien/humanoid/float(on)
	if(leaping)
		return
	..()

//Modified throw_at() that will use diagonal dirs where appropriate
//instead of locking it to cardinal dirs
/mob/living/carbon/alien/humanoid/throw_at(atom/target, range, speed)
	if(!target || !src || (flags & NODROP))	return 0

	src.throwing = 1

	var/dist_x = abs(target.x - src.x)
	var/dist_y = abs(target.y - src.y)
	var/dist_travelled = 0
	var/dist_since_sleep = 0

	var/tdist_x = dist_x;
	var/tdist_y = dist_y;

	if(dist_x <= dist_y)
		tdist_x = dist_y;
		tdist_y = dist_x;

	var/error = tdist_x/2 - tdist_y
	while(target && (((((dist_x > dist_y) && ((src.x < target.x) || (src.x > target.x))) || ((dist_x <= dist_y) && ((src.y < target.y) || (src.y > target.y))) || (src.x > target.x)) && dist_travelled < range) || !has_gravity(src)))

		if(!src.throwing) break
		if(!istype(src.loc, /turf)) break

		var/atom/step = get_step(src, get_dir(src,target))
		if(!step)
			break
		src.Move(step, get_dir(src, step))
		hit_check()
		error += (error < 0) ? tdist_x : -tdist_y;
		dist_travelled++
		dist_since_sleep++
		if(dist_since_sleep >= speed)
			dist_since_sleep = 0
			sleep(1)

	src.throwing = 0

	return 1


code:
/mob/living/carbon/alien/humanoid/sentinel
	name = "alien sentinel"
	caste = "s"
	maxHealth = 125
	health = 125
	storedPlasma = 100
	max_plasma = 250
	icon_state = "aliens_s"
	plasma_rate = 10

/mob/living/carbon/alien/humanoid/sentinel/New()
	create_reagents(100)
	if(name == "alien sentinel")
		name = text("alien sentinel ([rand(1, 1000)])")
	real_name = name

	AddAbility(new/obj/effect/proc_holder/alien/acid(null))
	AddAbility(new/obj/effect/proc_holder/alien/neurotoxin(null))

	..()

/mob/living/carbon/alien/humanoid/sentinel/handle_hud_icons_health()
	if (healths)
		if (stat != 2)
			switch(health)
				if(125 to INFINITY)
					healths.icon_state = "health0"
				if(100 to 125)
					healths.icon_state = "health1"
				if(75 to 100)
					healths.icon_state = "health2"
				if(50 to 75)
					healths.icon_state = "health3"
				if(25 to 50)
					healths.icon_state = "health4"
				if(0 to 25)
					healths.icon_state = "health5"
				else
					healths.icon_state = "health6"
		else
			healths.icon_state = "health7"

/mob/living/carbon/alien/humanoid/sentinel/movement_delay()
	. = ..()
	. += 1


code:
/mob/living/carbon/alien/humanoid/death(gibbed)
	if(stat == DEAD)	return
	if(healths)			healths.icon_state = "health6"
	stat = DEAD

	if(!gibbed)
		playsound(loc, 'sound/voice/hiss6.ogg', 80, 1, 1)
		visible_message("[src] lets out a waning guttural screech, green blood bubbling from its maw...")
		update_canmove()
		if(client)	blind.layer = 0
		update_icons()

	tod = worldtime2text() //weasellos time of death patch
	if(mind) 	mind.store_memory("Time of death: [tod]", 0)

	return ..(gibbed)


code:
/mob/living/carbon/alien/humanoid/emote(var/act)

	var/param = null
	if (findtext(act, "-", 1, null))
		var/t1 = findtext(act, "-", 1, null)
		param = copytext(act, t1 + 1, length(act) + 1)
		act = copytext(act, 1, t1)

	if(findtext(act,"s",-1) && !findtext(act,"_",-2))//Removes ending s's unless they are prefixed with a '_'
		act = copytext(act,1,length(act))
	var/muzzled = is_muzzled()
	var/m_type = 1
	var/message

	switch(act) //Alphabetical please
		if ("deathgasp")
			message = "[src] lets out a waning guttural screech, green blood bubbling from its maw..."
			m_type = 2

		if ("gnarl")
			if (!muzzled)
				message = "[src] gnarls and shows its teeth.."
				m_type = 2

		if ("hiss")
			if(!muzzled)
				message = "[src] hisses."
				m_type = 2

		if ("moan")
			message = "[src] moans!"
			m_type = 2

		if ("roar")
			if (!muzzled)
				message = "[src] roars."
				m_type = 2

		if ("roll")
			if (!src.restrained())
				message = "[src] rolls."
				m_type = 1

		if ("scratch")
			if (!src.restrained())
				message = "[src] scratches."
				m_type = 1

		if ("scretch")
			if (!muzzled)
				message = "[src] scretches."
				m_type = 2

		if ("shiver")
			message = "[src] shivers."
			m_type = 2

		if ("sign")
			if (!src.restrained())
				message = text("[src] signs[].", (text2num(param) ? text(" the number []", text2num(param)) : null))
				m_type = 1

		if ("tail")
			message = "[src] waves its tail."
			m_type = 1

		if ("help") //This is an exception
			src << "Help for xenomorph emotes. You can use these emotes with say \"*emote\":\n\naflap, airguitar, blink, blink_r, blush, bow, burp, choke, chucke, clap, collapse, cough, dance, deathgasp, drool, flap, frown, gasp, giggle, glare-(none)/mob, gnarl, hiss, jump, laugh, look-atom, me, moan, nod, point-atom, roar, roll, scream, scratch, scretch, shake, shiver, sign-#, sit, smile, sneeze, sniff, snore, stare-(none)/mob, sulk, sway, tail, tremble, twitch, twitch_s, wave, whimper, wink, yawn"

		else
			..(act)

	if ((message && src.stat == 0))
		log_emote("[name]/[key] : [message]")
		if (act == "roar")
			playsound(src.loc, 'sound/voice/hiss5.ogg', 40, 1, 1)

		if (act == "deathgasp")
			playsound(src.loc, 'sound/voice/hiss6.ogg', 80, 1, 1)

		if (m_type & 1)
			visible_message(message)
		else
			audible_message(message)
	return


code:
/mob/living/carbon/alien/humanoid
	name = "alien"
	icon_state = "alien_s"
	var/obj/item/r_store = null
	var/obj/item/l_store = null
	var/caste = ""
	var/leap_on_click = 0
	var/pounce_cooldown = 0
	var/pounce_cooldown_time = 30

//This is fine right now, if we're adding organ specific damage this needs to be updated
/mob/living/carbon/alien/humanoid/New()
	create_reagents(1000)
	if(name == "alien")
		name = text("alien ([rand(1, 1000)])")
	real_name = name

	AddAbility(new/obj/effect/proc_holder/alien/plant(null))
	AddAbility(new/obj/effect/proc_holder/alien/whisper(null))
	AddAbility(new/obj/effect/proc_holder/alien/transfer(null))
	AddAbility(new/obj/effect/proc_holder/alien/regurgitate(null))

	..()

/mob/living/carbon/alien/humanoid/movement_delay()
	. = ..()
	. += move_delay_add + config.alien_delay	//move_delay_add is used to slow aliens with stuns

///mob/living/carbon/alien/humanoid/bullet_act(var/obj/item/projectile/Proj) taken care of in living

/mob/living/carbon/alien/humanoid/emp_act(severity)
	if(r_store) r_store.emp_act(severity)
	if(l_store) l_store.emp_act(severity)
	..()

/mob/living/carbon/alien/humanoid/attack_slime(mob/living/carbon/slime/M as mob)
	..()
	var/damage = rand(5, 35)
	if(M.is_adult)
		damage = rand(10, 40)
	adjustBruteLoss(damage)
	add_logs(M, src, "attacked", admin=0)
	updatehealth()
	return

/mob/living/carbon/alien/humanoid/attack_hulk(mob/living/carbon/human/user)
	if(user.a_intent == "harm")
		..(user, 1)
		adjustBruteLoss(14 + rand(1,9))
		Paralyse(1)
		step_away(src,user,15)
		sleep(1)
		step_away(src,user,15)
		return 1

/mob/living/carbon/alien/humanoid/attack_hand(mob/living/carbon/human/M as mob)
	if(..())
		switch(M.a_intent)
			if ("harm")
				var/damage = rand(1, 9)
				if (prob(90))
					playsound(loc, "punch", 25, 1, -1)
					visible_message("[M] has punched [src]!", \
							"[M] has punched [src]!")
					if ((stat != DEAD) && (damage > 9 || prob(5)))//Regular humans have a very small chance of weakening an alien.
						Paralyse(2)
						visible_message("[M] has weakened [src]!", \
								"[M] has weakened [src]!")
					adjustBruteLoss(damage)
					add_logs(M, src, "attacked", admin=0)
					updatehealth()
				else
					playsound(loc, 'sound/weapons/punchmiss.ogg', 25, 1, -1)
					visible_message("[M] has attempted to punch [src]!")

			if ("disarm")
				if (!lying)
					if (prob(5))
						Paralyse(2)
						playsound(loc, 'sound/weapons/thudswoosh.ogg', 50, 1, -1)
						add_logs(M, src, "pushed", admin=0)
						visible_message("[M] has pushed down [src]!", \
							"[M] has pushed down [src]!")
					else
						if (prob(50))
							drop_item()
							playsound(loc, 'sound/weapons/thudswoosh.ogg', 50, 1, -1)
							visible_message("[M] has disarmed [src]!", \
							"[M] has disarmed [src]!")
						else
							playsound(loc, 'sound/weapons/punchmiss.ogg', 25, 1, -1)
							visible_message("[M] has attempted to disarm [src]!")

/mob/living/carbon/alien/humanoid/restrained()
	if (handcuffed)
		return 1
	return 0

/mob/living/carbon/alien/humanoid/show_inv(mob/user)
	user.set_machine(src)
	var/dat = {"

	[name]

Left Hand: 		[l_hand		? l_hand	: "Nothing"]

Right Hand: 		[r_hand		? r_hand	: "Nothing"]

Empty Pouches"}

	if(handcuffed)
		dat += "
Handcuffed"
	if(legcuffed)
		dat += "
Legcuffed"

	dat += {"

Close
	"}
	user << browse(dat, "window=mob\ref[src];size=325x500")
	onclose(user, "mob\ref[src]")

/mob/living/carbon/alien/humanoid/Topic(href, href_list)
	..()
	//strip panel
	if(usr.canUseTopic(src, BE_CLOSE, NO_DEXTERY))
		if(href_list["pouches"])
			visible_message("[usr] tries to empty [src]'s pouches.", \
							"[usr] tries to empty [src]'s pouches.")
			if(do_mob(usr, src, POCKET_STRIP_DELAY * 0.5))
				unEquip(r_store)
				unEquip(l_store)

/mob/living/carbon/alien/humanoid/reagent_check(var/datum/reagent/R)
	return 0


code:
/mob/living/carbon/alien/humanoid/unEquip(obj/item/I)
	. = ..()
	if(!. || !I)
		return


code:
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32

/mob/living/carbon/alien/humanoid
	pass_flags = PASSTABLE

/mob/living/carbon/alien/humanoid/proc/adjust_body_temperature(current, loc_temp, boost)
	var/temperature = current
	var/difference = abs(current-loc_temp)	//get difference
	var/increments// = difference/10			//find how many increments apart they are
	if(difference > 50)
		increments = difference/5
	else
		increments = difference/10
	var/change = increments*boost	// Get the amount to change by (x per increment)
	var/temp_change
	if(current < loc_temp)
		temperature = min(loc_temp, temperature+change)
	else if(current > loc_temp)
		temperature = max(loc_temp, temperature-change)
	temp_change = (temperature - current)
	return temp_change


code:
/mob/living/carbon/alien/humanoid/Login()
	..()
	update_hud()
	if(!isturf(loc))
		client.eye = loc
		client.perspective = EYE_PERSPECTIVE
	return


code:
/mob/living/carbon/alien/humanoid/queen
	name = "alien queen"
	caste = "q"
	maxHealth = 250
	health = 250
	icon_state = "alienq_s"
	status_flags = CANPARALYSE
	heal_rate = 5
	plasma_rate = 20
	ventcrawler = 0 //pull over that ass too fat

/mob/living/carbon/alien/humanoid/queen/New()
	create_reagents(100)

	//there should only be one queen
	for(var/mob/living/carbon/alien/humanoid/queen/Q in living_mob_list)
		if(Q == src)		continue
		if(Q.stat == DEAD)	continue
		if(Q.client)
			name = "alien princess ([rand(1, 999)])"	//if this is too cutesy feel free to change it/remove it.
			break

	real_name = src.name

	AddAbility(new/obj/effect/proc_holder/alien/acid(null))
	AddAbility(new/obj/effect/proc_holder/alien/neurotoxin(null))
	AddAbility(new/obj/effect/proc_holder/alien/resin(null))
	AddAbility(new/obj/effect/proc_holder/alien/lay_egg(null))

	..()

/mob/living/carbon/alien/humanoid/queen/handle_hud_icons_health()
	if (src.healths)
		if (src.stat != 2)
			switch(health)
				if(250 to INFINITY)
					src.healths.icon_state = "health0"
				if(200 to 250)
					src.healths.icon_state = "health1"
				if(150 to 200)
					src.healths.icon_state = "health2"
				if(100 to 150)
					src.healths.icon_state = "health3"
				if(50 to 100)
					src.healths.icon_state = "health4"
				if(0 to 50)
					src.healths.icon_state = "health5"
				else
					src.healths.icon_state = "health6"
		else
			src.healths.icon_state = "health7"

/mob/living/carbon/alien/humanoid/queen/movement_delay()
	. = ..()
	. += 5

//Queen verbs
/obj/effect/proc_holder/alien/lay_egg
	name = "Lay Egg"
	desc = "Lay an egg to produce huggers to impregnate prey with."
	plasma_cost = 75
	check_turf = 1

	action_icon_state = "alien_egg"

/obj/effect/proc_holder/alien/lay_egg/fire(var/mob/living/carbon/alien/user)
	if(locate(/obj/structure/alien/egg) in get_turf(user))
		user << "There's already an egg here."
		return 0
	user.visible_message("[user] has laid an egg!")
	new /obj/structure/alien/egg(user.loc)
	return 1

/mob/living/carbon/alien/humanoid/queen/large
	icon = 'icons/mob/alienqueen.dmi'
	icon_state = "queen_s"
	pixel_x = -16
	mob_size = MOB_SIZE_LARGE

/mob/living/carbon/alien/humanoid/queen/large/update_icons()
	update_hud()		//TODO: remove the need for this to be here
	overlays.Cut()
	if(stat == DEAD)
		icon_state = "queen_dead"
	else if(stat == UNCONSCIOUS || lying || resting)
		icon_state = "queen_sleep"
	else
		icon_state = "queen_s"
	for(var/image/I in overlays_standing)
		overlays += I


code:
//Xeno Overlays Indexes//////////
#define X_L_HAND_LAYER			1
#define X_R_HAND_LAYER			2
#define X_FIRE_LAYER			3
#define X_TOTAL_LAYERS			3
/////////////////////////////////

/mob/living/carbon/alien/humanoid
	var/list/overlays_standing[X_TOTAL_LAYERS]

/mob/living/carbon/alien/humanoid/update_icons()
	update_hud()		//TODO: remove the need for this to be here
	overlays.Cut()
	for(var/image/I in overlays_standing)
		overlays += I

	if(stat == DEAD)
		//If we mostly took damage from fire
		if(fireloss > 125)
			icon_state = "alien[caste]_husked"
			pixel_y = 0
		else
			icon_state = "alien[caste]_dead"
			pixel_y = 0

	else if(stat == UNCONSCIOUS || weakened)
		icon_state = "alien[caste]_unconscious"
		pixel_y = 0
	else if(leap_on_click)
		icon_state = "alien[caste]_pounce"

	else if(lying || resting)
		icon_state = "alien[caste]_sleep"
	else if(m_intent == "run")
		icon_state = "alien[caste]_running"
	else
		icon_state = "alien[caste]_s"

	if(leaping)
		icon = 'icons/mob/alienleap.dmi'
		icon_state = "alien[caste]_leap"
		pixel_x = -32
		pixel_y = -32
	else
		icon = initial(icon)
		pixel_x = initial(pixel_x)
		pixel_y = initial(pixel_y)

/mob/living/carbon/alien/humanoid/regenerate_icons()
	..()
	if (notransform)	return

	update_inv_r_hand(0)
	update_inv_l_hand(0)
	update_hud()
//	update_icons() //Handled in update_transform(), leaving this here as a reminder
	update_fire()
	update_transform()

/mob/living/carbon/alien/humanoid/update_transform() //The old method of updating lying/standing was update_icons(). Aliens still expect that.
	if(lying > 0)
		lying = 90 //Anything else looks retarded
	update_icons()
	..()

/mob/living/carbon/alien/humanoid/update_hud()
	if(client)
		client.screen |= contents

/mob/living/carbon/alien/humanoid/update_inv_r_hand(update_icons = 1)
	if(r_hand)
		var/t_state = r_hand.item_state
		if(!t_state)
			t_state = r_hand.icon_state
		r_hand.screen_loc = ui_rhand
		overlays_standing[X_R_HAND_LAYER]	= image("icon" = r_hand.righthand_file, "icon_state" = t_state)
	else
		overlays_standing[X_R_HAND_LAYER]	= null
	if(update_icons)
		update_icons()

/mob/living/carbon/alien/humanoid/update_inv_l_hand(update_icons = 1)
	if(l_hand)
		var/t_state = l_hand.item_state
		if(!t_state)
			t_state = l_hand.icon_state
		l_hand.screen_loc = ui_lhand
		overlays_standing[X_L_HAND_LAYER]	= image("icon" = l_hand.lefthand_file, "icon_state" = t_state)
	else
		overlays_standing[X_L_HAND_LAYER]	= null
	if(update_icons)
		update_icons()

/mob/living/carbon/alien/humanoid/update_fire()
	overlays -= overlays_standing[X_FIRE_LAYER]
	if(on_fire)
		overlays_standing[X_FIRE_LAYER] = image("icon"='icons/mob/OnFire.dmi', "icon_state"="Standing", "layer"= -X_FIRE_LAYER)
		overlays += overlays_standing[X_FIRE_LAYER]
		return
	else
		overlays_standing[X_FIRE_LAYER] = null

//Xeno Overlays Indexes//////////
#undef X_L_HAND_LAYER
#undef X_R_HAND_LAYER
#undef X_FIRE_LAYER
#undef X_TOTAL_LAYERS


code:
/mob/living/carbon/alien/larva/death(gibbed)
	if(stat == DEAD)	return
	if(healths)			healths.icon_state = "health6"
	stat = DEAD
	icon_state = "larva_dead"

	if(!gibbed)
		visible_message("[src] lets out a waning high-pitched cry.")
		update_canmove()
		if(client)	blind.layer = 0

	tod = worldtime2text() //weasellos time of death patch
	if(mind)	mind.store_memory("Time of death: [tod]", 0)
	living_mob_list -= src

	return ..(gibbed)


code:
/mob/living/carbon/alien/larva/emote(var/act)

	var/param = null
	if (findtext(act, "-", 1, null))
		var/t1 = findtext(act, "-", 1, null)
		param = copytext(act, t1 + 1, length(act) + 1)
		act = copytext(act, 1, t1)

	if(findtext(act,"s",-1) && !findtext(act,"_",-2))//Removes ending s's unless they are prefixed with a '_'
		act = copytext(act,1,length(act))
	var/muzzled = is_muzzled()
	var/m_type = 1
	var/message

	switch(act) //Alphabetically sorted please.
		if ("burp")
			if (!muzzled)
				message = "[src] burps."
				m_type = 2
		if ("choke")
			message = "[src] chokes."
			m_type = 2
		if ("collapse")
			Paralyse(2)
			message = "[src] collapses!"
			m_type = 2
		if ("dance")
			if (!src.restrained())
				message = "[src] dances around happily."
				m_type = 1
		if ("drool")
			message = "[src] drools."
			m_type = 1
		if ("gasp")
			message = "[src] gasps."
			m_type = 2
		if ("gnarl")
			if (!muzzled)
				message = "[src] gnarls and shows its teeth.."
				m_type = 2
		if ("hiss")
			message = "[src] hisses softly."
			m_type = 1
		if ("jump")
			message = "[src] jumps!"
			m_type = 1
		if ("moan")
			message = "[src] moans!"
			m_type = 2
		if ("nod")
			message = "[src] nods its head."
			m_type = 1
//		if ("roar")
//			if (!muzzled)
//				message = "[src] roars." Commenting out since larva shouldn't roar /N
//				m_type = 2
		if ("roll")
			if (!src.restrained())
				message = "[src] rolls."
				m_type = 1
		if ("scratch")
			if (!src.restrained())
				message = "[src] scratches."
				m_type = 1
		if ("scretch")
			if (!muzzled)
				message = "[src] scretches."
				m_type = 2
		if ("shake")
			message = "[src] shakes its head."
			m_type = 1
		if ("shiver")
			message = "[src] shivers."
			m_type = 2
		if ("sign")
			if (!src.restrained())
				message = text("[src] signs[].", (text2num(param) ? text(" the number []", text2num(param)) : null))
				m_type = 1
		if ("snore")
			message = "[src] snores."
			m_type = 2
		if ("sulk")
			message = "[src] sulks down sadly."
			m_type = 1
		if ("sway")
			message = "[src] sways around dizzily."
			m_type = 1
		if ("tail")
			message = "[src] waves its tail."
			m_type = 1
		if ("twitch")
			message = "[src] twitches violently."
			m_type = 1
		if ("whimper")
			if (!muzzled)
				message = "[src] whimpers."
				m_type = 2

		if ("help") //"The exception"
			src << "Help for larva emotes. You can use these emotes with say \"*emote\":\n\nburp, choke, collapse, dance, drool, gasp, gnarl, hiss, jump, moan, nod, roll, scratch,\nscretch, shake, shiver, sign-#, sulk, sway, tail, twitch, whimper"

		else
			src << " Unusable emote '[act]'. Say *help for a list."

	if ((message && src.stat == 0))
		log_emote("[name]/[key] : [message]")
		if (m_type & 1)
			visible_message(message)
		else
			audible_message(message)
	return


code:
//can't unequip since it can't equip anything
/mob/living/carbon/alien/larva/unEquip(obj/item/W as obj)
	return


code:
/mob/living/carbon/alien/larva
	name = "alien larva"
	real_name = "alien larva"
	icon_state = "larva0"
	pass_flags = PASSTABLE | PASSMOB
	mob_size = MOB_SIZE_SMALL

	maxHealth = 50
	health = 50
	storedPlasma = 50
	max_plasma = 50

	var/amount_grown = 0
	var/max_grown = 200
	var/time_of_birth

//This is fine right now, if we're adding organ specific damage this needs to be updated
/mob/living/carbon/alien/larva/New()
	create_reagents(100)
	if(name == "alien larva")
		name = "alien larva ([rand(1, 1000)])"
	real_name = name
	regenerate_icons()
	AddAbility(new/obj/effect/proc_holder/alien/hide(null))
	AddAbility(new/obj/effect/proc_holder/alien/larva_evolve(null))
	..()

//This needs to be fixed
/mob/living/carbon/alien/larva/Stat()
	..()
	if(statpanel("Status"))
		stat(null, "Progress: [amount_grown]/[max_grown]")

/mob/living/carbon/alien/larva/adjustToxLoss(amount)
	if(stat != DEAD)
		amount_grown = min(amount_grown + 1, max_grown)
	..(amount)

//can't equip anything
/mob/living/carbon/alien/larva/attack_ui(slot_id)
	return

/mob/living/carbon/alien/larva/attack_slime(mob/living/carbon/slime/M as mob)

	..()
	var/damage = rand(5, 35)
	if(M.is_adult)
		damage = rand(20, 40)
	adjustBruteLoss(damage)
	add_logs(M, src, "attacked", admin=0)
	updatehealth()
	return

/mob/living/carbon/alien/larva/attack_hulk(mob/living/carbon/human/user)
	if(user.a_intent == "harm")
		..(user, 1)
		adjustBruteLoss(5 + rand(1,9))
		Paralyse(1)
		spawn()
			step_away(src,user,15)
			sleep(1)
			step_away(src,user,15)
		return 1

/mob/living/carbon/alien/larva/attack_hand(mob/living/carbon/human/M as mob)
	if(..())
		var/damage = rand(1, 9)
		if (prob(90))
			playsound(loc, "punch", 25, 1, -1)
			add_logs(M, src, "attacked", admin=0)
			visible_message("[M] has kicked [src]!", \
					"[M] has kicked [src]!")
			if ((stat != DEAD) && (damage > 4.9))
				Paralyse(rand(5,10))

			adjustBruteLoss(damage)
			updatehealth()
		else
			playsound(loc, 'sound/weapons/punchmiss.ogg', 25, 1, -1)
			visible_message("[M] has attempted to kick [src]!", \
					"[M] has attempted to kick [src]!")

	return

/mob/living/carbon/alien/larva/restrained()
	return 0

// new damage icon system
// now constructs damage icon for each organ from mask * damage field

/mob/living/carbon/alien/larva/show_inv(mob/user)
	return

/mob/living/carbon/alien/larva/toggle_throw_mode()
	return

/mob/living/carbon/alien/larva/start_pulling()
	return

/mob/living/carbon/alien/larva/stripPanelUnequip(obj/item/what, mob/who)
	src << "You don't have the dexterity to do this!"
	return

/mob/living/carbon/alien/larva/stripPanelEquip(obj/item/what, mob/who)
	src << "You don't have the dexterity to do this!"
	return


code:
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32

/mob/living/carbon/alien/larva/Life()
	set invisibility = 0
	set background = BACKGROUND_ENABLED

	if (notransform)
		return
	if(..())
		// GROW!
		if(amount_grown < max_grown)
			amount_grown++

	//some kind of bug in canmove() isn't properly calling update_icons, so this is here as a placeholder
	update_icons()

/mob/living/carbon/alien/larva/handle_hud_icons_health()

	if (healths)
		if (stat != 2)
			switch(health)
				if(25 to INFINITY)
					healths.icon_state = "health0"
				if(20 to 25)
					healths.icon_state = "health1"
				if(15 to 20)
					healths.icon_state = "health2"
				if(10 to 15)
					healths.icon_state = "health3"
				if(5 to 10)
					healths.icon_state = "health4"
				if(0 to 5)
					healths.icon_state = "health5"
				else
					healths.icon_state = "health6"
		else
			healths.icon_state = "health7"


code:
/mob/living/carbon/alien/larva/Login()
	return ..()


code:
/obj/effect/proc_holder/alien/hide
	name = "Hide"
	desc = "Allows to hide beneath tables or certain items. Toggled on or off."
	plasma_cost = 0

	action_icon_state = "alien_hide"

/obj/effect/proc_holder/alien/hide/fire(var/mob/living/carbon/alien/user)
	if(user.stat != CONSCIOUS)
		return

	if (user.layer != TURF_LAYER+0.2)
		user.layer = TURF_LAYER+0.2
		user.visible_message("[user] scurries to the ground!", \
						"You are now hiding.")
	else
		user.layer = MOB_LAYER
		user.visible_message("[user.] slowly peaks up from the ground...", \
					"You stop hiding.")
	return 1

/obj/effect/proc_holder/alien/larva_evolve
	name = "Evolve"
	desc = "Evolve into a fully grown Alien."
	plasma_cost = 0

	action_icon_state = "alien_evolve_larva"

/obj/effect/proc_holder/alien/larva_evolve/fire(var/mob/living/carbon/alien/user)
	if(!islarva(user))
		return
	var/mob/living/carbon/alien/larva/L = user

	if(L.stat != CONSCIOUS)
		return
	if(L.handcuffed || L.legcuffed) // Cuffing larvas ? Eh ?
		user << "You cannot evolve when you are cuffed."

	if(L.amount_grown >= L.max_grown)	//TODO ~Carn
		L << "You are growing into a beautiful alien! It is time to choose a caste."
		L << "There are three to choose from:"
		L << "Hunters  are strong and agile, able to hunt away from the hive and rapidly move through ventilation shafts. Hunters generate plasma slowly and have low reserves."
		L << "Sentinels  are tasked with protecting the hive and are deadly up close and at a range. They are not as physically imposing nor fast as the hunters."
		L << "Drones  are the working class, offering the largest plasma storage and generation. They are the only caste which may evolve again, turning into the dreaded alien queen."
		var/alien_caste = alert(L, "Please choose which alien caste you shall belong to.",,"Hunter","Sentinel","Drone")

		var/mob/living/carbon/alien/humanoid/new_xeno
		switch(alien_caste)
			if("Hunter")
				new_xeno = new /mob/living/carbon/alien/humanoid/hunter(L.loc)
			if("Sentinel")
				new_xeno = new /mob/living/carbon/alien/humanoid/sentinel(L.loc)
			if("Drone")
				new_xeno = new /mob/living/carbon/alien/humanoid/drone(L.loc)
		L.transfer_borer(new_xeno)
		if(L.mind)	L.mind.transfer_to(new_xeno)
		qdel(L)
		return 0
	else
		user << "You are not fully grown."
		return 0


code:
/mob/living/carbon/alien/larva/regenerate_icons()
	overlays = list()
	update_icons()

/mob/living/carbon/alien/larva/update_icons()
	var/state = 0
	if(amount_grown > 150)
		state = 2
	else if(amount_grown > 50)
		state = 1

	if(stat == DEAD)
		icon_state = "larva[state]_dead"
	else if (handcuffed || legcuffed) //This should be an overlay. Who made this an icon_state?
		icon_state = "larva[state]_cuff"
	else if(stat == UNCONSCIOUS || lying || resting)
		icon_state = "larva[state]_sleep"
	else if (stunned)
		icon_state = "larva[state]_stun"
	else
		icon_state = "larva[state]"

/mob/living/carbon/alien/larva/update_transform() //All this is handled in update_icons()
	return update_icons()


code:
/mob/living/carbon/alien/check_breath(datum/gas_mixture/breath)
	if(status_flags & GODMODE)
		return

	if(!breath || (breath.total_moles() == 0))
		//Aliens breathe in vaccuum
		return 0

	var/toxins_used = 0
	var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.temperature)/BREATH_VOLUME

	//Partial pressure of the toxins in our breath
	var/Toxins_pp = (breath.toxins/breath.total_moles())*breath_pressure

	if(Toxins_pp) // Detect toxins in air

		adjustToxLoss(breath.toxins*250)
		throw_alert("alien_tox")

		toxins_used = breath.toxins

	else
		clear_alert("alien_tox")

	//Breathe in toxins and out oxygen
	breath.toxins -= toxins_used
	breath.oxygen += toxins_used

	//BREATH TEMPERATURE
	handle_breath_temperature(breath)

/mob/living/carbon/alien/handle_regular_status_updates()
	..()
	//natural reduction of movement delay due to stun.
	if(move_delay_add > 0)
		move_delay_add = max(0, move_delay_add - rand(1, 2))

	return 1

/mob/living/carbon/alien/handle_vision()

	client.screen.Remove(global_hud.blurry, global_hud.druggy, global_hud.vimpaired, global_hud.darkMask)

	if (stat == 2)
		sight |= SEE_TURFS
		sight |= SEE_MOBS
		sight |= SEE_OBJS
		see_in_dark = 8
		see_invisible = SEE_INVISIBLE_LEVEL_TWO
	else if (stat != 2)
		sight |= SEE_MOBS
		sight &= ~SEE_TURFS
		sight &= ~SEE_OBJS
		if(nightvision)
			see_in_dark = 8
			see_invisible = SEE_INVISIBLE_MINIMUM
		else if(!nightvision)
			see_in_dark = 4
			see_invisible = 45
		if(see_override)
			see_invisible = see_override

	if ((blind && stat != 2))
		if((eye_blind))
			blind.layer = 18
		else
			blind.layer = 0

			if (disabilities & NEARSIGHT)
				client.screen += global_hud.vimpaired

			if (eye_blurry)
				client.screen += global_hud.blurry

			if (druggy)
				client.screen += global_hud.druggy

	if (stat != 2)
		if(machine)
			if (!( machine.check_eye(src) ))
				reset_view(null)
		else
			if(!client.adminobs)
				reset_view(null)

/mob/living/carbon/alien/handle_hud_icons()
	update_action_buttons()
	handle_actions()

	handle_hud_icons_health()

	return 1


code:
/mob/living/carbon/alien/Login()
	..()
	AddInfectionImages()
	return


code:
/mob/living/carbon/alien/Logout()
	..()
	RemoveInfectionImages()
	return


code:
/mob/living/carbon/alien/say(var/message)
	. = ..(message, "A")
	if(.)
		playsound(loc, "hiss", 25, 1, 1) //erp just isn't the same without sound feedback

/mob/living/proc/alien_talk(var/message)
	log_say("[key_name(src)] : [message]")
	message = trim(message)

	if (!message)
		return

	var/message_a = say_quote(message)
	var/rendered = "Hivemind, [name] [message_a]"
	for(var/mob/S in player_list)
		if((!S.stat && (S.hivecheck())))
			S << rendered
	for (var/mob/M in dead_mob_list)
		if(!istype(M,/mob/new_player) && !istype(M,/mob/living/carbon/brain)) //No meta-evesdropping
			rendered = "Hivemind, (Follow)[name] [message_a]"
			M << rendered

/mob/living/carbon/alien/handle_inherent_channels(message, message_mode)
	if(!..())
		if(message_mode == MODE_ALIEN)
			if(hivecheck())
				alien_talk(message)
			return 1
		return 0

/mob/living/carbon/alien/hivecheck()
	return 1


code:
/obj/screen/zone_sel/alien/update_icon()
	overlays.Cut()
	overlays += selecting

/mob/living/carbon/alien/proc/updatePlasmaDisplay()
	if(hud_used) //clientless aliens
		hud_used.alien_plasma_display.maptext = "
 [storedPlasma]
"

/mob/living/carbon/alien/larva/updatePlasmaDisplay()
	return


code:
// This is to replace the previous datum/disease/alien_embryo for slightly improved handling and maintainability
// It functions almost identically (see code/datums/diseases/alien_embryo.dm)
var/const/ALIEN_AFK_BRACKET = 450 // 45 seconds

/obj/item/body_egg/alien_embryo
	name = "alien embryo"
	var/stage = 0

/obj/item/body_egg/alien_embryo/egg_process()
	if(stage < 5 && prob(3))
		stage++
		spawn(0)
			RefreshInfectionImage()

	switch(stage)
		if(2, 3)
			if(affected_mob == DEAD)
				return
			if(prob(1))
				affected_mob.emote("sneeze")
			if(prob(1))
				affected_mob.emote("cough")
			if(prob(1))
				affected_mob << "Your throat feels sore."
			if(prob(1))
				affected_mob << "Mucous runs down the back of your throat."
		if(4)
			if(affected_mob == DEAD)
				return
			if(prob(1))
				affected_mob.emote("sneeze")
			if(prob(1))
				affected_mob.emote("cough")
			if(prob(2))
				affected_mob << "Your muscles ache."
				if(prob(20))
					affected_mob.take_organ_damage(1)
			if(prob(2))
				affected_mob << "Your stomach hurts."
				if(prob(20))
					affected_mob.adjustToxLoss(1)
					affected_mob.updatehealth()
		if(5)
			if(affected_mob != DEAD)
				affected_mob << "You feel something tearing its way out of your stomach..."
				affected_mob.adjustToxLoss(10)
				affected_mob.updatehealth()
			if(prob(50))
				AttemptGrow()

/obj/item/body_egg/alien_embryo/proc/AttemptGrow(var/gib_on_success = 1)
	var/list/candidates = get_candidates(BE_ALIEN, ALIEN_AFK_BRACKET)
	var/client/C = null

	// To stop clientless larva, we will check that our host has a client
	// if we find no ghosts to become the alien. If the host has a client
	// he will become the alien but if he doesn't then we will set the stage
	// to 2, so we don't do a process heavy check everytime.

	if(candidates.len)
		C = pick(candidates)
	else if(affected_mob.client)
		C = affected_mob.client
	else
		stage = 4 // Let's try again later.
		return

	if(affected_mob.lying)
		affected_mob.overlays += image('icons/mob/alien.dmi', loc = affected_mob, icon_state = "burst_lie")
	else
		affected_mob.overlays += image('icons/mob/alien.dmi', loc = affected_mob, icon_state = "burst_stand")
	spawn(6)
		var/mob/living/carbon/alien/larva/new_xeno = new(affected_mob.loc)
		new_xeno.key = C.key
		new_xeno << sound('sound/voice/hiss5.ogg',0,0,0,100)	//To get the player's attention
		if(gib_on_success)
			affected_mob.gib()
		if(istype(new_xeno.loc,/mob/living/carbon))
			var/mob/living/carbon/digester = new_xeno.loc
			digester.stomach_contents += new_xeno
		qdel(src)

/*----------------------------------------
Proc: RefreshInfectionImage()
Des: Removes the current icons located in the infected mob adds the current stage
----------------------------------------*/
/obj/item/body_egg/alien_embryo/RefreshInfectionImage()
	RemoveInfectionImages()
	AddInfectionImages()

/*----------------------------------------
Proc: AddInfectionImages(C)
Des: Adds the infection image to all aliens for this embryo
----------------------------------------*/
/obj/item/body_egg/alien_embryo/AddInfectionImages()
	for(var/mob/living/carbon/alien/alien in player_list)
		if(alien.client)
			var/I = image('icons/mob/alien.dmi', loc = affected_mob, icon_state = "infected[stage]")
			alien.client.images += I

/*----------------------------------------
Proc: RemoveInfectionImage(C)
Des: Removes all images from the mob infected by this embryo
----------------------------------------*/
/obj/item/body_egg/alien_embryo/RemoveInfectionImages()
	for(var/mob/living/carbon/alien/alien in player_list)
		if(alien.client)
			for(var/image/I in alien.client.images)
				if(dd_hasprefix_case(I.icon_state, "infected") && I.loc == affected_mob)
					qdel(I)


code:
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32

//TODO: Make these simple_animals

var/const/MIN_IMPREGNATION_TIME = 100 //time it takes to impregnate someone
var/const/MAX_IMPREGNATION_TIME = 150

var/const/MIN_ACTIVE_TIME = 200 //time between being dropped and going idle
var/const/MAX_ACTIVE_TIME = 400

/obj/item/clothing/mask/facehugger
	name = "alien"
	desc = "It has some sort of a tube at the end of its tail."
	icon = 'icons/mob/alien.dmi'
	icon_state = "facehugger"
	item_state = "facehugger"
	w_class = 1 //note: can be picked up by aliens unlike most other items of w_class below 4
	flags = MASKCOVERSMOUTH | MASKCOVERSEYES | MASKINTERNALS
	throw_range = 5
	tint = 3

	var/stat = CONSCIOUS //UNCONSCIOUS is the idle state in this case

	var/sterile = 0
	var/real = 1 //0 for the toy, 1 for real. Sure I could istype, but fuck that. //quality
	var/strength = 5

	var/attached = 0

/obj/item/clothing/mask/facehugger/attack_alien(user as mob) //can be picked up by aliens
	attack_hand(user)
	return

/obj/item/clothing/mask/facehugger/attack_hand(user as mob)
	if((stat == CONSCIOUS && !sterile) && !isalien(user))
		if(Attach(user))
			return
	..()

/obj/item/clothing/mask/facehugger/attack(mob/living/M as mob, mob/user as mob)
	..()
	user.unEquip(src)
	Attach(M)

/obj/item/clothing/mask/facehugger/examine(mob/user)
	..()
	if(!real)//So that giant red text about probisci doesn't show up.
		return
	switch(stat)
		if(DEAD,UNCONSCIOUS)
			user << "[src] is not moving."
		if(CONSCIOUS)
			user << "[src] seems to be active!"
	if (sterile)
		user << "It looks like the proboscis has been removed."

/obj/item/clothing/mask/facehugger/attackby(var/obj/item/O,var/mob/m, params)
	if(O.force)
		Die()
	return

/obj/item/clothing/mask/facehugger/bullet_act(var/obj/item/projectile/P)
	if(P.damage)
		Die()
	return

/obj/item/clothing/mask/facehugger/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
	if(exposed_temperature > 300)
		Die()
	return

/obj/item/clothing/mask/facehugger/equipped(mob/M)
	Attach(M)

/obj/item/clothing/mask/facehugger/Crossed(atom/target)
	HasProximity(target)
	return

/obj/item/clothing/mask/facehugger/on_found(mob/finder as mob)
	if(stat == CONSCIOUS)
		return HasProximity(finder)
	return 0

/obj/item/clothing/mask/facehugger/HasProximity(atom/movable/AM as mob|obj)
	if(CanHug(AM))
		return Attach(AM)
	return 0

/obj/item/clothing/mask/facehugger/throw_at(atom/target, range, speed)
	if(!..())
		return
	if(stat == CONSCIOUS)
		icon_state = "[initial(icon_state)]_thrown"
		spawn(15)
			if(icon_state == "[initial(icon_state)]_thrown")
				icon_state = "[initial(icon_state)]"

/obj/item/clothing/mask/facehugger/throw_impact(atom/hit_atom)
	..()
	if(stat == CONSCIOUS)
		icon_state = "[initial(icon_state)]"
		Attach(hit_atom)

/obj/item/clothing/mask/facehugger/proc/Attach(M as mob)
	if( (!iscorgi(M) && !iscarbon(M)) || isalien(M))
		return 0
	if(attached)
		return 0
	else
		attached++
		spawn(MAX_IMPREGNATION_TIME)
			attached = 0

	var/mob/living/L = M //just so I don't need to use :

	if(loc == L) return 0
	if(stat != CONSCIOUS)	return 0
	if(locate(/obj/item/body_egg/alien_embryo) in L) return 0
	if(!sterile) L.take_organ_damage(strength,0) //done here so that even borgs and humans in helmets take damage

	L.visible_message("[src] leaps at [L]'s face!", \
						"[src] leaps at [L]'s face!")

	if(ishuman(L))
		var/mob/living/carbon/human/H = L
		if(H.is_mouth_covered(head_only = 1))
			H.visible_message("[src] smashes against [H]'s [H.head]!", \
								"[src] smashes against [H]'s [H.head]!")
			Die()
			return 0

	if(iscarbon(M))
		var/mob/living/carbon/target = L
		if(target.wear_mask)
			if(prob(20))	return 0
			var/obj/item/clothing/W = target.wear_mask
			if(W.flags & NODROP)	return 0
			target.unEquip(W)

			target.visible_message("[src] tears [W] off of [target]'s face!", \
									"[src] tears [W] off of [target]'s face!")

		src.loc = target
		target.equip_to_slot(src, slot_wear_mask,,0)

		if(!sterile) L.Paralyse(MAX_IMPREGNATION_TIME/6) //something like 25 ticks = 20 seconds with the default settings
	else if (iscorgi(M))
		var/mob/living/simple_animal/corgi/C = M
		loc = C
		C.facehugger = src
		C.regenerate_icons()

	GoIdle() //so it doesn't jump the people that tear it off

	spawn(rand(MIN_IMPREGNATION_TIME,MAX_IMPREGNATION_TIME))
		Impregnate(L)

	return 1

/obj/item/clothing/mask/facehugger/proc/Impregnate(mob/living/target as mob)
	if(!target || target.stat == DEAD) //was taken off or something
		return

	if(iscarbon(target))
		var/mob/living/carbon/C = target
		if(C.wear_mask != src)
			return

	if(!sterile)
		//target.contract_disease(new /datum/disease/alien_embryo(0)) //so infection chance is same as virus infection chance
		target.visible_message("[src] falls limp after violating [target]'s face!", \
								"[src] falls limp after violating [target]'s face!")

		Die()
		icon_state = "[initial(icon_state)]_impregnated"

		if(!target.getlimb(/obj/item/organ/limb/robot/chest) && !(target.status_flags & XENO_HOST))
			new /obj/item/body_egg/alien_embryo(target)

		if(iscorgi(target))
			var/mob/living/simple_animal/corgi/C = target
			src.loc = get_turf(C)
			C.facehugger = null
	else
		target.visible_message("[src] violates [target]'s face!", \
								"[src] violates [target]'s face!")
	return

/obj/item/clothing/mask/facehugger/proc/GoActive()
	if(stat == DEAD || stat == CONSCIOUS)
		return

	stat = CONSCIOUS
	icon_state = "[initial(icon_state)]"

/*		for(var/mob/living/carbon/alien/alien in world)
		var/image/activeIndicator = image('icons/mob/alien.dmi', loc = src, icon_state = "facehugger_active")
		activeIndicator.override = 1
		if(alien && alien.client)
			alien.client.images += activeIndicator	*/

	return

/obj/item/clothing/mask/facehugger/proc/GoIdle()
	if(stat == DEAD || stat == UNCONSCIOUS)
		return

/*		RemoveActiveIndicators()	*/

	stat = UNCONSCIOUS
	icon_state = "[initial(icon_state)]_inactive"

	spawn(rand(MIN_ACTIVE_TIME,MAX_ACTIVE_TIME))
		GoActive()
	return

/obj/item/clothing/mask/facehugger/proc/Die()
	if(stat == DEAD)
		return

/*		RemoveActiveIndicators()	*/

	icon_state = "[initial(icon_state)]_dead"
	stat = DEAD

	visible_message("[src] curls up into a ball!")

	return

/proc/CanHug(var/mob/M)
	if(!istype(M))
		return 0
	if(M.stat == DEAD)
		return 0

	if(iscorgi(M) || ismonkey(M))
		return 1

	var/mob/living/carbon/C = M
	if(ishuman(C))
		var/mob/living/carbon/human/H = C
		if(H.is_mouth_covered(head_only = 1))
			return 0
		return 1
	return 0


code:
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32

/obj/item/device/mmi
	name = "Man-Machine Interface"
	desc = "The Warrior's bland acronym, MMI, obscures the true horror of this monstrosity, that nevertheless has become standard-issue on Nanotrasen stations."
	icon = 'icons/obj/assemblies.dmi'
	icon_state = "mmi_empty"
	w_class = 3
	origin_tech = "biotech=3"
	var/braintype = "Cyborg"

	var/list/mommi_assembly_parts = list(
		/obj/item/weapon/stock_parts/cell = 1,
		/obj/item/robot_parts/l_leg = 2,
		/obj/item/robot_parts/r_leg = 2,
		/obj/item/robot_parts/r_arm = 1,
		/obj/item/robot_parts/l_arm = 1)

	req_access = list(access_robotics)

	//Revised. Brainmob is now contained directly within object of transfer. MMI in this case.

	var/locked = 0
	var/mob/living/carbon/brain/brainmob = null //The current occupant.
	var/mob/living/silicon/robot = null //Appears unused.
	var/obj/mecha = null //This does not appear to be used outside of reference in mecha.dm.
	var/obj/item/organ/brain/brain = null //The actual brain

/obj/item/device/mmi/update_icon()
	if(brain)
		if(istype(brain,/obj/item/organ/brain/alien))
			icon_state = "mmi_alien"
			braintype = "Xenoborg" //HISS....Beep.
		else
			icon_state = "mmi_full"
			braintype = "Cyborg"
	else
		icon_state = "mmi_empty"

/obj/item/device/mmi/proc/try_handling_mommi_construction(var/obj/item/O as obj, var/mob/user as mob)
	if (ismommi(user))
		return //no
	if(istype(O,/obj/item/weapon/screwdriver))
		for(var/t in mommi_assembly_parts)
			var/cc=contents_count(t)
			var/req=mommi_assembly_parts[t]
			if(cc<req)
				var/temppart = new t(src)
				user << "\red You're short [req-cc] [temppart]\s."
				del(temppart)
				return TRUE

		if(!istype(loc,/turf))
			user << "\red You can't assemble the MoMMI, \the [src] has to be standing on the ground (or a table) to be perfectly precise."
			return TRUE
		if(!brainmob)
			user << "\red What are you doing oh god put the brain back in."
			return TRUE
		if(!brainmob.key)
			var/ghost_can_reenter = 0
			if(brainmob.mind)
				for(var/mob/dead/observer/G in player_list)
					if(G.can_reenter_corpse && G.mind == brainmob.mind)
						ghost_can_reenter = 1
						break
			if(!ghost_can_reenter)
				user << "\The [src] indicates that their mind is completely unresponsive; there's no point."
				return TRUE

		if(brainmob.stat == DEAD)
			user << "\red Yeah, good idea. Give something deader than the pizza in your fridge legs.  Mom would be so proud."
			return TRUE

		if(brainmob.mind in ticker.mode.head_revolutionaries)
			user << "\red \The [src]'s firmware lets out a shrill sound, and flashes 'Abnormal Memory Engram'. It refuses to accept the brain."
			return TRUE

		if(jobban_isbanned(brainmob, "Cyborg"))
			user << "\red This brain does not seem to fit."
			return TRUE

			//canmove = 0
		icon = null
		invisibility = 101

		var/mob/living/silicon/robot/mommi/M = new /mob/living/silicon/robot/mommi(get_turf(loc))
		if(!M)	return

		user.drop_item()

		M.invisibility = 0
		//M.custom_name = created_name
		M.choose_icon()
		brainmob.mind.transfer_to(M)

		if(M.mind && M.mind.special_role)
			M.mind.store_memory("In case you look at this after being borged, the objectives are only here until I find a way to make them not show up for you, as I can't simply delete them without screwing up round-end reporting. --NeoFite")

		M.job = "Cyborg"

		M.cell = locate(/obj/item/weapon/stock_parts/cell) in contents
		M.cell.loc = M
		src.loc = M//Should fix cybros run time erroring when blown up. It got deleted before, along with the frame.
		M.mmi = src
		return TRUE
	for(var/t in mommi_assembly_parts)
		if(istype(O,t))
			var/cc=contents_count(t)
			if(cc<mommi_assembly_parts[t])
				if(!brainmob)
					user << "\red Why are you sticking robot legs on an empty [src], you idiot?"
					return TRUE
				contents += O
				user.drop_item()
				O.loc=src
				user << "\blue You successfully add \the [O] to the contraption,"
				return TRUE
			else if(cc==mommi_assembly_parts[t])
				user << "\red You have enough of these."
				return TRUE
	return FALSE

/obj/item/device/mmi/attackby(var/obj/item/O as obj, var/mob/user as mob, params)
	if(try_handling_mommi_construction(O,user))
		return
	if(istype(O,/obj/item/organ/brain)) //Time to stick a brain in it --NEO
		var/obj/item/organ/brain/newbrain = O
		if(brain)
			user << "There's already a brain in the MMI!"
			return
		if(!newbrain.brainmob)
			user << "You aren't sure where this brain came from, but you're pretty sure it's a useless brain."
			return
		visible_message("[user] sticks \a [newbrain] into \the [src]")

		brainmob = newbrain.brainmob
		newbrain.brainmob = null
		brainmob.loc = src
		brainmob.container = src
		brainmob.stat = 0
		dead_mob_list -= brainmob //Update dem lists
		living_mob_list += brainmob

		user.drop_item()
		newbrain.loc = src //P-put your brain in it
		brain = newbrain

		name = "Man-Machine Interface: [brainmob.real_name]"
		update_icon()

		locked = 1

		feedback_inc("cyborg_mmis_filled",1)

		return

	if((istype(O,/obj/item/weapon/card/id)||istype(O,/obj/item/device/pda)) && brainmob)
		if(allowed(user))
			locked = !locked
			user << "You [locked ? "lock" : "unlock"] the brain holder."
		else
			user << "Access denied."
		return
	if(brainmob)
		O.attack(brainmob, user) //Oh noooeeeee
		return
	..()

/obj/item/device/mmi/attack_self(mob/user as mob)
	if(!brain)
		user << "You upend the MMI, but there's nothing in it."
	else if(locked)
		user << "You upend the MMI, but the brain is clamped into place."
	else
		user << "You upend the MMI, spilling the brain onto the floor."

		brainmob.container = null //Reset brainmob mmi var.
		brainmob.loc = brain //Throw mob into brain.
		living_mob_list -= brainmob //Get outta here
		brain.brainmob = brainmob //Set the brain to use the brainmob
		brainmob = null //Set mmi brainmob var to null

		brain.loc = usr.loc
		brain = null //No more brain in here

		update_icon()
		name = "Man-Machine Interface"

/obj/item/device/mmi/proc/transfer_identity(var/mob/living/carbon/human/H) //Same deal as the regular brain proc. Used for human-->robot people.
	brainmob = new(src)
	brainmob.name = H.real_name
	brainmob.real_name = H.real_name
	if(check_dna_integrity(H))
		brainmob.dna = H.dna
	brainmob.container = src

	if(istype(H))
		var/obj/item/organ/brain/newbrain = H.getorgan(/obj/item/organ/brain)
		newbrain.loc = src
		brain = newbrain

	name = "Man-Machine Interface: [brainmob.real_name]"
	update_icon()
	locked = 1
	return

/obj/item/device/mmi/radio_enabled
	name = "Radio-enabled Man-Machine Interface"
	desc = "The Warrior's bland acronym, MMI, obscures the true horror of this monstrosity, that nevertheless has become standard-issue on Nanotrasen stations. This one comes with a built-in radio."
	origin_tech = "biotech=4"

	var/obj/item/device/radio/radio = null //Let's give it a radio.

/obj/item/device/mmi/radio_enabled/New()
	..()
	radio = new(src) //Spawns a radio inside the MMI.
	radio.broadcasting = 0 //researching radio mmis turned the robofabs into radios because this didnt start as 0.

/obj/item/device/mmi/radio_enabled/verb/Toggle_Listening()
	set name = "Toggle Listening"
	set desc = "Toggle listening channel on or off."
	set category = "MMI"
	set src = usr.loc
	set popup_menu = 0

	if(brainmob.stat)
		brainmob << "Can't do that while incapacitated or dead."

	radio.listening = radio.listening==1 ? 0 : 1
	brainmob << "Radio is [radio.listening==1 ? "now" : "no longer"] receiving broadcast."

/obj/item/device/mmi/emp_act(severity)
	if(!brainmob)
		return
	if(istype(src.loc, /mob/living/silicon) || istype(src.loc, /obj/mecha)) //don't emp MMIs if they're inside a robot or mech, that's just stupid
		return
	else
		switch(severity)
			if(1)
				brainmob.emp_damage += rand(20,30)
			if(2)
				brainmob.emp_damage += rand(10,20)
			if(3)
				brainmob.emp_damage += rand(0,10)
	..()

/obj/item/device/mmi/Destroy()
	if(isrobot(loc))
		var/mob/living/silicon/robot/borg = loc
		borg.mmi = null
	if(brainmob)
		qdel(brainmob)
		brainmob = null
	..()

/obj/item/device/mmi/proc/contents_count(var/type)
	var/c=0
	for(var/O in contents)
		if(istype(O,type))
			c++
	return c


code:
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32

/mob/living/carbon/brain
	languages = HUMAN
	var/obj/item/container = null
	var/timeofhostdeath = 0
	var/emp_damage = 0//Handles a type of MMI damage
	var/alert = null

/mob/living/carbon/brain/New()
	create_reagents(1000)
	..()

/mob/living/carbon/brain/Destroy()
	if(key)				//If there is a mob connected to this thing. Have to check key twice to avoid false death reporting.
		if(stat!=DEAD)	//If not dead.
			death(1)	//Brains can die again. AND THEY SHOULD AHA HA HA HA HA HA
		ghostize()		//Ghostize checks for key so nothing else is necessary.
	..()

/mob/living/carbon/brain/update_canmove()
	if(in_contents_of(/obj/mecha))	canmove = 1
	else							canmove = 0
	return canmove

/mob/living/carbon/brain/toggle_throw_mode()
	return

/mob/living/carbon/brain/ex_act() //you cant blow up brainmobs because it makes transfer_to() freak out when borgs blow up.
	return

/mob/living/carbon/brain/blob_act()
	return

/mob/living/carbon/brain/on_forcemove(var/atom/newloc)
	if(container)
		container.loc = newloc
	else //something went very wrong.
		CRASH("Brainmob without container.")
	loc = container

/mob/living/carbon/brain/UnarmedAttack(var/atom/A)//Stops runtimes due to attack_animal being the default
	return


code:
/obj/item/organ/brain
	name = "brain"
	desc = "A piece of juicy meat found in a person's head."
	icon = 'icons/obj/surgery.dmi'
	icon_state = "brain"
	force = 1.0
	w_class = 2.0
	throwforce = 0
	throw_speed = 3
	throw_range = 5
	origin_tech = "biotech=3"
	attack_verb = list("attacked", "slapped", "whacked")
	var/mob/living/carbon/brain/brainmob = null

/obj/item/organ/brain/New()
	..()
	//Shifting the brain "mob" over to the brain object so it's easier to keep track of. --NEO
	spawn(5)
		if(brainmob && brainmob.client)
			brainmob.client.screen.len = null //clear the hud

/obj/item/organ/brain/proc/transfer_identity(mob/living/carbon/H)
	name = "[H]'s brain"
	brainmob = new(src)
	brainmob.name = H.real_name
	brainmob.real_name = H.real_name
	brainmob.dna = H.dna
	brainmob.timeofhostdeath = H.timeofdeath
	if(H.mind)
		H.mind.transfer_to(brainmob)
	brainmob << "You feel slightly disoriented. That's normal when you're just a brain."

/obj/item/organ/brain/examine(mob/user)
	..()
	if(brainmob && brainmob.client)
		user << "You can feel the small spark of life still left in this one."
	else
		user << "This one seems particularly lifeless. Perhaps it will regain some of its luster later."

/obj/item/organ/brain/attack(mob/living/carbon/M, mob/user)
	if(!istype(M))
		return ..()

	add_fingerprint(user)

	if(user.zone_sel.selecting != "head")
		return ..()

	var/mob/living/carbon/human/H = M
	if(istype(M, /mob/living/carbon/human) && ((H.head && H.head.flags & HEADCOVERSEYES) || (H.wear_mask && H.wear_mask.flags & MASKCOVERSEYES) || (H.glasses && H.glasses.flags & GLASSESCOVERSEYES)))
		user << "You're going to need to remove their head cover first."
		return

//since these people will be dead M != usr

	if(!M.getorgan(/obj/item/organ/brain))
		user.drop_item()
		for(var/mob/O in viewers(M, null))
			if(O == (user || M))
				continue
			if(M == user)
				O << "[user] inserts [src] into \his head!"
			else
				O << "[M] has [src] inserted into \his head by [user]."

		if(M != user)
			M << "[user] inserts [src] into your head!"
			user << "You insert [src] into [M]'s head!"
		else
			user << "You insert [src] into your head!"	//LOL

		//this might actually be outdated since barring badminnery, a debrain'd body will have any client sucked out to the brain's internal mob. Leaving it anyway to be safe. --NEO
		if(M.key)
			M.ghostize()

		if(brainmob.mind)
			brainmob.mind.transfer_to(M)
		else
			M.key = brainmob.key

		qdel(brainmob)

		M.internal_organs += src
		loc = null

		//Update the body's icon so it doesnt appear debrained anymore
		if(ishuman(M))
			H.update_hair(0)

	else
		..()

/obj/item/organ/brain/alien
	name = "alien brain"
	desc = "We barely understand the brains of terrestial animals. Who knows what we may find in the brain of such an advanced species?"
	icon_state = "brain-alien"
	origin_tech = "biotech=7"

/obj/item/organ/brain/Destroy() //copypasted from MMIs.
	if(brainmob)
		qdel(brainmob)
		brainmob = null
	..()


code:
/mob/living/carbon/brain/death(gibbed)
	if(stat == DEAD)	return
	if(!gibbed && container && istype(container, /obj/item/device/mmi))//If not gibbed but in a container.
		for(var/mob/O in viewers(container, null))
			O.show_message(text("[]'s MMI flatlines!", src), 1, "You hear something flatline.", 2)
		if(istype(src,/obj/item/organ/brain/alien))
			container.icon_state = "mmi_alien_dead"
		else
			container.icon_state = "mmi_dead"
	stat = DEAD

	if(blind)	blind.layer = 0
	sight |= SEE_TURFS|SEE_MOBS|SEE_OBJS
	see_in_dark = 8
	see_invisible = SEE_INVISIBLE_LEVEL_TWO

	tod = worldtime2text() //weasellos time of death patch
	if(mind)	mind.store_memory("Time of death: [tod]", 0)	//mind. ?

	return ..(gibbed)

/mob/living/carbon/brain/gib(var/animation = 0)
	if(container && istype(container, /obj/item/device/mmi))
		qdel(container)//Gets rid of the MMI if there is one
	if(loc)
		if(istype(loc,/obj/item/organ/brain))
			qdel(loc)//Gets rid of the brain item
	..()


code:
/mob/living/carbon/brain/emote(var/act,var/m_type=1,var/message = null)
	if(!(container && istype(container, /obj/item/device/mmi)))//No MMI, no emotes
		return

	if (findtext(act, "-", 1, null))
		var/t1 = findtext(act, "-", 1, null)
		act = copytext(act, 1, t1)

	if(findtext(act,"s",-1) && !findtext(act,"_",-2))//Removes ending s's unless they are prefixed with a '_'
		act = copytext(act,1,length(act))

	if(src.stat == DEAD)
		return
	switch(act)
		if ("alarm")
			src << "You sound an alarm."
			message = "[src] sounds an alarm."
			m_type = 2

		if ("alert")
			src << "You let out a distressed noise."
			message = "[src] lets out a distressed noise."
			m_type = 2

		if ("beep")
			src << "You beep."
			message = "[src] beeps."
			m_type = 2

		if ("blink")
			message = "[src] blinks."
			m_type = 1

		if ("boop")
			src << "You boop."
			message = "[src] boops."
			m_type = 2

		if ("flash")
			message = "The lights on [src] flash quickly."
			m_type = 1

		if ("notice")
			src << "You play a loud tone."
			message = "[src] plays a loud tone."
			m_type = 2

		if ("whistle")
			src << "You whistle."
			message = "[src] whistles."
			m_type = 2

		if ("help")
			src << "Help for MMI emotes. You can use these emotes with say \"*emote\":\nalarm, alert, beep, blink, boop, flash, notice, whistle"

		else
			src << "Unusable emote '[act]'. Say *help for a list."

	if (message)
		log_emote("[name]/[key] : [message]")

		for(var/mob/M in dead_mob_list)
			if (!M.client || istype(M, /mob/new_player))
				continue //skip monkeys, leavers, and new_players
			if(M.stat == DEAD && (M.client && (M.client.prefs.chat_toggles & CHAT_GHOSTSIGHT)) && !(M in viewers(src,null)))
				M.show_message(message)

		if (m_type & 1)
			visible_message(message)
		else if (m_type & 2)
			audible_message(message)


code:
/mob/living/carbon/brain/handle_breathing()
	return

/mob/living/carbon/brain/handle_mutations_and_radiation()

	if (radiation)
		if (radiation > 100)
			if(!container)//If it's not in an MMI
				src << "You feel weak."
			else//Fluff-wise, since the brain can't detect anything itself, the MMI handles thing like that
				src << "STATUS: CRITICAL AMOUNTS OF RADIATION DETECTED."

		switch(radiation)

			if(50 to 75)
				if(prob(5))
					if(!container)
						src << "You feel weak."
					else
						src << "STATUS: DANGEROUS LEVELS OF RADIATION DETECTED."
		..()

/mob/living/carbon/brain/handle_environment(datum/gas_mixture/environment)
	if(!environment)
		return
	var/environment_heat_capacity = environment.heat_capacity()
	if(istype(get_turf(src), /turf/space))
		var/turf/heat_turf = get_turf(src)
		environment_heat_capacity = heat_turf.heat_capacity

	if((environment.temperature > (T0C + 50)) || (environment.temperature < (T0C + 10)))
		var/transfer_coefficient = 1

		handle_temperature_damage(HEAD, environment.temperature, environment_heat_capacity*transfer_coefficient)

	if(stat==2)
		bodytemperature += 0.1*(environment.temperature - bodytemperature)*environment_heat_capacity/(environment_heat_capacity + 270000)

	//Account for massive pressure differences

	return //TODO: DEFERRED

/mob/living/carbon/brain/proc/handle_temperature_damage(body_part, exposed_temperature, exposed_intensity)
	if(status_flags & GODMODE) return

	if(exposed_temperature > bodytemperature)
		var/discomfort = min( abs(exposed_temperature - bodytemperature)*(exposed_intensity)/2000000, 1.0)
		adjustFireLoss(20.0*discomfort)

	else
		var/discomfort = min( abs(exposed_temperature - bodytemperature)*(exposed_intensity)/2000000, 1.0)
		adjustFireLoss(5.0*discomfort)

/mob/living/carbon/brain/handle_regular_status_updates()	//TODO: comment out the unused bits >_>

	if(stat == DEAD)
		eye_blind = max(eye_blind, 1)
		silent = 0
	else
		updatehealth()
		if( !container && (health < config.health_threshold_dead || ((world.time - timeofhostdeath) > config.revival_brain_life)) )
			death()
			eye_blind = max(eye_blind, 1)
			silent = 0
			return 1
	/*	if(health < config.health_threshold_crit)
			stat = UNCONSCIOUS
			eye_blind = max(eye_blind, 1) */
		else
			stat = CONSCIOUS

			//Handling EMP effect in the Life(), it's made VERY simply, and has some additional effects handled elsewhere
			if(emp_damage)			//This is pretty much a damage type only used by MMIs, dished out by the emp_act
				if(!(container && istype(container, /obj/item/device/mmi)))
					emp_damage = 0
				else
					emp_damage = round(emp_damage,1)//Let's have some nice numbers to work with
				switch(emp_damage)
					if(31 to INFINITY)
						emp_damage = 30//Let's not overdo it
					if(21 to 30)//High level of EMP damage, unable to see, hear, or speak
						eye_blind = max(eye_blind, 1)
						setEarDamage(-1,1)
						silent = 1
						if(!alert)//Sounds an alarm, but only once per 'level'
							emote("alarm")
							src << "Major electrical distruption detected: System rebooting."
							alert = 1
						if(prob(75))
							emp_damage -= 1
					if(20)
						alert = 0
						eye_blind = 0
						setEarDamage(-1,0)
						silent = 0
						emp_damage -= 1
					if(11 to 19)//Moderate level of EMP damage, resulting in nearsightedness and ear damage
						eye_blurry = 1
						setEarDamage(1,-1)
						if(!alert)
							emote("alert")
							src << "Primary systems are now online."
							alert = 1
						if(prob(50))
							emp_damage -= 1
					if(10)
						alert = 0
						eye_blurry = 0
						setEarDamage(0,-1)
						emp_damage -= 1
					if(2 to 9)//Low level of EMP damage, has few effects(handled elsewhere)
						if(!alert)
							emote("notice")
							src << "System reboot nearly complete."
							alert = 1
						if(prob(25))
							emp_damage -= 1
					if(1)
						alert = 0
						src << "All systems restored."
						emp_damage -= 1
			else
				eye_blind = 0

	return 1

/mob/living/carbon/brain/handle_regular_hud_updates()

	handle_vision()

	handle_hud_icons_health()

	return 1


code:
/mob/living/carbon/brain/Login()
	return ..()


code:
var/global/posibrain_notif_cooldown = 0

/obj/item/device/mmi/posibrain
	name = "positronic brain"
	desc = "A cube of shining metal, four inches to a side and covered in shallow grooves."
	icon = 'icons/obj/assemblies.dmi'
	icon_state = "posibrain"
	w_class = 3
	origin_tech = "biotech=3;programming=2;bluespace=2;materials=4"
	var/notified = 0
	var/askDelay = 10 * 60 * 1
	brainmob = null
	req_access = list(access_robotics)
	locked = 0
	mecha = null//This does not appear to be used outside of reference in mecha.dm.
	braintype = "Android"

/obj/item/device/mmi/posibrain/Topic(href, href_list)
	if(href_list["activate"])
		var/mob/dead/observer/ghost = usr
		if(istype(ghost))
			activate(ghost)

/obj/item/device/mmi/posibrain/proc/ping_ghosts(var/msg)
	if(!posibrain_notif_cooldown)
		notify_ghosts("Positronic Brain [msg] in [get_area(src)]. (Enter)")
		posibrain_notif_cooldown = 1
		spawn(askDelay) //Global one minute cooldown to avoid spam.
			posibrain_notif_cooldown = 0

/obj/item/device/mmi/posibrain/attack_self(mob/user as mob)
	if(brainmob && !brainmob.key && !notified)
		//Start the process of notified for a new user.
		user << "You carefully locate the manual activation switch and start the positronic brain's boot process."
		ping_ghosts("requested")
		notified = 1
		update_icon()
		spawn(askDelay) //Seperate from the global cooldown.
			notified = 0
			update_icon()
			visible_message("The positronic brain buzzes quietly, and the golden lights fade away. Perhaps you could try again?")

	return //Code for deleting personalities recommended here.

/obj/item/device/mmi/posibrain/attack_ghost(mob/user)
	activate(user)

//Two ways to activate a positronic brain. A clickable link in the ghost notif, or simply clicking the object itself.
/obj/item/device/mmi/posibrain/proc/activate(mob/user)
	if((brainmob && brainmob.key) || jobban_isbanned(user,"posibrain") || istype(src.loc, /mob/living/silicon))
		return

	var/posi_ask = alert("Become a positronic brain? (Warning, You can no longer be cloned, and all past lives will be forgotten!)","Are you positive?","Yes","No")
	if(posi_ask == "No" || gc_destroyed)
		return
	transfer_personality(user)

/obj/item/device/mmi/posibrain/transfer_identity(var/mob/living/carbon/H)
	name = "positronic brain ([H])"
	brainmob.name = H.real_name
	brainmob.real_name = H.real_name
	brainmob.dna = H.dna
	brainmob.timeofhostdeath = H.timeofdeath
	brainmob.stat = 0
	if(brainmob.mind)
		brainmob.mind.assigned_role = "Positronic Brain"
	if(H.mind)
		H.mind.transfer_to(brainmob)

	brainmob.mind.remove_all_antag()
	brainmob.mind.wipe_memory()

	brainmob << "ALL PAST LIVES ARE FORGOTTEN."

	brainmob << "Hello World!"
	update_icon()
	return

/obj/item/device/mmi/posibrain/proc/transfer_personality(var/mob/candidate)
	if(brainmob && brainmob.key || istype(src.loc, /mob/living/silicon)) //Prevents hostile takeover if two ghosts get the prompt for the same brain.
		candidate << "This brain has already been taken! Please try your possesion again later!"
		return
	notified = 0
	brainmob.mind = candidate.mind
	brainmob.ckey = candidate.ckey
	brainmob.name = "[pick(list("PBU","HIU","SINA","ARMA","OSI","HBL","MSO","RR"))]-[rand(100, 999)]" //Re-initialize the name so it doesn't repeat
	name = "positronic brain ([brainmob.name])"

	brainmob.mind.remove_all_antag()
	brainmob.mind.wipe_memory()

	brainmob << "ALL PAST LIVES ARE FORGOTTEN."

	brainmob << "You are a positronic brain, brought into existence on [station_name()]."
	brainmob << "As a synthetic intelligence, you answer to all crewmembers, as well as the AI."
	brainmob << "Remember, the purpose of your existence is to serve the crew and the station. Above all else, do no harm."
	brainmob.mind.assigned_role = "Positronic Brain"

	visible_message("The positronic brain chimes quietly.")
	update_icon()

/obj/item/device/mmi/posibrain/examine()

	set src in oview()

	if(!usr || !src)	return
	if( (usr.disabilities & BLIND || usr.stat) && !istype(usr,/mob/dead/observer) )
		usr << "Something is there but you can't see it."
		return

	var/msg = "*---------*\nThis is \icon[src] \a [src]!\n[desc]\n"
	msg += ""

	if(brainmob && brainmob.key)
		switch(brainmob.stat)
			if(CONSCIOUS)
				if(!src.brainmob.client)	msg += "It appears to be in stand-by mode.\n" //afk
			if(UNCONSCIOUS)		msg += "It doesn't seem to be responsive.\n"
			if(DEAD)			msg += "It appears to be completely inactive.\n"
	else
		msg += "It appears to be completely inactive.\n"
	msg += "*---------*"
	usr << msg
	return

/obj/item/device/mmi/posibrain/New()

	brainmob = new(src)
	brainmob.name = "[pick(list("PBU","HIU","SINA","ARMA","OSI","HBL","MSO","RR"))]-[rand(100, 999)]" //I bet these initial are references to tg admins, we could use some new ones
	brainmob.real_name = brainmob.name
	brainmob.loc = src
	brainmob.container = src
	brainmob.stat = 0
	brainmob.silent = 0
	dead_mob_list -= brainmob
	ping_ghosts("created")

	..()

/obj/item/device/mmi/posibrain/attackby(var/obj/item/O as obj, var/mob/user as mob)
	if(try_handling_mommi_construction(O,user))
		return
	return

/obj/item/device/mmi/posibrain/update_icon()
	if(notified)
		icon_state = "posibrain-searching"
		return
	if(brainmob && brainmob.key)
		icon_state = "posibrain-occupied"
	else
		icon_state = "posibrain"


code:
/mob/living/carbon/brain/say(var/message)
	if(!(container && istype(container, /obj/item/device/mmi)))
		return //No MMI, can't speak, bucko./N
	else
		if(prob(emp_damage*4))
			if(prob(10))//10% chane to drop the message entirely
				return
			else
				message = Gibberish(message, (emp_damage*6))//scrambles the message, gets worse when emp_damage is higher
		..()

/mob/living/carbon/brain/radio(message, message_mode)
	if(message_mode && istype(container, /obj/item/device/mmi/radio_enabled))
		var/obj/item/device/mmi/radio_enabled/R = container
		if(R.radio)
			R.radio.talk_into(src, message)
			return ITALICS | REDUCE_RANGE

/mob/living/carbon/brain/lingcheck()
	return 0