|
1 | 1 | /mob/living/simple_animal/trained_bird/pigeon |
2 | | - name = "pigeon" |
| 2 | + name = "messenger pigeon" |
3 | 3 | icon = 'mods/pyrelight/icons/mobs/pigeon.dmi' |
4 | 4 | ai = /datum/mob_controller/passive/pigeon |
| 5 | + holder_type = /obj/item/holder/bird/pigeon |
| 6 | + var/weakref/home_hutch |
| 7 | + |
| 8 | +/mob/living/simple_animal/trained_bird/pigeon/Initialize() |
| 9 | + . = ..() |
| 10 | + update_hutch() |
| 11 | + |
| 12 | +/mob/living/simple_animal/trained_bird/pigeon/proc/go_home(mob/releaser) |
| 13 | + dropInto(get_turf(src)) |
| 14 | + if(!is_outside()) |
| 15 | + return |
| 16 | + var/obj/structure/hutch/hutch = home_hutch?.resolve() |
| 17 | + if(!istype(hutch) || QDELETED(hutch)) |
| 18 | + return // todo: check if the hutch is accessible from the sky |
| 19 | + if(releaser) |
| 20 | + releaser.visible_message(SPAN_NOTICE("\The [releaser] releases \a [src], which flutters away into the sky.")) |
| 21 | + else |
| 22 | + visible_message(SPAN_NOTICE("\The [src] flutters away into the sky.")) |
| 23 | + set_dir(SOUTH) |
| 24 | + new /obj/effect/dummy/fadeout(loc, NORTH, src) |
| 25 | + dropInto(hutch) |
| 26 | + hutch.visible_message(SPAN_NOTICE("\A [src] alights on \the [hutch] in a flutter of wings.")) |
| 27 | + |
| 28 | +/obj/item/holder/bird/pigeon/attack_self(mob/user) |
| 29 | + var/mob/living/simple_animal/trained_bird/pigeon/pigeon = locate() in contents |
| 30 | + if(!istype(pigeon)) |
| 31 | + return ..() |
| 32 | + if(!is_outside()) |
| 33 | + to_chat(user, SPAN_WARNING("You need to be outdoors to release \the [pigeon].")) |
| 34 | + return TRUE |
| 35 | + if(isnull(pigeon.home_hutch)) |
| 36 | + var/decl/pronouns/pronouns = pigeon.get_pronouns() |
| 37 | + to_chat(user, SPAN_WARNING("\The [pigeon] tilts [pronouns.his] head at you in confusion. [pronouns.He] must not have a hutch to return to.")) |
| 38 | + else |
| 39 | + releaser.drop_from_inventory(src) |
| 40 | + pigeon.go_home(user) |
| 41 | + qdel(src) |
| 42 | + return TRUE |
| 43 | + |
| 44 | +/mob/living/simple_animal/trained_bird/pigeon/proc/update_hutch() |
| 45 | + var/obj/structure/hutch/hutch = home_hutch?.resolve() |
| 46 | + if(!istype(hutch) || QDELETED(hutch)) |
| 47 | + hutch = get_recursive_loc_of_type(/obj/structure/hutch) |
| 48 | + if(istype(hutch) && !QDELETED(hutch)) |
| 49 | + home_hutch = weakref(hutch) |
| 50 | + events_repository.unregister(/decl/observ/moved, src, src) |
| 51 | + else |
| 52 | + events_repository.register(/decl/observ/moved, src, src, TYPE_PROC_REF(/mob/living/simple_animal/trained_bird/pigeon, update_hutch)) |
5 | 53 |
|
6 | 54 | /datum/mob_controller/passive/pigeon |
7 | 55 | emote_speech = list("Oo-ooo.","Oo-ooo?","Oo-ooo...") |
|
0 commit comments