forked from Monkestation/Monkestation2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors Morphs into Basic Mobs (there is now a swag action for morp…
…hification) (tgstation#77503) I was bored, so did this. Probably one of the neatest refactors I've done, sorry if there's some oddities because I was experimenting with some other stuff in this so just tell me to clean them up whenever I can. Anyways, morphs are basic mobs now. We are able to easily refactor the whole "eat items and corpses" stuff in the basic mob framework, but the whole "morph into objects and people" turned out to be a bit trickier. That was easily rectified with a datum mob cooldown action and copy-pasting the old code into that code, as well as doing some nice stuff with traits and signals to ensure the one-way communication from the action to the mob. Old Morph AI didn't seem to be existant whatsoever, they inappropriately leveraged some old procs and I have no idea how to make it work with new AI. They DEFINITELY don't spawn outside of admin interference/ the event anymore, and will always be controlled by a player, so this shouldn't be too bad of an issue. I gave them something to seem alive just in case though, but I think adding legitimate prop-hunt AI would be such a laborious task that I am unwilling to do it in this PR. If admins want to add the ability for Ian to assume the form of the HoP, they can do that now! The datum action cooldown is quite nice for simple and basic mobs... but it is currently not compatible with carbons. That is not within scope for this PR, but I am dwelling on ways to extend it to carbon but they all sound really awfully bad. Also morphs are smarter, and we tick another simple animal in need of refactoring off the list. :cl: refactor: Morphs are now basic mobs with a nice new ability to help you change forms rather than the old shift-click method, much more intuitive. admin: With the morph rework comes a new ability you can add to mobs, "Assume Form". Feel free to add that to any simple or basic mob for le funnies as Runtime turns into a pen or something. /:cl: ~~Does anyone know if there's a (sane) way to alias a cooldown action as a keypress? I can't think of a good way to retain the old shift-click functionality, because that does feel _kinda_ nice, but I think it can be lived without.~~ I added it. Kinda fugly but whatever.
- Loading branch information
Showing
15 changed files
with
355 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/// Allows a mob to assume the form of another item or mob. | ||
/// Warning, this will likely shit the bricks if you add this action to anything more sophisticated than a basic mob- this isn't built for anything carbon-wise. | ||
/datum/action/cooldown/mob_cooldown/assume_form | ||
name = "Assume Form" | ||
desc = "Choose something that you wish to blend into the environment as. Click on yourself to reset your appearance." | ||
button_icon_state = "sniper_zoom" | ||
background_icon_state = "bg_alien" | ||
overlay_icon_state = "bg_alien_border" | ||
ranged_mousepointer = 'icons/effects/mouse_pointers/supplypod_target.dmi' | ||
check_flags = AB_CHECK_CONSCIOUS | ||
cooldown_time = 1.5 SECONDS | ||
|
||
/// Stuff that we can not disguise as. | ||
var/static/list/blacklist_typecache = typecacheof(list( | ||
/atom/movable/screen, | ||
/obj/effect, | ||
/obj/energy_ball, | ||
/obj/narsie, | ||
/obj/singularity, | ||
)) | ||
|
||
/datum/action/cooldown/mob_cooldown/assume_form/Grant(mob/grant_to) | ||
. = ..() | ||
RegisterSignal(owner, COMSIG_LIVING_DEATH, PROC_REF(reset_appearances)) | ||
|
||
/datum/action/cooldown/mob_cooldown/assume_form/Remove(mob/remove_from) | ||
reset_appearances() | ||
UnregisterSignal(owner, COMSIG_LIVING_DEATH) | ||
return ..() | ||
|
||
/datum/action/cooldown/mob_cooldown/assume_form/Activate(atom/target_atom) | ||
StartCooldown(360 SECONDS, 360 SECONDS) | ||
determine_intent(target_atom) | ||
StartCooldown() | ||
return TRUE | ||
|
||
/// Rapid proc to test if we can assume the form of a given atom. Returns TRUE if we can, FALSE if we can't. Done like this so we can be nice and explicit. | ||
/datum/action/cooldown/mob_cooldown/assume_form/proc/can_assume_form(atom/target_atom) | ||
if(is_type_in_typecache(target_atom, blacklist_typecache) || (!isobj(target_atom) && !ismob(target_atom))) | ||
return FALSE | ||
|
||
return TRUE | ||
|
||
/// Determines what our user meant by their action. If they clicked on themselves, we reset our appearance. Otherwise, we assume the appearance of the clicked-on item. | ||
/datum/action/cooldown/mob_cooldown/assume_form/proc/determine_intent(atom/target_atom) | ||
if(!can_assume_form(target_atom)) | ||
return | ||
|
||
if(target_atom == owner) | ||
reset_appearances() | ||
return | ||
|
||
assume_appearances(target_atom) | ||
|
||
/// Assumes the appearance of a desired movable and applies it to our mob. Target is the movable in question. | ||
/datum/action/cooldown/mob_cooldown/assume_form/proc/assume_appearances(atom/movable/target_atom) | ||
owner.appearance = target_atom.appearance | ||
owner.copy_overlays(target_atom) | ||
owner.alpha = max(target_atom.alpha, 150) //fucking chameleons | ||
owner.transform = initial(target_atom.transform) | ||
owner.pixel_x = target_atom.base_pixel_x | ||
owner.pixel_y = target_atom.base_pixel_y | ||
|
||
// important: do this at the very end because we might have SIGNAL_ADDTRAIT for this on the mob that's dependent on the above logic | ||
SEND_SIGNAL(owner, COMSIG_ACTION_DISGUISED_APPEARANCE, target_atom) | ||
ADD_TRAIT(owner, TRAIT_DISGUISED, REF(src)) | ||
|
||
/// Resets the appearances of the mob to the default. | ||
/datum/action/cooldown/mob_cooldown/assume_form/proc/reset_appearances() | ||
SIGNAL_HANDLER | ||
|
||
if(!HAS_TRAIT(owner, TRAIT_DISGUISED)) | ||
return // in case we're being invoked on death and we aren't disguised (or we just click on ourselves randomly), no need to do this additional work. | ||
|
||
owner.animate_movement = SLIDE_STEPS | ||
owner.maptext = null | ||
owner.alpha = initial(owner.alpha) | ||
owner.color = initial(owner.color) | ||
owner.desc = initial(owner.desc) | ||
|
||
owner.name = initial(owner.name) | ||
owner.icon = initial(owner.icon) | ||
owner.icon_state = initial(owner.icon_state) | ||
owner.cut_overlays() | ||
|
||
// important: do this very end because we might have SIGNAL_REMOVETRAIT for this on the mob that's dependent on the above logic | ||
REMOVE_TRAIT(owner, TRAIT_DISGUISED, REF(src)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.