converts most pet behavior into elements (#85290)

## About The Pull Request
refactors pet behaviors, such as collars and pet cultists into elements.
also this is a first step to completely removing the pet subtype

## Why It's Good For The Game
this means itll be alot easier for coders to make their tameable mobs
able to wear pet collars without having to make them of the pet subtype,
which i also plan to do

## Changelog
🆑
refactor: refactors pet collars and cultist pets into elements
/🆑
This commit is contained in:
Ben10Omintrix
2024-08-04 21:59:12 -06:00
committed by GitHub
parent 03d635ff34
commit 0e36ba0808
11 changed files with 247 additions and 239 deletions
@@ -24,8 +24,6 @@
response_harm_simple = "kick"
mobility_flags = MOBILITY_FLAGS_REST_CAPABLE_DEFAULT
gold_core_spawnable = FRIENDLY_SPAWN
collar_icon_state = "cat"
has_collar_resting_icon_state = TRUE
can_be_held = TRUE
ai_controller = /datum/ai_controller/basic_controller/cat
held_state = "cat2"
@@ -33,7 +31,8 @@
attack_verb_simple = "claw"
attack_sound = 'sound/weapons/slash.ogg'
attack_vis_effect = ATTACK_EFFECT_CLAW
cult_icon_state = "cat_cult"
///icon of the collar we can wear
var/collar_icon_state = "cat"
///can this cat breed?
var/can_breed = TRUE
///can hold items?
@@ -50,9 +49,13 @@
var/obj/item/held_food
///mutable appearance for held item
var/mutable_appearance/held_item_overlay
///icon state of our cult icon
var/cult_icon_state = "cat_cult"
/mob/living/basic/pet/cat/Initialize(mapload)
. = ..()
AddElement(/datum/element/cultist_pet, pet_cult_icon_state = cult_icon_state)
AddElement(/datum/element/wears_collar, collar_icon_state = collar_icon_state, collar_resting_icon_state = TRUE)
AddElement(/datum/element/ai_retaliate)
AddElement(/datum/element/pet_bonus, "purrs!")
AddElement(/datum/element/footstep, footstep_type = FOOTSTEP_MOB_CLAW)
@@ -147,7 +150,6 @@
icon_living = "breadcat"
icon_dead = "breadcat_dead"
ai_controller = /datum/ai_controller/basic_controller/cat/bread
collar_icon_state = null
held_state = "breadcat"
can_interact_with_stove = TRUE
butcher_results = list(
@@ -156,6 +158,7 @@
/obj/item/organ/external/tail/cat = 1,
/obj/item/food/breadslice/plain = 1
)
collar_icon_state = null
/mob/living/basic/pet/cat/breadcat/add_cell_sample()
return
@@ -167,7 +170,6 @@
icon_state = "original"
icon_living = "original"
icon_dead = "original_dead"
collar_icon_state = null
unique_pet = TRUE
held_state = "original"
@@ -183,10 +185,10 @@
density = FALSE
pass_flags = PASSMOB
mob_size = MOB_SIZE_SMALL
collar_icon_state = "kitten"
can_breed = FALSE
ai_controller = /datum/ai_controller/basic_controller/cat/kitten
can_hold_item = FALSE
collar_icon_state = "kitten"
/mob/living/basic/pet/cat/kitten/Initialize(mapload)
. = ..()
@@ -44,9 +44,15 @@
/datum/pet_command/point_targeting/fetch,
/datum/pet_command/play_dead,
)
///icon state of the collar we can wear
var/collar_icon_state
///icon state of our cult icon
var/cult_icon_state
/mob/living/basic/pet/dog/Initialize(mapload)
. = ..()
AddElement(/datum/element/cultist_pet, pet_cult_icon_state = cult_icon_state)
AddElement(/datum/element/wears_collar, collar_icon_state = collar_icon_state)
ADD_TRAIT(src, TRAIT_WOUND_LICKER, INNATE_TRAIT)
AddElement(/datum/element/pet_bonus, "woofs happily!")
AddElement(/datum/element/footstep, FOOTSTEP_MOB_CLAW)
@@ -544,9 +544,9 @@
pass_flags = PASSMOB
ai_controller = /datum/ai_controller/basic_controller/dog/puppy
mob_size = MOB_SIZE_SMALL
collar_icon_state = "puppy"
strippable_inventory_slots = list(/datum/strippable_item/pet_collar, /datum/strippable_item/corgi_id) //puppies are too small to handle hats and back slot items
can_breed = FALSE
collar_icon_state = "puppy"
//PUPPY IAN! SQUEEEEEEEEE~
/mob/living/basic/pet/dog/corgi/puppy/ian
@@ -38,11 +38,11 @@ GLOBAL_LIST_INIT(strippable_corgi_items, create_strippable_list(list(
key = STRIPPABLE_ITEM_PET_COLLAR
/datum/strippable_item/pet_collar/get_item(atom/source)
var/mob/living/basic/pet/pet_source = source
var/mob/living/basic/pet_source = source
if(!istype(pet_source))
return
return pet_source.collar
return (locate(/obj/item/clothing/neck/petcollar) in source)
/datum/strippable_item/pet_collar/try_equip(atom/source, obj/item/equipping, mob/user)
. = ..()
@@ -56,18 +56,10 @@ GLOBAL_LIST_INIT(strippable_corgi_items, create_strippable_list(list(
return TRUE
/datum/strippable_item/pet_collar/finish_equip(atom/source, obj/item/equipping, mob/user)
var/mob/living/basic/pet/pet_source = source
if(!istype(pet_source))
return
pet_source.add_collar(equipping, user)
user.transferItemToLoc(equipping, source)
/datum/strippable_item/pet_collar/finish_unequip(atom/source, mob/user)
var/mob/living/basic/pet/pet_source = source
if(!istype(pet_source))
return
var/obj/collar = pet_source.remove_collar(user.drop_location())
var/obj/item/clothing/neck/petcollar/collar = locate() in source
user.put_in_hands(collar)
/datum/strippable_item/corgi_back
@@ -31,6 +31,8 @@
/mob/living/basic/pet/fox/Initialize(mapload)
. = ..()
AddElement(/datum/element/cultist_pet)
AddElement(/datum/element/wears_collar)
AddElement(/datum/element/pet_bonus, "pants and yaps happily!")
AddElement(/datum/element/footstep, footstep_type = FOOTSTEP_MOB_CLAW)
AddElement(/datum/element/tiny_mob_hunter, MOB_SIZE_SMALL)
@@ -20,6 +20,8 @@
/mob/living/basic/pet/penguin/Initialize(mapload)
. = ..()
AddElement(/datum/element/cultist_pet)
AddElement(/datum/element/wears_collar)
AddElement(/datum/element/ai_retaliate)
AddElement(/datum/element/ai_flee_while_injured)
AddElement(/datum/element/pet_bonus, "honks happily!")
-134
View File
@@ -3,146 +3,12 @@
mob_size = MOB_SIZE_SMALL
mob_biotypes = MOB_ORGANIC|MOB_BEAST
blood_volume = BLOOD_VOLUME_NORMAL
/// if the mob is protected from being renamed by collars.
var/unique_pet = FALSE
/// If the mob has collar sprites, this is the base of the icon states.
var/collar_icon_state = null
/// We have a seperate _rest collar icon state when the pet is resting.
var/has_collar_resting_icon_state = FALSE
/// Our collar
var/obj/item/clothing/neck/petcollar/collar
///can we become cultists?
var/can_cult_convert = TRUE
///whether we have a custom icon state when we get culted
var/cult_icon_state
/mob/living/basic/pet/Initialize(mapload)
. = ..()
/// Can set the collar var beforehand to start the pet with a collar.
if(collar)
collar = new(src)
update_icon(UPDATE_OVERLAYS)
if(can_cult_convert)
RegisterSignal(src, COMSIG_LIVING_CULT_SACRIFICED, PROC_REF(become_cultist))
/mob/living/basic/pet/Destroy()
. = ..()
QDEL_NULL(collar)
/mob/living/basic/pet/attackby(obj/item/thing, mob/user, params)
if(istype(thing, /obj/item/clothing/neck/petcollar) && !collar)
add_collar(thing, user)
return TRUE
if(istype(thing, /obj/item/newspaper) && !stat)
user.visible_message(span_notice("[user] baps [name] on the nose with the rolled up [thing]."))
dance_rotate(src)
return TRUE
return ..()
/mob/living/basic/pet/update_overlays()
. = ..()
if(isnull(mind) && (FACTION_CULT in faction))
var/image/cult_indicator = image(icon = 'icons/mob/simple/pets.dmi', icon_state = "pet_cult_indicator", layer = ABOVE_GAME_PLANE)
. += cult_indicator
if(!collar || !collar_icon_state)
return
// Determine which status tag to add to the middle of the icon state.
var/dead_tag = (stat == DEAD || HAS_TRAIT(src, TRAIT_FAKEDEATH)) ? "_dead" : null
var/rest_tag = has_collar_resting_icon_state && resting ? "_rest" : null
var/stat_tag = dead_tag || rest_tag || ""
. += mutable_appearance(icon, "[collar_icon_state][stat_tag]collar")
. += mutable_appearance(icon, "[collar_icon_state][stat_tag]tag")
/mob/living/basic/pet/update_icon_state()
if(cult_icon_state && (FACTION_CULT in faction))
icon_state = cult_icon_state
icon_living = cult_icon_state
return ..()
/mob/living/basic/pet/gib()
remove_collar(drop_location(), update_visuals = FALSE)
return ..()
/mob/living/basic/pet/revive(full_heal_flags = NONE, excess_healing = 0, force_grab_ghost = FALSE)
. = ..()
if(!.)
return
update_icon(UPDATE_OVERLAYS)
/mob/living/basic/pet/death(gibbed)
. = ..()
add_memory_in_range(src, 7, /datum/memory/pet_died, deuteragonist = src) //Protagonist is the person memorizing it
/mob/living/basic/pet/Exited(atom/movable/gone, direction)
. = ..()
if(gone != collar)
return
collar = null
if(QDELETED(src))
return
update_icon(UPDATE_OVERLAYS)
/mob/living/basic/pet/update_stat()
. = ..()
update_icon(UPDATE_OVERLAYS)
/mob/living/basic/pet/set_resting(new_resting, silent, instant)
. = ..()
if(!has_collar_resting_icon_state)
return
update_icon(UPDATE_OVERLAYS)
/**
* Add a collar to the pet.
*
* Arguments:
* * new_collar - the collar.
* * user - the user that did it.
*/
/mob/living/basic/pet/proc/add_collar(obj/item/clothing/neck/petcollar/new_collar, mob/user)
if(QDELETED(new_collar) || collar)
return
if(!user.transferItemToLoc(new_collar, src))
return
collar = new_collar
if(collar_icon_state)
update_icon(UPDATE_OVERLAYS)
to_chat(user, span_notice("You put [new_collar] around [src]'s neck."))
if(new_collar.tagname && !unique_pet)
fully_replace_character_name(null, "\proper [new_collar.tagname]")
/**
* Remove the collar from the pet.
*/
/mob/living/basic/pet/proc/remove_collar(atom/new_loc, update_visuals = TRUE)
if(!collar)
return
var/obj/old_collar = collar
collar.forceMove(new_loc)
collar = null
if(collar_icon_state && update_visuals)
update_icon(UPDATE_OVERLAYS)
return old_collar
@@ -1,85 +0,0 @@
#define PET_CULT_ATTACK 10
#define PET_CULT_HEALTH 50
///turn into terrifying beasts
/mob/living/basic/pet/proc/become_cultist(datum/source, list/invokers, datum/team)
SIGNAL_HANDLER
if(stat == DEAD || !can_cult_convert)
return
if(FACTION_CULT in faction)
return STOP_SACRIFICE
mind?.add_antag_datum(/datum/antagonist/cult, team)
qdel(GetComponent(/datum/component/obeys_commands))
melee_damage_lower = max(PET_CULT_ATTACK, initial(melee_damage_lower))
melee_damage_upper = max(PET_CULT_ATTACK + 5, initial(melee_damage_upper))
maxHealth = max(PET_CULT_HEALTH, initial(maxHealth))
fully_heal()
faction = list(FACTION_CULT) //we only serve the cult
if(isnull(cult_icon_state))
add_atom_colour(RUNE_COLOR_MEDIUMRED, FIXED_COLOUR_PRIORITY)
var/static/list/cult_appetite = list(
/obj/item/organ,
/obj/effect/decal/cleanable/blood,
)
var/static/list/death_loot = list(
/obj/effect/gibspawner/generic,
/obj/item/soulstone,
)
AddElement(/datum/element/basic_eating, heal_amt = 15, food_types = cult_appetite)
AddElement(/datum/element/death_drops, death_loot)
basic_mob_flags &= DEL_ON_DEATH
qdel(ai_controller)
ai_controller = new /datum/ai_controller/basic_controller/pet_cult(src)
var/datum/action/cooldown/spell/conjure/revive_rune/rune_ability = new(src)
rune_ability.Grant(src)
ai_controller.set_blackboard_key(BB_RUNE_ABILITY, rune_ability)
ai_controller.set_blackboard_key(BB_CULT_TEAM, team)
var/static/list/new_pet_commands = list(
/datum/pet_command/point_targeting/attack,
/datum/pet_command/follow,
/datum/pet_command/free,
/datum/pet_command/idle,
/datum/pet_command/untargeted_ability/draw_rune,
)
AddComponent(/datum/component/obeys_commands, new_pet_commands)
RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(activate_rune), override = TRUE)
update_appearance()
return STOP_SACRIFICE
/mob/living/basic/pet/proc/activate_rune(datum/source, atom/target)
SIGNAL_HANDLER
if(!istype(target, /obj/effect/rune/raise_dead))
return NONE
target.attack_hand(src)
return COMPONENT_CANCEL_ATTACK_CHAIN
/mob/living/basic/pet/Login()
. = ..()
if(!. || !client)
return FALSE
if(!(FACTION_CULT in faction))
return
var/datum/team/cult_team = locate(/datum/team/cult) in GLOB.antagonist_teams
if(isnull(cult_team))
return
mind.add_antag_datum(/datum/antagonist/cult, cult_team)
update_appearance(UPDATE_OVERLAYS)
#undef PET_CULT_ATTACK
#undef PET_CULT_HEALTH