Skip to content

Commit

Permalink
Removes the attack_slime proc, and other slime refactors (Fluffy-Fron…
Browse files Browse the repository at this point in the history
…tier#264)

* Removes the attack_slime proc, and other slime refactors (#80487)

## About The Pull Request

- **Removed attack_slime**. Most of the attack_slime content has been
moved to a proc that signs up for COMSIG_LIVING_UNARMED_ATTACK. Its
ugly, but will make converting slimes to a basic mob easier. They now
use attack_animal for now, which might cause some unexpected
interactions. Hopefully when they are converted to basic mobs, these can
be cleared up properly.

- This caused some issues with cyborgs, who used to get only half damage
dealt to them. As refactoring this would have been too much of a
difficult task without much real gain, after much pondering, I have
decided that since slimes can always flash cyborgs with each of their
strikes, maybe cyborgs should only fear slimes that have electric
charges in them. In addition, slimes electric charges decrease now after
they successfully zap an cyborg, making them more consistent with the
zaps that affect carbons. AIs are still fully immune to slimes.

- The slime.dm and slime.life files were extremely bloated, and
unorganized. I have created two new files, defense.dm and ai.dm. I have
moved the various attack_by/attack_hand/etc procs to defense.dm. Ai.dm
now contains every single proc the slime's "AI" uses; this should help
getting a clearer picture of the current functionality, which should aid
with basic mob conversion and decision tree creation. The remaining
files have been slightly organized, with overrides in front, and new
procs at the back.

- Created a proc for swapping out Adult and Baby states of a slime.
Previously, attack_slime was in many cases ignoring fields like
melee_damage_lower and melee_damage_upper, replacing it with magic
numbers based on the slime's lifestate. Now these values are hard set by
these procs. This has caused slimes to be more consistent, though baby
slimes might do a bit less damage on the low end. I am tempted to turn
these in datums in the future, or as part of this PR.

- Removed baby slime's chance to accidentally attack a window/grille by
bumping into it, they had 0 object damage anyways, unlike adult slimes,
so there was no reason not to early return.

- The proc of `handle_feeding` assumed adjustBruteLoss and adjustToxLoss
return positive values when damage has been done, when in reality, it
returns the total health change along with its direction. This meant
slimes would fell off simple or basic mobs after a single bite. This has
been fixed.

- Also updated the warning before the slime type defines, as they were
out of date.

- I have removed the bespoke spacewalk override for slimes, which should
allow them to drift, should gravity go out.

- The nutrition stats are assigned only once, when the slime grows up,
instead of compared to being an adult every life tick

## Why It's Good For The Game

Less duplicated code.
This refactor should help in the basic mob conversion process.
Cyborgs have an easier time wrangling slimes, who could previously kill
them in three hits, if charged. They are mostly encased in metal, they
should feel fine when not hit with electric attacks.
Lets slimes feast on delicious corgis.

* Removes the attack_slime proc, and other slime refactors

---------

Co-authored-by: Profakos <[email protected]>
Co-authored-by: NovaBot <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
  • Loading branch information
4 people authored and Iajret committed Jan 3, 2024
1 parent 757c92a commit 1dc0f89
Show file tree
Hide file tree
Showing 29 changed files with 900 additions and 988 deletions.
12 changes: 9 additions & 3 deletions code/__DEFINES/research/slimes.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#define SLIME_LIFE_STAGE_BABY "baby"
#define SLIME_LIFE_STAGE_ADULT "adult"

#define SLIME_MIN_POWER 0
#define SLIME_MEDIUM_POWER 5
#define SLIME_MAX_POWER 10

// Just slimin' here.
// Warning: These defines are used for slime cores and their icon states, so if you
// touch these names, remember to update icons/mob/simple/slimes.dmi and the respective
// slime core paths too!
// Warning: These defines are used for slime icon states, so if you
// touch these names, remember to update icons/mob/simple/slimes.dmi!

#define SLIME_TYPE_ADAMANTINE "adamantine"
#define SLIME_TYPE_BLACK "black"
Expand Down
25 changes: 0 additions & 25 deletions code/_onclick/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -237,31 +237,6 @@
/atom/proc/attack_larva_secondary(mob/user, list/modifiers)
return SECONDARY_ATTACK_CALL_NORMAL


/*
Slimes
Nothing happening here
*/
/mob/living/simple_animal/slime/resolve_unarmed_attack(atom/attack_target, proximity_flag, list/modifiers)
if(isturf(attack_target))
return ..()
attack_target.attack_slime(src, modifiers)

/mob/living/simple_animal/slime/resolve_right_click_attack(atom/target, list/modifiers)
if(isturf(target))
return ..()
return target.attack_slime_secondary(src, modifiers)

/atom/proc/attack_slime(mob/user, list/modifiers)
return

/**
* Called when a slime mob right clicks an atom (that is not a turf).
* Returns a SECONDARY_ATTACK_* value.
*/
/atom/proc/attack_slime_secondary(mob/user, list/modifiers)
return SECONDARY_ATTACK_CALL_NORMAL

/*
Drones
*/
Expand Down
2 changes: 1 addition & 1 deletion code/game/atom/atom_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
/atom/proc/hulk_damage()
return 150 //the damage hulks do on punches to this atom, is affected by melee armor

/atom/proc/attack_generic(mob/user, damage_amount = 0, damage_type = BRUTE, damage_flag = 0, sound_effect = 1, armor_penetration = 0) //used by attack_alien, attack_animal, and attack_slime
/atom/proc/attack_generic(mob/user, damage_amount = 0, damage_type = BRUTE, damage_flag = 0, sound_effect = 1, armor_penetration = 0) //used by attack_alien, attack_animal
if(!uses_integrity)
CRASH("unimplemented /atom/proc/attack_generic()!")
user.do_attack_animation(src)
Expand Down
3 changes: 0 additions & 3 deletions code/game/objects/items/devices/chameleonproj.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@
/obj/effect/dummy/chameleon/attack_animal(mob/user, list/modifiers)
master.disrupt()

/obj/effect/dummy/chameleon/attack_slime(mob/user, list/modifiers)
master.disrupt()

/obj/effect/dummy/chameleon/attack_alien(mob/user, list/modifiers)
master.disrupt()

Expand Down
8 changes: 4 additions & 4 deletions code/game/objects/items/devices/scanners/slime_scanner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@

/proc/slime_scan(mob/living/simple_animal/slime/scanned_slime, mob/living/user)
var/to_render = "<b>Slime scan results:</b>\
\n[span_notice("[scanned_slime.slime_type.colour] [scanned_slime.is_adult ? "adult" : "baby"] slime")]\
\nNutrition: [scanned_slime.nutrition]/[scanned_slime.get_max_nutrition()]"
\n[span_notice("[scanned_slime.slime_type.colour] [scanned_slime.life_stage] slime")]\
\nNutrition: [scanned_slime.nutrition]/[scanned_slime.max_nutrition]"

if (scanned_slime.nutrition < scanned_slime.get_starve_nutrition())
if (scanned_slime.nutrition < scanned_slime.starve_nutrition)
to_render += "\n[span_warning("Warning: slime is starving!")]"
else if (scanned_slime.nutrition < scanned_slime.get_hunger_nutrition())
else if (scanned_slime.nutrition < scanned_slime.hunger_nutrition)
to_render += "\n[span_warning("Warning: slime is hungry")]"

to_render += "\nElectric charge strength: [scanned_slime.powerlevel]\nHealth: [round(scanned_slime.health/scanned_slime.maxHealth,0.01)*100]%"
Expand Down
6 changes: 0 additions & 6 deletions code/game/objects/obj_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@
var/amt = max(0, ((force - (move_resist * MOVE_FORCE_CRUSH_RATIO)) / (move_resist * MOVE_FORCE_CRUSH_RATIO)) * 10)
take_damage(amt, BRUTE)

/obj/attack_slime(mob/living/simple_animal/slime/user, list/modifiers)
if(!user.is_adult)
return
if(attack_generic(user, rand(10, 15), BRUTE, MELEE, 1))
log_combat(user, src, "attacked")

/obj/singularity_act()
SSexplosions.high_mov_atom += src
if(src && !QDELETED(src))
Expand Down
11 changes: 0 additions & 11 deletions code/game/objects/structures/ladders.dm
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,6 @@
use(user, going_up = FALSE)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN

/obj/structure/ladder/attack_slime(mob/user, list/modifiers)
use(user)
return TRUE

/obj/structure/ladder/attack_slime_secondary(mob/user, list/modifiers)
. = ..()
if(. == SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
return
use(user, going_up = FALSE)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN

/obj/structure/ladder/attackby(obj/item/item, mob/user, params)
use(user)
return TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/window.dm
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
/obj/structure/window/attack_paw(mob/user, list/modifiers)
return attack_hand(user, modifiers)

/obj/structure/window/attack_generic(mob/user, damage_amount = 0, damage_type = BRUTE, damage_flag = 0, sound_effect = 1) //used by attack_alien, attack_animal, and attack_slime
/obj/structure/window/attack_generic(mob/user, damage_amount = 0, damage_type = BRUTE, damage_flag = 0, sound_effect = 1) //used by attack_alien, attack_animal
if(!can_be_reached(user))
return
return ..()
Expand Down
3 changes: 0 additions & 3 deletions code/modules/awaymissions/signpost.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
if (Adjacent(user))
return interact(user)

/obj/structure/signpost/attack_slime(mob/user, list/modifiers)
return interact(user)

/obj/structure/signpost/attack_animal(mob/user, list/modifiers)
return interact(user)

Expand Down
2 changes: 0 additions & 2 deletions code/modules/awaymissions/super_secret_room.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@
/obj/structure/speaking_tile/attack_ai(mob/user)
return interact(user)

/obj/structure/speaking_tile/attack_slime(mob/user, list/modifiers)
return interact(user)

/obj/structure/speaking_tile/attack_animal(mob/user, list/modifiers)
return interact(user)
Expand Down
3 changes: 0 additions & 3 deletions code/modules/mapfluff/ruins/spaceruin_code/hilbertshotel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,6 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999))
/turf/closed/indestructible/hoteldoor/attack_larva(mob/user, list/modifiers)
promptExit(user)

/turf/closed/indestructible/hoteldoor/attack_slime(mob/user, list/modifiers)
promptExit(user)

/turf/closed/indestructible/hoteldoor/attack_robot(mob/user)
if(get_dist(get_turf(src), get_turf(user)) <= 1)
promptExit(user)
Expand Down
7 changes: 0 additions & 7 deletions code/modules/mob/living/basic/basic_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,6 @@
if(damage_done > 0)
attacking_larva.amount_grown = min(attacking_larva.amount_grown + damage_done, attacking_larva.max_grown)

/mob/living/basic/attack_slime(mob/living/simple_animal/slime/M, list/modifiers)
if(..()) //successful slime attack
var/damage = rand(15, 25)
if(M.is_adult)
damage = rand(20, 35)
return apply_damage(damage, M.melee_damage_type)

/mob/living/basic/attack_drone(mob/living/basic/drone/attacking_drone)
if(attacking_drone.combat_mode) //No kicking dogs even as a rogue drone. Use a weapon.
return
Expand Down
9 changes: 0 additions & 9 deletions code/modules/mob/living/carbon/alien/alien_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ In all, this is a lot like the monkey code. /N
var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(user.zone_selected))
apply_damage(rand(1, 3), BRUTE, affecting)

/mob/living/carbon/alien/attack_slime(mob/living/simple_animal/slime/M, list/modifiers)
if(..()) //successful slime attack
var/damage = rand(5, 35)
if(M.is_adult)
damage = rand(10, 40)
adjustBruteLoss(damage)
log_combat(M, src, "attacked")
updatehealth()

/mob/living/carbon/alien/ex_act(severity, target, origin)
. = ..()
if(!. || QDELETED(src))
Expand Down
22 changes: 0 additions & 22 deletions code/modules/mob/living/carbon/carbon_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -215,28 +215,6 @@
ForceContractDisease(D)
return TRUE


/mob/living/carbon/attack_slime(mob/living/simple_animal/slime/M, list/modifiers)
if(..()) //successful slime attack
if(M.powerlevel > 0)
var/stunprob = M.powerlevel * 7 + 10 // 17 at level 1, 80 at level 10
if(prob(stunprob))
M.powerlevel -= 3
if(M.powerlevel < 0)
M.powerlevel = 0

visible_message(span_danger("The [M.name] shocks [src]!"), \
span_userdanger("The [M.name] shocks you!"))

do_sparks(5, TRUE, src)
var/power = M.powerlevel + rand(0,3)
Paralyze(power * 2 SECONDS)
set_stutter_if_lower(power * 2 SECONDS)
if (prob(stunprob) && M.powerlevel >= 8)
adjustFireLoss(M.powerlevel * rand(6,10))
updatehealth()
return 1

/**
* Really weird proc that attempts to dismebmer the passed zone if it is at max damage
* Unless the attacker is an NPC, in which case it disregards the zone and picks a random one
Expand Down
24 changes: 0 additions & 24 deletions code/modules/mob/living/carbon/human/human_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -256,30 +256,6 @@
var/armor_block = run_armor_check(affecting, MELEE)
apply_damage(damage, BRUTE, affecting, armor_block)

/mob/living/carbon/human/attack_slime(mob/living/simple_animal/slime/M, list/modifiers)
. = ..()
if(!.) // slime attack failed
return
var/damage = rand(M.melee_damage_lower, M.melee_damage_upper)
if(!damage)
return
var/wound_mod = -45 // 25^1.4=90, 90-45=45
if(M.is_adult)
damage += rand(5, 10)
wound_mod = -90 // 35^1.4=145, 145-90=55

if(check_block(M, damage, "the [M.name]"))
return FALSE

var/dam_zone = dismembering_strike(M, pick(BODY_ZONE_HEAD, BODY_ZONE_CHEST, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG))
if(!dam_zone) //Dismemberment successful
return TRUE

var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(dam_zone))
var/armor_block = run_armor_check(affecting, MELEE)
apply_damage(damage, BRUTE, affecting, armor_block, wound_bonus=wound_mod)


/mob/living/carbon/human/ex_act(severity, target, origin)
if(HAS_TRAIT(src, TRAIT_BOMBIMMUNE))
return FALSE
Expand Down
24 changes: 0 additions & 24 deletions code/modules/mob/living/living_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -296,30 +296,6 @@
user.set_pull_offsets(src, grab_state)
return TRUE


/mob/living/attack_slime(mob/living/simple_animal/slime/attacking_slime, list/modifiers)
if(attacking_slime.buckled)
if(attacking_slime in buckled_mobs)
attacking_slime.stop_feeding()
return // can't attack while eating!

if(HAS_TRAIT(attacking_slime, TRAIT_PACIFISM))
to_chat(attacking_slime, span_warning("You don't want to hurt anyone!"))
return FALSE

if(check_block(src, attacking_slime.melee_damage_upper, "[attacking_slime]'s glomp", MELEE_ATTACK, attacking_slime.armour_penetration, attacking_slime.melee_damage_type))
return FALSE

if (stat != DEAD)
log_combat(attacking_slime, src, "attacked")
attacking_slime.do_attack_animation(src)
visible_message(span_danger("\The [attacking_slime.name] glomps [src]!"), \
span_userdanger("\The [attacking_slime.name] glomps you!"), span_hear("You hear a sickening sound of flesh hitting flesh!"), COMBAT_MESSAGE_RANGE, attacking_slime)
to_chat(attacking_slime, span_danger("You glomp [src]!"))
return TRUE

return FALSE

/mob/living/attack_animal(mob/living/simple_animal/user, list/modifiers)
. = ..()
if(.)
Expand Down
3 changes: 0 additions & 3 deletions code/modules/mob/living/silicon/ai/ai_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

return ..()

/mob/living/silicon/ai/attack_slime(mob/living/simple_animal/slime/user, list/modifiers)
return //immune to slimes

/mob/living/silicon/ai/blob_act(obj/structure/blob/B)
if (stat != DEAD)
adjustBruteLoss(60)
Expand Down
18 changes: 0 additions & 18 deletions code/modules/mob/living/silicon/robot/robot_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,6 @@ GLOBAL_LIST_INIT(blacklisted_borg_hats, typecacheof(list( //Hats that don't real
..()
return

/mob/living/silicon/robot/attack_slime(mob/living/simple_animal/slime/M, list/modifiers)
if(..()) //successful slime shock
flash_act()
var/stunprob = M.powerlevel * 7 + 10
if(prob(stunprob) && M.powerlevel >= 8)
adjustBruteLoss(M.powerlevel * rand(6,10))

var/damage = rand(1, 3)

if(M.is_adult)
damage = rand(20, 40)
else
damage = rand(5, 35)
damage = round(damage / 2) // borgs receive half damage
adjustBruteLoss(damage)

return

/mob/living/silicon/robot/attack_hand(mob/living/carbon/human/user, list/modifiers)
add_fingerprint(user)
if(!opened)
Expand Down
7 changes: 0 additions & 7 deletions code/modules/mob/living/simple_animal/animal_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@
if(damage_done > 0)
L.amount_grown = min(L.amount_grown + damage_done, L.max_grown)

/mob/living/simple_animal/attack_slime(mob/living/simple_animal/slime/user, list/modifiers)
if(..()) //successful slime attack
var/damage = rand(15, 25)
if(user.is_adult)
damage = rand(20, 35)
return apply_damage(damage, user.melee_damage_type)

/mob/living/simple_animal/attack_drone(mob/living/basic/drone/user)
if(user.combat_mode) //No kicking dogs even as a rogue drone. Use a weapon.
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ IGNORE_PROC_IF_NOT_TARGET(attack_larva)

IGNORE_PROC_IF_NOT_TARGET(attack_animal)

IGNORE_PROC_IF_NOT_TARGET(attack_slime)

/mob/living/simple_animal/hostile/asteroid/curseblob/bullet_act(obj/projectile/Proj)
if(Proj.firer != set_target)
return
Expand Down
Loading

0 comments on commit 1dc0f89

Please sign in to comment.