Skip to content

Commit b57c949

Browse files
authored
Merge branch 'yogstation13:master' into master
2 parents bf4cb4b + 3a611d6 commit b57c949

File tree

20 files changed

+174
-180
lines changed

20 files changed

+174
-180
lines changed

code/__DEFINES/dcs/signals/signals_mob/signals_mob.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@
134134
///from base of /mob/living/start_pulling: (atom/movable/AM, state, force)
135135
#define COMSIG_MOB_PULL "mob_pull"
136136
#define COMPONENT_BLOCK_PULL (1<<0) // blocks pulling
137+
///from base of /obj/item/pickup: (obj/item/item)
138+
#define COMSIG_MOB_PICKUP_ITEM "mob_pickup_item"
137139
///Mob is trying to open the wires of a target [/atom], from /datum/wires/interactable(): (atom/target)
138140
#define COMSIG_TRY_WIRES_INTERACT "try_wires_interact"
139141
#define COMPONENT_CANT_INTERACT_WIRES (1<<0)

code/__HELPERS/mobs.dm

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -333,21 +333,12 @@ GLOBAL_LIST_EMPTY(species_list)
333333
return
334334
LAZYSET(user.do_afters, interaction_key, current_interaction_count + 1)
335335

336-
var/atom/user_loc = user.loc
337-
var/atom/target_loc = target?.loc
338-
339-
var/drifting = FALSE
340-
if(!user.Process_Spacemove() && user.inertia_dir)
341-
drifting = TRUE
342-
343-
var/holding = user.get_active_held_item()
344-
345336
if(!(timed_action_flags & IGNORE_SLOWDOWNS))
346337
delay *= user.action_speed_modifier * user.do_after_coefficent() //yogs: darkspawn
347338

348339
var/datum/progressbar/progbar
349340
if(progress)
350-
progbar = new(user, delay, target || user)
341+
progbar = new(user, delay, target || user, timed_action_flags, extra_checks)
351342

352343
SEND_SIGNAL(user, COMSIG_DO_AFTER_BEGAN)
353344

@@ -357,24 +348,7 @@ GLOBAL_LIST_EMPTY(species_list)
357348
while (world.time < endtime)
358349
stoplag(1)
359350

360-
if(!QDELETED(progbar))
361-
progbar.update(world.time - starttime)
362-
363-
if(drifting && !user.inertia_dir)
364-
drifting = FALSE
365-
user_loc = user.loc
366-
367-
if(QDELETED(user) \
368-
|| (!(timed_action_flags & IGNORE_USER_LOC_CHANGE) && !drifting && user.loc != user_loc) \
369-
|| (!(timed_action_flags & IGNORE_HELD_ITEM) && user.get_active_held_item() != holding) \
370-
|| (!(timed_action_flags & IGNORE_INCAPACITATED) && HAS_TRAIT(user, TRAIT_INCAPACITATED)) \
371-
|| (extra_checks && !extra_checks.Invoke()))
372-
. = FALSE
373-
break
374-
375-
if(target && (user != target) && \
376-
(QDELETED(target) \
377-
|| (!(timed_action_flags & IGNORE_TARGET_LOC_CHANGE) && target.loc != target_loc)))
351+
if(QDELETED(progbar) || !progbar.update(world.time - starttime))
378352
. = FALSE
379353
break
380354

code/datums/progressbar.dm

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010
var/mob/user
1111
///The client seeing the progress bar.
1212
var/client/user_client
13+
///Extra checks for whether to stop the progress.
14+
var/datum/callback/extra_checks
1315
///Effectively the number of steps the progress bar will need to do before reaching completion.
1416
var/goal = 1
1517
///Control check to see if the progress was interrupted before reaching its goal.
1618
var/last_progress = 0
1719
///Variable to ensure smooth visual stacking on multiple progress bars.
1820
var/listindex = 0
21+
///Whether progress has already been ended.
22+
var/progress_ended = FALSE
1923

2024

21-
/datum/progressbar/New(mob/User, goal_number, atom/target)
25+
/datum/progressbar/New(mob/User, goal_number, atom/target, timed_action_flags = NONE)
2226
. = ..()
2327
if (!istype(target))
2428
stack_trace("Invalid target [target] passed in")
@@ -50,6 +54,23 @@
5054
RegisterSignal(user, COMSIG_QDELETING, PROC_REF(on_user_delete))
5155
RegisterSignal(user, COMSIG_MOB_LOGOUT, PROC_REF(clean_user_client))
5256
RegisterSignal(user, COMSIG_MOB_LOGIN, PROC_REF(on_user_login))
57+
if(!(timed_action_flags & IGNORE_USER_LOC_CHANGE))
58+
RegisterSignal(user, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
59+
var/obj/mecha/mech = user.loc
60+
if(ismecha(user.loc) && user == mech.occupant)
61+
RegisterSignal(mech, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
62+
if(!(timed_action_flags & IGNORE_TARGET_LOC_CHANGE))
63+
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
64+
if(!(timed_action_flags & IGNORE_HELD_ITEM))
65+
var/obj/item/held = user.get_active_held_item()
66+
if(held)
67+
RegisterSignal(held, COMSIG_ITEM_EQUIPPED, PROC_REF(end_progress))
68+
RegisterSignal(held, COMSIG_ITEM_DROPPED, PROC_REF(end_progress))
69+
else
70+
RegisterSignal(user, COMSIG_MOB_PICKUP_ITEM, PROC_REF(end_progress))
71+
RegisterSignal(user, COMSIG_MOB_SWAPPING_HANDS, PROC_REF(end_progress))
72+
if(!(timed_action_flags & IGNORE_INCAPACITATED))
73+
RegisterSignal(user, SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), PROC_REF(end_progress))
5374

5475

5576
/datum/progressbar/Destroy()
@@ -121,22 +142,38 @@
121142

122143
///Updates the progress bar image visually.
123144
/datum/progressbar/proc/update(progress)
145+
if(progress_ended)
146+
return FALSE
124147
progress = clamp(progress, 0, goal)
125148
if(progress == last_progress)
126-
return
149+
return FALSE
127150
last_progress = progress
151+
if(extra_checks && !extra_checks.Invoke())
152+
return FALSE
128153
bar.icon_state = "prog_bar_[round(((progress / goal) * 100), 5)]"
154+
return TRUE
129155

130156

131157
///Called on progress end, be it successful or a failure. Wraps up things to delete the datum and bar.
132158
/datum/progressbar/proc/end_progress()
159+
if(progress_ended)
160+
return
161+
progress_ended = TRUE
162+
133163
if(last_progress != goal)
134164
bar.icon_state = "[bar.icon_state]_fail"
135165

136166
animate(bar, alpha = 0, time = PROGRESSBAR_ANIMATION_TIME)
137167

138168
QDEL_IN(src, PROGRESSBAR_ANIMATION_TIME)
139169

170+
/datum/progressbar/proc/on_moved(atom/movable/mover, atom/old_loc, movement_dir, forced, list/old_locs, momentum_change, interrupting)
171+
SIGNAL_HANDLER
172+
if(!interrupting)
173+
return
174+
if(!mover.Process_Spacemove() && mover.inertia_dir)
175+
return
176+
INVOKE_ASYNC(src, PROC_REF(end_progress))
140177

141178
#undef PROGRESSBAR_ANIMATION_TIME
142179
#undef PROGRESSBAR_HEIGHT

code/datums/traits/negative.dm

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,3 +985,35 @@
985985
if(!old_limb.is_organic_limb())
986986
cybernetics_level--
987987
update_mood()
988+
989+
/datum/quirk/lactose_intolerance
990+
name = "Lactose Intolerance"
991+
desc = "You don't tolerate milk or other dairy products."
992+
icon = "utensils"
993+
gain_text = span_danger("You suddenly feel intolerant towards milk.")
994+
lose_text = span_notice("You feel like you could drink milk again.")
995+
medical_record_text = "Patient is lactose intolerant."
996+
value = -1
997+
998+
/datum/quirk/lactose_intolerance/check_quirk(datum/preferences/prefs)
999+
var/datum/species/species_type = prefs.read_preference(/datum/preference/choiced/species)
1000+
if(initial(species_type.toxic_food) & DAIRY)
1001+
return "You're already lactose intolerant!"
1002+
species_type = new species_type()
1003+
if((TRAIT_POWERHUNGRY in species_type.inherent_traits) || (TRAIT_NOHUNGER in species_type.inherent_traits))
1004+
return "You don't eat food!"
1005+
return FALSE
1006+
1007+
/datum/quirk/lactose_intolerance/add()
1008+
if(!ishuman(quirk_holder))
1009+
return
1010+
var/mob/living/carbon/carbon_holder = quirk_holder
1011+
var/datum/species/spec = carbon_holder.dna.species
1012+
spec.toxic_food |= DAIRY
1013+
RegisterSignal(carbon_holder, COMSIG_SPECIES_GAIN, PROC_REF(on_species_gain))
1014+
1015+
/datum/quirk/lactose_intolerance/remove()
1016+
UnregisterSignal(quirk_holder, COMSIG_SPECIES_GAIN)
1017+
1018+
/datum/quirk/lactose_intolerance/proc/on_species_gain(datum/source, datum/species/new_species)
1019+
new_species.toxic_food |= DAIRY // no escape from your terrible fate

code/game/atoms_movable.dm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,9 @@
743743
* * The forced flag indicates whether this was a forced move, which skips many checks of regular movement.
744744
* * The old_locs is an optional argument, in case the moved movable was present in multiple locations before the movement.
745745
* * momentum_change represents whether this movement is due to a "new" force if TRUE or an already "existing" force if FALSE
746+
* * interrupting will cancel any do_after progress bars that should be canceled by moving.
746747
**/
747-
/atom/movable/proc/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE)
748+
/atom/movable/proc/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE, interrupting = TRUE)
748749
SHOULD_CALL_PARENT(TRUE)
749750

750751
if (!inertia_moving && momentum_change)
@@ -755,7 +756,7 @@
755756
if (!moving_diagonally && client_mobs_in_contents)
756757
update_parallax_contents()
757758

758-
SEND_SIGNAL(src, COMSIG_MOVABLE_MOVED, old_loc, movement_dir, forced, old_locs, momentum_change)
759+
SEND_SIGNAL(src, COMSIG_MOVABLE_MOVED, old_loc, movement_dir, forced, old_locs, momentum_change, interrupting)
759760

760761
if(old_loc)
761762
SEND_SIGNAL(old_loc, COMSIG_ATOM_ABSTRACT_EXITED, src, movement_dir)

code/game/mecha/equipment/mecha_equipment.dm

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
if(!chassis)
149149
return FALSE
150150
set_ready_state(FALSE)
151-
. = do_after(chassis.occupant, equip_cooldown * check_eva(), target, extra_checks = CALLBACK(src, PROC_REF(do_after_checks), target, chassis.loc))
151+
. = do_after(chassis.occupant, equip_cooldown * check_eva(), target, extra_checks = CALLBACK(src, PROC_REF(do_after_checks), target))
152152
set_ready_state(TRUE)
153153
if(!.)
154154
return
@@ -158,16 +158,14 @@
158158
/obj/item/mecha_parts/mecha_equipment/proc/do_after_mecha(atom/target, delay)
159159
if(!chassis)
160160
return
161-
return do_after(chassis.occupant, delay * check_eva(), target, extra_checks = CALLBACK(src, PROC_REF(do_after_checks), target, chassis.loc))
161+
return do_after(chassis.occupant, delay * check_eva(), target, extra_checks = CALLBACK(src, PROC_REF(do_after_checks), target))
162162

163-
/obj/item/mecha_parts/mecha_equipment/proc/do_after_checks(atom/target, atom/old_loc)
163+
/obj/item/mecha_parts/mecha_equipment/proc/do_after_checks(atom/target)
164164
if(!chassis)
165165
return FALSE
166-
if(chassis.loc != old_loc || chassis.inertia_dir)
167-
return FALSE
168166
if(src != chassis.selected)
169167
return FALSE
170-
if(!(chassis.omnidirectional_attacks || (get_dir(chassis, target) & chassis.dir)))
168+
if(target && !(chassis.omnidirectional_attacks || (get_dir(chassis, target) & chassis.dir)))
171169
return FALSE
172170
return TRUE
173171

code/game/objects/items.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE)
537537
/obj/item/proc/pickup(mob/user)
538538
SHOULD_CALL_PARENT(TRUE)
539539
SEND_SIGNAL(src, COMSIG_ITEM_PICKUP, user)
540+
SEND_SIGNAL(user, COMSIG_MOB_PICKUP_ITEM, src)
540541
item_flags |= IN_INVENTORY
541542

542543
// called when "found" in pockets and storage items. Returns 1 if the search should end.

code/modules/events/ghost_role/sentience.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ GLOBAL_LIST_INIT(high_priority_sentience, typecacheof(list(
4747

4848
/datum/round_event/ghost_role/sentience/spawn_role()
4949
var/list/mob/dead/observer/candidates
50-
candidates = get_candidates(ROLE_ALIEN, null, ROLE_ALIEN)
50+
candidates = get_candidates(ROLE_SENTIENCE, null, ROLE_SENTIENCE)
5151

5252
// find our chosen mob to breathe life into
5353
// Mobs have to be simple animals, mindless, on station, and NOT holograms.

code/modules/jobs/job_types/_job.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
if(outfit_override || outfit)
178178
H.equipOutfit(outfit_override ? outfit_override : outfit, visualsOnly)
179179

180-
H.dna.species.after_equip_job(src, H, visualsOnly)
180+
H.dna.species.after_equip_job(src, H, preference_source)
181181

182182
if(!visualsOnly && announce)
183183
announce(H)

code/modules/mining/equipment/regenerative_core.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
if(proximity_flag && ishuman(target))
8080
var/mob/living/carbon/human/H = target
8181
var/turf/user_turf = get_turf(user)
82+
if(isipc(target))
83+
return
8284
if(inert)
8385
to_chat(user, span_notice("[src] has decayed and can no longer be used to heal."))
8486
return
@@ -117,6 +119,8 @@
117119

118120
/obj/item/organ/regenerative_core/Insert(mob/living/carbon/M, special = 0, drop_if_replaced = TRUE)
119121
. = ..()
122+
if(isipc(M))
123+
return
120124
if(!preserved && !inert)
121125
preserved(TRUE)
122126
owner.visible_message(span_notice("[src] stabilizes as it's inserted."))

0 commit comments

Comments
 (0)