diff --git a/code/datums/ai/babies/babies_behaviors.dm b/code/datums/ai/babies/babies_behaviors.dm index 716922cc7b2..553b192a180 100644 --- a/code/datums/ai/babies/babies_behaviors.dm +++ b/code/datums/ai/babies/babies_behaviors.dm @@ -32,7 +32,7 @@ partner = other //shyness check. we're not shy in front of things that share a faction with us. - else if(isliving(other) && !pawn_mob.faction_check_mob(other)) + else if(isliving(other) && !pawn_mob.faction_check_atom(other)) finish_action(controller, FALSE) return diff --git a/code/datums/ai/basic_mobs/targetting_datums/basic_targetting_datum.dm b/code/datums/ai/basic_mobs/targetting_datums/basic_targetting_datum.dm index bc4a554bc02..1d6fde335cb 100644 --- a/code/datums/ai/basic_mobs/targetting_datums/basic_targetting_datum.dm +++ b/code/datums/ai/basic_mobs/targetting_datums/basic_targetting_datum.dm @@ -81,7 +81,7 @@ /datum/targetting_datum/basic/proc/faction_check(datum/ai_controller/controller, mob/living/living_mob, mob/living/the_target) if (controller.blackboard[BB_ALWAYS_IGNORE_FACTION] || controller.blackboard[BB_TEMPORARILY_IGNORE_FACTION]) return FALSE - return living_mob.faction_check_mob(the_target, exact_match = check_factions_exactly) + return living_mob.faction_check_atom(the_target, exact_match = check_factions_exactly) /// Subtype more forgiving for items. /// Careful, this can go wrong and keep a mob hyper-focused on an item it can't lose aggro on diff --git a/code/datums/ai/generic/find_and_set.dm b/code/datums/ai/generic/find_and_set.dm index dc941ec33fa..43337674969 100644 --- a/code/datums/ai/generic/find_and_set.dm +++ b/code/datums/ai/generic/find_and_set.dm @@ -129,7 +129,7 @@ continue if (living_pawn.see_invisible < dead_pal.invisibility) continue - if (!living_pawn.faction_check_mob(dead_pal)) + if (!living_pawn.faction_check_atom(dead_pal)) continue nearby_bodies += dead_pal diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 41172ff552d..53b248fde38 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -18,6 +18,8 @@ var/initial_language_holder = /datum/language_holder /// Holds all languages this mob can speak and understand VAR_PRIVATE/datum/language_holder/language_holder + /// The list of factions this atom belongs to + var/list/faction var/verb_say = "says" var/verb_ask = "asks" @@ -1656,3 +1658,20 @@ */ /atom/movable/proc/keybind_face_direction(direction) setDir(direction) + +/** + * Check if the other atom/movable has any factions the same as us. Defined at the atom/movable level so it can be defined for just about anything. + * + * If exact match is set, then all our factions must match exactly + */ +/atom/movable/proc/faction_check_atom(atom/movable/target, exact_match) + if(!exact_match) + return faction_check(faction, target.faction, FALSE) + + var/list/faction_src = LAZYCOPY(faction) + var/list/faction_target = LAZYCOPY(target.faction) + if(!("[REF(src)]" in faction_target)) //if they don't have our ref faction, remove it from our factions list. + faction_src -= "[REF(src)]" //if we don't do this, we'll never have an exact match. + if(!("[REF(target)]" in faction_src)) + faction_target -= "[REF(target)]" //same thing here. + return faction_check(faction_src, faction_target, TRUE) diff --git a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm index 701d6222369..cacecb6a684 100644 --- a/code/game/machinery/porta_turret/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -40,6 +40,8 @@ DEFINE_BITFIELD(turret_flags, list( armor_type = /datum/armor/machinery_porta_turret base_icon_state = "standard" blocks_emissive = EMISSIVE_BLOCK_UNIQUE + // Same faction mobs will never be shot at, no matter the other settings + faction = list(FACTION_TURRET) ///if TRUE this will cause the turret to stop working if the stored_gun var is null in process() var/uses_stored = TRUE @@ -89,8 +91,6 @@ DEFINE_BITFIELD(turret_flags, list( var/on = TRUE /// Determines if our projectiles hit our faction var/ignore_faction = FALSE - /// Same faction mobs will never be shot at, no matter the other settings - var/list/faction = list(FACTION_TURRET) /// The spark system, used for generating... sparks? var/datum/effect_system/spark_spread/spark_system /// The turret will try to shoot from a turf in that direction when in a wall diff --git a/code/game/objects/items/food/monkeycube.dm b/code/game/objects/items/food/monkeycube.dm index ffc9b63c62f..d61b05477de 100644 --- a/code/game/objects/items/food/monkeycube.dm +++ b/code/game/objects/items/food/monkeycube.dm @@ -8,7 +8,6 @@ foodtypes = MEAT | SUGAR food_flags = FOOD_FINGER_FOOD w_class = WEIGHT_CLASS_TINY - var/faction var/spawned_mob = /mob/living/carbon/human/species/monkey /obj/item/food/monkeycube/proc/Expand() diff --git a/code/game/objects/structures/spawner.dm b/code/game/objects/structures/spawner.dm index 2ad70bdbc84..b654e0d43f4 100644 --- a/code/game/objects/structures/spawner.dm +++ b/code/game/objects/structures/spawner.dm @@ -8,11 +8,12 @@ anchored = TRUE density = TRUE + faction = list(FACTION_HOSTILE) + var/max_mobs = 5 var/spawn_time = 30 SECONDS var/mob_types = list(/mob/living/basic/carp) var/spawn_text = "emerges from" - var/faction = list(FACTION_HOSTILE) var/spawner_type = /datum/component/spawner /// Is this spawner taggable with something? var/scanner_taggable = FALSE diff --git a/code/modules/mapfluff/ruins/objects_and_mobs/ash_walker_den.dm b/code/modules/mapfluff/ruins/objects_and_mobs/ash_walker_den.dm index 5775f0a20f2..6f08be00e5d 100644 --- a/code/modules/mapfluff/ruins/objects_and_mobs/ash_walker_den.dm +++ b/code/modules/mapfluff/ruins/objects_and_mobs/ash_walker_den.dm @@ -13,8 +13,8 @@ resistance_flags = FIRE_PROOF | LAVA_PROOF max_integrity = 200 + faction = list(FACTION_ASHWALKER) - var/faction = list(FACTION_ASHWALKER) var/meat_counter = 6 var/datum/team/ashwalkers/ashies var/datum/linked_objective diff --git a/code/modules/mining/lavaland/megafauna_loot.dm b/code/modules/mining/lavaland/megafauna_loot.dm index 65d3a1ad3b3..20cbec1444b 100644 --- a/code/modules/mining/lavaland/megafauna_loot.dm +++ b/code/modules/mining/lavaland/megafauna_loot.dm @@ -401,7 +401,7 @@ give_blood(10) /obj/item/soulscythe/attack_hand(mob/user, list/modifiers) - if(soul.ckey && !soul.faction_check_mob(user)) + if(soul.ckey && !soul.faction_check_atom(user)) to_chat(user, span_warning("You can't pick up [src]!")) return return ..() diff --git a/code/modules/mob/living/basic/lavaland/legion/legion_ai.dm b/code/modules/mob/living/basic/lavaland/legion/legion_ai.dm index 310bbeb708e..ff29ea3c240 100644 --- a/code/modules/mob/living/basic/lavaland/legion/legion_ai.dm +++ b/code/modules/mob/living/basic/lavaland/legion/legion_ai.dm @@ -32,7 +32,7 @@ /datum/targetting_datum/basic/attack_until_dead/legion /datum/targetting_datum/basic/attack_until_dead/legion/faction_check(datum/ai_controller/controller, mob/living/living_mob, mob/living/the_target) - if (!living_mob.faction_check_mob(the_target, exact_match = check_factions_exactly)) + if (!living_mob.faction_check_atom(the_target, exact_match = check_factions_exactly)) return FALSE if (istype(the_target, living_mob.type)) return TRUE @@ -46,7 +46,7 @@ /datum/ai_planning_subtree/flee_target/legion/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) var/mob/living/target = controller.blackboard[target_key] - if (QDELETED(target) || target.faction_check_mob(controller.pawn)) + if (QDELETED(target) || target.faction_check_atom(controller.pawn)) return // Only flee if we have a hostile target return ..() diff --git a/code/modules/mob/living/basic/lavaland/legion/legion_brood.dm b/code/modules/mob/living/basic/lavaland/legion/legion_brood.dm index 962d232c5ef..7ce568d5760 100644 --- a/code/modules/mob/living/basic/lavaland/legion/legion_brood.dm +++ b/code/modules/mob/living/basic/lavaland/legion/legion_brood.dm @@ -49,7 +49,7 @@ if (ishuman(target) && target.stat > SOFT_CRIT) infest(target) return - if (isliving(target) && faction_check_mob(target) && !istype(target, created_by?.type)) + if (isliving(target) && faction_check_atom(target) && !istype(target, created_by?.type)) visible_message(span_warning("[src] melds with [target]'s flesh!")) target.apply_status_effect(/datum/status_effect/regenerative_core) new /obj/effect/temp_visual/heal(get_turf(target), COLOR_HEALING_CYAN) diff --git a/code/modules/mob/living/basic/space_fauna/mushroom.dm b/code/modules/mob/living/basic/space_fauna/mushroom.dm index 96280db2923..6f900b08abf 100644 --- a/code/modules/mob/living/basic/space_fauna/mushroom.dm +++ b/code/modules/mob/living/basic/space_fauna/mushroom.dm @@ -74,7 +74,7 @@ ///we only attacked another mushrooms /datum/targetting_datum/basic/mushroom/faction_check(datum/ai_controller/controller, mob/living/living_mob, mob/living/the_target) - return !living_mob.faction_check_mob(the_target, exact_match = check_factions_exactly) + return !living_mob.faction_check_atom(the_target, exact_match = check_factions_exactly) /datum/ai_planning_subtree/find_and_hunt_target/mushroom_food target_key = BB_LOW_PRIORITY_HUNTING_TARGET diff --git a/code/modules/mob/living/basic/space_fauna/regal_rat/regal_rat.dm b/code/modules/mob/living/basic/space_fauna/regal_rat/regal_rat.dm index 3bff85bec8f..24e53b3bf44 100644 --- a/code/modules/mob/living/basic/space_fauna/regal_rat/regal_rat.dm +++ b/code/modules/mob/living/basic/space_fauna/regal_rat/regal_rat.dm @@ -82,7 +82,7 @@ return if(ismouse(user)) - if(user.faction_check_mob(src, exact_match = TRUE)) + if(user.faction_check_atom(src, exact_match = TRUE)) . += span_notice("This is your king. Long live [p_their()] majesty!") else . += span_warning("This is a false king! Strike [p_them()] down!") @@ -192,7 +192,7 @@ balloon_alert(src, "already dead!") return FALSE - if(living_target.faction_check_mob(src, exact_match = TRUE)) + if(living_target.faction_check_atom(src, exact_match = TRUE)) balloon_alert(src, "one of your soldiers!") return FALSE diff --git a/code/modules/mob/living/basic/space_fauna/space_dragon/dragon_breath.dm b/code/modules/mob/living/basic/space_fauna/space_dragon/dragon_breath.dm index c5825f2e2e2..5be5038b3a4 100644 --- a/code/modules/mob/living/basic/space_fauna/space_dragon/dragon_breath.dm +++ b/code/modules/mob/living/basic/space_fauna/space_dragon/dragon_breath.dm @@ -9,7 +9,7 @@ melee_cooldown_time = 0 SECONDS /datum/action/cooldown/mob_cooldown/fire_breath/carp/on_burn_mob(mob/living/barbecued, mob/living/source) - if (!source.faction_check_mob(barbecued)) + if (!source.faction_check_atom(barbecued)) return ..() to_chat(barbecued, span_notice("[source]'s fiery breath fills you with energy!")) barbecued.apply_status_effect(/datum/status_effect/carp_invigoration) diff --git a/code/modules/mob/living/basic/space_fauna/space_dragon/dragon_gust.dm b/code/modules/mob/living/basic/space_fauna/space_dragon/dragon_gust.dm index a1b9a466bb4..074804de86c 100644 --- a/code/modules/mob/living/basic/space_fauna/space_dragon/dragon_gust.dm +++ b/code/modules/mob/living/basic/space_fauna/space_dragon/dragon_gust.dm @@ -71,7 +71,7 @@ owner.pixel_y = 0 playsound(owner, 'sound/effects/gravhit.ogg', 100, TRUE) for (var/mob/living/candidate in view(gust_distance, owner)) - if(candidate == owner || candidate.faction_check_mob(owner)) + if(candidate == owner || candidate.faction_check_atom(owner)) continue owner.visible_message(span_boldwarning("[candidate] is knocked back by the gust!")) to_chat(candidate, span_userdanger("You're knocked back by the gust!")) diff --git a/code/modules/mob/living/basic/vermin/mouse.dm b/code/modules/mob/living/basic/vermin/mouse.dm index 87d549ac523..6043cceb4b1 100644 --- a/code/modules/mob/living/basic/vermin/mouse.dm +++ b/code/modules/mob/living/basic/vermin/mouse.dm @@ -72,7 +72,7 @@ /mob/living/basic/mouse/examine(mob/user) . = ..() - var/sameside = user.faction_check_mob(src, exact_match = TRUE) + var/sameside = user.faction_check_atom(src, exact_match = TRUE) if(isregalrat(user)) if(sameside) . += span_notice("This rat serves under you.") diff --git a/code/modules/mob/living/simple_animal/friendly/drone/drone_say.dm b/code/modules/mob/living/simple_animal/friendly/drone/drone_say.dm index 88fc3b5cd85..0a89b0f956b 100644 --- a/code/modules/mob/living/simple_animal/friendly/drone/drone_say.dm +++ b/code/modules/mob/living/simple_animal/friendly/drone/drone_say.dm @@ -6,7 +6,7 @@ * * dead_can_hear - Boolean that determines if ghosts can hear the message (`FALSE` by default) * * source - [/atom] source that created the message * * faction_checked_mob - [/mob/living] to determine faction matches from - * * exact_faction_match - Passed to [/mob/proc/faction_check_mob] + * * exact_faction_match - Passed to [/mob/proc/faction_check_atom] */ /proc/_alert_drones(msg, dead_can_hear = FALSE, atom/source, mob/living/faction_checked_mob, exact_faction_match) if (dead_can_hear && source) @@ -17,7 +17,7 @@ var/mob/living/simple_animal/drone/D = i if(istype(D) && D.stat != DEAD) if(faction_checked_mob) - if(D.faction_check_mob(faction_checked_mob, exact_faction_match)) + if(D.faction_check_atom(faction_checked_mob, exact_faction_match)) to_chat(D, msg) else to_chat(D, msg) @@ -28,7 +28,7 @@ * Wraps [/proc/_alert_drones] with defaults * * * source - `src` - * * faction_check_mob - `src` + * * faction_check_atom - `src` * * dead_can_hear - `TRUE` */ /mob/living/simple_animal/drone/proc/alert_drones(msg, dead_can_hear = FALSE) diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 305853adb96..96ae60c3e07 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -263,7 +263,7 @@ if(search_objects < 2) if(isliving(the_target)) var/mob/living/L = the_target - var/faction_check = faction_check_mob(L) + var/faction_check = faction_check_atom(L) if(robust_searching) if(faction_check && !attack_same) return FALSE @@ -433,7 +433,7 @@ playsound(loc, 'sound/machines/chime.ogg', 50, TRUE, -1) var/atom/target_from = GET_TARGETS_FROM(src) for(var/mob/living/simple_animal/hostile/M in oview(distance, target_from)) - if(faction_check_mob(M, TRUE)) + if(faction_check_atom(M, TRUE)) if(M.AIStatus == AI_OFF) return else @@ -445,7 +445,7 @@ for(var/mob/living/L in T) if(L == src || L == A) continue - if(faction_check_mob(L) && !attack_same) + if(faction_check_atom(L) && !attack_same) return TRUE /mob/living/simple_animal/hostile/proc/OpenFire(atom/A) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm index 02d9e582b1a..ec90fa9fa7b 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm @@ -137,7 +137,7 @@ Difficulty: Hard . = list() for(var/mob/living/L in targets) var/list/bloodpool = get_bloodcrawlable_pools(get_turf(L), 0) - if(bloodpool.len && (!faction_check_mob(L) || L.stat == DEAD)) + if(bloodpool.len && (!faction_check_atom(L) || L.stat == DEAD)) . += L /** @@ -201,7 +201,7 @@ Difficulty: Hard new /obj/effect/temp_visual/bubblegum_hands/leftsmack(T) SLEEP_CHECK_DEATH(4, src) for(var/mob/living/L in T) - if(!faction_check_mob(L)) + if(!faction_check_atom(L)) to_chat(L, span_userdanger("[src] rends you!")) playsound(T, attack_sound, 100, TRUE, -1) var/limb_to_hit = L.get_bodypart(L.get_random_valid_zone(even_weights = TRUE)) @@ -217,7 +217,7 @@ Difficulty: Hard new /obj/effect/temp_visual/bubblegum_hands/leftthumb(T) SLEEP_CHECK_DEATH(6, src) for(var/mob/living/L in T) - if(!faction_check_mob(L)) + if(!faction_check_atom(L)) if(L.stat != CONSCIOUS) to_chat(L, span_userdanger("[src] drags you through the blood!")) playsound(T, 'sound/magic/enter_blood.ogg', 100, TRUE, -1) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm index 828a78ccfb1..e20724227f1 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm @@ -694,7 +694,7 @@ Difficulty: Hard return for(var/mob/living/L in T.contents - hit_things) //find and damage mobs... hit_things += L - if((friendly_fire_check && caster?.faction_check_mob(L)) || L.stat == DEAD) + if((friendly_fire_check && caster?.faction_check_atom(L)) || L.stat == DEAD) continue if(L.client) flash_color(L.client, "#660099", 1) @@ -719,7 +719,7 @@ Difficulty: Hard hit_things += M for(var/O in M.occupants) var/mob/living/occupant = O - if(friendly_fire_check && caster?.faction_check_mob(occupant)) + if(friendly_fire_check && caster?.faction_check_atom(occupant)) continue to_chat(occupant, span_userdanger("Your [M.name] is struck by a [name]!")) playsound(M,'sound/weapons/sear.ogg', 50, TRUE, -4) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/legion.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/legion.dm index 777cb3b878f..de693bde9ea 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/legion.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/legion.dm @@ -269,14 +269,14 @@ density = TRUE layer = ABOVE_OBJ_LAYER armor_type = /datum/armor/structure_legionturret + //Compared with the targeted mobs. If they have the faction, turret won't shoot. + faction = list(FACTION_MINING) ///What kind of projectile the actual damaging part should be. var/projectile_type = /obj/projectile/beam/legion ///Time until the tracer gets shot var/initial_firing_time = 18 ///How long it takes between shooting the tracer and the projectile. var/shot_delay = 8 - ///Compared with the targeted mobs. If they have the faction, turret won't shoot. - var/faction = list(FACTION_MINING) /datum/armor/structure_legionturret laser = 100 diff --git a/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/elite.dm b/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/elite.dm index 6fe1fa1ecfc..fcfa4560611 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/elite.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/elite.dm @@ -37,7 +37,7 @@ /mob/living/simple_animal/hostile/asteroid/elite/AttackingTarget() if(ishostile(target)) var/mob/living/simple_animal/hostile/M = target - if(faction_check_mob(M)) + if(faction_check_atom(M)) return FALSE if(istype(target, /obj/structure/elite_tumor)) var/obj/structure/elite_tumor/T = target diff --git a/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/herald.dm b/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/herald.dm index bf4d33a10ed..aa61c128e3f 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/herald.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/herald.dm @@ -234,7 +234,7 @@ /obj/projectile/herald/on_hit(atom/target, blocked = FALSE) if(ismob(target) && ismob(firer)) var/mob/living/mob_target = target - if(mob_target.faction_check_mob(firer)) + if(mob_target.faction_check_atom(firer)) damage = 0 . = ..() diff --git a/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/legionnaire.dm b/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/legionnaire.dm index ec6c843080c..926f4e96baa 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/legionnaire.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/legionnaire.dm @@ -149,7 +149,7 @@ var/throwtarget = get_edge_target_turf(src, move_dir) for(var/mob/living/trample_target in T.contents - hit_things - src) hit_things += trample_target - if(faction_check_mob(trample_target)) + if(faction_check_atom(trample_target)) continue visible_message(span_boldwarning("[src] tramples and kicks [trample_target]!")) to_chat(trample_target, span_userdanger("[src] tramples you and kicks you away!")) diff --git a/code/modules/mob/living/simple_animal/hostile/mining_mobs/gutlunch.dm b/code/modules/mob/living/simple_animal/hostile/mining_mobs/gutlunch.dm index 92ad5f35927..7a3451e4ef8 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining_mobs/gutlunch.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining_mobs/gutlunch.dm @@ -60,7 +60,7 @@ if(isliving(the_target)) var/mob/living/L = the_target - if(faction_check_mob(L) && !attack_same) + if(faction_check_atom(L) && !attack_same) return FALSE if(L.stat > stat_attack || L.stat != stat_attack && stat_exclusive) return FALSE diff --git a/code/modules/mob/living/simple_animal/hostile/retaliate/retaliate.dm b/code/modules/mob/living/simple_animal/hostile/retaliate/retaliate.dm index 237360468f8..bf1c12d5da1 100644 --- a/code/modules/mob/living/simple_animal/hostile/retaliate/retaliate.dm +++ b/code/modules/mob/living/simple_animal/hostile/retaliate/retaliate.dm @@ -37,7 +37,7 @@ continue if(isliving(A)) var/mob/living/M = A - if(faction_check_mob(M) && attack_same || !faction_check_mob(M)) + if(faction_check_atom(M) && attack_same || !faction_check_atom(M)) enemies |= WEAKREF(M) else if(ismecha(A)) var/obj/vehicle/sealed/mecha/M = A @@ -46,7 +46,7 @@ add_enemies(M.occupants) for(var/mob/living/simple_animal/hostile/retaliate/H in around) - if(faction_check_mob(H) && !attack_same && !H.attack_same) + if(faction_check_atom(H) && !attack_same && !H.attack_same) H.enemies |= enemies /mob/living/simple_animal/hostile/retaliate/adjustHealth(amount, updating_health = TRUE, forced = FALSE) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 85c146b29c8..4c382a59b2f 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -509,7 +509,7 @@ else if(!is_child && M.gender == MALE && !(M.flags_1 & HOLOGRAM_1)) //Better safe than sorry ;_; partner = M - else if(isliving(M) && !faction_check_mob(M)) //shyness check. we're not shy in front of things that share a faction with us. + else if(isliving(M) && !faction_check_atom(M)) //shyness check. we're not shy in front of things that share a faction with us. return //we never mate when not alone, so just abort early if(alone && partner && children < 3) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 9002033a13e..e5ddcf1f0ae 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1202,21 +1202,7 @@ ///Can this mob use storage /mob/proc/canUseStorage() return FALSE -/** - * Check if the other mob has any factions the same as us - * - * If exact match is set, then all our factions must match exactly - */ -/mob/proc/faction_check_mob(mob/target, exact_match) - if(exact_match) //if we need an exact match, we need to do some bullfuckery. - var/list/faction_src = faction.Copy() - var/list/faction_target = target.faction.Copy() - if(!("[REF(src)]" in faction_target)) //if they don't have our ref faction, remove it from our factions list. - faction_src -= "[REF(src)]" //if we don't do this, we'll never have an exact match. - if(!("[REF(target)]" in faction_src)) - faction_target -= "[REF(target)]" //same thing here. - return faction_check(faction_src, faction_target, TRUE) - return faction_check(faction, target.faction, FALSE) + /* * Compare two lists of factions, returning true if any match * diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 12905700318..c5aac5f526e 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -20,6 +20,8 @@ // we never want to hide a turf because it's not lit // We can rely on the lighting plane to handle that for us see_in_dark = 1e6 + // A list of factions that this mob is currently in, for hostile mob targetting, amongst other things + faction = list(FACTION_NEUTRAL) /// The current client inhabiting this mob. Managed by login/logout /// This exists so we can do cleanup in logout for occasions where a client was transfere rather then destroyed /// We need to do this because the mob on logout never actually has a reference to client @@ -144,9 +146,6 @@ /// What job does this mob have var/job = null//Living - /// A list of factions that this mob is currently in, for hostile mob targetting, amongst other things - var/list/faction = list(FACTION_NEUTRAL) - /// Can this mob enter shuttles var/move_on_shuttle = 1 diff --git a/code/modules/mob_spawn/mob_spawn.dm b/code/modules/mob_spawn/mob_spawn.dm index 02b3ea1866f..3f5dd81c184 100644 --- a/code/modules/mob_spawn/mob_spawn.dm +++ b/code/modules/mob_spawn/mob_spawn.dm @@ -11,8 +11,6 @@ var/mob_name ///the type of the mob, you best inherit this var/mob_type = /mob/living/basic/cockroach - ///Lazy string list of factions that the spawned mob will be in upon spawn - var/list/faction ////Human specific stuff. Don't set these if you aren't using a human, the unit tests will put a stop to your sinful hand. diff --git a/modular_skyrat/modules/black_mesa/code/shockplant.dm b/modular_skyrat/modules/black_mesa/code/shockplant.dm index 3d77cbe6635..78b357677cb 100644 --- a/modular_skyrat/modules/black_mesa/code/shockplant.dm +++ b/modular_skyrat/modules/black_mesa/code/shockplant.dm @@ -11,7 +11,7 @@ light_power = 0.5 light_color = "#53fafa" /// Our faction - var/faction = FACTION_XEN + faction = list(FACTION_XEN) /// Our range to shock folks in. var/shock_range = 6 /// Our cooldown on the shocking. @@ -34,7 +34,7 @@ if(isliving(entered_atom)) var/mob/living/entering_mob = entered_atom - if(faction in entering_mob.faction) + if(faction_check_atom(entering_mob)) return tesla_zap(src, shock_range, shock_power, shocked_targets = list(entering_mob)) playsound(src, 'sound/magic/lightningbolt.ogg', 100, TRUE) diff --git a/modular_skyrat/modules/decay_subsystem/code/nests.dm b/modular_skyrat/modules/decay_subsystem/code/nests.dm index 74424371e87..dc883affe2a 100644 --- a/modular_skyrat/modules/decay_subsystem/code/nests.dm +++ b/modular_skyrat/modules/decay_subsystem/code/nests.dm @@ -12,12 +12,12 @@ light_range = 2 light_power = 1 light_color = LIGHT_COLOR_LAVA + faction = list(NEST_FACTION) var/spawn_delay = 0 /// What mob to spawn var/list/monster_types = list(/mob/living/simple_animal/hostile/blackmesa/xen/headcrab) /// How many mobs can we spawn? var/max_mobs = 3 - var/list/faction = list(NEST_FACTION) var/spawned_mobs = 0 /// How long it takes for a new mob to emerge after being triggered. var/spawn_cooldown = 30 SECONDS