Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into heretic.-What-mor…
Browse files Browse the repository at this point in the history
…e-is-there-to-say-
  • Loading branch information
Qwertytoforty committed Feb 3, 2025
2 parents a6b3a96 + a9b181e commit e30d619
Show file tree
Hide file tree
Showing 37 changed files with 308 additions and 115 deletions.
18 changes: 18 additions & 0 deletions code/__DEFINES/time_defines.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#define MILLISECONDS *0.01

#define DECISECONDS *1 //the base unit all of these defines are scaled by, because byond uses that as a unit of measurement for some fucking reason

// So you can be all 10 SECONDS
#define SECONDS *10

#define MINUTES *600

#define HOURS *36000

#define TICKS *world.tick_lag

#define SECONDS_TO_LIFE_CYCLES /2

#define DS2TICKS(DS) ((DS)/world.tick_lag)

#define TICKS2DS(T) ((T) TICKS)
19 changes: 0 additions & 19 deletions code/__HELPERS/time.dm
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
#define MILLISECONDS *0.01

#define DECISECONDS *1 //the base unit all of these defines are scaled by, because byond uses that as a unit of measurement for some fucking reason

// So you can be all 10 SECONDS
#define SECONDS *10

#define MINUTES *600

#define HOURS *36000

#define TICKS *world.tick_lag

#define SECONDS_TO_LIFE_CYCLES /2

#define DS2TICKS(DS) ((DS)/world.tick_lag)

#define TICKS2DS(T) ((T) TICKS)

/* This proc should only be used for world/Topic.
* If you want to display the time for which dream daemon has been running ("round time") use worldtime2text.
* If you want to display the canonical station "time" (aka the in-character time of the station) use station_time_timestamp
Expand Down
6 changes: 0 additions & 6 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1562,12 +1562,6 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
if(areas)
. |= T.loc

/proc/turf_clear(turf/T)
for(var/atom/A in T)
if(A.simulated)
return FALSE
return TRUE

/proc/screen_loc2turf(scr_loc, turf/origin)
var/tX = splittext(scr_loc, ",")
var/tY = splittext(tX[2], ":")
Expand Down
5 changes: 4 additions & 1 deletion code/controllers/subsystem/movement/movement_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@
if(flags & MOVEMENT_LOOP_IGNORE_GLIDE)
return

moving.set_glide_size(MOVEMENT_ADJUSTED_GLIDE_SIZE(delay, visual_delay))
var/glide_multiplier = visual_delay
if(IS_DIR_DIAGONAL(get_dir(old_loc, moving.loc)) && !(moving.appearance_flags & LONG_GLIDE))
glide_multiplier *= sqrt(2)
moving.set_glide_size(MOVEMENT_ADJUSTED_GLIDE_SIZE(delay, glide_multiplier))

///Handles the actual move, overriden by children
///Returns FALSE if nothing happen, TRUE otherwise
Expand Down
12 changes: 11 additions & 1 deletion code/datums/components/riding/riding_vehicle.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// For any /obj/tgvehicle's that can be ridden

/// For making timers not accidentally skip an extra tick.
#define EPSILON (world.tick_lag * 0.1)

/datum/component/riding/vehicle/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = (RIDER_NEEDS_LEGS | RIDER_NEEDS_ARMS), potion_boost = FALSE)
if(!istgvehicle(parent))
return COMPONENT_INCOMPATIBLE
Expand Down Expand Up @@ -75,7 +78,12 @@

step(movable_parent, direction)
last_move_diagonal = ((direction & (direction - 1)) && (movable_parent.loc == next))
COOLDOWN_START(src, vehicle_move_cooldown, (last_move_diagonal ? 2 : 1) * vehicle_move_delay)
if(last_move_diagonal)
movable_parent.set_glide_size(MOVEMENT_ADJUSTED_GLIDE_SIZE(vehicle_move_delay, 1) * 0.5)
COOLDOWN_START(src, vehicle_move_cooldown, 2 * vehicle_move_delay - EPSILON)
else
movable_parent.set_glide_size(MOVEMENT_ADJUSTED_GLIDE_SIZE(vehicle_move_delay, 1))
COOLDOWN_START(src, vehicle_move_cooldown, vehicle_move_delay - EPSILON)

if(QDELETED(src))
return
Expand Down Expand Up @@ -187,3 +195,5 @@
override_allow_spacemove = TRUE
return
override_allow_spacemove = FALSE

#undef EPSILON
3 changes: 3 additions & 0 deletions code/datums/components/scope.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
))

/datum/component/scope/process()
if(!tracker)
STOP_PROCESSING(SSprojectiles, src)
return
var/mob/user_mob = tracker.owner
var/client/user_client = user_mob.client
if(!user_client)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/status_effects/neutral.dm
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
for(var/mob/living/L in range(10, our_scope.given_turf))
if(locks >= LWAP_LOCK_CAP)
return
if(L == owner || L.stat == DEAD || isslime(L) || ismonkeybasic(L) || L.invisibility > owner.see_invisible) //xenobio moment
if(L == owner || L.stat == DEAD || isslime(L) || ismonkeybasic(L) || L.invisibility > owner.see_invisible || isLivingSSD(L)) //xenobio moment
continue
new /obj/effect/temp_visual/single_user/lwap_ping(owner.loc, owner, L)
locks++
Expand Down
9 changes: 8 additions & 1 deletion code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,17 @@
continue

// At this point, the area is safe and the door is technically functional.
// Firedoors do not close automatically by default, and setting it to false when the alarm is off prevents unnecessary timers from being created. Emagged doors are permanently disabled from automatically closing, or being operated by alarms altogether apart from the lights.
if(!D.emagged)
if(opening)
D.autoclose = FALSE
else
D.autoclose = TRUE

INVOKE_ASYNC(D, (opening ? TYPE_PROC_REF(/obj/machinery/door/firedoor, deactivate_alarm) : TYPE_PROC_REF(/obj/machinery/door/firedoor, activate_alarm)))
if(D.welded)
if(D.welded || D.emagged)
continue // Alarm is toggled, but door stuck

if(D.operating)
if((D.operating == DOOR_OPENING && opening) || (D.operating == DOOR_CLOSING && !opening))
continue
Expand Down
13 changes: 11 additions & 2 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,18 @@
return TRUE

/// Called when src is being moved to a target turf because another movable (puller) is moving around.
/atom/movable/proc/move_from_pull(atom/movable/puller, turf/target_turf, glide_size_override)
/atom/movable/proc/move_from_pull(atom/movable/puller, turf/target_turf, puller_glide_size)
moving_from_pull = puller
Move(target_turf, get_dir(src, target_turf), glide_size_override)
var/new_glide_size = puller_glide_size
var/pull_dir = get_dir(src, target_turf)
// Adjust diagonal pulls for LONG_GLIDE differences.
if(IS_DIR_DIAGONAL(pull_dir))
if((puller.appearance_flags & LONG_GLIDE) && !(appearance_flags & LONG_GLIDE))
new_glide_size *= sqrt(2)
if(!(puller.appearance_flags & LONG_GLIDE) && (appearance_flags & LONG_GLIDE))
new_glide_size /= sqrt(2)
set_glide_size(new_glide_size)
Move(target_turf, pull_dir)
moving_from_pull = null

// Make sure you know what you're doing if you call this
Expand Down
22 changes: 13 additions & 9 deletions code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
user.visible_message(
"<span class='notice'>[user] opens [src].</span>",
"<span class='notice'>You open [src].</span>")
open(auto_close = FALSE)
open()

/obj/machinery/door/firedoor/item_interaction(mob/living/user, obj/item/used, list/modifiers)
add_fingerprint(user)
Expand Down Expand Up @@ -187,6 +187,12 @@
welded = !welded
update_icon(UPDATE_OVERLAYS)

/obj/machinery/door/firedoor/emag_act(mob/user)
if(!density)
return
autoclose = FALSE
return ..()

/obj/machinery/door/firedoor/try_to_crowbar(obj/item/I, mob/user)
if(welded || operating)
return
Expand Down Expand Up @@ -245,15 +251,13 @@
adjust_light()
update_icon()

/obj/machinery/door/firedoor/open(auto_close = TRUE)
/obj/machinery/door/firedoor/open()
if(welded)
return
. = ..()
latetoggle(auto_close)
latetoggle()
if(active_alarm)
layer = closingLayer // Active firedoors take precedence and remain visible over closed airlocks.
if(auto_close)
autoclose = TRUE

/obj/machinery/door/firedoor/close()
. = ..()
Expand All @@ -263,20 +267,20 @@
if(active_alarm)
. = ..()

/obj/machinery/door/firedoor/proc/latetoggle(auto_close = TRUE)
/obj/machinery/door/firedoor/proc/latetoggle()
if(operating || !hasPower() || !nextstate)
return
if(nextstate == FD_OPEN)
INVOKE_ASYNC(src, PROC_REF(open), auto_close)
INVOKE_ASYNC(src, PROC_REF(open))
if(nextstate == FD_CLOSED)
INVOKE_ASYNC(src, PROC_REF(close))
nextstate = null

/obj/machinery/door/firedoor/proc/forcetoggle(magic = FALSE, auto_close = TRUE)
/obj/machinery/door/firedoor/proc/forcetoggle(magic = FALSE)
if(!magic && (operating || !hasPower()))
return
if(density)
open(auto_close)
open()
else
close()

Expand Down
108 changes: 92 additions & 16 deletions code/game/machinery/vendors/custom_vendors.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#define INSERT_FAIL 0
#define INSERT_DONE 1
#define INSERT_NEEDS_INPUT 2

/obj/machinery/economy/vending/custom
name = "\improper CrewVend 3000"
refill_canister = null
Expand All @@ -17,6 +21,9 @@
return linked_pos?.linked_account || ..()

/obj/machinery/economy/vending/custom/item_interaction(mob/living/user, obj/item/used, list/modifiers)
if(user.a_intent == INTENT_HARM)
return ..()

if(istype(used, /obj/item/eftpos))
visible_message("<span class='notice'>[src] beeps as [user] links it to [used].</span>", "<span class='notice'>You hear something beep.</span>")
if(!isnull(linked_pos))
Expand All @@ -30,9 +37,25 @@
return ITEM_INTERACT_COMPLETE
else if(locked())
return ..()
if(!user.canUnEquip(used, FALSE))

try_add_stock(user, used)
return ITEM_INTERACT_COMPLETE

/// Tries to add something to the vendor. can_wait returns INSERT_NEEDS_INPUT if it would wait for user input, quiet suppresses success messages, and bag is used when the item is being transferred from a storage item.
/obj/machinery/economy/vending/custom/proc/try_add_stock(mob/living/user, obj/item/used, can_wait = TRUE, quiet = FALSE, obj/item/storage/bag = null)
if(isnull(bag) && !user.canUnEquip(used, FALSE))
to_chat(user, "<span class='warning'>\The [used] is stuck to your hand!</span>")
return ITEM_INTERACT_COMPLETE
return INSERT_FAIL
else if(bag)
if(!Adjacent(user))
to_chat(user, "<span class='warning'>You can't reach [src] from here!</span>")
return INSERT_FAIL
if(!user.is_holding(bag))
to_chat(user, "<span class='warning'>\The [bag] isn't in your hand anymore!</span>")
return INSERT_FAIL
if(used.loc != bag)
to_chat(user, "<span class='warning'>\The [used] isn't in [bag] anymore!</span>")
return INSERT_FAIL

for(var/datum/data/vending_product/physical/record in physical_product_records)
if(record.get_amount_left() == 0)
Expand All @@ -42,33 +65,82 @@
var/obj/item/existing = record.items[1]
if(existing.should_stack_with(used))
record.items += used
user.unequip(used)
if(isnull(bag))
user.unequip(used)
else
bag.remove_from_storage(used)
used.moveToNullspace()
user.visible_message("<span class='notice'>[user] puts [used] into [src].</span>", "<span class='notice>'You put [used] into [src].</span>")
return ITEM_INTERACT_COMPLETE
if(!quiet)
user.visible_message("<span class='notice'>[user] puts [used] into [src].</span>", "<span class='notice>'You put [used] into [src].</span>")
return INSERT_DONE

if(!can_wait)
return INSERT_NEEDS_INPUT

var/price = tgui_input_number(user, "How much do you want to sell [used] for?")
if(!isnum(price))
return ITEM_INTERACT_COMPLETE
return INSERT_FAIL
if(!Adjacent(user))
to_chat(user, "<span class='warning'>You can't reach [src] from here!</span>")
return ITEM_INTERACT_COMPLETE
if(!user.is_holding(used))
to_chat(user, "<span class='warning'>\The [used] isn't in your hand anymore!</span>")
return ITEM_INTERACT_COMPLETE
if(!user.canUnEquip(used, FALSE))
to_chat(user, "<span class='warning'>\The [used] is stuck to your hand!</span>")
return ITEM_INTERACT_COMPLETE
return INSERT_FAIL
if(isnull(bag))
if(!user.is_holding(used))
to_chat(user, "<span class='warning'>\The [used] isn't in your hand anymore!</span>")
return INSERT_FAIL
if(!user.canUnEquip(used, FALSE))
to_chat(user, "<span class='warning'>\The [used] is stuck to your hand!</span>")
return INSERT_FAIL
else
if(!user.is_holding(bag))
to_chat(user, "<span class='warning'>\The [bag] isn't in your hand anymore!</span>")
return INSERT_FAIL
if(used.loc != bag)
to_chat(user, "<span class='warning'>\The [used] isn't in [bag] anymore!</span>")
return INSERT_FAIL

var/datum/data/vending_product/physical/record = new(used.name, used.icon, used.icon_state)
record.items += used
record.price = price
physical_product_records += record
SStgui.update_uis(src, TRUE)
user.unequip(used)
if(isnull(bag))
user.unequip(used)
else
bag.remove_from_storage(used)
used.moveToNullspace()
user.visible_message("[user] puts [used] into [src].", "You put [used] into [src].")
return ITEM_INTERACT_COMPLETE
if(!quiet)
user.visible_message("<span class='notice'>[user] puts [used] into [src].</span>", "<span class='notice'>You put [used] into [src].</span>")
return INSERT_DONE

/obj/machinery/economy/vending/custom/MouseDrop_T(atom/dragged, mob/user, params)
if(!istype(dragged, /obj/item/storage))
return ..()

var/obj/item/storage/bag = dragged
var/inserted = FALSE
for(var/obj/item/thing in bag.contents.Copy())
var/result = try_add_stock(user, thing, can_wait = FALSE, quiet = TRUE, bag = bag)
if(result == INSERT_FAIL)
break
if(result == INSERT_DONE)
inserted = TRUE
continue

// result == INSERT_NEEDS_INPUT
if(inserted)
user.visible_message("<span class='notice'>[user] transfers some things from [bag] into [src].</span>", "<span class='notice'>You transfer some things from [bag] into [src].</span>")
// We've reported on our insertions so far, don't repeat it.
inserted = FALSE

// Try again, this time expecting it to wait.
result = try_add_stock(user, thing, bag = bag)
if(result == INSERT_FAIL)
break

if(inserted)
user.visible_message("<span class='notice'>[user] transfers everything from [bag] into [src].</span>", "<span class='notice'>You transfer everything from [bag] into [src].</span>")

return TRUE

/obj/machinery/economy/vending/custom/crowbar_act(mob/user, obj/item/I)
if(!isnull(linked_pos) && linked_pos.transaction_locked)
Expand All @@ -82,3 +154,7 @@
physical_product_records -= R
physical_hidden_records -= R
SStgui.update_uis(src, TRUE)

#undef INSERT_FAIL
#undef INSERT_DONE
#undef INSERT_NEEDS_INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/obj/item/clothing/suit/armor/bulletproof = 5,
/obj/item/clothing/mask/gas/explorer/marines = 5,
/obj/item/clothing/gloves/combat = 5,
/obj/item/storage/belt/military/assault = 5,
/obj/item/storage/belt/federation_webbing = 5,
/obj/item/clothing/under/solgov = 5,
/obj/item/mod/module/dispenser = 5,
/obj/item/flag/solgov = 3
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/cards_ids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

/obj/item/card/emag/magic_key/interact_with_atom(atom/target, mob/living/user, list/modifiers)
if(!isairlock(target))
return ITEM_INTERACT_COMPLETE
return NONE
var/obj/machinery/door/D = target
D.locked = FALSE
D.update_icon()
Expand Down
Loading

0 comments on commit e30d619

Please sign in to comment.