Files
Bubberstation/code/modules/events/ghost_role/sentience.dm
T
MrMelbert 8c1e35e1c0 Refactors mind language holders into non-existent, fixes new languages being deleted on species swap + tests (#76612)
## About The Pull Request

This PR refactors mind language holders into non-existence

As a result, `update_atom_languages` is no longer necessary

Mind-bound languages are transferred via `/mind/proc/transfer_to`

Species changing no longer deletes and re-creates the mob's language
holder, allowing them to keep any languages they have.

Species languages are sourced from `LANGUAGE_SPECIES` now, meaning they
are removed when they change species. If the mob is not a human with a
species datum, these are effectively just atom level languages.

Makes a bunch of unit tests to ensure language transfer over certain
events works as intended

## Why It's Good For The Game

Mobs with minds having two independent language holders results in a
good few bugs, and simply doesn't make sense when we have sources
(`LANGUAGE_MIND`).

Instead of tracking two language holders, we can simply use sources
better and only track one.

This means that the language holder you start with is your language
holder, period. It doesn't get deleted or re-instantiated or whatever.

## Changelog

🆑 Melbert
refactor: Refactored language holders, making species changes not delete
all of your known languages
/🆑
2023-07-10 18:34:57 +00:00

134 lines
4.7 KiB
Plaintext

GLOBAL_LIST_INIT(high_priority_sentience, typecacheof(list(
/mob/living/basic/bat,
/mob/living/basic/butterfly,
/mob/living/basic/carp/pet/cayenne,
/mob/living/basic/chicken,
/mob/living/basic/cow,
/mob/living/basic/giant_spider/sgt_araneus,
/mob/living/basic/lizard,
/mob/living/basic/mouse/brown/tom,
/mob/living/basic/pet,
/mob/living/basic/pig,
/mob/living/basic/rabbit,
/mob/living/basic/sheep,
/mob/living/simple_animal/bot/mulebot,
/mob/living/simple_animal/bot/secbot/beepsky,
/mob/living/simple_animal/hostile/retaliate/goat,
/mob/living/simple_animal/hostile/retaliate/goose/vomit,
/mob/living/simple_animal/hostile/retaliate/snake,
/mob/living/simple_animal/parrot,
/mob/living/simple_animal/pet,
/mob/living/simple_animal/sloth,
)))
/datum/round_event_control/sentience
name = "Random Human-level Intelligence"
typepath = /datum/round_event/ghost_role/sentience
weight = 10
category = EVENT_CATEGORY_FRIENDLY
description = "An animal or robot becomes sentient!"
min_wizard_trigger_potency = 0
max_wizard_trigger_potency = 7
/datum/round_event/ghost_role/sentience
minimum_required = 1
role_name = "random animal"
var/animals = 1
var/one = "one"
fakeable = TRUE
/datum/round_event/ghost_role/sentience/announce(fake)
var/sentience_report = ""
var/data = pick("scans from our long-range sensors", "our sophisticated probabilistic models", "our omnipotence", "the communications traffic on your station", "energy emissions we detected", "\[REDACTED\]")
var/pets = pick("animals/bots", "bots/animals", "pets", "simple animals", "lesser lifeforms", "\[REDACTED\]")
var/strength = pick("human", "moderate", "lizard", "security", "command", "clown", "low", "very low", "\[REDACTED\]")
sentience_report += "Based on [data], we believe that [one] of the station's [pets] has developed [strength] level intelligence, and the ability to communicate."
priority_announce(sentience_report,"[command_name()] Medium-Priority Update")
/datum/round_event/ghost_role/sentience/spawn_role()
var/list/mob/dead/observer/candidates
candidates = get_candidates(ROLE_SENTIENCE, ROLE_SENTIENCE)
// find our chosen mob to breathe life into
// Mobs have to be simple animals, mindless, on station, and NOT holograms.
// prioritize starter animals that people will recognise
var/list/potential = list()
var/list/hi_pri = list()
var/list/low_pri = list()
for(var/mob/living/simple_animal/check_mob in GLOB.alive_mob_list)
set_mob_priority(check_mob, hi_pri, low_pri)
for(var/mob/living/basic/check_mob in GLOB.alive_mob_list)
set_mob_priority(check_mob, hi_pri, low_pri)
shuffle_inplace(hi_pri)
shuffle_inplace(low_pri)
potential = hi_pri + low_pri
if(!potential.len)
return WAITING_FOR_SOMETHING
if(!candidates.len)
return NOT_ENOUGH_PLAYERS
var/spawned_animals = 0
while(spawned_animals < animals && candidates.len && potential.len)
var/mob/living/selected = popleft(potential)
var/mob/dead/observer/picked_candidate = pick_n_take(candidates)
spawned_animals++
selected.key = picked_candidate.key
selected.grant_all_languages(UNDERSTOOD_LANGUAGE, grant_omnitongue = FALSE, source = LANGUAGE_ATOM)
if (isanimal(selected))
var/mob/living/simple_animal/animal_selected = selected
animal_selected.sentience_act()
animal_selected.del_on_death = FALSE
else if (isbasicmob(selected))
var/mob/living/basic/animal_selected = selected
animal_selected.basic_mob_flags &= ~DEL_ON_DEATH
selected.maxHealth = max(selected.maxHealth, 200)
selected.health = selected.maxHealth
spawned_mobs += selected
to_chat(selected, span_userdanger("Hello world!"))
to_chat(selected, "<span class='warning'>Due to freak radiation and/or chemicals \
and/or lucky chance, you have gained human level intelligence \
and the ability to speak and understand human language!</span>")
return SUCCESSFUL_SPAWN
/// Adds a mob to either the high or low priority event list
/datum/round_event/ghost_role/sentience/proc/set_mob_priority(mob/living/checked_mob, list/high, list/low)
var/turf/mob_turf = get_turf(checked_mob)
if(!mob_turf || !is_station_level(mob_turf.z))
return
if((checked_mob in GLOB.player_list) || checked_mob.mind || (checked_mob.flags_1 & HOLOGRAM_1))
return
if(is_type_in_typecache(checked_mob, GLOB.high_priority_sentience))
high += checked_mob
else
low += checked_mob
/datum/round_event_control/sentience/all
name = "Station-wide Human-level Intelligence"
typepath = /datum/round_event/ghost_role/sentience/all
weight = 0
category = EVENT_CATEGORY_FRIENDLY
description = "ALL animals and robots become sentient, provided there is enough ghosts."
/datum/round_event/ghost_role/sentience/all
one = "all"
animals = INFINITY // as many as there are ghosts and animals
// cockroach pride, station wide