diff --git a/code/game/objects/items/implants/implant_mindshield.dm b/code/game/objects/items/implants/implant_mindshield.dm
index af2e7ffe765..31445f0f928 100644
--- a/code/game/objects/items/implants/implant_mindshield.dm
+++ b/code/game/objects/items/implants/implant_mindshield.dm
@@ -26,6 +26,21 @@
if(target.mind.has_antag_datum(/datum/antagonist/brainwashed))
target.mind.remove_antag_datum(/datum/antagonist/brainwashed)
+ var/datum/antagonist/hivemind/host = target.mind.has_antag_datum(/datum/antagonist/hivemind) //Releases the target from mind control beforehand
+ if(host)
+ var/datum/mind/M = host.owner
+ if(M)
+ var/obj/effect/proc_holder/spell/target_hive/hive_control/the_spell = locate(/obj/effect/proc_holder/spell/target_hive/hive_control) in M.spell_list
+ if(the_spell && the_spell.active)
+ the_spell.release_control()
+
+ if(target.mind.has_antag_datum(/datum/antagonist/rev/head) || target.mind.has_antag_datum(/datum/antagonist/hivemind) || target.mind.unconvertable)
+ if(!silent)
+ target.visible_message("[target] seems to resist the implant!", "You feel something interfering with your mental conditioning, but you resist it!")
+ removed(target, 1)
+ qdel(src)
+ return FALSE
+
if(is_hivemember(target))
var/warning = ""
for(var/datum/antagonist/hivemind/hive in GLOB.antagonists)
@@ -36,13 +51,6 @@
to_chat(target, "You hear supernatural wailing echo throughout your mind. If you listen closely you can hear... [warning]Are those... names?")
remove_hivemember(target)
- if(target.mind.has_antag_datum(/datum/antagonist/rev/head) || target.mind.unconvertable)
- if(!silent)
- target.visible_message("[target] seems to resist the implant!", "You feel something interfering with your mental conditioning, but you resist it!")
- removed(target, 1)
- qdel(src)
- return FALSE
-
var/datum/antagonist/rev/rev = target.mind.has_antag_datum(/datum/antagonist/rev)
if(rev)
rev.remove_revolutionary(FALSE, user)
diff --git a/code/modules/antagonists/hivemind/hivemind.dm b/code/modules/antagonists/hivemind/hivemind.dm
index c7dca50044e..9e43bd6af82 100644
--- a/code/modules/antagonists/hivemind/hivemind.dm
+++ b/code/modules/antagonists/hivemind/hivemind.dm
@@ -131,8 +131,8 @@
assim_objective.owner = owner
if(prob(25)) //Decently high chance to have to assimilate an implanted crew member
assim_objective.find_target_by_role(pick("Captain","Head of Security","Security Officer","Detective","Warden"))
- if(!assim_objective.target) //If the prob doesn't happen or there are no implanted crew, find any target
- assim_objective.find_target()
+ if(!assim_objective.target) //If the prob doesn't happen or there are no implanted crew, find any target that isn't a hivemmind host
+ assim_objective.find_target_by_role(role = ROLE_HIVE, role_type = 1, invert = 1)
assim_objective.update_explanation_text()
objectives += assim_objective
else if(prob(70))
diff --git a/code/modules/spells/spell_types/hivemind.dm b/code/modules/spells/spell_types/hivemind.dm
index 258bbd9b9b4..719dd623c81 100644
--- a/code/modules/spells/spell_types/hivemind.dm
+++ b/code/modules/spells/spell_types/hivemind.dm
@@ -291,13 +291,6 @@
else
power = 1200
charge_max = 1200
- for(var/datum/antagonist/hivemind/H in GLOB.antagonists)
- if(H.owner == user.mind)
- continue
- if(H.hivemembers.Find(vessel))
- to_chat(user, "We have detected a foreign presence within this mind, it would be unwise to merge so intimately with it.")
- revert_cast()
- return
original_body = user
vessel = targets[1]
to_chat(user, "We begin merging our mind with [vessel.name].")
@@ -309,6 +302,13 @@
to_chat(user, "Our vessel is too far away to control.")
revert_cast()
return
+ for(var/datum/antagonist/hivemind/H in GLOB.antagonists)
+ if(H.owner == user.mind)
+ continue
+ if(H.owner == vessel.mind)
+ to_chat(user, "We have detected a foreign presence within this mind, it would be unwise to merge so intimately with it.")
+ revert_cast()
+ return
backseat = new /mob/living/passenger()
if(vessel && vessel.mind && backseat)
var/obj/effect/proc_holder/spell/target_hive/hive_see/the_spell = locate(/obj/effect/proc_holder/spell/target_hive/hive_see) in user.mind.spell_list