Skip to content

Commit

Permalink
Merge pull request Civ13#2835 from Bierkraan/working-branch
Browse files Browse the repository at this point in the history
Controlable drones
  • Loading branch information
Bierkraan authored May 15, 2024
2 parents ac5d3ec + 6de4d10 commit c1f92f6
Show file tree
Hide file tree
Showing 19 changed files with 1,021 additions and 983 deletions.
1 change: 1 addition & 0 deletions civ13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@
#include "code\game\objects\items\clothing\under\accessories\sheaths.dm"
#include "code\game\objects\items\clothing\under\accessories\stethoscope.dm"
#include "code\game\objects\items\clothing\under\accessories\storage.dm"
#include "code\game\objects\items\devices\drone.dm"
#include "code\game\objects\items\devices\flashlight.dm"
#include "code\game\objects\items\devices\shamisen.dm"
#include "code\game\objects\items\devices\trombone.dm"
Expand Down
4 changes: 3 additions & 1 deletion code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@
M.Translate(1,-6)
transform = M
else
face_atom(A) // change direction to face what you clicked on
if (!using_drone)
face_atom(A) // change direction to face what you clicked on

if (!canClick()) // in the year 2000...
return

Expand Down
2 changes: 2 additions & 0 deletions code/game/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
var/mob/living/human/H = src
if (H.using_look())
look_into_distance(src, FALSE)
if (using_drone)
unset_using_drone()
return

/mob/living/human/proc/activate_hand(var/selhand) //0 or "r" or "right" for right hand; TRUE or "l" or "left" for left hand.
Expand Down
2 changes: 1 addition & 1 deletion code/game/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ var/list/coefflist = list()

/mob/living/human/proc/can_look(mob/living/user)//Largely copied from zoom.dm
var/mob/living/human/H = user

if (H.using_drone) return FALSE
if(user.stat || !ishuman(user))
to_chat(user, SPAN_WARNING("You are unable to look into the distance right now."))
return FALSE
Expand Down
2 changes: 2 additions & 0 deletions code/game/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ default behaviour is:
/mob/living/Move(a, b, flag)
if (buckled)
return
if (using_drone)
return

if (restrained())
stop_pulling()
Expand Down
1 change: 1 addition & 0 deletions code/game/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@
else if (cannot_stand())
lying = TRUE
canmove = FALSE
facing_dir = null
else if (stunned)
canmove = FALSE
else if (captured)
Expand Down
3 changes: 0 additions & 3 deletions code/game/mob/mob_damage.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

/mob/proc/Stun(amount)
if (status_flags & CANSTUN)
facing_dir = null
stunned = max(max(stunned,amount),0) //can't go below 0, getting a low amount of stun doesn't lower your current stun
return

Expand All @@ -17,7 +16,6 @@

/mob/proc/Weaken(amount)
if (status_flags & CANWEAKEN)
facing_dir = null
weakened = max(max(weakened,amount),0)
update_canmove() //updates lying, canmove and icons
return
Expand All @@ -36,7 +34,6 @@

/mob/proc/Paralyse(amount)
if (status_flags & CANPARALYSE)
facing_dir = null
paralysis = max(max(paralysis,amount),0)
return

Expand Down
1 change: 1 addition & 0 deletions code/game/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
var/use_me = TRUE //Allows all mobs to use the me verb by default, will have to manually specify they cannot
var/damageoverlaytemp = FALSE
var/atom/movable/using_object = null
var/obj/item/drone_controller/using_drone = null
var/poll_answer = 0.0
var/sdisabilities = FALSE //Carbon
var/disabilities = FALSE //Carbon
Expand Down
26 changes: 25 additions & 1 deletion code/game/mob/mob_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,9 @@
MW.control.axis.reverse = FALSE
for(var/obj/item/turret_controls/C in H)
C.increase_distance(1)
for(var/obj/item/drone_controller/RC in H)
if(H.using_drone)
RC.start_move_drone(NORTH)
if (H.driver && H.driver_vehicle)
H.dir = NORTH
H.driver_vehicle.dir = NORTH
Expand Down Expand Up @@ -998,6 +1001,9 @@
MW.control.axis.reverse = TRUE
for(var/obj/item/turret_controls/C in H)
C.increase_distance(-1)
for(var/obj/item/drone_controller/RC in H)
if(H.using_drone)
RC.start_move_drone(SOUTH)
if (H.driver && H.driver_vehicle)
H.dir = SOUTH
H.driver_vehicle.dir = SOUTH
Expand Down Expand Up @@ -1034,6 +1040,9 @@
MW.turndir(mob,"right")
for(var/obj/item/turret_controls/C in H)
C.start_rotation(1)
for(var/obj/item/drone_controller/RC in H)
if(H.using_drone)
RC.start_move_drone(EAST)
if (H.driver && H.driver_vehicle)
H.dir = EAST
H.driver_vehicle.dir = EAST
Expand Down Expand Up @@ -1070,6 +1079,9 @@
MW.turndir(mob,"left")
for(var/obj/item/turret_controls/C in H)
C.start_rotation(-1)
for(var/obj/item/drone_controller/RC in H)
if(H.using_drone)
RC.start_move_drone(WEST)
if (H.driver && H.driver_vehicle)
H.dir = WEST
H.driver_vehicle.dir = WEST
Expand All @@ -1094,12 +1106,18 @@
set instant = TRUE
if (mob && mob.movement_northsouth == NORTH)
mob.movement_northsouth = null
for(var/obj/item/drone_controller/RC in mob)
if(mob.using_drone)
RC.stop_move_drone()

/client/verb/stopmovingdown()
set name = ".stopmovingdown"
set instant = TRUE
if (mob && mob.movement_northsouth == SOUTH)
mob.movement_northsouth = null
for(var/obj/item/drone_controller/RC in mob)
if(mob.using_drone)
RC.stop_move_drone()

/client/verb/stopmovingright()
set name = ".stopmovingright"
Expand All @@ -1108,11 +1126,17 @@
mob.movement_eastwest = null
for(var/obj/item/turret_controls/C in mob)
C.stop_rotation()
for(var/obj/item/drone_controller/RC in mob)
if(mob.using_drone)
RC.stop_move_drone()

/client/verb/stopmovingleft()
set name = ".stopmovingleft"
set instant = TRUE
if (mob && mob.movement_eastwest == WEST)
mob.movement_eastwest = null
for(var/obj/item/turret_controls/C in mob)
C.stop_rotation()
C.stop_rotation()
for(var/obj/item/drone_controller/RC in mob)
if(mob.using_drone)
RC.stop_move_drone()
175 changes: 175 additions & 0 deletions code/game/objects/items/devices/drone.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/obj/item/drone_controller
name = "drone controller"
desc = "A controller for moving a drone."
icon = 'icons/obj/device.dmi'
icon_state = "rc_control"
secondary_action = TRUE
var/obj/item/drone/connected_drone = null
var/is_moving = FALSE
var/executing_move = FALSE
var/moving_dir = NORTH

/obj/item/drone_controller/attack_self(var/mob/living/human/H)
if(ishuman(H))
toggle(H)

/obj/item/drone_controller/secondary_attack_self(var/mob/living/human/H)
if(secondary_action && connected_drone && connected_drone.has_special)
to_chat(H, SPAN_DANGER("You press the detonate button."))
connected_drone.do_special(H)

/obj/item/drone_controller/proc/toggle(var/mob/living/human/H)
if(connected_drone)
to_chat(H, SPAN_NOTICE("You [H.using_drone ? "deactivate" : "activate"] \the [src]."))
if(H.using_drone)
H.unset_using_drone(src)
else
H.set_using_drone(src)
return
else
to_chat(H, SPAN_WARNING("There is no drone connected to \the [src]."))
return

/obj/item/drone_controller/proc/cut_connection(var/mob/living/human/H)
if(H.using_drone)
connected_drone = null
H.unset_using_drone(src)
to_chat(H, SPAN_NOTICE("The connection to \the [connected_drone] has been lost."))
return

/obj/item/drone_controller/dropped(var/mob/living/human/H)
H.unset_using_drone(src)
..()

/obj/item/drone_controller/proc/stop_move_drone()
is_moving = FALSE

/obj/item/drone_controller/proc/start_move_drone(var/direction)
moving_dir = direction
if(!is_moving)
is_moving = TRUE
move_drone()

/obj/item/drone_controller/proc/move_drone()
if(!is_moving)
return
if(executing_move)
return
executing_move = TRUE
connected_drone.Move(get_step(connected_drone, moving_dir))
connected_drone.dir = moving_dir

spawn(connected_drone.movement_delay)
executing_move = FALSE
move_drone()

/obj/item/drone
name = "drone"
desc = "A movable drone."
icon = 'icons/obj/vehicles/vehicleparts.dmi'
icon_state = "goliath"
var/obj/item/drone_controller/connected_controller = null
var/movement_delay = 5
var/movement_sound = 'sound/machines/rc_car.ogg'
var/has_special = FALSE

heavy_armor_penetration = 0
var/devastation_range = 2
var/heavy_impact_range = 3
var/light_impact_range = 5
var/flash_range = 6

/obj/item/drone/attackby(obj/item/I as obj, mob/user)
if(istype(I, /obj/item/drone_controller))
var/obj/item/drone_controller/RC = I
if (!connected_controller && !RC.connected_drone)
connected_controller = RC
connected_controller.connected_drone = src
to_chat(user, SPAN_NOTICE("You pair \the [src] to \the [connected_controller]."))
return
else
to_chat(user, SPAN_WARNING("\The [src] is already paired with a controller."))
return
else
..()

/obj/item/drone/proc/do_special(var/mob/living/human/H)
connected_controller.cut_connection(H)
var/turf/T = get_turf(src)
qdel(src)
explosion(T, devastation_range, heavy_impact_range, light_impact_range, flash_range)
for(var/obj/structure/vehicleparts/frame/F in range(1,src))
for (var/mob/M in F.axis.transporting)
shake_camera(M, 3, 3)
var/penloc = F.CheckPenLoc(T)
switch(penloc)
if ("left")
if (F.w_left[5] > 0)
F.w_left[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The left hull gets damaged!</big></span>"))
if ("right")
if (F.w_right[5] > 0)
F.w_right[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The right hull gets damaged!</big></span>"))
if ("front")
if (F.w_front[5] > 0)
F.w_front[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The front hull gets damaged!</big></span>"))
if ("back")
if (F.w_back[5] > 0)
F.w_back[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The rear hull gets damaged!</big></span>"))
if ("frontleft")
if (F.w_left[5] > 0 && F.w_front[5] > 0)
if (F.w_left[4] > F.w_front[4] && F.w_left[5]>0)
F.w_left[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The left hull gets damaged!</big></span>"))
else
F.w_front[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The front hull gets damaged!</big></span>"))
if ("frontright")
if (F.w_right[5] > 0 && F.w_front[5] > 0)
if (F.w_right[4] > F.w_front[4] && F.w_right[5]>0)
F.w_right[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The right hull gets damaged!</big></span>"))
else
F.w_front[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The front hull gets damaged!</big></span>"))
if ("backleft")
if (F.w_left[5] > 0 && F.w_back[5] > 0)
if (F.w_left[4] > F.w_back[4] && F.w_left[5]>0)
F.w_left[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The left hull gets damaged!</big></span>"))
else
F.w_back[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The rear hull gets damaged!</big></span>"))
if ("backright")
if (F.w_right[5] > 0 && F.w_back[5] > 0)
if (F.w_right[4] > F.w_back[4] && F.w_right[5]>0)
F.w_right[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The right hull gets damaged!</big></span>"))
else
F.w_back[5] -= heavy_armor_penetration
visible_message(SPAN_DANGER("<big>The rear hull gets damaged!</big></span>"))
F.try_destroy()
for(var/obj/structure/vehicleparts/movement/MV in F)
MV.broken = TRUE
MV.update_icon()
F.update_icon()
return

/obj/item/drone/Move()
..()
playsound(loc, movement_sound, 100, TRUE)

/obj/item/drone/goliath
name = "Goliath SdKfz. 302"
desc = "The SdKfz. 302, also known as the Goliath, is a remote-controlled tracked mine carrying either 60 or 100 kg of high explosives. It is used for destroying tanks, disrupting dense infantry formations, and the demolition of buildings or bridges."
movement_delay = 4
has_special = TRUE
heavy_armor_penetration = 40
devastation_range = 2
heavy_impact_range = 3
light_impact_range = 5
flash_range = 6

Loading

0 comments on commit c1f92f6

Please sign in to comment.