diff --git a/code/modules/cm_marines/dropship_ammo.dm b/code/modules/cm_marines/dropship_ammo.dm index 19086b36c957..93768e218375 100644 --- a/code/modules/cm_marines/dropship_ammo.dm +++ b/code/modules/cm_marines/dropship_ammo.dm @@ -427,7 +427,7 @@ max_ammo_count = 1 ammo_name = "area denial sentry" travelling_time = 0 // handled by droppod - point_cost = 800 + point_cost = 800 //handled by printer accuracy_range = 0 // pinpoint max_inaccuracy = 0 /// Special structures it needs to break with drop pod diff --git a/code/modules/cm_marines/vehicle_part_fabricator.dm b/code/modules/cm_marines/vehicle_part_fabricator.dm index 0095ff54a2ab..fd9b0faafa61 100644 --- a/code/modules/cm_marines/vehicle_part_fabricator.dm +++ b/code/modules/cm_marines/vehicle_part_fabricator.dm @@ -10,8 +10,8 @@ icon_state = "drone_fab_idle" var/busy = FALSE var/generate_points = TRUE - var/valid_parts = null - var/valid_ammo = null + var/omnisentry_price_scale = 100 + var/omnisentry_price = 300 /obj/structure/machinery/part_fabricator/New() ..() @@ -28,7 +28,8 @@ /obj/structure/machinery/part_fabricator/dropship/ui_data(mob/user) return list( - "points" = get_point_store() + "points" = get_point_store(), + "omnisentrygun_price" = omnisentry_price ) /obj/structure/machinery/part_fabricator/power_change() @@ -53,11 +54,15 @@ /obj/structure/machinery/part_fabricator/proc/build_part(part_type, cost, mob/user) set waitfor = 0 if(stat & NOPOWER) return + if(ispath(part_type,/obj/structure/ship_ammo/sentry)) + cost = omnisentry_price if(get_point_store() < cost) to_chat(user, SPAN_WARNING("You don't have enough points to build that.")) return visible_message(SPAN_NOTICE("[src] starts printing something.")) spend_point_store(cost) + if(ispath(part_type,/obj/structure/ship_ammo/sentry)) + omnisentry_price += omnisentry_price_scale icon_state = "drone_fab_active" busy = TRUE addtimer(CALLBACK(src, PROC_REF(do_build_part), part_type), 10 SECONDS) @@ -68,7 +73,7 @@ new part_type(get_step(src, SOUTHEAST)) icon_state = "drone_fab_idle" -/obj/structure/machinery/part_fabricator/ui_act(action, params) +/obj/structure/machinery/part_fabricator/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) . = ..() if(.) return @@ -77,27 +82,33 @@ to_chat(usr, SPAN_WARNING("The [name] is busy. Please wait for completion of previous operation.")) return - if(action == "produce") - var/produce = text2path(params["path"]) - var/cost = text2num(params["cost"]) - var/exploiting = TRUE - - if (valid_parts && ispath(produce, valid_parts)) - exploiting = FALSE - else if (valid_ammo && ispath(produce, valid_ammo)) - exploiting = FALSE + var/mob/user = ui.user - if (cost < 0) - exploiting = TRUE + if(action == "produce") + var/cost = 0 + var/is_ammo = params["is_ammo"] + var/index = params["index"] + + if(is_ammo == 0) + var/obj/structure/dropship_equipment/produce = (typesof(/obj/structure/dropship_equipment))[index] + if(SSticker.mode && MODE_HAS_TOGGLEABLE_FLAG(MODE_NO_COMBAT_CAS) && produce.combat_equipment) + log_admin("Bad topic: [user] may be trying to HREF exploit [src] to bypass no combat cas") + return + cost = initial(produce.point_cost) + build_part(produce, cost, user) + return - if (exploiting) - log_admin("Bad topic: [usr] may be trying to HREF exploit [src] with [produce], [cost]") + else + var/obj/structure/ship_ammo/produce = (typesof(/obj/structure/ship_ammo))[index] + if(SSticker.mode && MODE_HAS_TOGGLEABLE_FLAG(MODE_NO_COMBAT_CAS) && produce.combat_equipment) + log_admin("Bad topic: [user] may be trying to HREF exploit [src] to bypass no combat cas") + return + cost = initial(produce.point_cost) + build_part(produce, cost, user) return - build_part(produce, cost, usr) - return else - log_admin("Bad topic: [usr] may be trying to HREF exploit [src]") + log_admin("Bad topic: [user] may be trying to HREF exploit [src]") return /obj/structure/machinery/part_fabricator/attack_hand(mob/user) @@ -116,12 +127,11 @@ name = "dropship part fabricator" desc = "A large automated 3D printer for producing dropship parts. You can recycle parts or ammo in it, and get 80% of your points back, by clicking it while holding them in a powerloader claw." req_access = list(ACCESS_MARINE_DROPSHIP) - valid_parts = /obj/structure/dropship_equipment - valid_ammo = /obj/structure/ship_ammo unslashable = TRUE unacidable = TRUE + /obj/structure/machinery/part_fabricator/dropship/get_point_store() return GLOB.supply_controller.dropship_points @@ -134,86 +144,100 @@ /obj/structure/machinery/part_fabricator/dropship/ui_static_data(mob/user) var/list/static_data = list() static_data["Equipment"] = list() + var/is_ammo = 0 + var/index = 1 for(var/build_type in typesof(/obj/structure/dropship_equipment)) - var/obj/structure/dropship_equipment/DE = build_type - if(SSticker.mode && MODE_HAS_TOGGLEABLE_FLAG(MODE_NO_COMBAT_CAS) && initial(DE.combat_equipment)) + var/obj/structure/dropship_equipment/dropship_equipment_data = build_type + if(SSticker.mode && MODE_HAS_TOGGLEABLE_FLAG(MODE_NO_COMBAT_CAS) && dropship_equipment_data.combat_equipment) + index += 1 continue - var/build_name = initial(DE.name) - var/build_description = initial(DE.desc) - var/build_cost = initial(DE.point_cost) + var/build_name = initial(dropship_equipment_data.name) + var/build_description = initial(dropship_equipment_data.desc) + var/build_cost = initial(dropship_equipment_data.point_cost) if(build_cost) static_data["Equipment"] += list(list( "name" = capitalize_first_letters(build_name), "desc" = build_description, - "path" = build_type, - "cost" = build_cost + "cost" = build_cost, + "index" = index, + "is_ammo" = is_ammo )) + index += 1 static_data["Ammo"] = list() + is_ammo = 1 + index = 1 for(var/build_type in typesof(/obj/structure/ship_ammo)) - var/obj/structure/ship_ammo/SA = build_type - if(SSticker.mode && MODE_HAS_TOGGLEABLE_FLAG(MODE_NO_COMBAT_CAS) && initial(SA.combat_equipment)) + var/obj/structure/ship_ammo/ship_ammo_data = build_type + if(SSticker.mode && MODE_HAS_TOGGLEABLE_FLAG(MODE_NO_COMBAT_CAS) && ship_ammo_data.combat_equipment) + index = index + 1 continue - var/build_name = initial(SA.name) - var/build_description = initial(SA.desc) - var/build_cost = initial(SA.point_cost) + var/build_name = initial(ship_ammo_data.name) + var/build_description = initial(ship_ammo_data.desc) + var/build_cost = initial(ship_ammo_data.point_cost) if(build_cost) static_data["Ammo"] += list(list( "name" = capitalize_first_letters(build_name), "desc" = build_description, - "path" = build_type, - "cost" = build_cost + "cost" = build_cost, + "index" = index, + "is_ammo" = is_ammo )) + index += 1 return static_data /obj/structure/machinery/part_fabricator/dropship/attackby(obj/item/I, mob/user) if(istype(I, /obj/item/powerloader_clamp)) - var/obj/item/powerloader_clamp/PC = I - recycle_equipment(PC, user) + var/obj/item/powerloader_clamp/powerloader_clamp_used = I + recycle_equipment(powerloader_clamp_used, user) return return ..() -/obj/structure/machinery/part_fabricator/dropship/proc/recycle_equipment(obj/item/powerloader_clamp/PC, mob/living/user) - if(!PC.loaded) - to_chat(user, SPAN_WARNING("There is nothing loaded in \the [PC].")) +/obj/structure/machinery/part_fabricator/dropship/proc/recycle_equipment(obj/item/powerloader_clamp/powerloader_clamp_used, mob/living/user) + if(!powerloader_clamp_used.loaded) + to_chat(user, SPAN_WARNING("There is nothing loaded in \the [powerloader_clamp_used].")) return var/recycle_points - if(istype(PC.loaded, /obj/structure/dropship_equipment)) - var/obj/structure/dropship_equipment/SE = PC.loaded - recycle_points = SE.point_cost - else if(istype(PC.loaded, /obj/structure/ship_ammo)) - var/obj/structure/ship_ammo/SE = PC.loaded - if(!SE.ammo_count) - to_chat(user, SPAN_WARNING("\The [SE] is empty!")) + if(istype(powerloader_clamp_used.loaded, /obj/structure/dropship_equipment)) + var/obj/structure/dropship_equipment/sold_eqipment = powerloader_clamp_used.loaded + recycle_points = sold_eqipment.point_cost + else if(istype(powerloader_clamp_used.loaded, /obj/structure/ship_ammo)) + var/obj/structure/ship_ammo/sold_eqipment = powerloader_clamp_used.loaded + if(!sold_eqipment.ammo_count) + to_chat(user, SPAN_WARNING("\The [sold_eqipment] is empty!")) return - if(SE.ammo_count != SE.max_ammo_count) - recycle_points = (SE.point_cost * (SE.ammo_count / SE.max_ammo_count)) - to_chat(user, SPAN_WARNING("\The [SE] is not fully loaded, and less points will be able to be refunded.")) + if(sold_eqipment.ammo_count != sold_eqipment.max_ammo_count) + recycle_points = (sold_eqipment.point_cost * (sold_eqipment.ammo_count / sold_eqipment.max_ammo_count)) + to_chat(user, SPAN_WARNING("\The [sold_eqipment] is not fully loaded, and less points will be able to be refunded.")) else - recycle_points = SE.point_cost + recycle_points = sold_eqipment.point_cost + if(istype(powerloader_clamp_used.loaded, /obj/structure/ship_ammo/sentry)) + recycle_points = omnisentry_price - omnisentry_price_scale if(!recycle_points) - to_chat(user, SPAN_WARNING("\The [PC.loaded] can't be recycled!")) + to_chat(user, SPAN_WARNING("\The [powerloader_clamp_used.loaded] can't be recycled!")) return - var/thing_to_recycle = PC.loaded - to_chat(user, SPAN_WARNING("You start recycling \the [PC.loaded]!")) + var/thing_to_recycle = powerloader_clamp_used.loaded + to_chat(user, SPAN_WARNING("You start recycling \the [powerloader_clamp_used.loaded]!")) playsound(loc, 'sound/machines/hydraulics_1.ogg', 40, 1) - if(!user || !do_after(user, (7 SECONDS) * user.get_skill_duration_multiplier(SKILL_ENGINEER), INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_HOSTILE, PC.loaded, INTERRUPT_ALL)) + if(!user || !do_after(user, (7 SECONDS) * user.get_skill_duration_multiplier(SKILL_ENGINEER), INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_HOSTILE, powerloader_clamp_used.loaded, INTERRUPT_ALL)) to_chat(user, SPAN_NOTICE("You stop recycling \the [thing_to_recycle].")) return - for(var/obj/thing as anything in PC.loaded) + if(istype(powerloader_clamp_used.loaded, /obj/structure/ship_ammo/sentry)) + omnisentry_price -= omnisentry_price_scale + for(var/obj/thing as anything in powerloader_clamp_used.loaded) thing.forceMove(loc) // no sentries popping out when we qdel please qdel(thing) - qdel(PC.loaded) - PC.loaded = null + qdel(powerloader_clamp_used.loaded) + powerloader_clamp_used.loaded = null to_chat(user, SPAN_NOTICE("You recycle \the [thing_to_recycle] into [src], and get back [round(recycle_points * 0.8)] points.")) msg_admin_niche("[key_name(user)] recycled a [thing_to_recycle] into \the [src] for [round(recycle_points * 0.8)] points.") add_to_point_store(round(recycle_points * 0.8)) playsound(loc, 'sound/machines/fax.ogg', 40, 1) - PC.update_icon() + powerloader_clamp_used.update_icon() // WARNING: IF YOU DECIDE TO READD THIS, GIVE THE HARDPOINTS POINT COSTS @@ -223,8 +247,6 @@ desc = "A large automated 3D printer for producing vehicle parts." req_access = list(ACCESS_MARINE_CREWMAN) generate_points = FALSE - valid_parts = /obj/item/hardpoint - valid_ammo = /obj/item/ammo_magazine/hardpoint unacidable = TRUE indestructible = TRUE @@ -242,9 +264,9 @@ var/list/static_data = list() static_data["Equipment"] = list() for(var/build_type in typesof(/obj/item/hardpoint)) - var/obj/item/hardpoint/TE = build_type - var/build_name = initial(TE.name) - var/build_description = initial(TE.desc) + var/obj/item/hardpoint/hardpoint_data = build_type + var/build_name = initial(hardpoint_data.name) + var/build_description = initial(hardpoint_data.desc) var/build_cost = 0 if(build_cost) static_data["Equipment"] += list(list( @@ -256,9 +278,9 @@ static_data["Ammo"] = list() for(var/build_type in typesof(/obj/item/ammo_magazine/hardpoint)) - var/obj/item/ammo_magazine/hardpoint/TA = build_type - var/build_name = initial(TA.name) - var/build_description = initial(TA.desc) + var/obj/item/ammo_magazine/hardpoint/ammo_data = build_type + var/build_name = initial(ammo_data.name) + var/build_description = initial(ammo_data.desc) var/build_cost = 0 if(build_cost) static_data["Ammo"] += list(list( diff --git a/tgui/packages/tgui/interfaces/PartFabricator.jsx b/tgui/packages/tgui/interfaces/PartFabricator.jsx index 0bccb7009bee..829ba2c2f88b 100644 --- a/tgui/packages/tgui/interfaces/PartFabricator.jsx +++ b/tgui/packages/tgui/interfaces/PartFabricator.jsx @@ -13,10 +13,9 @@ export const PartFabricator = (props) => { ); }; -const GeneralPanel = (props) => { - const { act, data } = useBackend(); - const { points, Equipment, Ammo } = data; - +const GeneralPanel = (props, context) => { + const { act, data } = useBackend(context); + const { points, omnisentrygun_price, Equipment, Ammo } = data; return (
Points: {points}
@@ -37,8 +36,8 @@ const GeneralPanel = (props) => { tooltipPosition="left" onClick={() => act('produce', { - path: Equipment.path, - cost: Equipment.cost, + index: Equipment.index, + is_ammo: Equipment.is_ammo, }) } /> @@ -57,18 +56,34 @@ const GeneralPanel = (props) => { label={Ammo.name} className="underline" buttons={ -