Files
Bubberstation/code/datums/components/regenerative_shield.dm
SkyratBot 48383f32d3 [MIRROR] minebot buff (#27106)
* minebot buff (#82001)

## About The Pull Request
this pr buffs non-sentient minebots a bit to make them more helpful with
the new arcmining changes.
Minebots now have a better overall AI, they will maintain distance from
enemies and shoot while running. they will also plant landmines while
theyre running away from enemies. these landmines are carefully
programmed by the bot not to trigger when any of its miner friends step
on it. u no longer need to feed minebots an ore to get them to listen to
you, as they now automatically listen to any miners around.
minebots can now repair damaged node drones

![image](https://github.com/tgstation/tgstation/assets/138636438/12e67eb2-3711-465c-a3ac-54fdadbed5e4)
they also have a new autodefend feature, which makes them automatically
attack any mob that attacks its miner friends or the drone. They also
have some new upgrades!
First is the regenerative shield, this shield allows minebots to tank a
limited amount of hits before breaking. minebots will then need to wait
sometime before the shield re-activates.
Second is the rocket launcher remote control, this allows players to
direct minebots to fire anti-fauna missiles at their target

https://github.com/tgstation/tgstation/assets/138636438/3ec3605e-8e11-4a31-acaa-1382bed98294

Also minebots are now highly customizable, you can rename them, change
their colors, or program their AI through their new user interface

![image](https://github.com/tgstation/tgstation/assets/138636438/d2e1c39d-f9d2-4da7-a5fa-5a41cea31d6e)

## Why It's Good For The Game
Improves minebot AI a bit, and makes it a more viable option for mining
solo players

## Changelog
🆑
balance: minebots have been buffed and have recieved new upgrades
/🆑

* minebot buff

---------

Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
2024-04-04 14:48:31 -04:00

92 lines
3.2 KiB
Plaintext

#define SHIELD_FILTER "shield filter"
/// gives the mobs a regenerative shield, it will tank hits for them and then need to recharge for a bit
/datum/component/regenerative_shield
///number of hits we can tank
var/number_of_hits = 15
///the limit of the damage we can tank
var/damage_threshold
///the overlay of the shield
var/list/shield_overlays = list()
///how long before the shield can regenerate
var/regeneration_time
/datum/component/regenerative_shield/Initialize(number_of_hits = 15, damage_threshold = 50, regeneration_time = 2 MINUTES, list/shield_overlays)
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
src.number_of_hits = number_of_hits
src.damage_threshold = damage_threshold
src.regeneration_time = regeneration_time
var/atom/movable/living_parent = parent
for(var/type_path as anything in shield_overlays)
if(!ispath(type_path))
continue
var/obj/effect/overlay/new_effect = new type_path()
living_parent.vis_contents += new_effect
apply_filter_effects(new_effect)
src.shield_overlays += new_effect
/datum/component/regenerative_shield/RegisterWithParent()
. = ..()
ADD_TRAIT(parent, TRAIT_REGEN_SHIELD, REF(src))
RegisterSignal(parent, COMSIG_LIVING_CHECK_BLOCK, PROC_REF(block_attack))
/datum/component/regenerative_shield/UnregisterFromParent()
var/atom/movable/living_parent = parent
for(var/obj/effect/overlay as anything in shield_overlays)
living_parent.vis_contents -= overlay
QDEL_LIST(shield_overlays)
UnregisterSignal(parent, COMSIG_LIVING_CHECK_BLOCK)
REMOVE_TRAIT(parent, TRAIT_REGEN_SHIELD, REF(src))
return ..()
/datum/component/regenerative_shield/proc/block_attack(
mob/living/source,
atom/hitby,
damage,
attack_text,
attack_type,
armour_penetration,
damage_type,
attack_flag,
)
SIGNAL_HANDLER
if(damage <= 0 ||damage_type == STAMINA)
return NONE
if(damage >= damage_threshold || number_of_hits <= 0)
return NONE
playsound(get_turf(parent), 'sound/weapons/tap.ogg', 20)
new /obj/effect/temp_visual/guardian/phase/out(get_turf(parent))
number_of_hits = max(0, number_of_hits - 1)
if(number_of_hits <= 0)
disable_shield()
return SUCCESSFUL_BLOCK
/datum/component/regenerative_shield/proc/disable_shield()
addtimer(CALLBACK(src, PROC_REF(enable_shield)), regeneration_time)
for(var/obj/effect/my_effect as anything in shield_overlays)
animate(my_effect, alpha = 0, time = 3 SECONDS)
my_effect.remove_filter(SHIELD_FILTER)
playsound(parent, 'sound/mecha/mech_shield_drop.ogg', 20)
/datum/component/regenerative_shield/proc/enable_shield()
number_of_hits = initial(number_of_hits)
for(var/obj/effect/my_effect as anything in shield_overlays)
animate(my_effect, alpha = 255, time = 3 SECONDS)
addtimer(CALLBACK(src, PROC_REF(apply_filter_effects), my_effect), 5 SECONDS)
playsound(parent, 'sound/mecha/mech_shield_raise.ogg', 20)
/datum/component/regenerative_shield/proc/apply_filter_effects(obj/effect/new_effect)
if(isnull(new_effect))
return
new_effect.add_filter(SHIELD_FILTER, 1, list("type" = "outline", "color" = "#b6e6f3", "alpha" = 0, "size" = 1))
var/filter = new_effect.get_filter(SHIELD_FILTER)
animate(filter, alpha = 200, time = 0.5 SECONDS, loop = -1)
animate(alpha = 0, time = 0.5 SECONDS)
#undef SHIELD_FILTER