Skip to content

Commit

Permalink
Толстая пачка фиксов мехам
Browse files Browse the repository at this point in the history
  • Loading branch information
AmShegars committed Feb 16, 2024
1 parent bb79f34 commit d34a70e
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 25 deletions.
1 change: 1 addition & 0 deletions code/modules/mechs/components/body.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@

air_supply = new /obj/machinery/portable_atmospherics/canister/air/mech(src)
storage_compartment = new(src)
owner = loc

/obj/item/mech_component/chassis/proc/update_air(var/take_from_supply)

Expand Down
41 changes: 31 additions & 10 deletions code/modules/mechs/mech_icon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
for(var/hardpoint in hardpoints)
var/obj/item/mech_equipment/hardpoint_object = hardpoints[hardpoint]
if(hardpoint_object)
//
if(hardpoint == "left hand")
if(dir == WEST || dir == SOUTHWEST || dir == NORTHWEST)
hardpoint_object.mech_layer = MECH_GEAR_LAYER
else if(dir == EAST || dir == SOUTHEAST || dir == NORTHEAST)
hardpoint_object.mech_layer = MECH_BACK_LAYER
if(hardpoint == "right hand")
if(dir == WEST || dir == SOUTHWEST || dir == NORTHWEST)
hardpoint_object.mech_layer = MECH_BACK_LAYER
else if(dir == EAST || dir == SOUTHEAST || dir == NORTHEAST)
hardpoint_object.mech_layer = MECH_GEAR_LAYER
//
var/use_icon_state = "[hardpoint_object.icon_state]_[hardpoint]"
if(power == MECH_POWER_ON)
if(use_icon_state in GLOB.mech_weapon_overlays)
Expand All @@ -59,20 +71,25 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
overlays = new_overlays

/mob/living/exosuit/proc/update_pilots(var/update_overlays = TRUE)
var/local_dir = dir
if(update_overlays && LAZYLEN(pilot_overlays))
overlays -= pilot_overlays
pilot_overlays = null
if(local_dir == NORTHEAST || local_dir == SOUTHEAST)
local_dir = EAST
else if(local_dir == NORTHWEST || local_dir == SOUTHWEST)
local_dir = WEST
if(!body || ((body.pilot_coverage < 100 || body.transparent_cabin) && !body.hide_pilot))
for(var/i = 1 to LAZYLEN(pilots))
var/mob/pilot = pilots[i]
var/image/draw_pilot = new
draw_pilot.appearance = pilot
var/rel_pos = dir == NORTH ? -1 : 1
var/rel_pos = local_dir == NORTH ? -1 : 1
draw_pilot.layer = MECH_PILOT_LAYER + (body ? ((LAZYLEN(body.pilot_positions)-i)*0.001 * rel_pos) : 0)
draw_pilot.plane = FLOAT_PLANE
if(body && i <= LAZYLEN(body.pilot_positions))
var/list/offset_values = body.pilot_positions[i]
var/list/directional_offset_values = offset_values["[dir]"]
var/list/directional_offset_values = offset_values["[local_dir]"]
draw_pilot.pixel_x = pilot.default_pixel_x + directional_offset_values["x"]
draw_pilot.pixel_y = pilot.default_pixel_y + directional_offset_values["y"]
draw_pilot.pixel_z = 0
Expand All @@ -82,6 +99,7 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
overlays += pilot_overlays

/mob/living/exosuit/proc/update_passengers(var/update_overlays = TRUE)
var/local_dir = dir // <- Для того чтоб не руинить направление передвижения меха, мы применим эту переменную
if(update_overlays && LAZYLEN(back_passengers_overlays))
overlays -= back_passengers_overlays
if(update_overlays && LAZYLEN(left_back_passengers_overlays))
Expand All @@ -94,20 +112,23 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
var/passenger_back_layer
var/passenger_left_back_layer
var/passenger_right_back_layer
//
if(dir == EAST)
// Дабы исключить момент когда при боковом движении пассажиров не видно, помимо обычных направлений, будут прописаны следующие:

if(local_dir == EAST || local_dir == NORTHEAST || local_dir == SOUTHEAST)
local_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)
else if(local_dir == WEST || local_dir == NORTHWEST || local_dir == SOUTHWEST)
local_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)
else if(local_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)
else if(local_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
Expand All @@ -118,7 +139,7 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
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]"]
var/list/back_directional_offset_values = back_offset_values["[local_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
Expand All @@ -132,7 +153,7 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
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]"]
var/list/left_directional_offset_values = left_offset_values["[local_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
Expand All @@ -147,7 +168,7 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
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]"]
var/list/right_directional_offset_values = right_offset_values["[local_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
Expand Down
26 changes: 13 additions & 13 deletions code/modules/mechs/mech_interaction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,10 @@

/mob/living/exosuit/proc/enter_passenger(var/mob/user,var/place)// Пытается пихнуть на пассажирское место пассажира, перед этим ещё раз проверяя их
//Проверка спины
src.visible_message(SPAN_NOTICE(" [user] Starts climb on the [place] of mech!"))
src.visible_message(SPAN_NOTICE(" [user] starts climb on the [place] of [src]!"))
if(do_after(user, 2 SECONDS, get_turf(src),DO_SHOW_PROGRESS|DO_FAIL_FEEDBACK|DO_USER_CAN_TURN| DO_USER_UNIQUE_ACT | DO_PUBLIC_PROGRESS))
if(user.r_hand != null || user.l_hand != null)
to_chat(user,SPAN_NOTICE("You need two free hands to clim on[place] of mech."))
to_chat(user,SPAN_NOTICE("You need two free hands to clim on[place] of [src]."))
return
if(place == "Back" && LAZYLEN(passenger_compartment.back_passengers) == 0)
user.forceMove(passenger_compartment)
Expand All @@ -404,13 +404,13 @@
else
to_chat(user,SPAN_NOTICE("Looks like [place] is busy!"))
return 0
src.visible_message(SPAN_NOTICE(" [user] climbed on [place] of mech!"))
src.visible_message(SPAN_NOTICE(" [user] climbed on [place] of [src]!"))
passengers_ammount += 1
update_passengers()

// будет использоваться Life() дабы исключить моменты, когда по какой-то причине пассажир слез с меха, лежа на полу. Life вызовется, обработается pinned, всем в кайф.
/mob/living/exosuit/proc/leave_passenger(var/mob/user)// Пассажир сам покидает меха
src.visible_message(SPAN_NOTICE("[user] jump off from mech!"))
src.visible_message(SPAN_NOTICE("[user] jump off [src]!"))
user.dropInto(loc)
user.pinned -= src
user.Life()
Expand All @@ -433,23 +433,23 @@
i.pinned -= src
i.Life()
passengers_ammount -= 1
src.visible_message(SPAN_WARNING("[i] was forcelly removed from mech by [author]"))
src.visible_message(SPAN_WARNING("[i] was forcelly removed from [src] by [author]"))
if(LAZYLEN(passenger_compartment.left_back_passengers)>0)
for(var/mob/i in passenger_compartment.left_back_passengers)
LAZYREMOVE(passenger_compartment.left_back_passengers,i)
i.dropInto(loc)
i.pinned -= src
i.Life()
passengers_ammount -= 1
src.visible_message(SPAN_WARNING("[i] was forcelly removed from mech by [author]"))
src.visible_message(SPAN_WARNING("[i] was forcelly removed from [src] by [author]"))
if(LAZYLEN(passenger_compartment.right_back_passengers) > 0)
for(var/mob/i in passenger_compartment.right_back_passengers)
LAZYREMOVE(passenger_compartment.right_back_passengers,i)
i.dropInto(loc)
i.pinned -= src
i.Life()
passengers_ammount -= 1
src.visible_message(SPAN_WARNING("[i] was forcelly removed from mech by [author]"))
src.visible_message(SPAN_WARNING("[i] was forcelly removed from [src] by [author]"))
update_passengers()

else if(mode == MECH_DROP_ANY_PASSENGER) // Сброс по приоритету спина - левый бок - правый бок.
Expand All @@ -459,7 +459,7 @@
i.dropInto(loc)
i.pinned -= src
i.Life()
src.visible_message(SPAN_WARNING("[i] was forcelly removed from mech by [author]"))
src.visible_message(SPAN_WARNING("[i] was forcelly removed from [src] by [author]"))
passengers_ammount -= 1
update_passengers()
return
Expand All @@ -469,7 +469,7 @@
i.dropInto(loc)
i.pinned -= src
i.Life()
src.visible_message(SPAN_WARNING("[i] was forcelly removed from mech by [author]"))
src.visible_message(SPAN_WARNING("[i] was forcelly removed from [src] by [author]"))
passengers_ammount -= 1
update_passengers()
return
Expand All @@ -480,27 +480,27 @@
i.pinned -= src
i.Life()
i.Life()
src.visible_message(SPAN_WARNING("[i] was forcelly removed from mech by [author]"))
src.visible_message(SPAN_WARNING("[i] was forcelly removed from [src] by [author]"))
passengers_ammount -= 1
update_passengers()
return

else // <- Опустошается определённое место
if(place == "Back")
for(var/mob/i in passenger_compartment.back_passengers)
src.visible_message(SPAN_WARNING("[i] was forcelly removed from mech by [author]"))
src.visible_message(SPAN_WARNING("[i] was forcelly removed from [src] by [author]"))
i.dropInto(loc)
i.pinned -= src
LAZYREMOVE(passenger_compartment.back_passengers,i)
else if(place == "Left back")
for(var/mob/i in passenger_compartment.left_back_passengers)
src.visible_message(SPAN_WARNING("[i] was forcelly removed from mech by [author]!"))
src.visible_message(SPAN_WARNING("[i] was forcelly removed from [src] by [author]!"))
i.dropInto(loc)
i.pinned -= src
LAZYREMOVE(passenger_compartment.left_back_passengers,i)
else if(place == "Right back")
for(var/mob/i in passenger_compartment.right_back_passengers)
src.visible_message(SPAN_WARNING("[i] was forcelly removed from mech by [author]!"))
src.visible_message(SPAN_WARNING("[i] was forcelly removed from [src] by [author]!"))
i.dropInto(loc)
i.pinned -= src
LAZYREMOVE(passenger_compartment.right_back_passengers,i)
Expand Down
7 changes: 6 additions & 1 deletion code/modules/mechs/mech_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,14 @@
if(exosuit.dir != moving_dir && !(direction & (UP|DOWN)))
playsound(exosuit.loc, exosuit.mech_turn_sound, 40,1)
exosuit.set_dir(moving_dir)
if(exosuit.passengers_ammount>0)
if(exosuit.passengers_ammount > 0)
exosuit.update_passengers()
for(var/hardpoint in exosuit.hardpoints)
if(hardpoint == "left hand" || hardpoint == "right hand")
exosuit.update_icon()
exosuit.SetMoveCooldown(exosuit.legs.turn_delay)
//Данная формула нужна чтобы УБЕДИТЬСЯ в расчётах количества пассажиров, ибо по не очевидным причинам, оно может не расчитать верно
exosuit.passengers_ammount = LAZYLEN(exosuit.passenger_compartment.back_passengers) + LAZYLEN(exosuit.passenger_compartment.left_back_passengers) + LAZYLEN(exosuit.passenger_compartment.right_back_passengers)
//TURN

//MOVE
Expand Down
1 change: 1 addition & 0 deletions code/modules/mechs/premade/powerloader.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
max_damage = 180
power_use = 0
climb_time = 6
allow_passengers = FALSE

/obj/item/mech_component/chassis/powerloader/prebuild()
. = ..()
Expand Down
Binary file modified icons/mecha/mech_weapon_overlays.dmi
Binary file not shown.
Binary file modified icons/mecha/mech_weapon_overlays_off.dmi
Binary file not shown.
2 changes: 1 addition & 1 deletion infinity/code/modules/mechs/guns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
/obj/item/mech_equipment/mounted_system/taser/laser/Ert //Mech laser canon (Danger shit)
name = "\improper CH-PS \"Anigilator\" laser"
desc = "An exosuit-mounted laser rifle. Handle with care."
icon_state = "mech_lasercarbine"
icon_state = "mech_lasercanon"
holding_type = /obj/item/gun/energy/lasercannon/mounted

/obj/item/gun/energy/lasercannon/mounted
Expand Down

0 comments on commit d34a70e

Please sign in to comment.