-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathresonator.dm
125 lines (113 loc) · 4.25 KB
/
resonator.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**********************Resonator**********************/
/obj/item/resonator
name = "resonator"
icon = 'icons/obj/mining.dmi'
icon_state = "resonator"
item_state = "resonator"
lefthand_file = 'icons/mob/inhands/equipment/mining_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/mining_righthand.dmi'
desc = "A handheld device that creates small fields of energy that resonate until they detonate, crushing rock. It does increased damage in low pressure."
w_class = WEIGHT_CLASS_NORMAL
obj_flags = UNIQUE_RENAME | UNIQUE_REDESC
force = 15
throwforce = 10
var/burst_time = 30
var/fieldlimit = 4
var/list/fields = list()
var/quick_burst_mod = 0.8
/obj/item/resonator/upgraded
name = "upgraded resonator"
desc = "An upgraded version of the resonator that can produce more fields at once, as well as having no damage penalty for bursting a resonance field early."
icon_state = "resonator_u"
item_state = "resonator_u"
fieldlimit = 6
quick_burst_mod = 1
/obj/item/resonator/attack_self(mob/user)
if(burst_time == 50)
burst_time = 30
to_chat(user, span_info("You set the resonator's fields to detonate after 3 seconds."))
else
burst_time = 50
to_chat(user, span_info("You set the resonator's fields to detonate after 5 seconds."))
/obj/item/resonator/proc/CreateResonance(target, mob/user)
var/turf/T = get_turf(target)
var/obj/effect/temp_visual/resonance/R = locate(/obj/effect/temp_visual/resonance) in T
if(R)
R.damage_multiplier = quick_burst_mod
R.burst()
return
if(LAZYLEN(fields) < fieldlimit)
new /obj/effect/temp_visual/resonance(T, user, src, burst_time)
user.changeNext_move(CLICK_CD_MELEE)
/obj/item/resonator/pre_attack(atom/target, mob/user, params)
if(check_allowed_items(target, 1))
CreateResonance(target, user)
return FALSE
//resonance field, crushes rock, damages mobs
/obj/effect/temp_visual/resonance
name = "resonance field"
desc = "A resonating field that significantly damages anything inside of it when the field eventually ruptures. More damaging in low pressure environments."
icon_state = "shield1"
layer = ABOVE_ALL_MOB_LAYER
duration = 5 SECONDS
var/resonance_damage = 20
var/damage_multiplier = 1
var/creator
var/obj/item/resonator/res
/obj/effect/temp_visual/resonance/Initialize(mapload, set_creator, set_resonator, set_duration)
duration = set_duration
. = ..()
creator = set_creator
res = set_resonator
if(res)
res.fields += src
playsound(src,'sound/weapons/resonator_fire.ogg',50,1)
transform = matrix()*0.75
animate(src, transform = matrix()*1.5, time = duration)
deltimer(timerid)
timerid = addtimer(CALLBACK(src, PROC_REF(burst)), duration, TIMER_STOPPABLE)
/obj/effect/temp_visual/resonance/Destroy()
if(res)
res.fields -= src
res = null
creator = null
. = ..()
/obj/effect/temp_visual/resonance/proc/check_pressure(turf/proj_turf)
if(!proj_turf)
proj_turf = get_turf(src)
resonance_damage = initial(resonance_damage)
if(lavaland_equipment_pressure_check(proj_turf))
name = "strong [initial(name)]"
resonance_damage *= 3
else
name = initial(name)
resonance_damage *= damage_multiplier
/obj/effect/temp_visual/resonance/proc/burst()
var/turf/T = get_turf(src)
new /obj/effect/temp_visual/resonance_crush(T)
if(ismineralturf(T))
var/turf/closed/mineral/M = T
replicate(M)
M.attempt_drill(creator)
check_pressure(T)
playsound(T,'sound/weapons/resonator_blast.ogg',50,1)
for(var/mob/living/L in T)
if(creator)
log_combat(creator, L, "used a resonator field on", "resonator")
to_chat(L, span_userdanger("[src] ruptured with you in it!"))
L.apply_damage(resonance_damage, BRUTE)
qdel(src)
/obj/effect/temp_visual/resonance_crush
icon_state = "shield1"
layer = ABOVE_ALL_MOB_LAYER
duration = 0.4 SECONDS
/obj/effect/temp_visual/resonance_crush/Initialize(mapload)
. = ..()
transform = matrix()*1.5
animate(src, transform = matrix()*0.1, alpha = 50, time = 0.4 SECONDS)
/obj/effect/temp_visual/resonance/proc/replicate(turf/closed/mineral/M) //yogs start: adds replication to resonator fields
if(!istype(M) || !M.mineralType) // so we don't end up in the ultimate chain reaction
return
for(var/turf/closed/mineral/T in orange(1, M))
if(istype(T) && !(locate(/obj/effect/temp_visual/resonance) in T))
new /obj/effect/temp_visual/resonance(T, creator, null, duration) //yogs end