Spiders/carp will now pull/move water/welding fuel tanks/canisters slower and won't be able to attack stationary atmospherics equipment (#61616)

Adds 2 new elements, one for slowing down pulling of dangerous objects (dispenser tanks and canisters), and one for preventing hostile attacking of elements in a typecache.

Also updates the obj_flags bitfield 'cause I thought I was gonna use that, but I didn't.

Adds these elements to spiders and space carp (from space dragon)
This commit is contained in:
Mothblocks
2021-09-24 04:07:03 +01:00
committed by GitHub
parent 029a74c821
commit f13dd0695d
10 changed files with 125 additions and 0 deletions
+5
View File
@@ -345,6 +345,11 @@
///called on /living, when pull is attempted, but before it completes, from base of [/mob/living/start_pulling]: (atom/movable/thing, force)
#define COMSIG_LIVING_TRY_PULL "living_try_pull"
#define COMSIG_LIVING_CANCEL_PULL (1 << 0)
/// Called from /mob/living/update_pull_movespeed
#define COMSIG_LIVING_UPDATING_PULL_MOVESPEED "living_updating_pull_movespeed"
/// Called from /mob/living/PushAM -- Called when this mob is about to push a movable, but before it moves
/// (aotm/movable/being_pushed)
#define COMSIG_LIVING_PUSHING_MOVABLE "living_pushing_movable"
///from base of [/atom/proc/interact]: (mob/user)
#define COMSIG_ATOM_UI_INTERACT "atom_ui_interact"
///called on /living when attempting to pick up an item, from base of /mob/living/put_in_hand_check(): (obj/item/I)
+5
View File
@@ -250,11 +250,16 @@ DEFINE_BITFIELD(movement_type, list(
DEFINE_BITFIELD(obj_flags, list(
"BEING_SHOCKED" = BEING_SHOCKED,
"BLOCK_Z_IN_DOWN" = BLOCK_Z_IN_DOWN,
"BLOCK_Z_IN_UP" = BLOCK_Z_IN_UP,
"BLOCK_Z_OUT_DOWN" = BLOCK_Z_OUT_DOWN,
"BLOCK_Z_OUT_UP" = BLOCK_Z_OUT_UP,
"CAN_BE_HIT" = CAN_BE_HIT,
"DANGEROUS_POSSESSION" = DANGEROUS_POSSESSION,
"EMAGGED" = EMAGGED,
"FROZEN" = FROZEN,
"IN_USE" = IN_USE,
"NO_BUILD" = NO_BUILD,
"ON_BLUEPRINTS" = ON_BLUEPRINTS,
"UNIQUE_RENAME" = UNIQUE_RENAME,
"USES_TGUI" = USES_TGUI,
+13
View File
@@ -13,3 +13,16 @@ GLOBAL_LIST_INIT(typecache_machine_or_structure, typecacheof(list(/obj/machinery
/// A typecache listing structures that are considered to have surfaces that you can place items on that are higher than the floor. This, of course, should be restricted to /atom/movables. This is primarily used for food decomposition code.
GLOBAL_LIST_INIT(typecache_elevated_structures, typecacheof(list(/obj/structure/table,/obj/structure/rack,/obj/machinery/conveyor,/obj/structure/closet)))
/// A typecache of objects that player controlled, easily accessible, hostile mobs should not be able to attack
GLOBAL_LIST_INIT(typecache_general_bad_hostile_attack_targets, typecacheof(list(
/obj/machinery/airalarm,
/obj/machinery/atmospherics,
/obj/machinery/power/apc,
)))
/// A typecache of objects that player controlled, easily accessible, hostile mobs should not be able to move around easily
GLOBAL_LIST_INIT(typecache_general_bad_things_to_easily_move, typecacheof(list(
/obj/machinery/portable_atmospherics/canister,
/obj/structure/reagent_dispensers,
)))
+53
View File
@@ -0,0 +1,53 @@
/// This living will be slower when pulling/moving anything in the given typecache
/datum/element/nerfed_pulling
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH
id_arg_index = 2
/// The typecache of things that shouldn't be easily movable
var/list/typecache
/datum/element/nerfed_pulling/Attach(datum/target, list/typecache)
. = ..()
if (!isliving(target))
return ELEMENT_INCOMPATIBLE
src.typecache = typecache
RegisterSignal(target, COMSIG_LIVING_PUSHING_MOVABLE, .proc/on_push_movable)
RegisterSignal(target, COMSIG_LIVING_UPDATING_PULL_MOVESPEED, .proc/on_updating_pull_movespeed)
/datum/element/nerfed_pulling/Detach(mob/living/source)
source.remove_movespeed_modifier(/datum/movespeed_modifier/nerfed_bump)
source.remove_movespeed_modifier(/datum/movespeed_modifier/nerfed_pull)
UnregisterSignal(source, list(COMSIG_LIVING_PUSHING_MOVABLE, COMSIG_LIVING_UPDATING_PULL_MOVESPEED))
return ..()
/datum/element/nerfed_pulling/proc/on_push_movable(mob/living/source, atom/movable/being_pushed)
SIGNAL_HANDLER
if (!will_slow_down(being_pushed))
return
source.add_movespeed_modifier(/datum/movespeed_modifier/nerfed_bump)
addtimer(CALLBACK(source, /mob/proc/remove_movespeed_modifier, /datum/movespeed_modifier/nerfed_bump), 1 SECONDS, TIMER_OVERRIDE | TIMER_UNIQUE)
/datum/element/nerfed_pulling/proc/on_updating_pull_movespeed(mob/living/source)
SIGNAL_HANDLER
if (!will_slow_down(source.pulling))
source.remove_movespeed_modifier(/datum/movespeed_modifier/nerfed_pull)
return
source.add_movespeed_modifier(/datum/movespeed_modifier/nerfed_pull)
/datum/element/nerfed_pulling/proc/will_slow_down(datum/input)
return !isnull(input) && typecache[input.type]
/datum/movespeed_modifier/nerfed_pull
multiplicative_slowdown = 5.5
/datum/movespeed_modifier/nerfed_bump
multiplicative_slowdown = 5.5
@@ -0,0 +1,38 @@
/// This hostile will not be able to attack a given typecache, and will receive
/// a balloon alert when it tries to.
/datum/element/prevent_attacking_of_types
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH
id_arg_index = 2
/// The typecache of things this hostile can't attack
var/list/typecache
/// The message to send to the hostile mob when they try to attack something they can't
var/alert_message
/datum/element/prevent_attacking_of_types/Attach(datum/target, list/typecache, alert_message)
. = ..()
if (!ishostile(target))
return ELEMENT_INCOMPATIBLE
src.alert_message = alert_message
src.typecache = typecache
RegisterSignal(target, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, .proc/on_pre_attacking_target)
/datum/element/prevent_attacking_of_types/Detach(datum/source, ...)
UnregisterSignal(source, COMSIG_HOSTILE_PRE_ATTACKINGTARGET)
return ..()
/datum/element/prevent_attacking_of_types/proc/on_pre_attacking_target(mob/source, atom/target)
SIGNAL_HANDLER
if (!typecache[target.type])
return
target.balloon_alert(source, alert_message)
return COMPONENT_HOSTILE_NO_ATTACK
+1
View File
@@ -216,6 +216,7 @@
if(!client && (mob_size < MOB_SIZE_SMALL))
return
now_pushing = TRUE
SEND_SIGNAL(src, COMSIG_LIVING_PUSHING_MOVABLE, AM)
var/dir_to_target = get_dir(src, AM)
// If there's no dir_to_target then the player is on the same turf as the atom they're trying to push.
@@ -34,6 +34,8 @@
/mob/living/proc/update_pull_movespeed()
SEND_SIGNAL(src, COMSIG_LIVING_UPDATING_PULL_MOVESPEED)
if(pulling)
if(isliving(pulling))
var/mob/living/L = pulling
@@ -69,6 +69,8 @@
lay_web.Grant(src)
if(poison_per_bite)
AddElement(/datum/element/venomous, poison_type, poison_per_bite)
AddElement(/datum/element/nerfed_pulling, GLOB.typecache_general_bad_things_to_easily_move)
AddElement(/datum/element/prevent_attacking_of_types, GLOB.typecache_general_bad_hostile_attack_targets, "this tastes awful!")
/mob/living/simple_animal/hostile/giant_spider/Login()
. = ..()
@@ -696,7 +696,11 @@
if(carp_stored <= 0)
to_chat(user, span_warning("The rift already summoned enough carp!"))
return FALSE
var/mob/living/simple_animal/hostile/carp/newcarp = new /mob/living/simple_animal/hostile/carp(loc)
newcarp.AddElement(/datum/element/nerfed_pulling, GLOB.typecache_general_bad_things_to_easily_move)
newcarp.AddElement(/datum/element/prevent_attacking_of_types, GLOB.typecache_general_bad_hostile_attack_targets, "this tastes awful!")
if(!is_listed)
ckey_list += user.ckey
newcarp.key = user.key
+2
View File
@@ -779,11 +779,13 @@
#include "code\datums\elements\light_eater.dm"
#include "code\datums\elements\movement_turf_changer.dm"
#include "code\datums\elements\movetype_handler.dm"
#include "code\datums\elements\nerfed_pulling.dm"
#include "code\datums\elements\obj_regen.dm"
#include "code\datums\elements\openspace_item_click_handler.dm"
#include "code\datums\elements\pet_bonus.dm"
#include "code\datums\elements\plant_backfire.dm"
#include "code\datums\elements\point_of_interest.dm"
#include "code\datums\elements\prevent_attacking_of_types.dm"
#include "code\datums\elements\rad_insulation.dm"
#include "code\datums\elements\ranged_attacks.dm"
#include "code\datums\elements\ridable.dm"