-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy path_powers_targeted.dm
92 lines (78 loc) · 3.43 KB
/
_powers_targeted.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// NOTE: All Targeted spells are Toggles! We just don't bother checking here.
/datum/action/cooldown/bloodsucker/targeted
power_flags = BP_AM_TOGGLE
///If set, how far the target has to be for the power to work.
var/target_range
///Message sent to chat when clicking on the power, before you use it.
var/prefire_message
///Most powers happen the moment you click. Some, like Mesmerize, require time and shouldn't cost you if they fail.
var/power_activates_immediately = TRUE
///Is this power LOCKED due to being used?
var/power_in_use = FALSE
/// Modify description to add notice that this is aimed.
/datum/action/cooldown/bloodsucker/targeted/New(Target)
desc += "<br>\[<i>Targeted Power</i>\]"
return ..()
/datum/action/cooldown/bloodsucker/targeted/Remove(mob/living/remove_from)
. = ..()
if(remove_from.click_intercept == src)
unset_click_ability(remove_from)
/datum/action/cooldown/bloodsucker/targeted/Trigger(trigger_flags, atom/target)
if(active && can_deactivate())
DeactivatePower()
return FALSE
if(!can_pay_cost(owner) || !CanUse(owner, trigger_flags))
return FALSE
if(prefire_message)
to_chat(owner, span_announce("[prefire_message]"))
ActivatePower(trigger_flags)
if(target)
return InterceptClickOn(owner, null, target)
return set_click_ability(owner)
/datum/action/cooldown/bloodsucker/targeted/DeactivatePower()
if(power_flags & BP_AM_TOGGLE)
STOP_PROCESSING(SSprocessing, src)
active = FALSE
build_all_button_icons()
unset_click_ability(owner)
// ..() // we don't want to pay cost here
/// Check if target is VALID (wall, turf, or character?)
/datum/action/cooldown/bloodsucker/targeted/proc/CheckValidTarget(atom/target_atom)
if(target_atom == owner)
return FALSE
return TRUE
/// Check if valid target meets conditions
/datum/action/cooldown/bloodsucker/targeted/proc/CheckCanTarget(atom/target_atom)
if(target_range)
// Out of Range
if(!(target_atom in view(target_range, owner)))
if(target_range > 1) // Only warn for range if it's greater than 1. Brawn doesn't need to announce itself.
owner.balloon_alert(owner, "out of range.")
return FALSE
return istype(target_atom)
/// Click Target
/datum/action/cooldown/bloodsucker/targeted/proc/click_with_power(atom/target_atom)
// CANCEL RANGED TARGET check
if(power_in_use || !CheckValidTarget(target_atom))
return FALSE
// Valid? (return true means DON'T cancel power!)
if(!can_pay_cost() || !CanUse(owner) || !CheckCanTarget(target_atom))
return TRUE
power_in_use = TRUE // Lock us into this ability until it successfully fires off. Otherwise, we pay the blood even if we fail.
FireTargetedPower(target_atom) // We use this instead of ActivatePower(trigger_flags), which has no input
// Skip this part so we can return TRUE right away.
if(power_activates_immediately)
power_activated_sucessfully() // Mesmerize pays only after success.
power_in_use = FALSE
return TRUE
/// Like ActivatePower, but specific to Targeted (and takes an atom input). We don't use ActivatePower for targeted.
/datum/action/cooldown/bloodsucker/targeted/proc/FireTargetedPower(atom/target_atom)
log_combat(owner, target_atom, "used [name] on")
/// The power went off! We now pay the cost of the power.
/datum/action/cooldown/bloodsucker/targeted/proc/power_activated_sucessfully()
unset_click_ability(owner)
pay_cost()
StartCooldown()
DeactivatePower()
/datum/action/cooldown/bloodsucker/targeted/InterceptClickOn(mob/living/caller, params, atom/target)
click_with_power(target)