Skip to content

Commit

Permalink
refactored some mob part and limb code (goonstation#13670)
Browse files Browse the repository at this point in the history
Co-authored-by: TobleroneSwordfish <[email protected]>
  • Loading branch information
TheTyrant25 and TobleroneSwordfish authored Apr 20, 2023
1 parent b2a0492 commit 9e2906e
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 156 deletions.
33 changes: 18 additions & 15 deletions code/datums/limb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

/datum/limb
var/obj/item/parts/holder = null
///used for ON_COOLDOWN stuff
/// used for ON_COOLDOWN stuff
var/cooldowns
var/special_next = 0
var/datum/item_special/disarm_special = null //Contains the datum which executes the items special, if it has one, when used beyond melee range.
var/datum/item_special/harm_special = null //Contains the datum which executes the items special, if it has one, when used beyond melee range.
/// Contains the datum which executes the items special, if it has one, when used beyond melee range.
var/datum/item_special/disarm_special = null
/// Contains the datum which executes the items special, if it has one, when used beyond melee range.
var/datum/item_special/harm_special = null
var/can_pickup_item = TRUE
var/attack_strength_modifier = 1 // scale from 0 to 1 on how well this limb can attack/hit things with items
var/can_gun_grab = TRUE // if the limb can gun grab with a held gun
/// scale from 0 to 1 on how well this limb can attack/hit things with items
var/attack_strength_modifier = 1
/// if the limb can gun grab with a held gun
var/can_gun_grab = TRUE

New(var/obj/item/parts/holder)
..()
Expand Down Expand Up @@ -276,7 +280,7 @@
harm(mob/living/target, mob/living/user)
src.point_blank(target, user)

//despite the name, this means reloading
/// despite the name, this means reloading
is_on_cooldown(var/mob/user)
return GET_COOLDOWN(user, "\ref[src] reload")

Expand Down Expand Up @@ -411,10 +415,8 @@
user.lastattacked = target
ON_COOLDOWN(src, "limb_cooldown", COMBAT_CLICK_DELAY)




/datum/limb/mouth/small // for cats/mice/etc
/// for cats/mice/etc
/datum/limb/mouth/small
sound_attack = 'sound/impact_sounds/Flesh_Tear_1.ogg'
dam_low = 1
dam_high = 3
Expand Down Expand Up @@ -779,7 +781,7 @@
log_name = "severed werewolf limb"
quality = 1

// Currently used by the High Fever disease which is obtainable from the "Too Much" chem which only shows up in sickly pears, which are currently commented out. Go there to make use of this.
/// Currently used by the High Fever disease which is obtainable from the "Too Much" chem which only shows up in sickly pears, which are currently commented out. Go there to make use of this.
/datum/limb/hot //because
attack_hand(atom/target, var/mob/living/user, var/reach, params, location, control)
if (!holder)
Expand Down Expand Up @@ -1372,7 +1374,7 @@
user.lastattacked = target


//little critters with teeth, like mice! can pick up small items only.
/// little critters with teeth, like mice! can pick up small items only.
/datum/limb/small_critter
var/max_wclass = W_CLASS_TINY // biggest thing we can carry
var/dam_low = 1
Expand Down Expand Up @@ -1477,7 +1479,8 @@
return
..()

/datum/limb/small_critter/med //same as the previous, but can pick up some heavier shit
/// same as the parent, but can pick up some heavier shit
/datum/limb/small_critter/med
max_wclass = W_CLASS_SMALL
stam_damage_mult = 0.5

Expand Down Expand Up @@ -1529,14 +1532,14 @@
logTheThing(LOG_COMBAT, user, "slashes [constructTarget(target,"combat")] with dash arms at [log_loc(user)].")
..()

//test for crab attack thing
/// test for crab attack thing
/datum/limb/swipe_quake
New(var/obj/item/parts/holder)
..()
src.setDisarmSpecial (/datum/item_special/slam/no_item_attack)
src.setHarmSpecial (/datum/item_special/swipe/limb)

//I wanted a claw-like limb but without the random item pickup fail
/// I wanted a claw-like limb but without the random item pickup fail
/datum/limb/tentacle
harm(mob/target, var/mob/living/user)
if(check_target_immunity( target ))
Expand Down
69 changes: 45 additions & 24 deletions code/obj/item/mob_parts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@ ABSTRACT_TYPE(/obj/item/parts)
c_flags = ONBELT
override_attack_hand = 0
var/skin_tone = "#FFFFFF"
var/slot = null // which part of the person or robot suit does it go on???????
var/streak_decal = /obj/decal/cleanable/blood // what streaks everywhere when it's cut off?
var/streak_descriptor = "bloody" //bloody, oily, etc
var/datum/limb/limb_data = null // used by arms for attack_hand overrides
var/limb_type = /datum/limb // the type of limb_data
var/obj/item/remove_object = null //set to create an item when severed rather than removing the arm itself
var/side = "left" //used for streak direction
var/remove_stage = 0 //2 will fall off, 3 is removed
var/no_icon = 0 //if the only icon is above the clothes layer ie. in the handlistPart list
var/skintoned = 1 // is this affected by human skin tones? Also if the severed limb uses a separate bloody-stump icon layered on top

/// Gets overlaid onto the severed limb, under the stump if the limb is skintoned
/// which part of the person or robot suit does it go on???????
var/slot = null
/// what streaks everywhere when it's cut off?
var/streak_decal = /obj/decal/cleanable/blood
/// bloody, oily, etc
var/streak_descriptor = "bloody"
/// used by arms for attack_hand overrides
var/datum/limb/limb_data = null
/// the type of limb_data
var/limb_type = /datum/limb
/// set to create an item when severed rather than removing the arm itself
var/obj/item/remove_object = null
/// used for streak direction
var/side = "left"
/// 2 will fall off, 3 is removed. This should use defines honestly but eh.
var/remove_stage = 0
///if the only icon is above the clothes layer ie. in the handlistPart list
var/no_icon = FALSE
/// is this affected by human skin tones? Also if the severed limb uses a separate bloody-stump icon layered on top
var/skintoned = TRUE

// Gets overlaid onto the severed limb, under the stump if the limb is skintoned
/// The icon of this overlay
var/severed_overlay_1_icon
/// The state of this overlay
Expand All @@ -46,36 +56,47 @@ ABSTRACT_TYPE(/obj/item/parts)
/// The color reference. null for uncolored("#ffffff"), CUST_1/2/3 for one of the mob's haircolors, SKIN_TONE for the mob's skintone
var/handfoot_overlay_1_color

var/easy_attach = 0 //Attachable without surgery?
///Attachable without surgery?
var/easy_attach = FALSE

var/decomp_affected = 1 // set to 1 if this limb has decomposition icons
/// set to TRUE if this limb has decomposition icons
var/decomp_affected = TRUE
var/current_decomp_stage_l = -1
var/current_decomp_stage_s = -1

var/mob/living/holder = null

var/image/standImage // Used by getMobIcon to pass off to update_body. Typically holds image(the_limb's_icon, "[src.slot]")
var/image/lyingImage // Appears to be unused, since we just rotate the sprite through animagic
var/partIcon = 'icons/mob/human.dmi' // The icon the mob sprite uses when attached, change if the limb's icon isnt in 'icons/mob/human.dmi'
/// Used by getMobIcon to pass off to update_body. Typically holds image(the_limb's_icon, "[src.slot]")
var/image/standImage
/// Appears to be unused, since we just rotate the sprite through animagic
var/image/lyingImage
/// The icon the mob sprite uses when attached, change if the limb's icon isnt in 'icons/mob/human.dmi'
var/partIcon = 'icons/mob/human.dmi'
var/partDecompIcon = 'icons/mob/human_decomp.dmi'
var/handlistPart // Used by getHandIconState to determine the attached-to-mob-sprite hand sprite
var/partlistPart // Ditto, but for foot sprites, presumably
var/datum/bone/bones = null // for medical crap
/// Used by getHandIconState to determine the attached-to-mob-sprite hand sprite
var/handlistPart
/// Used by getPartIconState to determine the attached-to-mob-sprite non-hand sprite
var/partlistPart
/// for medical crap
var/datum/bone/bones = null
var/brute_dam = 0
var/burn_dam = 0
var/tox_dam = 0
var/siemens_coefficient = 1
var/step_image_state = null // for legs, we leave footprints in this style (located in blood.dmi)
var/accepts_normal_human_overlays = 1 //for avoiding istype in update icon
var/datum/movement_modifier/movement_modifier // When attached, applies this movement modifier
/// for legs, we leave footprints in this style (located in blood.dmi)
var/step_image_state = null
/// for avoiding istype in update icon
var/accepts_normal_human_overlays = TRUE
/// When attached, applies this movement modifier
var/datum/movement_modifier/movement_modifier
/// If TRUE, it'll resist mutantraces trying to change them
var/limb_is_unnatural = FALSE
/// Limb is not attached to its original owner
var/limb_is_transplanted = FALSE
/// What kind of limb is this? So we dont have to do dozens of typechecks. is bitflags, check defines/item.dm
var/kind_of_limb
/// Can we roll this limb as a random limb?
var/random_limb_blacklisted = 0
var/random_limb_blacklisted = FALSE

New(atom/new_holder)
..()
Expand Down
Loading

0 comments on commit 9e2906e

Please sign in to comment.