Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo fast delivery #21

Merged
merged 12 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 115 additions & 1 deletion code/controllers/subsystem/points.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ SUBSYSTEM_DEF(points)
var/psp_limit = 600
///Var used to calculate points difference between updates
var/supply_points_old = 0
///Used to delay fast delivery and for animation
var/fast_delivery_is_active = TRUE
///Reference to the balloon vis obj effect
var/atom/movable/vis_obj/fulton_balloon/baloon
var/obj/effect/fulton_extraction_holder/holder_obj

/datum/controller/subsystem/points/Recover()
ordernum = SSpoints.ordernum
Expand Down Expand Up @@ -114,13 +119,122 @@ SUBSYSTEM_DEF(points)
personal_supply_points[user.ckey] -= cost
ckey_shopping_cart.Cut()

/datum/controller/subsystem/points/proc/fast_delivery(datum/supply_order/O, mob/living/user)
//select beacon
var/datum/supply_beacon/supply_beacon = GLOB.supply_beacon[tgui_input_list(user, "Select the beacon to send supplies", "Beacon choice", GLOB.supply_beacon)]
if(!istype(supply_beacon))
to_chat(user, span_warning("Beacon not selected"))
return

if(!fast_delivery_is_active)
to_chat(user, span_warning("Fast delivery is not ready"))
return FALSE

//Same checks as for supply console
if(!supply_beacon)
to_chat(user, span_warning("There was an issue with that beacon. Check it's still active."))
return
if(!istype(supply_beacon.drop_location))
to_chat(user, span_warning("The [supply_beacon.name] was not detected on the ground."))
return
if(isspaceturf(supply_beacon.drop_location) || supply_beacon.drop_location.density)
to_chat(user, span_warning("The [supply_beacon.name]'s landing zone appears to be obstructed or out of bounds."))
return

//Just in case
if(!length_char(SSpoints.shoppinglist[O.faction]))
return

//Finally create the supply box

var/turf/TC = locate(supply_beacon.drop_location.x, supply_beacon.drop_location.y, supply_beacon.drop_location.z)

//spawn crate and clear shoping list
delivery_to_turf(O, TC)

//effects
supply_beacon.drop_location.visible_message(span_boldnotice("A supply drop appears suddendly!"))

/datum/controller/subsystem/points/proc/delivery_to_turf(datum/supply_order/O, turf/TC)
var/datum/supply_packs/firstpack = O.pack[1]

var/obj/structure/crate_type = firstpack.containertype || firstpack.contains[1]

var/obj/structure/A = new crate_type(null)
if(firstpack.containertype)
A.name = "Order #[O.id] for [O.orderer]"

//supply manifest generation begin

var/obj/item/paper/manifest/slip = new /obj/item/paper/manifest(A)
slip.info = "<h3>Automatic Storage Retrieval Manifest</h3><hr><br>"
slip.info +="Order #[O.id]<br>"
slip.info +="[length_char(O.pack)] PACKAGES IN THIS SHIPMENT<br>"
slip.info +="CONTENTS:<br><ul>"
slip.update_icon()
Copy link
Collaborator

@Helg2 Helg2 Jul 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Генерацию листочка наверное можно сделать отдельным проком, если он используется для обычных ящиков.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

с кода лифта брал как там было

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну и в целом спавн ящика если он настолько совпадает.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я не хочу трогать код лифта по причине наличия анимации и разного место спавна ящиков

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и почему то сейчас в коде лифта нет генерации манифестов, странно


var/list/contains = list()
//spawn the stuff, finish generating the manifest while you're at it
for(var/P in O.pack)
var/datum/supply_packs/SP = P
// yes i know
if(SP.access)
A.req_access = list()
homexp13 marked this conversation as resolved.
Show resolved Hide resolved
A.req_access += text2num(SP.access)

if(SP.randomised_num_contained)
if(length_char(SP.contains))
for(var/j in 1 to SP.randomised_num_contained)
contains += pick(SP.contains)
else
contains += SP.contains

for(var/typepath in contains)
if(!typepath)
continue
if(!firstpack.containertype)
break
var/atom/B2 = new typepath(A)
slip.info += "<li>[B2.name]</li>" //add the item to the manifest

//manifest finalisation
slip.info += "</ul><br>"
slip.info += "CHECK CONTENTS AND STAMP BELOW THE LINE TO CONFIRM RECEIPT OF GOODS<hr>"

SSpoints.shoppinglist[O.faction] -= "[O.id]"
SSpoints.shopping_history += O

baloon = new()
holder_obj = new()

holder_obj.appearance = A.appearance
holder_obj.forceMove(TC)

baloon.icon_state = initial(baloon.icon_state)
holder_obj.vis_contents += baloon

addtimer(CALLBACK(src, PROC_REF(end_fast_delivery), A, TC), 1 SECONDS)

flick("fulton_expand", baloon)
baloon.icon_state = "fulton_balloon"

holder_obj.pixel_z = 360
animate(holder_obj, 1 SECONDS, pixel_z = 0)

/datum/controller/subsystem/points/proc/end_fast_delivery(atom/movable/A, turf/TC)
A.forceMove(TC)
holder_obj.moveToNullspace()
holder_obj.pixel_z = initial(A.pixel_z)
holder_obj.vis_contents -= baloon
baloon.icon_state = initial(baloon.icon_state)
fast_delivery_is_active = TRUE

///Add amount of psy points to the selected hive only if the gamemode support psypoints
/datum/controller/subsystem/points/proc/add_psy_points(hivenumber, amount)
if(!CHECK_BITFIELD(SSticker.mode.flags_round_type, MODE_PSY_POINTS))
return
xeno_points_by_hive[hivenumber] += amount


/datum/controller/subsystem/points/proc/approve_request(datum/supply_order/O, mob/living/user)
var/cost = 0
for(var/i in O.pack)
Expand Down
28 changes: 27 additions & 1 deletion code/game/objects/machinery/squad_supply/supply_console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
///Faction of this drop console
var/faction = FACTION_TERRAGOV
COOLDOWN_DECLARE(next_fire)
///Reference to the balloon vis obj effect
var/atom/movable/vis_obj/fulton_balloon/baloon
homexp13 marked this conversation as resolved.
Show resolved Hide resolved
var/obj/effect/fulton_extraction_holder/holder_obj

/obj/machinery/computer/supplydrop_console/Initialize(mapload)
. = ..()
Expand Down Expand Up @@ -175,10 +178,33 @@
visible_message("[icon2html(supply_pad, usr)] [span_warning("Launch aborted! No deployable object detected on the drop pad.")]")
return

baloon = new()
holder_obj = new()

supply_beacon.drop_location.visible_message(span_boldnotice("A supply drop appears suddendly!"))
playsound(supply_beacon.drop_location,'sound/effects/phasein.ogg', 50, TRUE)
playsound(supply_pad.loc,'sound/effects/phasein.ogg', 50, TRUE)
for(var/obj/C in supplies)
var/turf/TC = locate(supply_beacon.drop_location.x + x_offset, supply_beacon.drop_location.y + y_offset, supply_beacon.drop_location.z)
C.forceMove(TC)
C.moveToNullspace()
holder_obj.appearance = C.appearance
holder_obj.forceMove(TC)
addtimer(CALLBACK(src, PROC_REF(cleanup_delivery), C, TC), 1 SECONDS)

supply_pad.visible_message("[icon2html(supply_pad, viewers(src))] [span_boldnotice("Supply drop teleported! Another launch will be available in [launch_cooldown/10] seconds.")]")

baloon.icon_state = initial(baloon.icon_state)
holder_obj.vis_contents += baloon

flick("fulton_expand", baloon)
baloon.icon_state = "fulton_balloon"

holder_obj.pixel_z = 360
animate(holder_obj, 1 SECONDS, pixel_z = 0)

/obj/machinery/computer/supplydrop_console/proc/cleanup_delivery(atom/movable/C, turf/TC)
C.forceMove(TC)
holder_obj.moveToNullspace()
holder_obj.pixel_z = initial(C.pixel_z)
holder_obj.vis_contents -= baloon
baloon.icon_state = initial(baloon.icon_state)
10 changes: 8 additions & 2 deletions code/modules/reqs/supply.dm
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
.["elevator_dir"] = "up"
else
.["elevator"] = "MISSING!"
.["beacon"] = length(GLOB.supply_beacon) ? TRUE : FALSE

/datum/supply_ui/proc/get_shopping_cart(mob/user)
return SSpoints.shopping_cart
Expand Down Expand Up @@ -505,11 +506,15 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
var/list/shopping_cart = get_shopping_cart(ui.user)
shopping_cart.Cut()
. = TRUE
// RUTGMC EDIT BEGIN
if("buypersonal")
SSpoints.buy_using_psp(ui.user)
. = TRUE
// RUTGMC EDIT END
if("delivery")
var/datum/supply_order/O = SSpoints.shoppinglist[faction]["[params["id"]]"]
if(!O)
return
SSpoints.fast_delivery(O, ui.user)
. = TRUE

/datum/supply_ui/requests
tgui_name = "CargoRequest"
Expand Down Expand Up @@ -571,6 +576,7 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
.["shopping_list_items"] += SSpoints.request_shopping_cart[user.ckey][i]
.["shopping_list_cost"] += SP.cost * SSpoints.request_shopping_cart[user.ckey][SP.type]
.["shopping_list"][SP.type] = list("count" = SSpoints.request_shopping_cart[user.ckey][SP.type])
.["beacon"] = length(GLOB.supply_beacon) ? TRUE : FALSE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем дублирующее определение?


/datum/supply_ui/requests/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
Expand Down
31 changes: 19 additions & 12 deletions tgui/packages/tgui/interfaces/Cargo.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,24 +265,31 @@ const OrderList = (props, context) => {
level={2}
title={'Order #' + id}
buttons={
!readOnly && (
<>
{(!authed_by || selectedMenu === 'Denied Requests') && (
<>
{!readOnly &&
(!authed_by || selectedMenu === 'Denied Requests') && (
<Button
onClick={() => act('approve', { id: id })}
icon="check"
content="Approve"
/>
)}
{!authed_by && (
<Button
onClick={() => act('deny', { id: id })}
icon="times"
content="Deny"
/>
)}
</>
)
{!readOnly && !authed_by && (
<Button
onClick={() => act('deny', { id: id })}
icon="times"
content="Deny"
/>
)}
{selectedMenu === 'Awaiting Delivery' && (
<Button
onClick={() => act('delivery', { id: id })}
icon="luggage-cart"
content="Delivery"
disabled={!data.beacon}
/>
)}
</>
}>
<LabeledList>
<LabeledList.Item label="Requested by">
Expand Down
Loading