Skip to content

Commit

Permalink
Feat: add exosuit strafe ability (#691)
Browse files Browse the repository at this point in the history
1.У мехов теперь есть новая механика передвижения - Стрейф, суть
заключается в блокировании стороны передвижения (Ходьба спиной или
боком)
Данная механика замедляет меха в 2 раза, даёт возможность двигаться без
разворота и стрелять в направлении взгляда. (Условно, можно отсупать
задом, выступать из укрытия боком). Это фича лишь для паучьих лап, ибо
УВЫ, мир не готов к стрейфам для всех лап.
2. Теперь внешние спрайты модулей меняются, в зависимости от состояния
POWER меха.
  • Loading branch information
AmShegars authored Jan 29, 2024
1 parent 38084cc commit a54e175
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 8 deletions.
4 changes: 3 additions & 1 deletion code/modules/mechs/components/legs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
var/obj/item/robot_parts/robot_component/actuator/motivator
power_use = 50
var/max_fall_damage = 30
var/can_strafe = FALSE
var/good_in_strafe = FALSE //Влияет на эффективность стрейфа, используйте когда мир будет к нему готов.

/obj/item/mech_component/propulsion/Destroy()
QDEL_NULL(motivator)
Expand Down Expand Up @@ -60,4 +62,4 @@
if(max_fall_damage > 0)
var/mob/living/exosuit/E = loc
if(istype(E)) //route it through exosuit for proper handling
E.apply_damage(rand(0, max_fall_damage), BRUTE, BP_R_LEG) //Any leg is good, will damage us correctly
E.apply_damage(rand(0, max_fall_damage), BRUTE, BP_R_LEG) //Any leg is good, will damage us correctly
4 changes: 3 additions & 1 deletion code/modules/mechs/mech.dm
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,13 @@
if(.)
update_pilots()

/mob/living/exosuit/proc/toggle_power(var/mob/user)
/mob/living/exosuit/proc/toggle_power(var/mob/user) //Отвечает за энергообеспечение меха, обновляет спрайты меха и его модулей при изменении питания
if(power == MECH_POWER_TRANSITION)
to_chat(user, SPAN_NOTICE("Power transition in progress. Please wait."))
else if(power == MECH_POWER_ON) //Turning it off is instant
playsound(src, 'sound/mecha/mech-shutdown.ogg', 100, 0)
power = MECH_POWER_OFF
update_icon()
else if(get_cell(TRUE))
//Start power up sequence
power = MECH_POWER_TRANSITION
Expand All @@ -230,6 +231,7 @@
else
to_chat(user, SPAN_WARNING("You abort the powerup sequence."))
power = MECH_POWER_OFF
update_icon()
hud_power_control?.queue_icon_update()
else
to_chat(user, SPAN_WARNING("Error: No power cell was detected."))
9 changes: 6 additions & 3 deletions code/modules/mechs/mech_icon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
var/obj/item/mech_equipment/hardpoint_object = hardpoints[hardpoint]
if(hardpoint_object)
var/use_icon_state = "[hardpoint_object.icon_state]_[hardpoint]"
if(use_icon_state in GLOB.mech_weapon_overlays)
new_overlays += get_mech_image(null, use_icon_state, 'icons/mecha/mech_weapon_overlays.dmi', null, hardpoint_object.mech_layer )
if(power == MECH_POWER_ON)
if(use_icon_state in GLOB.mech_weapon_overlays)
new_overlays += get_mech_image(null, use_icon_state, 'icons/mecha/mech_weapon_overlays.dmi', null, hardpoint_object.mech_layer )
else
new_overlays += get_mech_image(null, use_icon_state, 'icons/mecha/mech_weapon_overlays_off.dmi', null, hardpoint_object.mech_layer )
overlays = new_overlays

/mob/living/exosuit/proc/update_pilots(var/update_overlays = TRUE)
Expand All @@ -76,4 +79,4 @@ proc/get_mech_images(var/list/components = list(), var/overlay_layer = FLOAT_LAY
overlays += pilot_overlays

/mob/living/exosuit/regenerate_icons()
return
return
33 changes: 30 additions & 3 deletions code/modules/mechs/mech_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
playsound(src.loc, mech_step_sound, 40, 1)

/mob/living/exosuit/can_ztravel()
if(Allow_Spacemove()) //Handle here
if(Allow_Spacemove()) //Handle here
return TRUE

/mob/living/exosuit/Allow_Spacemove(check_drift)
Expand Down Expand Up @@ -43,7 +43,7 @@

/mob/living/exosuit/can_float()
return FALSE //Nope

/datum/movement_handler/mob/delay/exosuit
expected_host_type = /mob/living/exosuit

Expand Down Expand Up @@ -115,16 +115,43 @@
var/txt_dir = direction & UP ? "upwards" : "downwards"
exosuit.visible_message(SPAN_NOTICE("\The [exosuit] moves [txt_dir]."))

//STRAFE
if(exosuit.legs.can_strafe)
for(var/thing in exosuit.pilots) //Для всех пилотов внутри
var/mob/pilot = thing
if(pilot && pilot.client)
for(var/key in pilot.client.keys_held)
if (key == "Space")
var/move_speed = exosuit.legs.move_delay
if(!exosuit.legs.good_in_strafe)
move_speed = move_speed * 2.5
if(direction == NORTHWEST || direction == NORTHEAST || direction == SOUTHWEST || direction == SOUTHEAST)
move_speed = sqrt((move_speed*move_speed) + (move_speed * move_speed))
if(move_speed > 12)
move_speed = 12
exosuit.SetMoveCooldown(exosuit.legs ? move_speed : 3)
var/turf/target_loc = get_step(exosuit, direction)
if(target_loc && exosuit.legs && exosuit.legs.can_move_on(exosuit.loc, target_loc) && exosuit.MayEnterTurf(target_loc))
exosuit.Move(target_loc)
return MOVEMENT_HANDLED
//STRAFE

//TURN
if(exosuit.dir != moving_dir && !(direction & (UP|DOWN)))
playsound(exosuit.loc, exosuit.mech_turn_sound, 40,1)
exosuit.set_dir(moving_dir)
exosuit.SetMoveCooldown(exosuit.legs.turn_delay)
//TURN

//MOVE
else
exosuit.SetMoveCooldown(exosuit.legs ? exosuit.legs.move_delay : 3)
var/turf/target_loc = get_step(exosuit, direction)
if(target_loc && exosuit.legs && exosuit.legs.can_move_on(exosuit.loc, target_loc) && exosuit.MayEnterTurf(target_loc))
exosuit.Move(target_loc)
return MOVEMENT_HANDLED
//MOVE

/datum/movement_handler/mob/space/exosuit
expected_host_type = /mob/living/exosuit

Expand All @@ -140,7 +167,7 @@
return MOVEMENT_HANDLED
else
mob.inertia_dir = 0 //If not then we can reset inertia and move
else
else
mob.anchored = TRUE
mob.inertia_dir = 0 //Reset inertia values as we are not going to be treated as floating

Expand Down
1 change: 1 addition & 0 deletions code/modules/mechs/premade/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
move_delay = 4
turn_delay = 1
power_use = 25
can_strafe = TRUE

/obj/item/mech_component/propulsion/tracks
name = "tracks"
Expand Down
Binary file modified icons/mecha/mech_parts_held.dmi
Binary file not shown.
Binary file added icons/mecha/mech_parts_off.dmi
Binary file not shown.
Binary file added icons/mecha/mech_weapon_overlays_off.dmi
Binary file not shown.

0 comments on commit a54e175

Please sign in to comment.