Merge remote-tracking branch 'origin/master' into semi-sync
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
# Datum Component System (DCS)
|
||||
|
||||
## Concept
|
||||
|
||||
Loosely adapted from /vg/. This is an entity component system for adding behaviours to datums when inheritance doesn't quite cut it. By using signals and events instead of direct inheritance, you can inject behaviours without hacky overloads. It requires a different method of thinking, but is not hard to use correctly. If a behaviour can have application across more than one thing. Make it generic, make it a component. Atom/mob/obj event? Give it a signal, and forward it's arguments with a `SendSignal()` call. Now every component that want's to can also know about this happening.
|
||||
|
||||
See [this thread](https://tgstation13.org/phpBB/viewtopic.php?f=5&t=22674) for an introduction to the system as a whole.
|
||||
|
||||
### See/Define signals and their arguments in [__DEFINES\components.dm](..\..\__DEFINES\components.dm)
|
||||
# Datum Component System (DCS)
|
||||
|
||||
## Concept
|
||||
|
||||
Loosely adapted from /vg/. This is an entity component system for adding behaviours to datums when inheritance doesn't quite cut it. By using signals and events instead of direct inheritance, you can inject behaviours without hacky overloads. It requires a different method of thinking, but is not hard to use correctly. If a behaviour can have application across more than one thing. Make it generic, make it a component. Atom/mob/obj event? Give it a signal, and forward it's arguments with a `SendSignal()` call. Now every component that want's to can also know about this happening.
|
||||
|
||||
See [this thread](https://tgstation13.org/phpBB/viewtopic.php?f=5&t=22674) for an introduction to the system as a whole.
|
||||
|
||||
### See/Define signals and their arguments in [__DEFINES\components.dm](..\..\__DEFINES\components.dm)
|
||||
|
||||
@@ -17,6 +17,44 @@
|
||||
var/stealth = FALSE //if TRUE, does not appear on HUDs and health scans
|
||||
var/diagnostics = TRUE //if TRUE, displays program list when scanned by nanite scanners
|
||||
|
||||
/// Delete ourselves when we're depleted.
|
||||
var/qdel_self_on_depletion = TRUE
|
||||
/// Allow deletion
|
||||
var/can_be_deleted = TRUE
|
||||
/// Whether or not we can survive no cloud syncing without errors
|
||||
var/requires_cloud_sync = TRUE
|
||||
/// Permanent programs - can never be deleted. does not count towards max_programs.
|
||||
var/list/datum/nanite_program/permanent_programs = list()
|
||||
|
||||
// Vulnerabilities
|
||||
/// EMP flat deletion upper
|
||||
var/emp_flat_deletion_upper = 35
|
||||
/// EMP flat deletion lower
|
||||
var/emp_flat_deletion_lower = 20
|
||||
/// EMP percent deletion upper
|
||||
var/emp_percent_deletion_upper = 0.35
|
||||
/// EMP percent deletion lower
|
||||
var/emp_percent_deletion_lower = 0.30
|
||||
/// EMP severity multiplier, capping to 0 to 100
|
||||
var/emp_severity_mod = 1
|
||||
/// EMP severity div for cloudsync reset chance
|
||||
var/emp_desync_mod = 0.25
|
||||
|
||||
/// Shock flat deletion upper
|
||||
var/shock_flat_deletion_upper = 45
|
||||
/// Shock flat deletion lower
|
||||
var/shock_flat_deletion_lower = 25
|
||||
/// Shock percent deletion upper
|
||||
var/shock_percent_deletion_upper = 0.25
|
||||
/// Shock percent deletion lower
|
||||
var/shock_percent_deletion_lower = 0.20
|
||||
|
||||
|
||||
/// minor shock deletion lower
|
||||
var/minor_shock_deletion_lower = 5
|
||||
/// minor shock deletion upper
|
||||
var/minor_shock_deletion_upper = 15
|
||||
|
||||
/datum/component/nanites/Initialize(amount = 100, cloud = 0)
|
||||
if(!isliving(parent) && !istype(parent, /datum/nanite_cloud_backup))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
@@ -55,6 +93,9 @@
|
||||
RegisterSignal(parent, COMSIG_NANITE_ADD_PROGRAM, .proc/add_program)
|
||||
RegisterSignal(parent, COMSIG_NANITE_SCAN, .proc/nanite_scan)
|
||||
RegisterSignal(parent, COMSIG_NANITE_SYNC, .proc/sync)
|
||||
RegisterSignal(parent, COMSIG_NANITE_CHECK_CONSOLE_LOCK, .proc/check_console_locking)
|
||||
RegisterSignal(parent, COMSIG_NANITE_CHECK_HOST_LOCK, .proc/check_host_lockout)
|
||||
RegisterSignal(parent, COMSIG_NANITE_CHECK_VIRAL_PREVENTION, .proc/check_viral_prevention)
|
||||
|
||||
if(isliving(parent))
|
||||
RegisterSignal(parent, COMSIG_ATOM_EMP_ACT, .proc/on_emp)
|
||||
@@ -118,13 +159,63 @@
|
||||
next_sync = world.time + NANITE_SYNC_DELAY
|
||||
set_nanite_bar()
|
||||
|
||||
/**
|
||||
* Called when nanites are depleted.
|
||||
* Deletes ourselves by default.
|
||||
*/
|
||||
/datum/component/nanites/proc/nanites_depleted()
|
||||
if(qdel_self_on_depletion)
|
||||
delete_nanites()
|
||||
|
||||
/**
|
||||
* Used to rid ourselves
|
||||
*/
|
||||
/datum/component/nanites/proc/delete_nanites()
|
||||
qdel(src)
|
||||
if(can_be_deleted)
|
||||
qdel(src)
|
||||
|
||||
/**
|
||||
* Adds permanent programs
|
||||
*
|
||||
* WARNING: Has no sanity checks. Make sure you know what you are doing! (make sure programs do not conflict)
|
||||
*/
|
||||
/datum/component/nanites/proc/add_permanent_program(list/program, immutable = FALSE)
|
||||
if(!islist(program))
|
||||
program = list(program)
|
||||
for(var/i in program)
|
||||
if(i in permanent_programs)
|
||||
continue
|
||||
var/datum/nanite_program/P = i
|
||||
permanent_programs += P
|
||||
if(immutable)
|
||||
P.immutable = TRUE
|
||||
for(var/e in programs)
|
||||
var/datum/nanite_program/E = e
|
||||
if(E.unique && (E.type == P.type))
|
||||
qdel(e)
|
||||
programs += P
|
||||
|
||||
/**
|
||||
* Checks if we can block out console modification
|
||||
*/
|
||||
/datum/component/nanites/proc/check_console_locking()
|
||||
return SEND_SIGNAL(src, COMSIG_NANITE_INTERNAL_CONSOLE_LOCK_CHECK)
|
||||
|
||||
/**
|
||||
* Checks if we can lock out host internal conscious modification
|
||||
*/
|
||||
/datum/component/nanites/proc/check_host_lockout()
|
||||
return SEND_SIGNAL(src, COMSIG_NANITE_INTERNAL_HOST_LOCK_CHECK)
|
||||
|
||||
/**
|
||||
* Checks if we can block out viral replica
|
||||
*/
|
||||
/datum/component/nanites/proc/check_viral_prevention()
|
||||
return SEND_SIGNAL(src, COMSIG_NANITE_INTERNAL_VIRAL_PREVENTION_CHECK)
|
||||
|
||||
//Syncs the nanite component to another, making it so programs are the same with the same programming (except activation status)
|
||||
/datum/component/nanites/proc/sync(datum/signal_source, datum/component/nanites/source, full_overwrite = TRUE, copy_activation = FALSE)
|
||||
var/list/programs_to_remove = programs.Copy()
|
||||
var/list/programs_to_remove = programs.Copy() - permanent_programs
|
||||
var/list/programs_to_add = source.programs.Copy()
|
||||
for(var/X in programs)
|
||||
var/datum/nanite_program/NP = X
|
||||
@@ -151,7 +242,7 @@
|
||||
sync(null, cloud_copy)
|
||||
return
|
||||
//Without cloud syncing nanites can accumulate errors and/or defects
|
||||
if(prob(8) && programs.len)
|
||||
if(prob(8) && programs.len && requires_cloud_sync)
|
||||
var/datum/nanite_program/NP = pick(programs)
|
||||
NP.software_error()
|
||||
|
||||
@@ -159,8 +250,11 @@
|
||||
for(var/X in programs)
|
||||
var/datum/nanite_program/NP = X
|
||||
if(NP.unique && NP.type == new_program.type)
|
||||
qdel(NP)
|
||||
if(programs.len >= max_programs)
|
||||
if(NP in permanent_programs)
|
||||
return COMPONENT_PROGRAM_NOT_INSTALLED
|
||||
else
|
||||
qdel(NP)
|
||||
if((programs.len - length(permanent_programs)) >= max_programs)
|
||||
return COMPONENT_PROGRAM_NOT_INSTALLED
|
||||
if(source_program)
|
||||
source_program.copy_programming(new_program)
|
||||
@@ -177,7 +271,7 @@
|
||||
/datum/component/nanites/proc/adjust_nanites(datum/source, amount)
|
||||
nanite_volume = clamp(nanite_volume + amount, 0, max_nanites)
|
||||
if(nanite_volume <= 0) //oops we ran out
|
||||
qdel(src)
|
||||
nanites_depleted()
|
||||
|
||||
/datum/component/nanites/proc/set_nanite_bar(remove = FALSE)
|
||||
var/image/holder = host_mob.hud_list[DIAG_NANITE_FULL_HUD]
|
||||
@@ -191,28 +285,28 @@
|
||||
holder.icon_state = "nanites[nanite_percent]"
|
||||
|
||||
/datum/component/nanites/proc/on_emp(datum/source, severity)
|
||||
nanite_volume *= (rand(60, 90) * 0.01) //Lose 10-40% of nanites
|
||||
adjust_nanites(null, -(rand(5, 50))) //Lose 5-50 flat nanite volume
|
||||
if(prob(40/severity))
|
||||
severity *= emp_severity_mod
|
||||
var/loss = (severity / 100) * (rand(emp_percent_deletion_lower, emp_percent_deletion_upper) * nanite_volume) + rand(emp_flat_deletion_lower, emp_flat_deletion_upper)
|
||||
adjust_nanites(null, -loss)
|
||||
if(prob(severity * emp_desync_mod))
|
||||
cloud_id = 0
|
||||
for(var/X in programs)
|
||||
var/datum/nanite_program/NP = X
|
||||
NP.on_emp(severity)
|
||||
|
||||
|
||||
/datum/component/nanites/proc/on_shock(datum/source, shock_damage, siemens_coeff = 1, flags = NONE)
|
||||
if(shock_damage < 1)
|
||||
return
|
||||
|
||||
if(!HAS_TRAIT_NOT_FROM(host_mob, TRAIT_SHOCKIMMUNE, "nanites"))//Another shock protection must protect nanites too, but nanites protect only host
|
||||
nanite_volume *= (rand(45, 80) * 0.01) //Lose 20-55% of nanites
|
||||
adjust_nanites(null, -(rand(5, 50))) //Lose 5-50 flat nanite volume
|
||||
var/loss = (rand(shock_percent_deletion_lower, shock_percent_deletion_upper) * nanite_volume) + rand(shock_flat_deletion_lower, shock_flat_deletion_upper)
|
||||
adjust_nanites(null, -loss)
|
||||
for(var/X in programs)
|
||||
var/datum/nanite_program/NP = X
|
||||
NP.on_shock(shock_damage)
|
||||
|
||||
/datum/component/nanites/proc/on_minor_shock(datum/source)
|
||||
adjust_nanites(null, -(rand(5, 15))) //Lose 5-15 flat nanite volume
|
||||
adjust_nanites(null, -(rand(minor_shock_deletion_lower, minor_shock_deletion_upper))) //Lose 5-15 flat nanite volume
|
||||
for(var/X in programs)
|
||||
var/datum/nanite_program/NP = X
|
||||
NP.on_minor_shock()
|
||||
@@ -237,7 +331,7 @@
|
||||
NP.receive_comm_signal(comm_code, comm_message, comm_source)
|
||||
|
||||
/datum/component/nanites/proc/check_viable_biotype()
|
||||
if(!(host_mob.mob_biotypes & (MOB_ORGANIC|MOB_UNDEAD)))
|
||||
if(!(host_mob.mob_biotypes & (MOB_ORGANIC|MOB_UNDEAD|MOB_NANITES)))
|
||||
qdel(src) //bodytype no longer sustains nanites
|
||||
|
||||
/datum/component/nanites/proc/check_access(datum/source, obj/O)
|
||||
@@ -378,3 +472,10 @@
|
||||
id++
|
||||
mob_programs += list(mob_program)
|
||||
data["mob_programs"] = mob_programs
|
||||
|
||||
/**
|
||||
* Subtype that doesn't erase itself from running out
|
||||
*/
|
||||
/datum/component/nanites/permanent
|
||||
qdel_self_on_depletion = FALSE
|
||||
can_be_deleted = FALSE
|
||||
|
||||
@@ -16,6 +16,32 @@
|
||||
to_chat(M, "<span class='warning'>[parent] only accepts machine parts!</span>")
|
||||
return FALSE
|
||||
|
||||
/datum/component/storage/concrete/rped/quick_empty(mob/M)
|
||||
var/atom/A = parent
|
||||
if(!M.canUseStorage() || !A.Adjacent(M) || M.incapacitated())
|
||||
return
|
||||
if(check_locked(null, M, TRUE))
|
||||
return FALSE
|
||||
A.add_fingerprint(M)
|
||||
var/list/things = contents()
|
||||
var/lowest_rating = INFINITY
|
||||
for(var/obj/item/B in things)
|
||||
if(B.get_part_rating() < lowest_rating)
|
||||
lowest_rating = B.get_part_rating()
|
||||
for(var/obj/item/B in things)
|
||||
if(B.get_part_rating() > lowest_rating)
|
||||
things.Remove(B)
|
||||
if(lowest_rating == INFINITY)
|
||||
to_chat(M, "<span class='notice'>There's no parts to dump out from [parent].</span>")
|
||||
return
|
||||
to_chat(M, "<span class='notice'>You start dumping out tier/cell rating [lowest_rating] parts from [parent].</span>")
|
||||
var/turf/T = get_turf(A)
|
||||
var/datum/progressbar/progress = new(M, length(things), T)
|
||||
while (do_after(M, 10, TRUE, T, FALSE, CALLBACK(src, .proc/mass_remove_from_storage, T, things, progress)))
|
||||
stoplag(1)
|
||||
qdel(progress)
|
||||
A.do_squish(0.8, 1.2)
|
||||
|
||||
/datum/component/storage/concrete/bluespace/rped
|
||||
collection_mode = COLLECT_EVERYTHING
|
||||
allow_quick_gather = TRUE
|
||||
@@ -33,5 +59,29 @@
|
||||
to_chat(M, "<span class='warning'>[parent] only accepts machine parts!</span>")
|
||||
return FALSE
|
||||
|
||||
/datum/component/storage/concrete/cyborg/rped
|
||||
max_items = 150
|
||||
|
||||
/datum/component/storage/concrete/bluespace/rped/quick_empty(mob/M)
|
||||
var/atom/A = parent
|
||||
if(!M.canUseStorage() || !A.Adjacent(M) || M.incapacitated())
|
||||
return
|
||||
if(check_locked(null, M, TRUE))
|
||||
return FALSE
|
||||
A.add_fingerprint(M)
|
||||
var/list/things = contents()
|
||||
var/lowest_rating = INFINITY
|
||||
for(var/obj/item/B in things)
|
||||
if(B.get_part_rating() < lowest_rating)
|
||||
lowest_rating = B.get_part_rating()
|
||||
for(var/obj/item/B in things)
|
||||
if(B.get_part_rating() > lowest_rating)
|
||||
things.Remove(B)
|
||||
if(lowest_rating == INFINITY)
|
||||
to_chat(M, "<span class='notice'>There's no parts to dump out from [parent].</span>")
|
||||
return
|
||||
to_chat(M, "<span class='notice'>You start dumping out tier/cell rating [lowest_rating] parts from [parent].</span>")
|
||||
var/turf/T = get_turf(A)
|
||||
var/datum/progressbar/progress = new(M, length(things), T)
|
||||
while (do_after(M, 10, TRUE, T, FALSE, CALLBACK(src, .proc/mass_remove_from_storage, T, things, progress)))
|
||||
stoplag(1)
|
||||
qdel(progress)
|
||||
A.do_squish(0.8, 1.2)
|
||||
|
||||
+12
-3
@@ -660,27 +660,34 @@
|
||||
return
|
||||
if(dna.stability > 0)
|
||||
return
|
||||
var/instability = -dna.stability
|
||||
var/instability = - dna.stability
|
||||
dna.remove_all_mutations()
|
||||
dna.stability = 100
|
||||
if(prob(max(70-instability,0)))
|
||||
if(prob(max(70 - instability,0)))
|
||||
switch(rand(0,3)) //not complete and utter death
|
||||
if(0)
|
||||
monkeyize()
|
||||
if(1)
|
||||
gain_trauma(/datum/brain_trauma/severe/paralysis)
|
||||
if(2)
|
||||
unequip_everything()
|
||||
drop_all_held_items()
|
||||
corgize()
|
||||
if(3)
|
||||
to_chat(src, "<span class='notice'>Oh, we actually feel quite alright!</span>")
|
||||
else
|
||||
switch(rand(0,3))
|
||||
if(0)
|
||||
unequip_everything()
|
||||
drop_all_held_items()
|
||||
gib()
|
||||
if(1)
|
||||
unequip_everything()
|
||||
drop_all_held_items()
|
||||
dust()
|
||||
|
||||
if(2)
|
||||
unequip_everything()
|
||||
drop_all_held_items()
|
||||
death()
|
||||
petrify(INFINITY)
|
||||
if(3)
|
||||
@@ -689,6 +696,8 @@
|
||||
if(BP)
|
||||
BP.dismember()
|
||||
else
|
||||
unequip_everything()
|
||||
drop_all_held_items()
|
||||
gib()
|
||||
else
|
||||
set_species(/datum/species/dullahan)
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
var/sound //Sound to play when emote is called
|
||||
var/vary = FALSE //used for the honk borg emote
|
||||
var/volume = 50
|
||||
mob_type_allowed_typecache = list(/mob/living/brain, /mob/living/silicon)
|
||||
mob_type_allowed_typecache = list(/mob/living/brain, /mob/living/silicon, /mob/camera/aiEye)
|
||||
|
||||
/datum/emote/sound/run_emote(mob/user, params)
|
||||
. = ..()
|
||||
|
||||
@@ -134,6 +134,28 @@
|
||||
return BULLET_ACT_FORCE_PIERCE
|
||||
return BULLET_ACT_HIT
|
||||
|
||||
/datum/block_parry_data/sleeping_carp
|
||||
parry_time_windup = 0
|
||||
parry_time_active = 25
|
||||
parry_time_spindown = 0
|
||||
// we want to signal to players the most dangerous phase, the time when automatic counterattack is a thing.
|
||||
parry_time_windup_visual_override = 1
|
||||
parry_time_active_visual_override = 3
|
||||
parry_time_spindown_visual_override = 12
|
||||
parry_flags = PARRY_DEFAULT_HANDLE_FEEDBACK //can attack while
|
||||
parry_time_perfect = 2.5 // first ds isn't perfect
|
||||
parry_time_perfect_leeway = 1.5
|
||||
parry_imperfect_falloff_percent = 5
|
||||
parry_efficiency_to_counterattack = 100
|
||||
parry_efficiency_considered_successful = 65 // VERY generous
|
||||
parry_efficiency_perfect = 100
|
||||
parry_failed_stagger_duration = 4 SECONDS
|
||||
parry_cooldown = 0.5 SECONDS
|
||||
|
||||
/mob/living/carbon/human/UseStaminaBuffer(amount, warn = FALSE, considered_action = TRUE)
|
||||
amount *= physiology? physiology.stamina_buffer_mod : 1
|
||||
return ..()
|
||||
|
||||
/datum/martial_art/the_sleeping_carp/teach(mob/living/carbon/human/H, make_temporary = FALSE)
|
||||
. = ..()
|
||||
if(!.)
|
||||
@@ -144,12 +166,12 @@
|
||||
ADD_TRAIT(H, TRAIT_TASED_RESISTANCE, SLEEPING_CARP_TRAIT)
|
||||
H.physiology.brute_mod *= 0.4 //brute is really not gonna cut it
|
||||
H.physiology.burn_mod *= 0.7 //burn is distinctly more useful against them than brute but they're still resistant
|
||||
H.physiology.stamina_mod *= 0.5 //You take less stamina damage overall, but you do not reduce the damage from stun batons
|
||||
H.physiology.stamina_mod *= 0.4 //You take less stamina damage overall, but you do not reduce the damage from stun batons as much
|
||||
H.physiology.stun_mod *= 0.3 //for those rare stuns
|
||||
H.physiology.pressure_mod *= 0.3 //go hang out with carp
|
||||
H.physiology.cold_mod *= 0.3 //cold mods are different to burn mods, they do stack however
|
||||
H.physiology.heat_mod *= 2 //this is mostly so sleeping carp has a viable weakness. Cooking them alive. Setting them on fire and heating them will be their biggest weakness. The reason for this is....filet jokes.
|
||||
|
||||
H.physiology.stamina_buffer_mod *= 0.75 //to help with some stamina
|
||||
H.faction |= "carp" //:D
|
||||
|
||||
/datum/martial_art/the_sleeping_carp/on_remove(mob/living/carbon/human/H)
|
||||
@@ -165,7 +187,7 @@
|
||||
H.physiology.pressure_mod = initial(H.physiology.pressure_mod) //no more carpies
|
||||
H.physiology.cold_mod = initial(H.physiology.cold_mod)
|
||||
H.physiology.heat_mod = initial(H.physiology.heat_mod)
|
||||
|
||||
H.physiology.stamina_buffer_mod = initial(H.physiology.stamina_buffer_mod)
|
||||
H.faction -= "carp" //:(
|
||||
|
||||
/mob/living/carbon/human/proc/sleeping_carp_help()
|
||||
|
||||
Reference in New Issue
Block a user