Skip to content

Commit

Permalink
CPR Buddy 9000 (#7092)
Browse files Browse the repository at this point in the history
# About the pull request

Adds a brand new bot type called the CPR bot, which is able to target
and locate downed marines and perform CPR automatically.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

I have tested this CPR bot many times; it showed no problems or bugs
that are known to me at least.
it functions as it should.

# Explain why it's good for the game

I think this would be a huge change to how synthetics operate on the
ground of operations.
It actually replaces a piece of equipment that was left out to collect
dust for many years.
while the cpr bot is only a little bit better by a few seconds.
It is designed to make using the autocomprossor more fun and an
enjoyable experience for synthetic players.
I think it will encourage synthetics to really think about what to pick
for their experimental equipment, which is normally a good thing!

Code was inspected and edited by Sindorman

# Testing Photographs and Procedure
I have tested the logic of the CPRbot many times, from it's pathfinding
to it's CPR actions performed.
It performs CPR every 7 seconds and only restors 4 seconds to the downed
person's CPR timer, which is done this way for balance reasons so it
doesn't outperform the auto compressor as it doesn't have a battery like
the auto compressor, but when tested, it performed the same with a few
extra seconds gained but performed the same none the less.
It's pathfinding isn't the best as it's made with the Astar logic, which
all other bots use ingame, but it's decent enough to do the job!
If a bot can't find a valid path, it stops marking that patient as a
valid patient and stops looking for it to save on memory power.
cprbot also uses an IFF check to make sure it only assists people of
it's faction from the USCM and no one else, much like the motion
detector functions "same logic."
It also checks if the person is human, which is a strict requirement,
and also checks if there is another cprbot nearby by at least 2 tiles;
otherwise, the cprbot will go in and assist if all checks are clear.

<details>


https://github.com/user-attachments/assets/c65709d7-a043-4a29-a6f4-9e5e94ae4172

</details>


# Changelog

:cl:
add: Added CPR Buddy 9000 to the experimental vendor.
/:cl:

---------

Co-authored-by: kiVts <[email protected]>
  • Loading branch information
HIDgamer and kiVts authored Dec 27, 2024
1 parent 1069779 commit d2d90e3
Show file tree
Hide file tree
Showing 8 changed files with 599 additions and 0 deletions.
485 changes: 485 additions & 0 deletions code/game/machinery/bots/cprbot.dm

Large diffs are not rendered by default.

112 changes: 112 additions & 0 deletions code/game/objects/items/cprbot_item.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/obj/item/cprbot_item
name = "CPRbot"
desc = "A compact CPRbot 9000 assembly"
icon = 'icons/obj/structures/machinery/aibots.dmi'
icon_state = "cprbot"
w_class = SIZE_MEDIUM
var/deployment_path = /obj/structure/machinery/bot/cprbot

/obj/item/cprbot_item/attack_self(mob/user as mob)
if (..())
return TRUE

if(user)
deploy_cprbot(user, user.loc)

/obj/item/cprbot_item/proc/deploy_cprbot(mob/user, atom/location)
if(!user || !location)
return

if (istype(user) && !skillcheck(user, SKILL_MEDICAL, SKILL_MEDICAL_MEDIC))
to_chat(user, SPAN_WARNING("You don't seem to know how to use [src]..."))
return

qdel(src)

// Proceed with the CPRbot deployment
var/obj/structure/machinery/bot/cprbot/cprbot_entity = new deployment_path(location)
if(cprbot_entity)
cprbot_entity.add_fingerprint(user)
cprbot_entity.owner = user

/obj/item/cprbot_item/afterattack(atom/target, mob/user, proximity)
if(proximity && isturf(target))
var/turf/target_turf = target
if(!target_turf.density)
deploy_cprbot(user, target_turf)

/obj/item/cprbot_broken
name = "CPRbot"
desc = "A compact CPRbot 9000 assembly, it appears to be in bad shape"
icon = 'icons/obj/structures/machinery/aibots.dmi'
icon_state = "cprbot_broken"
w_class = SIZE_MEDIUM

/obj/item/cprbot_broken/attackby(obj/item/attacked_by, mob/living/user)
if(iswelder(attacked_by))
if(!HAS_TRAIT(attacked_by, TRAIT_TOOL_BLOWTORCH))
to_chat(user, SPAN_WARNING("You need a stronger blowtorch!"))
return

var/obj/item/tool/weldingtool/welder_tool = attacked_by
if(!welder_tool.isOn())
to_chat(user, SPAN_WARNING("The [welder_tool] needs to be on!"))
return

if(!welder_tool.remove_fuel(5, user)) // Ensure the welder has enough fuel to operate
to_chat(user, SPAN_NOTICE("You need more welding fuel to complete this task."))
return

playsound(src, 'sound/items/Welder.ogg', 25, 1)

if(!do_after(user, 10 * user.get_skill_duration_multiplier(SKILL_CONSTRUCTION), INTERRUPT_ALL | BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD))
return

var/obj/item/cprbot_item/new_cprbot_item = new /obj/item/cprbot_item(loc)

if(user)
if(!user.put_in_active_hand(new_cprbot_item))
if(!user.put_in_inactive_hand(new_cprbot_item))
new_cprbot_item.forceMove(loc)
else
new_cprbot_item.forceMove(loc)

/obj/item/cprbot_broken/attackby(obj/item/attacked_by, mob/living/user)
if(iswelder(attacked_by))
if(!HAS_TRAIT(attacked_by, TRAIT_TOOL_BLOWTORCH))
to_chat(user, SPAN_WARNING("You need a stronger blowtorch!"))
return

var/obj/item/tool/weldingtool/welder_tool = attacked_by
if(!welder_tool.isOn())
to_chat(user, SPAN_WARNING("The [welder_tool] needs to be on!"))
return

if(!welder_tool.remove_fuel(5, user)) // Ensure enough fuel is available
to_chat(user, SPAN_NOTICE("You need more welding fuel to complete this task."))
return

playsound(src, 'sound/items/Welder.ogg', 25, 1)

if(!do_after(user, 10 * user.get_skill_duration_multiplier(SKILL_CONSTRUCTION), INTERRUPT_ALL | BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD))
return

// Create the repaired item
var/obj/item/cprbot_item/repaired_cprbot_item = new /obj/item/cprbot_item(loc)

// Check if the broken item is in the user's hand
var/hand_was_active = user.get_active_hand() == src
var/hand_was_inactive = user.get_inactive_hand() == src

// Remove the broken item
qdel(src)

// Attempt to place the new item into the user's hands
if (hand_was_active)
if (!user.put_in_active_hand(repaired_cprbot_item))
repaired_cprbot_item.forceMove(user.loc) // Place it at user's location if hands are full
else if (hand_was_inactive)
if (!user.put_in_inactive_hand(repaired_cprbot_item))
repaired_cprbot_item.forceMove(user.loc) // Place it at user's location if hands are full
else
repaired_cprbot_item.forceMove(user.loc) // Place at the original location if not in hand
2 changes: 2 additions & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@
#include "code\game\machinery\atmoalter\scrubber.dm"
#include "code\game\machinery\bots\bots.dm"
#include "code\game\machinery\bots\cleanbot.dm"
#include "code\game\machinery\bots\cprbot.dm"
#include "code\game\machinery\bots\floorbot.dm"
#include "code\game\machinery\bots\medbot.dm"
#include "code\game\machinery\bots\mulebot.dm"
Expand Down Expand Up @@ -1124,6 +1125,7 @@
#include "code\game\objects\items\contraband.dm"
#include "code\game\objects\items\cosmetics.dm"
#include "code\game\objects\items\cpr_dummy.dm"
#include "code\game\objects\items\cprbot_item.dm"
#include "code\game\objects\items\disks.dm"
#include "code\game\objects\items\fulton.dm"
#include "code\game\objects\items\gift_wrappaper.dm"
Expand Down
Binary file modified icons/obj/structures/machinery/aibots.dmi
Binary file not shown.
Binary file added sound/CPRbot/CPR.ogg
Binary file not shown.
Binary file added sound/CPRbot/CPRbot_beep.ogg
Binary file not shown.
Binary file added sound/CPRbot/CPRbot_poweroff.ogg
Binary file not shown.
Binary file added sound/CPRbot/CPRbot_poweron.ogg
Binary file not shown.

0 comments on commit d2d90e3

Please sign in to comment.