From 6f0c0fe39bfdaefde612a6039b3f54e261e217a0 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 9 Sep 2020 08:22:05 +0200 Subject: [PATCH] [MIRROR] Allows you to use the ability of vatbeasts when riding them (#714) * Allows you to use the ability of vatbeasts when riding them (#53266) * Allows you to use the ability of vatbeasts when riding them Co-authored-by: Qustinnus --- code/datums/components/riding.dm | 30 +++++++++++++++++++ .../living/simple_animal/hostile/vatbeast.dm | 15 +++++----- code/modules/spells/spell.dm | 4 ++- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/code/datums/components/riding.dm b/code/datums/components/riding.dm index b62a7a189f3..d53b456822b 100644 --- a/code/datums/components/riding.dm +++ b/code/datums/components/riding.dm @@ -7,6 +7,9 @@ var/slowed = FALSE var/slowvalue = 1 + ///Bool to check if you gain the ridden mob's abilities. + var/can_use_abilities = FALSE + var/list/riding_offsets = list() //position_of_user = list(dir = list(px, py)), or RIDING_OFFSET_ALL for a generic one. var/list/directional_vehicle_layers = list() //["[DIRECTION]"] = layer. Don't set it for a direction for default, set a direction to null for no change. var/list/directional_vehicle_offsets = list() //same as above but instead of layer you have a list(px, py) @@ -37,6 +40,7 @@ SIGNAL_HANDLER var/atom/movable/AM = parent + remove_abilities(M) restore_position(M) unequip_buckle_inhands(M) M.updating_glide_size = TRUE @@ -50,6 +54,32 @@ M.set_glide_size(movable_parent.glide_size) M.updating_glide_size = FALSE handle_vehicle_offsets(movable_parent.dir) + if(can_use_abilities) + setup_abilities(M) + +///Gives the rider the riding parent's abilities +/datum/component/riding/proc/setup_abilities(mob/living/M) + + if(!istype(parent, /mob/living)) + return + + var/mob/living/ridden_creature = parent + + for(var/i in ridden_creature.abilities) + var/obj/effect/proc_holder/proc_holder = i + M.AddAbility(proc_holder) + +///Takes away the riding parent's abilities from the rider +/datum/component/riding/proc/remove_abilities(mob/living/M) + + if(!istype(parent, /mob/living)) + return + + var/mob/living/ridden_creature = parent + + for(var/i in ridden_creature.abilities) + var/obj/effect/proc_holder/proc_holder = i + M.RemoveAbility(proc_holder) /datum/component/riding/proc/handle_vehicle_layer(dir) var/atom/movable/AM = parent diff --git a/code/modules/mob/living/simple_animal/hostile/vatbeast.dm b/code/modules/mob/living/simple_animal/hostile/vatbeast.dm index 68b953acfa6..42181915547 100644 --- a/code/modules/mob/living/simple_animal/hostile/vatbeast.dm +++ b/code/modules/mob/living/simple_animal/hostile/vatbeast.dm @@ -28,7 +28,7 @@ /mob/living/simple_animal/hostile/vatbeast/Initialize() . = ..() - tentacle_slap = new + tentacle_slap = new(src) AddAbility(tentacle_slap) add_cell_sample() @@ -41,6 +41,7 @@ can_buckle = TRUE buckle_lying = 0 var/datum/component/riding/riding = LoadComponent(/datum/component/riding) + riding.can_use_abilities = TRUE riding.set_riding_offsets(RIDING_OFFSET_ALL, list(TEXT_NORTH = list(0, 15), TEXT_SOUTH = list(0, 15), TEXT_EAST = list(-10, 15), TEXT_WEST = list(10, 15))) riding.set_vehicle_dir_layer(SOUTH, ABOVE_MOB_LAYER) riding.set_vehicle_dir_layer(NORTH, OBJ_LAYER) @@ -85,7 +86,7 @@ if(.) return - if(!istype(ranged_ability_user, /mob/living/simple_animal/hostile/vatbeast) || ranged_ability_user.stat) + if(owner.stat) remove_ranged_ability() return @@ -97,12 +98,10 @@ var/mob/living/living_target = target - var/mob/living/simple_animal/hostile/vatbeast/vatbeast = ranged_ability_user - - vatbeast.visible_message("You slap [living_target] with your tentacle.") - playsound(vatbeast, 'sound/effects/assslap.ogg', 90) - var/atom/throw_target = get_edge_target_turf(target, vatbeast.dir) - living_target.throw_at(throw_target, 6, 4, vatbeast) + owner.visible_message("You slap [living_target] with your tentacle.") + playsound(owner, 'sound/effects/assslap.ogg', 90) + var/atom/throw_target = get_edge_target_turf(target, ranged_ability_user.dir) + living_target.throw_at(throw_target, 6, 4, owner) living_target.apply_damage(30) current_cooldown = world.time + cooldown remove_ranged_ability() diff --git a/code/modules/spells/spell.dm b/code/modules/spells/spell.dm index dd06bc386a2..77150ac3176 100644 --- a/code/modules/spells/spell.dm +++ b/code/modules/spells/spell.dm @@ -14,9 +14,11 @@ var/action_icon_state = "spell_default" var/action_background_icon_state = "bg_spell" var/base_action = /datum/action/spell_action + var/mob/living/owner -/obj/effect/proc_holder/Initialize() +/obj/effect/proc_holder/Initialize(mob/living/owner) . = ..() + src.owner = owner if(has_action) action = new base_action(src)