Skip to content

Commit

Permalink
Feat: add the ability for exosuits to have passengers (#719)
Browse files Browse the repository at this point in the history
Мне лень, давайте вы просто почитаете отложку, ладно?

https://discord.com/channels/617003227182792704/1102977734373818489/1203769927081664523
  • Loading branch information
AmShegars authored Feb 12, 2024
1 parent 423d484 commit 4a6f517
Show file tree
Hide file tree
Showing 25 changed files with 545 additions and 18 deletions.
1 change: 1 addition & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,7 @@
#include "code\modules\mechs\components\frame.dm"
#include "code\modules\mechs\components\head.dm"
#include "code\modules\mechs\components\legs.dm"
#include "code\modules\mechs\components\passenger_compartment.dm"
#include "code\modules\mechs\components\software.dm"
#include "code\modules\mechs\equipment\_equipment.dm"
#include "code\modules\mechs\equipment\combat.dm"
Expand Down
1 change: 1 addition & 0 deletions code/__defines/_planes+layers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ What is the naming convention for planes or layers?
//MOB
#define MECH_UNDER_LAYER 3.11
// MOB_LAYER 4
#define MECH_BACK_LAYER 4.00
#define MECH_BASE_LAYER 4.01
#define MECH_INTERMEDIATE_LAYER 4.02
#define MECH_PILOT_LAYER 4.03
Expand Down
6 changes: 5 additions & 1 deletion code/modules/mechs/_mech_setup.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ GLOBAL_LIST_INIT(mech_weapon_overlays, icon_states('icons/mecha/mech_weapon_over
//POWER!
#define MECH_POWER_OFF 0
#define MECH_POWER_TRANSITION 1
#define MECH_POWER_ON 2
#define MECH_POWER_ON 2

//Passengers
#define MECH_DROP_ALL_PASSENGER 1 // Скинуть всех пассажиров
#define MECH_DROP_ANY_PASSENGER 2 // Скинуть первого попавшегося пассажира
3 changes: 2 additions & 1 deletion code/modules/mechs/components/arms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

var/melee_damage = 15
var/action_delay = 15
var/allow_passengers = TRUE // Отвечает за то, что могут ли руки перевозить пассажиров
var/obj/item/robot_parts/robot_component/actuator/motivator
power_use = 10
w_class = ITEM_SIZE_LARGE
Expand Down Expand Up @@ -46,4 +47,4 @@
if(motivator)
to_chat(user, SPAN_NOTICE(" Actuator Integrity: <b>[round((((motivator.max_dam - motivator.total_dam) / motivator.max_dam)) * 100)]%</b>"))
else
to_chat(user, SPAN_WARNING(" Actuator Missing or Non-functional."))
to_chat(user, SPAN_WARNING(" Actuator Missing or Non-functional."))
7 changes: 6 additions & 1 deletion code/modules/mechs/components/body.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@
var/transparent_cabin = FALSE
var/hide_pilot = FALSE
var/hatch_descriptor = "cockpit"
var/mob/living/exosuit/owner
var/list/pilot_positions
var/list/back_passengers_positions
var/list/left_back_passengers_positions
var/list/right_back_passengers_positions
var/pilot_coverage = 100
var/min_pilot_size = MOB_SMALL
var/max_pilot_size = MOB_LARGE
has_hardpoints = list(HARDPOINT_BACK, HARDPOINT_LEFT_SHOULDER, HARDPOINT_RIGHT_SHOULDER)
var/climb_time = 25
var/allow_passengers = TRUE

/obj/item/mech_component/chassis/New()
..()
Expand Down Expand Up @@ -185,7 +190,7 @@ obj/item/mech_component/chassis/MouseDrop(atom/over)
if(!usr || !over) return
if(!Adjacent(usr) || !over.Adjacent(usr)) return

if(storage_compartment)
if(storage_compartment && LAZYLEN(owner.passenger_compartment.back_passengers) <= 0) //Багажник не откроется, пока на спине есть пассажир.
return storage_compartment.MouseDrop(over)

/obj/item/mech_component/chassis/return_diagnostics(mob/user)
Expand Down
33 changes: 33 additions & 0 deletions code/modules/mechs/components/passenger_compartment.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/obj/item/mech_component/passenger_compartment
var/list/back_passengers
var/list/left_back_passengers
var/list/right_back_passengers
var/datum/gas_mixture/air_contents = new
var/mob/living/exosuit/owner

/obj/item/mech_component/passenger_compartment/Initialize()
. = ..()
owner = loc

/obj/item/mech_component/passenger_compartment/proc/check_passengers_status()
var/mob/living/passenger
if(LAZYLEN(back_passengers) > 0)
passenger = back_passengers[1]
if(passenger.incapacitated(INCAPACITATION_UNRESISTING) == TRUE)
to_chat(passenger,SPAN_WARNING("You cant hold anymore yourself on mech."))
owner.leave_passenger(passenger)
if(LAZYLEN(left_back_passengers) > 0)
passenger = left_back_passengers[1]
if(passenger.incapacitated(INCAPACITATION_UNRESISTING) == TRUE)
to_chat(passenger,SPAN_WARNING("You cant hold anymore yourself on mech."))
owner.leave_passenger(passenger)
if(LAZYLEN(right_back_passengers > 0))
passenger = right_back_passengers[1]
if(passenger.incapacitated(INCAPACITATION_UNRESISTING) == TRUE)
to_chat(passenger,SPAN_WARNING("You cant hold anymore yourself on mech."))
owner.leave_passenger(passenger)

/obj/item/mech_component/passenger_compartment/return_air()
var/turf/T = get_turf(loc)
if(istype(T))
return T.return_air()
15 changes: 8 additions & 7 deletions code/modules/mechs/equipment/_equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
var/passive_power_use = 0 // For gear that for some reason takes up power even if it's supposedly doing nothing (mech will idly consume power)
var/mech_layer = MECH_GEAR_LAYER //For the part where it's rendered as mech gear
var/require_adjacent = TRUE
var/disturb_passengers = FALSE // Отвечает за то, мешает ли модуль посадке пассажира в занятый хардпоинт.
var/active = FALSE //For gear that has an active state (ie, floodlights)

/obj/item/mech_equipment/attack(mob/living/M, mob/living/user, target_zone) //Generally it's not desired to be able to attack with items
Expand All @@ -23,25 +24,25 @@
/obj/item/mech_equipment/afterattack(var/atom/target, var/mob/living/user, var/inrange, var/params)
if(require_adjacent)
if(!inrange)
return 0
return 0
if (owner && loc == owner && ((user in owner.pilots) || user == owner))
if(target in owner.contents)
return 0

if(!(owner.get_cell()?.check_charge(active_power_use * CELLRATE)))
to_chat(user, SPAN_WARNING("The power indicator flashes briefly as you attempt to use \the [src]"))
return 0
return 0
return 1
else
else
return 0

/obj/item/mech_equipment/attack_self(var/mob/user)
if (owner && loc == owner && ((user in owner.pilots) || user == owner))
if(!(owner.get_cell()?.check_charge(active_power_use * CELLRATE)))
to_chat(user, SPAN_WARNING("The power indicator flashes briefly as you attempt to use \the [src]"))
return 0
return 0
return 1
else
else
return 0

/obj/item/mech_equipment/examine(mob/user, distance)
Expand Down Expand Up @@ -115,14 +116,14 @@
icon_state = holding.icon_state
SetName(holding.name)
desc = "[holding.desc] This one is suitable for installation on an exosuit."


/obj/item/mech_equipment/mounted_system/Destroy()
GLOB.destroyed_event.unregister(holding, src, .proc/forget_holding)
if(holding)
QDEL_NULL(holding)
. = ..()


/obj/item/mech_equipment/mounted_system/get_effective_obj()
return (holding ? holding : src)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mechs/equipment/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
active_power_use = 0 //Usage doesn't really require power. We don't want people stuck inside
origin_tech = list(TECH_DATA = 2, TECH_BIO = 3)
passive_power_use = 1.5 KILOWATTS
disturb_passengers = TRUE // Мешает залезть пассажирам на спину(не бока)
var/obj/machinery/sleeper/mounted/sleeper = null

/obj/item/mech_equipment/sleeper/Initialize()
Expand Down Expand Up @@ -77,4 +78,3 @@
user.visible_message("<span class='notice'>\The [user] removes \the [beaker] from \the [src].</span>", "<span class='notice'>You remove \the [beaker] from \the [src].</span>")
beaker = I
user.visible_message("<span class='notice'>\The [user] adds \a [I] to \the [src].</span>", "<span class='notice'>You add \a [I] to \the [src].</span>")

2 changes: 2 additions & 0 deletions code/modules/mechs/equipment/utility.dm
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@
name = "mounted plasma cutter"
desc = "An industrial plasma cutter mounted onto the chassis of the mech. "
icon_state = "railauto" //TODO: Make a new sprite that doesn't get sec called on you.
disturb_passengers = TRUE // Мешает пассажирам у плеч, слишком длинная байда
holding_type = /obj/item/gun/energy/plasmacutter/mounted/mech
restricted_hardpoints = list(HARDPOINT_LEFT_HAND, HARDPOINT_RIGHT_HAND, HARDPOINT_LEFT_SHOULDER, HARDPOINT_RIGHT_SHOULDER)
restricted_software = list(MECH_SOFTWARE_UTILITY)
Expand Down Expand Up @@ -593,6 +594,7 @@
require_adjacent = FALSE
var/stabilizers = FALSE
var/slide_distance = 6
disturb_passengers = TRUE

/obj/item/mech_equipment/ionjets/Initialize()
. = ..()
Expand Down
14 changes: 14 additions & 0 deletions code/modules/mechs/mech.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@
var/obj/screen/movable/exosuit/toggle/camera/hud_camera
//POWER
var/power = MECH_POWER_OFF
// Passenger places
// В связи с кор механом, пассажиры будут помещены в отдельный обьект, для того чтобы пассажиры не курили воздух внутри меха!
var/obj/item/mech_component/passenger_compartment/passenger_compartment
var/list/passenger_places = list(
"Back",
"Left back",
"Right back"
)
var/passengers_ammount = 0 // Хранит в себе общее число пассажиров меха
var/list/back_passengers_overlays // <- Изображение пассажира на спине
var/list/left_back_passengers_overlays // <- Изображение пассажира на левом боку
var/list/right_back_passengers_overlays // <- Изображение пассажира на правом боку


/mob/living/exosuit/MayZoom()
if(head?.vision_flags)
Expand Down Expand Up @@ -112,6 +125,7 @@
body = source_frame.body
if(source_frame.material)
material = source_frame.material
passenger_compartment = new(src)
maxHealth = (body.mech_health + material.integrity) + head.max_damage + arms.max_damage + legs.max_damage
health = maxHealth
updatehealth()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mechs/mech_construction.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/mob/living/exosuit/proc/dismantle()

forced_leave_passenger(0 , MECH_DROP_ALL_PASSENGER , "dismantle of [src]") // Перед разбором, сбросим всех пассажиров
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
var/obj/structure/heavy_vehicle_frame/frame = new(get_turf(src))
for(var/hardpoint in hardpoints)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mechs/mech_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
if(LAZYLEN(pilots) && (!hatch_closed || !prob(body.pilot_coverage)))
var/mob/living/pilot = pick(pilots)
return pilot.bullet_act(P, def_zone, used_weapon)
if(passengers_ammount > 0) // <- Если в меха выстрелили и были пассажиры,пассажирку меха опустошит
forced_leave_passenger(null , MECH_DROP_ALL_PASSENGER , "attack")

..()

/mob/living/exosuit/get_armors_by_zone(def_zone, damage_type, damage_flags)
Expand Down
84 changes: 84 additions & 0 deletions code/modules/mechs/mech_icon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
/mob/living/exosuit/on_update_icon()
var/list/new_overlays = get_mech_images(list(body, head), MECH_BASE_LAYER)
if(body)
new_overlays += back_passengers_overlays
new_overlays += left_back_passengers_overlays
new_overlays += right_back_passengers_overlays
new_overlays += get_mech_image(body.decal, "[body.icon_state]_cockpit", body.on_mech_icon, overlay_layer = MECH_INTERMEDIATE_LAYER)
update_pilots(FALSE)
if(LAZYLEN(pilot_overlays))
Expand Down Expand Up @@ -78,5 +81,86 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
if(update_overlays && LAZYLEN(pilot_overlays))
overlays += pilot_overlays

/mob/living/exosuit/proc/update_passengers(var/update_overlays = TRUE)
if(update_overlays && LAZYLEN(back_passengers_overlays))
overlays -= back_passengers_overlays
if(update_overlays && LAZYLEN(left_back_passengers_overlays))
overlays -= left_back_passengers_overlays
if(update_overlays && LAZYLEN(right_back_passengers_overlays))
overlays -= right_back_passengers_overlays
back_passengers_overlays = null
left_back_passengers_overlays = null
right_back_passengers_overlays = null
var/passenger_back_layer
var/passenger_left_back_layer
var/passenger_right_back_layer
//
if(dir == EAST)
passenger_back_layer = MECH_BACK_LAYER
passenger_left_back_layer = MECH_BACK_LAYER - 0.01
passenger_right_back_layer = MECH_GEAR_LAYER
else if(dir == WEST)
passenger_back_layer = MECH_BACK_LAYER
passenger_left_back_layer = MECH_GEAR_LAYER
passenger_right_back_layer = MECH_BACK_LAYER - 0.01
else if(dir == SOUTH)
passenger_back_layer = MECH_BACK_LAYER
passenger_left_back_layer = MECH_BACK_LAYER
passenger_right_back_layer = MECH_BACK_LAYER
else if(dir == NORTH)
passenger_back_layer = MECH_GEAR_LAYER + 0.01
passenger_left_back_layer = MECH_GEAR_LAYER + 0.01
passenger_right_back_layer = MECH_GEAR_LAYER + 0.01
//
//
if(LAZYLEN(passenger_compartment.back_passengers) > 0) // Отрисовка среднего пассажирка
var/mob/passenger_back = passenger_compartment.back_passengers[1]
var/image/draw_passenger_back = new
draw_passenger_back.appearance = passenger_back
var/list/back_offset_values = body.back_passengers_positions
var/list/back_directional_offset_values = back_offset_values["[dir]"]
draw_passenger_back.pixel_x = passenger_back.default_pixel_x + back_directional_offset_values["x"]
draw_passenger_back.pixel_y = passenger_back.default_pixel_y + back_directional_offset_values["y"]
draw_passenger_back.pixel_z = 0
draw_passenger_back.transform = null
draw_passenger_back.layer = passenger_back_layer
LAZYADD(back_passengers_overlays, draw_passenger_back)
//
if(LAZYLEN(passenger_compartment.left_back_passengers) > 0) // Отрисовка левого пассажира
var/mob/passenger_left_back = passenger_compartment.left_back_passengers[1]
var/image/draw_passenger_left_back = new
draw_passenger_left_back.appearance = passenger_left_back
draw_passenger_left_back.plane = FLOAT_PLANE
var/list/left_offset_values = body.left_back_passengers_positions
var/list/left_directional_offset_values = left_offset_values["[dir]"]
draw_passenger_left_back.pixel_x = passenger_left_back.default_pixel_x + left_directional_offset_values["x"]
draw_passenger_left_back.pixel_y = passenger_left_back.default_pixel_y + left_directional_offset_values["y"]
draw_passenger_left_back.pixel_z = 0
draw_passenger_left_back.transform = null
draw_passenger_left_back.layer = passenger_left_back_layer
LAZYADD(left_back_passengers_overlays, draw_passenger_left_back)
//
if(LAZYLEN(passenger_compartment.right_back_passengers) > 0) // Отрисовка правого пассажира
var/mob/passenger_right_back = passenger_compartment.right_back_passengers[1]
var/image/draw_passenger_right_back = new
draw_passenger_right_back.layer = passenger_right_back_layer
draw_passenger_right_back.appearance = passenger_right_back
draw_passenger_right_back.plane = FLOAT_PLANE
var/list/right_offset_values = body.right_back_passengers_positions
var/list/right_directional_offset_values = right_offset_values["[dir]"]
draw_passenger_right_back.pixel_x = passenger_right_back.default_pixel_x + right_directional_offset_values["x"]
draw_passenger_right_back.pixel_y = passenger_right_back.default_pixel_y + right_directional_offset_values["y"]
draw_passenger_right_back.pixel_z = 0
draw_passenger_right_back.transform = null
draw_passenger_right_back.layer = passenger_right_back_layer
LAZYADD(right_back_passengers_overlays, draw_passenger_right_back)
//
if(update_overlays && LAZYLEN(back_passengers_overlays))
overlays += back_passengers_overlays
if(update_overlays && LAZYLEN(left_back_passengers_overlays))
overlays += left_back_passengers_overlays
if(update_overlays && LAZYLEN(right_back_passengers_overlays))
overlays += right_back_passengers_overlays

/mob/living/exosuit/regenerate_icons()
return
Loading

0 comments on commit 4a6f517

Please sign in to comment.