Non-Hostile Migrations and Angry Goats (#12016)

This commit is contained in:
Geeves
2021-06-21 18:11:54 -03:00
committed by GitHub
parent cfdc63cc94
commit 27944fb32d
14 changed files with 125 additions and 26 deletions
@@ -0,0 +1,51 @@
/mob/living/simple_animal/cosmozoan
name = "cosmozoan"
desc = "These jellyfish-like entities drift through asteroid fields, emitting a soft glow."
desc_info = "Schools of Cosmozoans often congregate in asteroid fields, though they have rarely been witnessed in greater number and size in the Frontier. Their origin remains a mystery but it is believed they predate early man. This belief landed them the name Cosmozoa."
icon_state = "cosmozoan"
icon_living = "cosmozoan"
icon_dead = "cosmozoan_dead"
maxHealth = 15
health = 15
meat_type = /obj/item/reagent_containers/food/snacks/fish/cosmozoan
meat_amount = 2
organ_names = list("hood", "tentacles")
response_help = "pets"
response_disarm = "gently pushes aside"
response_harm = "whacks"
harm_intent_damage = 5
blood_type = COLOR_CRYSTAL
blood_overlay_icon = null
canbrush = TRUE
brush = /obj/item/reagent_containers/glass/rag
wanders_diagonally = TRUE
min_oxy = 0
max_oxy = 0
min_tox = 0
max_tox = 0
min_co2 = 0
max_co2 = 0
min_n2 = 0
max_n2 = 0
minbodytemp = 0
flying = TRUE
see_in_dark = 8
see_invisible = SEE_INVISIBLE_NOLIGHTING
/mob/living/simple_animal/cosmozoan/Initialize()
. = ..()
set_light(1.4, 3, COLOR_CRYSTAL)
// run away when attacked
/mob/living/simple_animal/cosmozoan/handle_attack_by(var/mob/M)
var/list/valid_dirs = alldirs.Copy()
valid_dirs -= get_dir(src, M)
var/turf/target_turf = get_ranged_target_turf(src, pick(valid_dirs), 5)
if(target_turf)
for(var/i = 1 to 5)
if(loc == target_turf)
break
step_to(src, target_turf)
sleep(6)
@@ -48,7 +48,9 @@
..()
//chance to go crazy and start wacking stuff
if(!enemies.len && prob(1))
Retaliate()
var/mob/living/L = locate() in oview(world.view, src)
if(L)
handle_attack_by(L)
if(enemies.len && prob(10))
enemies = list()
@@ -61,10 +63,10 @@
var/step = get_step_to(src, food, 0)
Move(step)
/mob/living/simple_animal/hostile/retaliate/goat/Retaliate()
/mob/living/simple_animal/hostile/retaliate/goat/handle_attack_by(mob/M)
..()
if(stat == CONSCIOUS)
visible_message("<span class='warning'>[src] gets an evil-looking gleam in their eye.</span>")
visible_message(SPAN_WARNING("[src] gets an evil-looking gleam in their eye."))
/mob/living/simple_animal/hostile/retaliate/goat/Move()
..()
@@ -21,30 +21,10 @@
see &= enemies // Remove all entries that aren't in enemies
return see
/mob/living/simple_animal/hostile/retaliate/proc/Retaliate(var/mob/M)
/mob/living/simple_animal/hostile/retaliate/handle_attack_by(mob/M)
enemies |= M
targets |= M
for(var/mob/living/simple_animal/hostile/retaliate/H in view(world.view, get_turf(src)))
if(H.faction == faction)
H.enemies |= M
/mob/living/simple_animal/hostile/retaliate/attack_hand(mob/living/carbon/human/M)
. = ..()
if(M.a_intent in list(I_DISARM, I_GRAB, I_HURT))
Retaliate(M)
/mob/living/simple_animal/hostile/retaliate/attacked_with_item(obj/item/O, mob/user, var/proximity)
. = ..()
if(.)
Retaliate(user)
/mob/living/simple_animal/hostile/retaliate/hitby(atom/movable/AM, speed)
. = ..()
if(ismob(AM.thrower))
Retaliate(AM.thrower)
/mob/living/simple_animal/hostile/retaliate/bullet_act(obj/item/projectile/P, def_zone)
. = ..()
if(ismob(P.firer))
Retaliate(P.firer)
H.enemies |= M
@@ -46,6 +46,7 @@
var/stop_thinking = FALSE // prevents them from doing any AI stuff whatsoever
var/stop_automated_movement = 0 //Use this to temporarely stop random movement or to if you write special movement code for animals.
var/wander = 1 // Does the mob wander around when idle?
var/wanders_diagonally = FALSE // does the mob move diagonally when wandering?
var/stop_automated_movement_when_pulled = 1 //When set to 1 this stops the animal from moving when someone is pulling it.
var/atom/movement_target = null//Thing we're moving towards
var/turns_since_scan = 0
@@ -285,7 +286,7 @@
if(isturf(loc) && !resting && !buckled_to && canmove) //This is so it only moves if it's not inside a closet, gentics machine, etc.
if(turns_since_move >= turns_per_move && !(stop_automated_movement_when_pulled && pulledby)) //Some animals don't move when pulled
var/moving_to = 0 // otherwise it always picks 4, fuck if I know. Did I mention fuck BYOND
moving_to = pick(cardinal)
moving_to = wanders_diagonally ? pick(alldirs) : pick(cardinal)
set_dir(moving_to) //How about we turn them the direction they are moving, yay.
Move(get_step(src,moving_to))
turns_since_move = 0
@@ -454,6 +455,9 @@
var/can_ghosts_hear = client ? GHOSTS_ALL_HEAR : ONLY_GHOSTS_IN_VIEW
custom_emote(AUDIBLE_MESSAGE, act_desc, can_ghosts_hear)
/mob/living/simple_animal/proc/handle_attack_by(var/mob/M)
return
/mob/living/simple_animal/attack_hand(mob/living/carbon/human/M as mob)
..()
switch(M.a_intent)
@@ -467,6 +471,7 @@
M.visible_message("<b>\The [M]</b> [response_disarm] \the [src]")
M.do_attack_animation(src)
poke(1)
handle_attack_by(M)
//TODO: Push the mob away or something
if(I_GRAB)
@@ -489,9 +494,11 @@
M.visible_message(SPAN_WARNING("\The [M] has grabbed \the [src] passively!"))
M.do_attack_animation(src)
poke(1)
handle_attack_by(M)
if(I_HURT)
unarmed_harm_attack(M)
handle_attack_by(M)
return
@@ -580,8 +587,19 @@
if(O.hitsound)
playsound(loc, O.hitsound, O.get_clamped_volume(), 1, -1)
user.do_attack_animation(src, O)
handle_attack_by(user)
return TRUE
/mob/living/simple_animal/hitby(atom/movable/AM, speed)
. = ..()
if(ismob(AM.thrower))
handle_attack_by(AM.thrower)
/mob/living/simple_animal/bullet_act(obj/item/projectile/P, def_zone)
. = ..()
if(ismob(P.firer))
handle_attack_by(P.firer)
/mob/living/simple_animal/apply_damage(damage, damagetype, def_zone, blocked, used_weapon, damage_flags, armor_pen, silent = FALSE)
. = ..()
handle_bleeding_timer(damage)