surgery_operation 
Surgery operation datum
A singleton datum which represents a surgical operation that can be performed on a mob.
Surgery operations can be something simple, like moving between surgery states (tend wounds, clamp vessels), or more complex, like outright replacing limbs or organs. As such the datum is very flexible.
At most basic, you must implement the vars:
-
- implements And the procs:
-
- on success - put the effects of the operation here Other noteworthy vars and procs you probably want to implement or override:
-
- operation flags - flags modifying the behavior of the operation
-
- required surgery state - target must have ALL of these states to be eligible for the operation
-
- blocked surgery state - target must NOT have ANY these states to be eligible for the operation
-
- state check - extra checks for if the operating target is valid
-
- get default radial image - what icon to use for this operation on the radial menu
It's recommended to work off of /datum/surgery_operation/limb or /datum/surgery_operation/organ as they implement a lot of common functionality for targeting limbs or organs for you.
See also /datum/surgery_operation/basic, which is a bit more complex to use but allows for operations to target any mob type, rather than only those with limbs or organs.
Vars | |
| all_surgery_states_required | The target must have ALL of these surgery states for the operation to be available |
|---|---|
| any_surgery_states_blocked | The target must NOT have ANY of these surgery states for the operation to be available |
| any_surgery_states_required | The target must have ANY of these surgery states for the operation to be available |
| desc | Required - Description of the operation, keep it short and format it like an action - "Amputate a patient's limb.", "Remove a patient's organ.". |
| failure_sound | SFX played on failure, after the do-after Can be a sound path or an assoc list of item typepath to sound path to make different sounds for different tools |
| implements | What tool(s) can be used to perform this operation? |
| main_option | The default radial menu choice for this operation, lazily created on first use Some subtypes won't have this set as they provide their own options |
| name | Required - Name of the operation, keep it short and format it like an action - "amputate limb", "remove organ" Don't capitalize it, it will be capitalized automatically where necessary. |
| operation_flags | Flags modifying the behavior of this operation |
| preop_sound | SFX played before the do-after begins Can be a sound path or an assoc list of item typepath to sound path to make different sounds for different tools |
| replaced_by | Typepath of a surgical operation that supersedes this one If this operation and the replaced_by operation are both available, only the replaced_by one will be usable |
| rnd_desc | Optional - the description of the operation shown in RND consoles and the operating computer. Here is where you may want to provide more information on why an operation is done ("Fixes a broken liver") or special requirements ("Requires Synthflesh"). Use "the patient" instead of "a patient" to keep it specific. |
| rnd_name | Optional - the name of the operation shown in RND consoles and the operating computer. You can get fancier here, givin an official surgery name ("Lobectomy") or rephrase it to be more descriptive ("Brain Lobectomy"). Capitalize it as necessary. |
| success_sound | SFX played on success, after the do-after Can be a sound path or an assoc list of item typepath to sound path to make different sounds for different tools |
| surgery_failure_mood_event | Which mood event to give the consious patient when surgery fails. Lasts muuuuuch longer. |
| surgery_started_mood_event | Which mood event to give the patient when surgery is starting while they're conscious. This should be permanent/not have a timer until the surgery either succeeds or fails, as those states will immediately replace it. Mostly just flavor text. |
| surgery_success_mood_event | Which mood event to give the conscious patient when surgery succeeds. Lasts far shorter than if it failed. |
| time | Base time to perform this operation |
Procs | |
| add_radial_overlays | Helper for constructing overlays to apply to a radial image |
| all_blocked_strings | Returns a list of strings indicating blocked states for this operation "Blocked requirements" are formatted as "However, none of the following may be true:" |
| all_required_strings | Returns a list of strings indicating requirements for this operation "All requirements" are formatted as "All of the following must be true:" |
| any_optional_strings | Returns a list of strings indicating optional conditions for this operation "Optional conditions" are formatted as "Additionally, any of the following may be true:" |
| any_required_strings | Returns a list of strings indicating any of the requirements for this operation "Any requirements" are formatted as "At least one of the following must be true:" |
| can_loop | Called after an operation to check if it can be repeated/looped |
| check_availability | Checks to see if this operation can be performed This is the main entry point for checking availability |
| display_pain | Display pain message to the target based on their traits and condition |
| display_results | Used to display messages to the surgeon and patient |
| failure | Called when the operation fails Don't touch this proc, override on_failure() instead |
| get_any_tool | For surgery operations that can be performed with any item, this explains what kind of item is needed |
| get_default_radial_image | Returns what icon this surgery uses by default on the radial wheel if it does not implement its own radial options |
| get_generic_limb_radial_image | Helper to get a generic limb radial image based on body zone |
| get_location_modifier | Gets the surgery speed modifier for a given mob, based off what sort of table/bed/whatever is on their turf. |
| get_mob_surgery_speed_mod | Returns a time modifier based on the mob's status |
| get_morbid_modifier | Returns a time modifier for morbid operations |
| get_operation_target | Gets what movable is being operated on by a surgeon during this operation Determines what gets passed into the try_perform() proc If null is returned, the operation cannot be performed |
| get_patient | Helper for getting the mob who is ultimately being operated on, given the movable that is truly being operated on. For example in limb surgeries this would return the mob the limb is attached to. |
| get_radial_options | Return a radial slice, a list of radial slices, or an assoc list of radial slice to operation info |
| get_recommended_tool | Returns the name of whatever tool is recommended for this operation, such as "hemostat" |
| get_requirements | Return a list of lists of strings indicating the various requirements for this operation |
| get_time_modifiers | Collates all time modifiers for this operation and returns the final modifier |
| get_tool_quality | Returns the quality of the passed tool for this operation Quality directly affects the time taken to perform the operation |
| has_any_surgery_state | Check if the movable being operated on has any of the passed surgery states |
| has_surgery_state | Check if the movable being operated on has all the passed surgery states |
| is_available | Checks to see if this operation can be performed on the provided target |
| locate_operating_computer | Helper for getting an operating compupter the patient is linked to |
| on_failure | Used to customize behavior when the operation fails |
| on_preop | Used to customize behavior when the operation starts |
| on_success | Used to customize behavior when the operation is successful |
| operate_check | Called during the do-after to check if the operation can continue |
| play_operation_sound | Plays a sound for the operation based on the tool used |
| pre_preop | Allows for any extra checks or setup when the operation starts If you want user input before for an operation, do it here |
| show_as_next_step | Called by operating computers to hint that this surgery could come next given the target's current state |
| snowflake_check_availability | Snowflake checks for surgeries which need many interconnected conditions to be met |
| start_operation | Called when the operation initiates Don't touch this proc, override on_preop() instead |
| state_check | Any operation specific state checks, such as checking for traits or more complex state requirements |
| success | Called when the operation is successful Don't touch this proc, override on_success() instead |
| tool_check | Checks to see if the provided tool is valid for this operation You can override this to add more specific checks, such as checking sharpness |
| try_perform | The actual chain of performing the operation |
| update_surgery_mood | Updates a patient's mood based on the surgery state and their traits |
Var Details
all_surgery_states_required 
The target must have ALL of these surgery states for the operation to be available
any_surgery_states_blocked 
The target must NOT have ANY of these surgery states for the operation to be available
any_surgery_states_required 
The target must have ANY of these surgery states for the operation to be available
desc 
Required - Description of the operation, keep it short and format it like an action - "Amputate a patient's limb.", "Remove a patient's organ.".
failure_sound 
SFX played on failure, after the do-after Can be a sound path or an assoc list of item typepath to sound path to make different sounds for different tools
implements 
What tool(s) can be used to perform this operation?
Assoc list of item typepath, TOOL_X, or IMPLEMENT_HAND to a multiplier for how effective that tool is at performing the operation. For example, list(TOOL_SCALPEL = 2, TOOL_SAW = 0.5) means that you can use a scalpel to operate, and it will double the time the operation takes. Likewise using a saw will halve the time it takes. If a tool is not listed, it cannot be used for this operation.
Order matters! If a tool matches multiple entries, the first one will always be used. For example, if you have list(TOOL_SCREWDRIVER = 2, /obj/item/screwdriver = 1), and use a screwdriver it will use the TOOL_SCREWDRIVER modifier, making your operation 2x slower, even though the latter entry would have been faster.
For this, it is handy to keep in mind SURGERY_MODIFIER_FAILURE_THRESHOLD. While speeds are soft capped and cannot be reduced beyond this point, larger modifiers still increase failure chances.
Lastly, while most operations have its main tool with a 1x modifier (representing the "intended" tool), some will have its main tool's multiplier above or below 1x to represent an innately easier or harder operation
main_option 
The default radial menu choice for this operation, lazily created on first use Some subtypes won't have this set as they provide their own options
name 
Required - Name of the operation, keep it short and format it like an action - "amputate limb", "remove organ" Don't capitalize it, it will be capitalized automatically where necessary.
operation_flags 
Flags modifying the behavior of this operation
preop_sound 
SFX played before the do-after begins Can be a sound path or an assoc list of item typepath to sound path to make different sounds for different tools
replaced_by 
Typepath of a surgical operation that supersedes this one If this operation and the replaced_by operation are both available, only the replaced_by one will be usable
rnd_desc 
Optional - the description of the operation shown in RND consoles and the operating computer. Here is where you may want to provide more information on why an operation is done ("Fixes a broken liver") or special requirements ("Requires Synthflesh"). Use "the patient" instead of "a patient" to keep it specific.
rnd_name 
Optional - the name of the operation shown in RND consoles and the operating computer. You can get fancier here, givin an official surgery name ("Lobectomy") or rephrase it to be more descriptive ("Brain Lobectomy"). Capitalize it as necessary.
success_sound 
SFX played on success, after the do-after Can be a sound path or an assoc list of item typepath to sound path to make different sounds for different tools
surgery_failure_mood_event 
Which mood event to give the consious patient when surgery fails. Lasts muuuuuch longer.
surgery_started_mood_event 
Which mood event to give the patient when surgery is starting while they're conscious. This should be permanent/not have a timer until the surgery either succeeds or fails, as those states will immediately replace it. Mostly just flavor text.
surgery_success_mood_event 
Which mood event to give the conscious patient when surgery succeeds. Lasts far shorter than if it failed.
time 
Base time to perform this operation
Proc Details
add_radial_overlays
Helper for constructing overlays to apply to a radial image
Input can be
-
- An atom typepath
-
- An atom instance
-
- Another image
Returns a list of images
all_blocked_strings
Returns a list of strings indicating blocked states for this operation "Blocked requirements" are formatted as "However, none of the following may be true:"
all_required_strings
Returns a list of strings indicating requirements for this operation "All requirements" are formatted as "All of the following must be true:"
any_optional_strings
Returns a list of strings indicating optional conditions for this operation "Optional conditions" are formatted as "Additionally, any of the following may be true:"
any_required_strings
Returns a list of strings indicating any of the requirements for this operation "Any requirements" are formatted as "At least one of the following must be true:"
can_loop
Called after an operation to check if it can be repeated/looped
check_availability
Checks to see if this operation can be performed This is the main entry point for checking availability
display_pain
Display pain message to the target based on their traits and condition
display_results
Used to display messages to the surgeon and patient
failure
Called when the operation fails Don't touch this proc, override on_failure() instead
get_any_tool
For surgery operations that can be performed with any item, this explains what kind of item is needed
get_default_radial_image
Returns what icon this surgery uses by default on the radial wheel if it does not implement its own radial options
Also used when generating icons for the wiki
get_generic_limb_radial_image
Helper to get a generic limb radial image based on body zone
get_location_modifier
Gets the surgery speed modifier for a given mob, based off what sort of table/bed/whatever is on their turf.
get_mob_surgery_speed_mod
Returns a time modifier based on the mob's status
get_morbid_modifier
Returns a time modifier for morbid operations
get_operation_target
Gets what movable is being operated on by a surgeon during this operation Determines what gets passed into the try_perform() proc If null is returned, the operation cannot be performed
- patient - The mob being operated on
- body_zone - The body zone being operated on
Returns the atom/movable being operated on
get_patient
Helper for getting the mob who is ultimately being operated on, given the movable that is truly being operated on. For example in limb surgeries this would return the mob the limb is attached to.
get_radial_options
Return a radial slice, a list of radial slices, or an assoc list of radial slice to operation info
By default it returns a single option with the operation name and description, but you can override this proc to return multiple options for one operation, like selecting which organ to operate on.
get_recommended_tool
Returns the name of whatever tool is recommended for this operation, such as "hemostat"
get_requirements
Return a list of lists of strings indicating the various requirements for this operation
get_time_modifiers
Collates all time modifiers for this operation and returns the final modifier
get_tool_quality
Returns the quality of the passed tool for this operation Quality directly affects the time taken to perform the operation
0 = unusable 1 = standard quality
has_any_surgery_state
Check if the movable being operated on has any of the passed surgery states
has_surgery_state
Check if the movable being operated on has all the passed surgery states
is_available
Checks to see if this operation can be performed on the provided target
locate_operating_computer
Helper for getting an operating compupter the patient is linked to
on_failure
Used to customize behavior when the operation fails
total_penalty_modifier is the final modifier applied to the time taken to perform the operation, and it can be interpreted as how badly the operation was performed
At its lowest, it will be just above 2.5 (the threshold for success), and can go up to infinity (theoretically)
on_preop
Used to customize behavior when the operation starts
on_success
Used to customize behavior when the operation is successful
operate_check
Called during the do-after to check if the operation can continue
play_operation_sound
Plays a sound for the operation based on the tool used
pre_preop
Allows for any extra checks or setup when the operation starts If you want user input before for an operation, do it here
This proc can sleep, sanity checks are automatically performed after it completes
Return FALSE to cancel the operation Return TRUE to continue
show_as_next_step
Called by operating computers to hint that this surgery could come next given the target's current state
snowflake_check_availability
Snowflake checks for surgeries which need many interconnected conditions to be met
start_operation
Called when the operation initiates Don't touch this proc, override on_preop() instead
state_check
Any operation specific state checks, such as checking for traits or more complex state requirements
success
Called when the operation is successful Don't touch this proc, override on_success() instead
tool_check
Checks to see if the provided tool is valid for this operation You can override this to add more specific checks, such as checking sharpness
try_perform
The actual chain of performing the operation
- operating_on - The atom being operated on, probably a bodypart or occasionally a mob directly
- surgeon - The mob performing the operation
- tool - The tool being used to perform the operation. CAN BE A STRING, ie, IMPLEMENT_HAND, be careful
- operation_args - Additional arguments passed into the operation. Contains largely niche info that only certain operations care about or can be accessed through other means
Returns an item interaction flag - intended to be invoked from the interaction chain
update_surgery_mood
Updates a patient's mood based on the surgery state and their traits