Skip to content

Commit

Permalink
Merge branch 'weight-pick-fixes' of https://github.com/Absolucy/Monke…
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy committed Jun 7, 2024
3 parents c4fecce + b5bc07e + 7c8b6dd commit 4c2798e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
15 changes: 6 additions & 9 deletions code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
**/
/proc/list_clear_nulls(list/list_to_clear)
return (list_to_clear.RemoveAll(null) > 0)


/*
* Returns list containing all the entries from first list that are not present in second.
Expand Down Expand Up @@ -435,22 +435,19 @@
* B would have a 30% chance of being picked,
* C would have a 10% chance of being picked,
* and D would have a 0% chance of being picked.
* You should only pass integers in.
*/
/proc/pick_weight(list/list_to_pick)
/proc/pick_weight(list/list_to_pick) // monkestation edit: port superior pick_weight impl
var/total = 0
var/item
for(item in list_to_pick)
if(!list_to_pick[item])
list_to_pick[item] = 0
if(isnull(list_to_pick[item]))
stack_trace("weighted_pick given null weight: [json_encode(list_to_pick)]")
total += list_to_pick[item]

total = rand(1, total)
total = rand() * total
for(item in list_to_pick)
total -= list_to_pick[item]
if(total <= 0 && list_to_pick[item])
if(total <= 0)
return item

return null
#endif

Expand Down
9 changes: 8 additions & 1 deletion code/modules/antagonists/brother/brother.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@
return ..()

/datum/antagonist/brother/proc/on_mob_successful_flashed_carbon(mob/living/source, mob/living/carbon/flashed, obj/item/assembly/flash/flash)
SIGNAL_HANDLER
/* SIGNAL_HANDLER */ // monkestation edit: allow used of is_banned_from

if (flashed.stat == DEAD)
return


if (flashed.stat != CONSCIOUS)
flashed.balloon_alert(source, "unconscious!")
return
Expand All @@ -62,6 +63,12 @@
flashed.balloon_alert(source, "[flashed.p_their()] mind is vacant!")
return

// monkestation edit: allow people to opt-out of BB
if(!(ROLE_BROTHER in flashed.client?.prefs?.be_special) || is_banned_from(flashed.ckey, list(ROLE_BROTHER, ROLE_SYNDICATE)))
flashed.balloon_alert(source, "unwilling to play role!")
return
// monkestation end

for(var/datum/objective/brother_objective as anything in source.mind.get_all_objectives())
// If the objective has a target, are we flashing them?
if(flashed == brother_objective.target?.current)
Expand Down
4 changes: 4 additions & 0 deletions html/changelogs/AutoChangeLog-pr-2134.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
author: "Absolucy"
delete-after: True
changes:
- qol: "Blood Brothers can now only convert people who have BB enabled in their prefs. Failing to convert will give an appropriate feedback message (and the failed convert won't notice anything other than a normal flashing)."
4 changes: 2 additions & 2 deletions monkestation/code/modules/clothing/shoes/clown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
desc = "A court jester's shoes, updated with modern squeaking technology."
icon_state = "jester_shoes"
icon = 'icons/obj/clothing/shoes.dmi'
squeak_sound = list('monkestation/sound/effects/clown_jingle1.ogg'=1, 'monkestation/sound/effects/clown_jingle2.ogg') //jingHONK jinglHONK jHONKgle jiHONKgle
squeak_sound = list('monkestation/sound/effects/clown_jingle1.ogg'=1, 'monkestation/sound/effects/clown_jingle2.ogg'=1) //jingHONK jinglHONK jHONKgle jiHONKgle

/obj/item/clothing/shoes/clown_shoes/harlequin_boots
name = "harlequin boots"
Expand All @@ -29,4 +29,4 @@
icon_state = "harlequin_boots"
worn_icon = 'monkestation/icons/mob/clothing/feet.dmi'
worn_icon_state = "harlequin_boots"
squeak_sound = list('monkestation/sound/effects/clown_jingle1.ogg'=1, 'monkestation/sound/effects/clown_jingle2.ogg')
squeak_sound = list('monkestation/sound/effects/clown_jingle1.ogg'=1, 'monkestation/sound/effects/clown_jingle2.ogg'=1)
28 changes: 13 additions & 15 deletions monkestation/code/modules/smithing/oozelings/body/organs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
RegisterSignal(organ_owner, COMSIG_MOB_STATCHANGE, PROC_REF(on_stat_change))

/obj/item/organ/internal/brain/slime/proc/colorize()
if(owner && isoozeling(owner))
if(isoozeling(owner))
core_color = owner.dna.features["mcolor"]
add_atom_colour(core_color, FIXED_COLOUR_PRIORITY)

Expand All @@ -120,9 +120,7 @@

/obj/item/organ/internal/brain/slime/proc/enable_coredeath()
coredeath = TRUE
if(owner)
if(owner.stat != DEAD)
return
if(owner?.stat == DEAD)
addtimer(CALLBACK(src, PROC_REF(core_ejection), owner), 0)

///////
Expand All @@ -132,20 +130,18 @@
/obj/item/organ/internal/brain/slime/proc/core_ejection(mob/living/carbon/human/victim, new_stat, turf/loc_override)
if(core_ejected || !coredeath)
return
if(!stored_dna)
if(QDELETED(stored_dna))
stored_dna = new

victim.dna.copy_dna(stored_dna)
core_ejected = TRUE
victim.visible_message(span_warning("[victim]'s body completely dissolves, collapsing outwards!"), span_notice("Your body completely dissolves, collapsing outwards!"), span_notice("You hear liquid splattering."))
var/turf/death_turf = get_turf(victim)

var/list/items = list()
items |= victim.get_equipped_items(TRUE)
for(var/atom/movable/I as anything in items)
victim.dropItemToGround(I)
stored_items |= I
I.forceMove(src)
for(var/atom/movable/item as anything in victim.get_equipped_items(include_pockets = TRUE))
victim.dropItemToGround(item)
stored_items |= item
item.forceMove(src)

if(victim.get_organ_slot(ORGAN_SLOT_BRAIN) == src)
Remove(victim)
Expand Down Expand Up @@ -175,6 +171,7 @@
target_bloodsucker.bloodsucker_blood_volume -= target_bloodsucker.max_blood_volume * 0.15

rebuilt = FALSE
victim.transfer_observers_to(src)
Remove(victim)
qdel(victim)

Expand Down Expand Up @@ -221,7 +218,7 @@
/obj/item/organ/internal/brain/slime/proc/drop_items_to_ground(turf/turf)
for(var/atom/movable/item as anything in stored_items)
item.forceMove(turf)
stored_items -= item
stored_items.Cut()

/obj/item/organ/internal/brain/slime/proc/rebuild_body(mob/user)
if(rebuilt)
Expand All @@ -234,7 +231,7 @@
qdel(GetComponent(/datum/component/gps))

//we have the plasma. we can rebuild them.
brainmob.mind.grab_ghost()
brainmob?.mind?.grab_ghost()
if(isnull(brainmob))
user?.balloon_alert(user, "This brain is not a viable candidate for repair!")
return TRUE
Expand Down Expand Up @@ -267,13 +264,14 @@
forceMove(new_body)
Insert(new_body)
for(var/obj/item/bodypart as anything in new_body.bodyparts)
if(!istype(bodypart, /obj/item/bodypart/chest))
qdel(bodypart)
if(istype(bodypart, /obj/item/bodypart/chest))
continue
qdel(bodypart)
new_body.visible_message(span_warning("[new_body]'s torso \"forms\" from [new_body.p_their()] core, yet to form the rest."))
to_chat(owner, span_purple("Your torso fully forms out of your core, yet to form the rest."))

brainmob?.mind?.transfer_to(new_body)
new_body.grab_ghost()
transfer_observers_to(new_body)

drop_items_to_ground(new_body.drop_location())

0 comments on commit 4c2798e

Please sign in to comment.