-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
venomous.dm
62 lines (51 loc) · 1.89 KB
/
venomous.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
/**
* Venomous element; which makes the attacks of the simplemob attached poison the enemy.
*
* Used for spiders and bees!
*/
/datum/element/venomous
element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH
id_arg_index = 2
///Path of the reagent added
var/poison_type
///How much of the reagent added. if it's a list, it'll pick a range with the range being list(lower_value, upper_value)
var/list/amount_added
/datum/element/venomous/Attach(datum/target, poison_type, amount_added)
. = ..()
if(isgun(target))
RegisterSignal(target, COMSIG_PROJECTILE_ON_HIT, .proc/projectile_hit)
else if(isitem(target))
RegisterSignal(target, COMSIG_ITEM_AFTERATTACK, .proc/item_afterattack)
else if(ishostile(target))
RegisterSignal(target, COMSIG_HOSTILE_POST_ATTACKINGTARGET, .proc/hostile_attackingtarget)
else
return ELEMENT_INCOMPATIBLE
src.poison_type = poison_type
src.amount_added = amount_added
/datum/element/venomous/Detach(datum/target)
UnregisterSignal(target, list(COMSIG_PROJECTILE_ON_HIT, COMSIG_ITEM_AFTERATTACK, COMSIG_HOSTILE_POST_ATTACKINGTARGET))
return ..()
/datum/element/venomous/proc/projectile_hit(atom/fired_from, atom/movable/firer, atom/target, Angle)
SIGNAL_HANDLER
add_reagent(target)
/datum/element/venomous/proc/item_afterattack(obj/item/source, atom/target, mob/user, proximity_flag, click_parameters)
SIGNAL_HANDLER
if(!proximity_flag)
return
add_reagent(target)
/datum/element/venomous/proc/hostile_attackingtarget(mob/living/simple_animal/hostile/attacker, atom/target, success)
SIGNAL_HANDLER
if(!success)
return
add_reagent(target)
/datum/element/venomous/proc/add_reagent(mob/living/target)
if(!istype(target))
return
if(target.stat == DEAD)
return
var/final_amount_added
if(islist(amount_added))
final_amount_added = rand(amount_added[1], amount_added[2])
else
final_amount_added = amount_added
target.reagents?.add_reagent(poison_type, final_amount_added)