mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 20:20:33 +01:00
Fixes riding abilities by sharing action buttons (#61854)
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
var/icon_icon = 'icons/hud/actions.dmi' //This is the file for the ACTION icon
|
||||
var/button_icon_state = "default" //And this is the state for the action icon
|
||||
var/mob/owner
|
||||
///All mobs that are sharing our action button.
|
||||
var/list/sharers = list()
|
||||
|
||||
/datum/action/New(Target)
|
||||
link_to(Target)
|
||||
@@ -78,6 +80,12 @@
|
||||
Remove(owner)
|
||||
|
||||
/datum/action/proc/Remove(mob/M)
|
||||
for(var/datum/weakref/reference as anything in sharers)
|
||||
var/mob/freeloader = reference.resolve()
|
||||
if(!freeloader)
|
||||
continue
|
||||
Unshare(freeloader)
|
||||
sharers = null
|
||||
if(M)
|
||||
if(M.client)
|
||||
M.client.screen -= button
|
||||
@@ -149,6 +157,25 @@
|
||||
SIGNAL_HANDLER
|
||||
UpdateButtonIcon()
|
||||
|
||||
//Adds our action button to the screen of another player
|
||||
/datum/action/proc/Share(mob/freeloader)
|
||||
if(!freeloader.client)
|
||||
return
|
||||
sharers += WEAKREF(freeloader)
|
||||
freeloader.client.screen += button
|
||||
freeloader.update_action_buttons()
|
||||
|
||||
//Removes our action button from the screen of another player
|
||||
/datum/action/proc/Unshare(mob/freeloader)
|
||||
if(!freeloader.client)
|
||||
return
|
||||
for(var/freeloader_reference in sharers)
|
||||
if(IS_WEAKREF_OF(freeloader, freeloader_reference))
|
||||
sharers -= freeloader_reference
|
||||
break
|
||||
freeloader.client.screen -= button
|
||||
freeloader.update_action_buttons()
|
||||
|
||||
//Presets for item actions
|
||||
/datum/action/item_action
|
||||
check_flags = AB_CHECK_HANDS_BLOCKED|AB_CHECK_CONSCIOUS
|
||||
@@ -672,6 +699,27 @@
|
||||
if(next_use_time > world.time)
|
||||
START_PROCESSING(SSfastprocess, src)
|
||||
|
||||
///Like a cooldown action, but with an associated proc holder.
|
||||
/datum/action/cooldown/spell_like
|
||||
|
||||
/datum/action/cooldown/spell_like/New(Target)
|
||||
..()
|
||||
var/obj/effect/proc_holder/our_proc_holder = target
|
||||
our_proc_holder.action = src
|
||||
name = our_proc_holder.name
|
||||
desc = our_proc_holder.desc
|
||||
icon_icon = our_proc_holder.action_icon
|
||||
button_icon_state = our_proc_holder.action_icon_state
|
||||
background_icon_state = our_proc_holder.action_background_icon_state
|
||||
button.name = name
|
||||
|
||||
/datum/action/cooldown/spell_like/Trigger()
|
||||
if(!..())
|
||||
return FALSE
|
||||
if(target)
|
||||
var/obj/effect/proc_holder/our_proc_holder = target
|
||||
our_proc_holder.Click()
|
||||
return TRUE
|
||||
|
||||
//Stickmemes
|
||||
/datum/action/item_action/stickmen
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
var/can_be_driven = TRUE
|
||||
/// If TRUE, this creature's abilities can be triggered by the rider while mounted
|
||||
var/can_use_abilities = FALSE
|
||||
var/list/shared_action_buttons = list()
|
||||
|
||||
/datum/component/riding/creature/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = NONE, potion_boost = FALSE)
|
||||
if(!isliving(parent))
|
||||
@@ -129,24 +130,32 @@
|
||||
force_dismount(yeet_mob, (!user.combat_mode)) // gentle on help, byeeee if not
|
||||
|
||||
/// If the ridden creature has abilities, and some var yet to be made is set to TRUE, the rider will be able to control those abilities
|
||||
/datum/component/riding/creature/proc/setup_abilities(mob/living/M)
|
||||
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/creature/proc/remove_abilities(mob/living/M)
|
||||
/datum/component/riding/creature/proc/setup_abilities(mob/living/rider)
|
||||
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)
|
||||
for(var/ability in ridden_creature.abilities)
|
||||
var/obj/effect/proc_holder/proc_holder = ability
|
||||
if(!proc_holder.action)
|
||||
return
|
||||
proc_holder.action.Share(rider)
|
||||
|
||||
/// Takes away the riding parent's abilities from the rider
|
||||
/datum/component/riding/creature/proc/remove_abilities(mob/living/rider)
|
||||
if(!istype(parent, /mob/living))
|
||||
return
|
||||
|
||||
var/mob/living/ridden_creature = parent
|
||||
|
||||
for(var/ability in ridden_creature.abilities)
|
||||
var/obj/effect/proc_holder/proc_holder = ability
|
||||
if(!proc_holder.action)
|
||||
return
|
||||
if(rider == proc_holder.ranged_ability_user)
|
||||
proc_holder.remove_ranged_ability()
|
||||
proc_holder.action.Unshare(rider)
|
||||
|
||||
///////Yes, I said humans. No, this won't end well...//////////
|
||||
/datum/component/riding/creature/human
|
||||
|
||||
Reference in New Issue
Block a user