Skip to content

Commit

Permalink
[MIRROR] Basic Mob Gorillas [MDB IGNORE] (#24284)
Browse files Browse the repository at this point in the history
* Basic Mob Gorillas (#78918)

Now we can make basic mobs with hands easily so I did, they don't
actually use their hands for anything with AI.
In the future we can come back and share the monkey AI where they pick
up items to hit people with, but frankly few weapons are more deadly
than a gorilla's fists.

IIRC I didn't really change their behaviour much, this is mostly just a
straight conversion. Main difference is that they will prioritise eating
nearby bananas and fruit salads over punching people.

When I make these conversions nowadays I need to decide between "does
this attack at the speed that it did as an NPC mob or the speed it did
as a player?"
I am arbitrarily deciding that gorillas are usually not players and
electing for the former, but tell me if you disagree.

I also made "show basic inhand sprites" into a component shared by
Gorillas, Drones, and Dextrous Guardians (all also now available to
become basic, once I get around to it),

And I added an AI behaviour to run a basic emote. This is similar but
different to "random speech", which kind of sucks and needs rewriting
anyway.
Gorillas don't speak, only ooga.

https://www.youtube.com/watch?v=npuuTBlEb1U

🆑
refactor: Gorillas now use the basic mob framework. Please report any
unusual side effects.
/🆑

* Basic Mob Gorillas

* Modular paths

---------

Co-authored-by: Jacquerel <[email protected]>
Co-authored-by: Giz <[email protected]>
  • Loading branch information
3 people authored and Iajret committed Oct 12, 2023
1 parent 3ab93db commit 7359c0e
Show file tree
Hide file tree
Showing 40 changed files with 399 additions and 173 deletions.
2 changes: 1 addition & 1 deletion _maps/RandomRuins/SpaceRuins/skyrat/gorilla.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/obj/structure/chair/sofa/right/brown{
dir = 4
},
/mob/living/simple_animal/hostile/gorilla{
/mob/living/basic/gorilla{
anchored = 1;
dir = 4;
faction = list("neutral")
Expand Down
7 changes: 6 additions & 1 deletion code/__DEFINES/ai/ai_blackboard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
///How close a mob must be for us to select it as a target, if that is less than how far we can maintain it as a target
#define BB_AGGRO_RANGE "BB_aggro_range"

/// Store a single or list of emotes at this key
#define BB_EMOTE_KEY "BB_emotes"
/// Chance to perform an emote per second
#define BB_EMOTE_CHANCE "BB_EMOTE_CHANCE"

///Turf we want a mob to move to
#define BB_TRAVEL_DESTINATION "BB_travel_destination"

Expand Down Expand Up @@ -105,4 +110,4 @@
#define BB_EMOTE_HEAR "emote_hear"
#define BB_EMOTE_SEE "emote_see"
#define BB_EMOTE_SOUND "emote_sound"
#define BB_EMOTE_CHANCE "emote_chance"
#define BB_SPEAK_CHANCE "emote_chance"
3 changes: 3 additions & 0 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
/// From base of /mob/living/simple_animal/bot/proc/bot_step()
#define COMSIG_MOB_BOT_STEP "mob_bot_step"

/// From base of /mob/proc/update_held_items
#define COMSIG_MOB_UPDATE_HELD_ITEMS "mob_update_held_items"

/// From base of /client/Move(): (list/move_args)
#define COMSIG_MOB_CLIENT_PRE_LIVING_MOVE "mob_client_pre_living_move"
/// Should we stop the current living movement attempt
Expand Down
5 changes: 2 additions & 3 deletions code/__DEFINES/drone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
/// If drones are blacklisted from certain sensitive machines
GLOBAL_VAR_INIT(drone_machine_blacklist_enabled, FALSE)

#define DRONE_HANDS_LAYER 1
#define DRONE_HEAD_LAYER 2
#define DRONE_TOTAL_LAYERS 2
#define DRONE_HEAD_LAYER 1
#define DRONE_TOTAL_LAYERS 1

/// Message displayed when new drone spawns in drone network
#define DRONE_NET_CONNECT span_notice("DRONE NETWORK: [name] connected.")
Expand Down
5 changes: 2 additions & 3 deletions code/__DEFINES/guardian_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
#define GUARDIAN_THEME_CARP "carp"
#define GUARDIAN_THEME_MINER "miner"

#define GUARDIAN_COLOR_LAYER 2
#define GUARDIAN_HANDS_LAYER 1
#define GUARDIAN_TOTAL_LAYERS 2
#define GUARDIAN_COLOR_LAYER 1
#define GUARDIAN_TOTAL_LAYERS 1
33 changes: 33 additions & 0 deletions code/datums/ai/basic_mobs/basic_subtrees/run_emote.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/// Intermittently run an emote
/datum/ai_planning_subtree/run_emote
var/emote_key = BB_EMOTE_KEY
var/emote_chance_key = BB_EMOTE_CHANCE

/datum/ai_planning_subtree/run_emote/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
var/emote_chance = controller.blackboard[emote_chance_key] || 0
if (!SPT_PROB(emote_chance, seconds_per_tick))
return
controller.queue_behavior(/datum/ai_behavior/run_emote, emote_key)

/// Emote from a blackboard key
/datum/ai_behavior/run_emote

/datum/ai_behavior/run_emote/perform(seconds_per_tick, datum/ai_controller/controller, emote_key)
var/mob/living/living_pawn = controller.pawn
if (!isliving(living_pawn))
finish_action(controller, FALSE)
return

var/list/emote_list = controller.blackboard[emote_key]
var/emote
if (islist(emote_list))
emote = length(emote_list) ? pick(emote_list) : null
else
emote = emote_list

if(isnull(emote))
finish_action(controller, FALSE)
return

living_pawn.emote(emote)
finish_action(controller, TRUE)
2 changes: 1 addition & 1 deletion code/datums/ai/basic_mobs/basic_subtrees/speech_subtree.dm
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,6 @@
emote_see = speech_lines[BB_EMOTE_SEE] || list()
emote_hear = speech_lines[BB_EMOTE_HEAR] || list()
sound = speech_lines[BB_EMOTE_SOUND] || list()
speech_chance = speech_lines[BB_EMOTE_CHANCE] ? speech_lines[BB_EMOTE_CHANCE] : initial(speech_chance)
speech_chance = speech_lines[BB_SPEAK_CHANCE] ? speech_lines[BB_SPEAK_CHANCE] : initial(speech_chance)

return ..()
50 changes: 50 additions & 0 deletions code/datums/components/basic_inhands.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Basic handling for showing held items in a mob's hands
*/
/datum/component/basic_inhands
/// Layer index we show our inhands upon
var/display_layer
/// Y offset to apply to inhands
var/y_offset
/// X offset to apply to inhands, is inverted for the left hand
var/x_offset
/// What overlays are we currently showing?
var/list/cached_overlays

/datum/component/basic_inhands/Initialize(display_layer = 1, y_offset = 0, x_offset = 0)
. = ..()
if (!isliving(parent))
return COMPONENT_INCOMPATIBLE
src.display_layer = display_layer
src.y_offset = y_offset
src.x_offset = x_offset
cached_overlays = list()

/datum/component/basic_inhands/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_updated_overlays))
RegisterSignal(parent, COMSIG_MOB_UPDATE_HELD_ITEMS, PROC_REF(on_updated_held_items))

/datum/component/basic_inhands/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, list(COMSIG_ATOM_UPDATE_OVERLAYS, COMSIG_MOB_UPDATE_HELD_ITEMS))

/// When your overlays update, add your held overlays
/datum/component/basic_inhands/proc/on_updated_overlays(atom/parent_atom, list/overlays)
SIGNAL_HANDLER
overlays += cached_overlays

/// When your number of held items changes, regenerate held icons
/datum/component/basic_inhands/proc/on_updated_held_items(mob/living/holding_mob)
SIGNAL_HANDLER
var/list/held_overlays = list()
for(var/obj/item/held in holding_mob.held_items)
var/is_right = holding_mob.get_held_index_of_item(held) % 2 == 0
var/icon_file = is_right ? held.righthand_file : held.lefthand_file
var/mutable_appearance/held_overlay = held.build_worn_icon(default_layer = HANDS_LAYER, default_icon_file = icon_file, isinhands = TRUE)
held_overlay.pixel_y += y_offset
held_overlay.pixel_x += x_offset * (is_right ? 1 : -1)
held_overlays += held_overlay

cached_overlays = held_overlays
holding_mob.update_appearance(UPDATE_OVERLAYS)
2 changes: 1 addition & 1 deletion code/datums/elements/amputating_limbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

/// Chop one off
/datum/element/amputating_limbs/proc/amputate(mob/living/surgeon, mob/living/carbon/victim, obj/item/bodypart/to_remove)
surgeon.visible_message(span_warning("[surgeon] begins [surgery_verb] [to_remove] off of [victim]!"))
surgeon.visible_message(span_warning("[surgeon] [surgery_verb] [to_remove] off of [victim]!"))
if (surgery_time > 0 && !do_after(surgeon, delay = surgery_time, target = victim))
return
to_remove.dismember()
2 changes: 1 addition & 1 deletion code/datums/memory/_memory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
/mob/living/basic/cow/wisdom,
/mob/living/basic/crab,
/mob/living/basic/goat,
/mob/living/basic/gorilla,
/mob/living/basic/headslug,
/mob/living/basic/killer_tomato,
/mob/living/basic/lizard,
Expand All @@ -274,7 +275,6 @@
/mob/living/basic/statue,
/mob/living/basic/stickman,
/mob/living/basic/stickman/dog,
/mob/living/simple_animal/hostile/gorilla,
/mob/living/simple_animal/hostile/megafauna/dragon/lesser,
/mob/living/simple_animal/parrot,
/mob/living/simple_animal/pet/cat,
Expand Down
4 changes: 2 additions & 2 deletions code/datums/station_traits/neutral_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
show_in_report = FALSE // Selective attention test. Did you spot the gorilla?

/// The gorilla we created, we only hold this ref until the round starts.
var/mob/living/simple_animal/hostile/gorilla/cargo_domestic/cargorilla
var/mob/living/basic/gorilla/cargorilla/cargorilla

/datum/station_trait/cargorilla/New()
. = ..()
Expand Down Expand Up @@ -189,7 +189,7 @@
cargorilla = null

/// Get us a ghost for the gorilla.
/datum/station_trait/cargorilla/proc/get_ghost_for_gorilla(mob/living/simple_animal/hostile/gorilla/cargo_domestic/gorilla)
/datum/station_trait/cargorilla/proc/get_ghost_for_gorilla(mob/living/basic/gorilla/cargorilla/gorilla)
if(QDELETED(gorilla))
return

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/food/monkeycube.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
/datum/reagent/medicine/strange_reagent = 5,
)
tastes = list("the jungle" = 1, "bananas" = 1, "jimmies" = 1)
spawned_mob = /mob/living/simple_animal/hostile/gorilla
spawned_mob = /mob/living/basic/gorilla

/obj/item/food/monkeycube/chicken
name = "chicken cube"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/traitor/objectives/kill_pet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
JOB_CHIEF_MEDICAL_OFFICER = /mob/living/simple_animal/pet/cat/runtime,
JOB_CHIEF_ENGINEER = /mob/living/simple_animal/parrot/poly,
JOB_QUARTERMASTER = list(
/mob/living/basic/gorilla/cargorilla,
/mob/living/basic/sloth/citrus,
/mob/living/basic/sloth/paperwork,
/mob/living/simple_animal/hostile/gorilla/cargo_domestic,
)
)
/// The head that we are targetting
Expand Down
4 changes: 4 additions & 0 deletions code/modules/mob/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@
I.dropped(src)
return FALSE

/// Returns true if a mob is holding something
/mob/proc/is_holding_items()
return !!locate(/obj/item) in held_items

/mob/proc/drop_all_held_items()
. = FALSE
for(var/obj/item/I in held_items)
Expand Down
25 changes: 25 additions & 0 deletions code/modules/mob/living/basic/basic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,28 @@
else if(on_fire && !isnull(last_icon_state))
return last_icon_state
return null
<<<<<<< HEAD
=======

/mob/living/basic/put_in_hands(obj/item/I, del_on_fail = FALSE, merge_stacks = TRUE, ignore_animation = TRUE)
. = ..()
if (.)
update_held_items()

/mob/living/basic/update_held_items()
. = ..()
if(isnull(client) || isnull(hud_used) || hud_used.hud_version == HUD_STYLE_NOHUD)
return
var/turf/our_turf = get_turf(src)
for(var/obj/item/held in held_items)
var/index = get_held_index_of_item(held)
SET_PLANE(held, ABOVE_HUD_PLANE, our_turf)
held.screen_loc = ui_hand_position(index)
client.screen |= held

/mob/living/basic/get_body_temp_heat_damage_limit()
return maximum_survivable_temperature

/mob/living/basic/get_body_temp_cold_damage_limit()
return minimum_survivable_temperature
>>>>>>> b2ccdeab8b9 ([MIRROR] Basic Mob Gorillas [MDB IGNORE] (#24284))
16 changes: 8 additions & 8 deletions code/modules/mob/living/basic/clown/clown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
BB_EMOTE_SAY = list("HONK", "Honk!", "Welcome to clown planet!"),
BB_EMOTE_HEAR = list("honks", "squeaks"),
BB_EMOTE_SOUND = list('sound/items/bikehorn.ogg'), //WE LOVE TO PARTY
BB_EMOTE_CHANCE = 5,
BB_SPEAK_CHANCE = 5,
)
///do we waddle (honk)
var/waddles = TRUE
Expand Down Expand Up @@ -150,9 +150,9 @@
),
BB_EMOTE_HEAR = list("honks", "contemplates its existence"),
BB_EMOTE_SEE = list("sweats", "jiggles"),
BB_EMOTE_CHANCE = 5,
BB_SPEAK_CHANCE = 5,
)

/mob/living/basic/clown/fleshclown/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT)
Expand Down Expand Up @@ -185,7 +185,7 @@
emotes = list(
BB_EMOTE_SAY = list("YA-HONK!!!"),
BB_EMOTE_HEAR = list("honks", "squeaks"),
BB_EMOTE_CHANCE = 60,
BB_SPEAK_CHANCE = 60,
)

/mob/living/basic/clown/clownhulk
Expand Down Expand Up @@ -221,7 +221,7 @@
BB_EMOTE_SAY = list("HONK", "Honk!", "HAUAUANK!!!", "GUUURRRRAAAHHH!!!"),
BB_EMOTE_HEAR = list("honks", "grunts"),
BB_EMOTE_SEE = list("sweats"),
BB_EMOTE_CHANCE = 5,
BB_SPEAK_CHANCE = 5,
)

/mob/living/basic/clown/clownhulk/chlown
Expand Down Expand Up @@ -252,7 +252,7 @@
emotes = list(
BB_EMOTE_SAY = list("HONK", "Honk!", "Bruh", "cheeaaaahhh?"),
BB_EMOTE_SEE = list("asserts his dominance", "emasculates everyone implicitly"),
BB_EMOTE_CHANCE = 5,
BB_SPEAK_CHANCE = 5,
)

/mob/living/basic/clown/clownhulk/honkmunculus
Expand Down Expand Up @@ -318,7 +318,7 @@
BB_EMOTE_SAY = list("HONK!!!", "The Honkmother is merciful, so I must act out her wrath.", "parce mihi ad beatus honkmother placet mihi ut peccata committere,", "DIE!!!"),
BB_EMOTE_HEAR = list("honks", "grunts"),
BB_EMOTE_SEE = list("sweats"),
BB_EMOTE_CHANCE = 5,
BB_SPEAK_CHANCE = 5,
)

/mob/living/basic/clown/mutant
Expand Down Expand Up @@ -354,7 +354,7 @@
emotes = list(
BB_EMOTE_SAY = list("aaaaaahhhhuuhhhuhhhaaaaa", "AAAaaauuuaaAAAaauuhhh", "huuuuuh... hhhhuuuooooonnnnkk", "HuaUAAAnKKKK"),
BB_EMOTE_SEE = list("squirms", "writhes", "pulsates", "froths", "oozes"),
BB_EMOTE_CHANCE = 10,
BB_SPEAK_CHANCE = 10,
)

/mob/living/basic/clown/mutant/slow
Expand Down
Loading

0 comments on commit 7359c0e

Please sign in to comment.