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

Admin Vehicles Fixes #4912

Merged
merged 5 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions code/__DEFINES/vehicle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@
#define VEHICLE_CLASS_LIGHT (1<<2) //light class armor (APC, tank)
#define VEHICLE_CLASS_MEDIUM (1<<3) //medium class armor (tank)
#define VEHICLE_CLASS_HEAVY (1<<4) //heavy class armor (tank)

#define TANK_POPLOCK 90
// Other vehicle flags
/// Vehicle can bypass vehicle blockers, typically going further into maps than intended
#define VEHICLE_BYPASS_BLOCKERS (1<<5)
8 changes: 8 additions & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,11 @@ DEFINE_BITFIELD(vend_flags, list(
"VEND_FACTION_THEMES" = VEND_FACTION_THEMES,
"VEND_USE_VENDOR_FLAGS" = VEND_USE_VENDOR_FLAGS,
))

DEFINE_BITFIELD(vehicle_flags, list(
"VEHICLE_CLASS_WEAK" = VEHICLE_CLASS_WEAK,
"VEHICLE_CLASS_LIGHT" = VEHICLE_CLASS_LIGHT,
"VEHICLE_CLASS_MEDIUM" = VEHICLE_CLASS_MEDIUM,
"VEHICLE_CLASS_HEAVY" = VEHICLE_CLASS_HEAVY,
"VEHICLE_BYPASS_BLOCKERS" = VEHICLE_BYPASS_BLOCKERS,
))
6 changes: 4 additions & 2 deletions code/game/machinery/vending/vendor_types/crew/vehicle_crew.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@
SIGNAL_HANDLER
UnregisterSignal(SSdcs, COMSIG_GLOB_VEHICLE_ORDERED)

selected_vehicle = "APC"
available_categories &= ~(VEHICLE_ARMOR_AVAILABLE|VEHICLE_INTEGRAL_AVAILABLE) //APC lacks these, so we need to remove these flags to be able to access spare parts section
if(!selected_vehicle)
selected_vehicle = "APC" // The whole thing seems to be based upon the assumption you unlock tank as an override, defaulting to APC
if(selected_vehicle == "APC")
available_categories &= ~(VEHICLE_ARMOR_AVAILABLE|VEHICLE_INTEGRAL_AVAILABLE) //APC lacks these, so we need to remove these flags to be able to access spare parts section

/obj/structure/machinery/cm_vending/gear/vehicle_crew/get_listed_products(mob/user)
var/list/display_list = list()
Expand Down
12 changes: 12 additions & 0 deletions code/game/objects/structures/blocker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,21 @@
/obj/structure/blocker/forcefield/vehicles
types = list(/obj/vehicle/)


/obj/structure/blocker/forcefield/vehicles/handle_vehicle_bump(obj/vehicle/multitile/multitile_vehicle)
if(multitile_vehicle.vehicle_flags & VEHICLE_BYPASS_BLOCKERS)
return TRUE
return FALSE

/obj/structure/blocker/forcefield/multitile_vehicles
types = list(/obj/vehicle/multitile/)


/obj/structure/blocker/forcefield/multitile_vehicles/handle_vehicle_bump(obj/vehicle/multitile/multitile_vehicle)
if(multitile_vehicle.vehicle_flags & VEHICLE_BYPASS_BLOCKERS)
return TRUE
return FALSE

/obj/structure/blocker/forcefield/human
types = list(/mob/living/carbon/human)
icon_state = "purple_line"
Expand Down
22 changes: 16 additions & 6 deletions code/game/supplyshuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,14 @@ var/datum/controller/supply/supply_controller = new()
/datum/vehicle_order/tank/has_vehicle_lock()
return

/datum/vehicle_order/tank/broken
name = "Smashed M34A2 Longstreet Light Tank"
ordered_vehicle = /obj/effect/vehicle_spawner/tank/hull/broken

/datum/vehicle_order/tank/plain
name = "M34A2 Longstreet Light Tank"
ordered_vehicle = /obj/effect/vehicle_spawner/tank

/datum/vehicle_order/apc
name = "M577 Armored Personnel Carrier"
ordered_vehicle = /obj/effect/vehicle_spawner/apc/decrepit
Expand All @@ -1327,18 +1335,19 @@ var/datum/controller/supply/supply_controller = new()
name = "M577-CMD Armored Personnel Carrier"
ordered_vehicle = /obj/effect/vehicle_spawner/apc_cmd/decrepit

/datum/vehicle_order/apc/empty
name = "Barebones M577 Armored Personal Carrier"
ordered_vehicle = /obj/effect/vehicle_spawner/apc/unarmed/broken

/obj/structure/machinery/computer/supplycomp/vehicle/Initialize()
. = ..()

vehicles = list(
/datum/vehicle_order/apc,
/datum/vehicle_order/apc/med,
/datum/vehicle_order/apc/cmd,
new /datum/vehicle_order/apc(),
new /datum/vehicle_order/apc/med(),
new /datum/vehicle_order/apc/cmd(),
)

for(var/order as anything in vehicles)
new order

if(!VehicleElevatorConsole)
VehicleElevatorConsole = src

Expand Down Expand Up @@ -1408,6 +1417,7 @@ var/datum/controller/supply/supply_controller = new()
return

if(!is_admin_level(SSshuttle.vehicle_elevator.z))
to_chat(usr, SPAN_WARNING("The elevator needs to be in the cargo bay dock to call a vehicle up. Ask someone to send it away."))
return

if(ismaintdrone(usr))
Expand Down
49 changes: 17 additions & 32 deletions code/modules/cm_tech/implements/tank.dm
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
/datum/supply_packs/vc_kit
name = "Vehicle Crewman Kits"
contains = list(
/obj/item/pamphlet/skill/vc,
/obj/item/pamphlet/skill/vc,
)
cost = 0
containertype = /obj/structure/closet/crate/supply
containername = "vehicle crewman kits crate"
buyable = 0
group = "Operations"
iteration_needed = null

/obj/item/pamphlet/skill/vc
name = "vehicle training manual"
desc = "A manual used to quickly impart vital knowledge on driving vehicles."
icon_state = "pamphlet_vehicle"
trait = /datum/character_trait/skills/vc
bypass_pamphlet_limit = TRUE

/obj/item/tank_coupon
name = "tank coupon"
desc = "A coupon to be used for ASRS Vehicle Consoles to grant the wearer a TANK! One use only."
/obj/item/vehicle_coupon
name = "vehicle coupon"
desc = "A coupon to be used for ASRS Vehicle Consoles to grant the wearer an actual APC! Yeah baby, we're done walking! One use only. The ASRS elevator must be manually sent to lower level. Special restrictions may apply. No warranty."
icon = 'icons/obj/items/pamphlets.dmi'
icon_state = "pamphlet_written"
item_state = "pamphlet_written"
var/vehicle_type = /datum/vehicle_order/apc/empty
var/vehicle_category = "APC"

/obj/item/tank_coupon/attack_self(mob/user)
/obj/item/vehicle_coupon/tank
name = "tank coupon"
desc = "We're done playing! This coupon allows the ship crew to retrieve a complete Longstreet tank from Vehicle ASRS. Make sure to send the ASRS lift down so it can be retrieved. One use only. LTB not included. Comes with free friendly fire."
vehicle_type = /datum/vehicle_order/tank/broken
vehicle_category = "TANK"

/obj/item/vehicle_coupon/attack_self(mob/user)
if(QDELETED(src))
return
if(redeem_tank())
to_chat(user, SPAN_WARNING("\The [src] catches fire as it is read, resetting the ASRS Vehicle system!"))
if(redeem_vehicle())
to_chat(user, SPAN_WARNING("\The [src] catches fire as it is read and resets the ASRS Vehicle system! Send the lift down and haul your prize up."))
qdel(src)
return ..()

/obj/item/tank_coupon/proc/redeem_tank(mob/user)
/obj/item/vehicle_coupon/proc/redeem_vehicle(mob/user)
SHOULD_NOT_SLEEP(TRUE)
. = FALSE
var/obj/structure/machinery/computer/supplycomp/vehicle/comp = VehicleElevatorConsole
Expand All @@ -46,7 +41,7 @@
comp.spent = FALSE
QDEL_NULL_LIST(comp.vehicles)
comp.vehicles = list(
new /datum/vehicle_order/tank()
new vehicle_type(),
)
comp.allowed_roles = null
comp.req_access = list()
Expand All @@ -56,17 +51,7 @@
gearcomp.req_access = list()
gearcomp.req_one_access = list()
gearcomp.vendor_role = list()
gearcomp.selected_vehicle = "TANK"
gearcomp.selected_vehicle = vehicle_category
gearcomp.available_categories = VEHICLE_ALL_AVAILABLE

var/datum/supply_packs/VK = /datum/supply_packs/vc_kit
var/pack = initial(VK.name)
var/datum/supply_order/O = new /datum/supply_order()
O.ordernum = supply_controller.ordernum
supply_controller.ordernum++
O.object = supply_controller.supply_packs[pack]
O.orderedby = MAIN_AI_SYSTEM
O.approvedby = MAIN_AI_SYSTEM
supply_controller.shoppinglist += O

return TRUE
7 changes: 7 additions & 0 deletions code/modules/vehicles/apc/apc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,16 @@ GLOBAL_LIST_EMPTY(command_apc_list)
handle_direction(APC)
APC.update_icon()

return APC

/obj/effect/vehicle_spawner/apc/unarmed/load_hardpoints(obj/vehicle/multitile/apc/V)
return

/obj/effect/vehicle_spawner/apc/unarmed/broken/spawn_vehicle()
var/obj/vehicle/multitile/apc/apc = ..()
load_damage(apc)
apc.update_icon()

//PRESET: default hardpoints, destroyed
/obj/effect/vehicle_spawner/apc/unarmed/decrepit/spawn_vehicle()
var/obj/vehicle/multitile/apc/unarmed/APC = new (loc)
Expand Down
29 changes: 9 additions & 20 deletions code/modules/vehicles/multitile/multitile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -240,26 +240,15 @@

var/amt_hardpoints = LAZYLEN(hardpoints)
if(amt_hardpoints)
var/list/hardpoint_images[amt_hardpoints]
var/list/C[HDPT_LAYER_MAX]

// Counting sort the images into a list so we get the hardpoint images sorted by layer
for(var/obj/item/hardpoint/H in hardpoints)
C[H.hdpt_layer] += 1

for(var/i = 2 to HDPT_LAYER_MAX)
C[i] += C[i-1]

for(var/obj/item/hardpoint/H in hardpoints)
hardpoint_images[C[H.hdpt_layer]] = H.get_hardpoint_image()
C[H.hdpt_layer] -= 1

for(var/i = 1 to amt_hardpoints)
var/image/I = hardpoint_images[i]
// get_hardpoint_image() can return a list of images
if(istype(I))
I.layer = layer + (i*0.1)
overlays += I
for(var/obj/item/hardpoint/hardpoint in hardpoints)
var/image/hardpoint_image = hardpoint.get_hardpoint_image()
if(istype(hardpoint_image))
hardpoint_image.layer = layer + hardpoint.hdpt_layer * 0.1
else if(islist(hardpoint_image))
var/list/image/hardpoint_image_list = hardpoint_image // Linter will complain about iterating on "an image" otherwise
for(var/image/subimage in hardpoint_image_list)
subimage.layer = layer + hardpoint.hdpt_layer * 0.1
overlays += hardpoint_image

if(clamped)
var/image/J = image(icon, icon_state = "vehicle_clamp", layer = layer+0.1)
Expand Down
8 changes: 8 additions & 0 deletions code/modules/vehicles/tank/tank.dm
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
handle_direction(TANK)
TANK.update_icon()

return TANK

/obj/effect/vehicle_spawner/tank/load_hardpoints(obj/vehicle/multitile/tank/V)
V.add_hardpoint(new /obj/item/hardpoint/holder/tank_turret)

Expand All @@ -201,6 +203,12 @@
/obj/effect/vehicle_spawner/tank/hull/load_hardpoints(obj/vehicle/multitile/tank/V)
return

//Just the hull and it's broken TOO, you get the full experience
/obj/effect/vehicle_spawner/tank/hull/broken/spawn_vehicle()
var/obj/vehicle/multitile/tank/tonk = ..()
load_damage(tonk)
tonk.update_icon()

//PRESET: default hardpoints, destroyed
/obj/effect/vehicle_spawner/tank/decrepit/spawn_vehicle()
var/obj/vehicle/multitile/tank/TANK = new (loc)
Expand Down