-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathcarp_rift.dm
242 lines (220 loc) · 10 KB
/
carp_rift.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/// The carp rift is currently charging.
#define CHARGE_ONGOING 0
/// The carp rift is currently charging and has output a final warning.
#define CHARGE_FINALWARNING 1
/// The carp rift is now fully charged.
#define CHARGE_COMPLETED 2
/datum/action/innate/summon_rift
name = "Summon Rift"
desc = "Summon a rift to bring forth a horde of space carp."
background_icon_state = "bg_default"
button_icon = 'icons/mob/actions/actions_space_dragon.dmi'
button_icon_state = "carp_rift"
/datum/action/innate/summon_rift/Activate()
var/datum/antagonist/space_dragon/dragon = owner.mind?.has_antag_datum(/datum/antagonist/space_dragon)
if(!dragon)
return
var/area/rift_location = get_area(owner)
if(!rift_location.valid_territory)
to_chat(owner, span_warning("You can't summon a rift here! Try summoning somewhere secure within the station!"))
return
for(var/obj/structure/carp_rift/rift as anything in dragon.rift_list)
var/area/used_location = get_area(rift)
if(used_location == rift_location)
to_chat(owner, span_warning("You've already summoned a rift in this area! You have to summon again somewhere else!"))
return
var/turf/rift_spawn_turf = get_turf(dragon)
if(isspaceturf(rift_spawn_turf))
owner.balloon_alert(dragon, "needs stable ground!")
return
owner.balloon_alert(owner, "opening rift...")
if(!do_after(owner, 10 SECONDS, owner))
return
if(locate(/obj/structure/carp_rift) in owner.loc)
return
var/obj/structure/carp_rift/new_rift = new(get_turf(owner))
playsound(owner.loc, 'sound/vehicles/rocketlaunch.ogg', 100, TRUE)
dragon.riftTimer = -1
new_rift.dragon = dragon
dragon.rift_list += new_rift
to_chat(owner, span_boldwarning("The rift has been summoned. Prevent the crew from destroying it at all costs!"))
notify_ghosts("The Space Dragon has opened a rift!", source = new_rift, action = NOTIFY_ORBIT, flashwindow = FALSE, header = "Carp Rift Opened")
ASSERT(dragon.rift_ability == src) // Badmin protection.
QDEL_NULL(dragon.rift_ability) // Deletes this action when used successfully, we re-gain a new one on success later.
/**
* # Carp Rift
*
* The portals Space Dragon summons to bring carp onto the station.
*
* The portals Space Dragon summons to bring carp onto the station. His main objective is to summon 3 of them and protect them from being destroyed.
* The portals can summon sentient space carp in limited amounts. The portal also changes color based on whether or not a carp spawn is available.
* Once it is fully charged, it becomes indestructible, and intermitently spawns non-sentient carp. It is still destroyed if Space Dragon dies.
*/
/obj/structure/carp_rift
name = "carp rift"
desc = "A rift akin to the ones space carp use to travel long distances."
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 50, BIO = 100, RAD = 100, FIRE = 100, ACID = 100, ELECTRIC = 100)
max_integrity = 300
icon = 'icons/obj/carp_rift.dmi'
icon_state = "carp_rift_carpspawn"
light_color = LIGHT_COLOR_PURPLE
light_range = 10
anchored = TRUE
density = FALSE
layer = HIGH_OBJ_LAYER
/// The amount of time the rift has charged for.
var/time_charged = 0
/// The maximum charge the rift can have.
var/max_charge = 300
/// How many carp spawns it has available.
var/carp_stored = 1
/// A reference to the Space Dragon antag that created it.
var/datum/antagonist/space_dragon/dragon
/// Current charge state of the rift.
var/charge_state = CHARGE_ONGOING
/// The interval for adding additional space carp spawns to the rift.
var/carp_interval = 60
/// The time since an extra carp was added to the ghost role spawning pool.
var/last_carp_inc = 0
/// A list of all the ckeys which have used this carp rift to spawn in as carps.
var/list/ckey_list = list()
/obj/structure/carp_rift/Initialize(mapload)
. = ..()
START_PROCESSING(SSobj, src)
// Carp rifts always take heavy explosion damage. Discourages the use of maxcaps
// and favours more weaker explosives to destroy the portal
// as they have the same effect on the portal.
/obj/structure/carp_rift/ex_act(severity, target)
return ..(min(EXPLODE_HEAVY, severity))
/obj/structure/carp_rift/examine(mob/user)
. = ..()
if(time_charged < max_charge)
. += span_notice("It seems to be [(time_charged / max_charge) * 100]% charged.")
else
. += span_warning("This one is fully charged. In this state, it is poised to transport a much larger amount of carp than normal.")
if(isobserver(user))
. += span_notice("It has [carp_stored] carp available to spawn as.")
/obj/structure/carp_rift/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
playsound(src, 'sound/magic/lightningshock.ogg', 50, TRUE)
/obj/structure/carp_rift/Destroy()
STOP_PROCESSING(SSobj, src)
if(charge_state != CHARGE_COMPLETED)
if(dragon)
to_chat(dragon.owner.current, span_boldwarning("A rift has been destroyed! You have failed, and find yourself weakened."))
dragon.destroy_rifts()
dragon = null
return ..()
/obj/structure/carp_rift/process(delta_time)
// If we're fully charged, just start mass spawning carp and move around.
if(charge_state == CHARGE_COMPLETED)
if(DT_PROB(1.25, delta_time) && dragon)
var/mob/living/newcarp = new dragon.ai_to_spawn(loc)
newcarp.faction = dragon.owner.current.faction.Copy()
if(DT_PROB(1.5, delta_time))
var/rand_dir = pick(GLOB.cardinals)
forceMove(get_step(src, rand_dir))
return
// Increase time trackers and check for any updated states.
time_charged = min(time_charged + delta_time, max_charge)
last_carp_inc += delta_time
update_check()
var/turf/current_turf = get_turf(src)
for(var/mob/living/simple_animal/hostile/hostilehere in current_turf)
if(LAZYFIND(hostilehere.faction, "carp"))
hostilehere.adjustHealth(-5)
var/obj/effect/temp_visual/heal/H = new /obj/effect/temp_visual/heal(get_turf(hostilehere))
H.color = COLOR_BLUE
/obj/structure/carp_rift/attack_ghost(mob/user)
. = ..()
if(.)
return
summon_carp(user)
/**
* Does a series of checks based on the portal's status.
*
* Performs a number of checks based on the current charge of the portal, and triggers various effects accordingly.
* If the current charge is a multiple of carp_interval, add an extra carp spawn.
* If we're halfway charged, announce to the crew our location in a CENTCOM announcement.
* If we're fully charged, tell the crew we are, change our color to yellow, become invulnerable, and give Space Dragon the ability to make another rift, if he hasn't summoned 3 total.
*/
/obj/structure/carp_rift/proc/update_check()
// If the rift is fully charged, there's nothing to do here anymore.
if(charge_state == CHARGE_COMPLETED)
return
// Can we increase the carp spawn pool size?
if(last_carp_inc >= carp_interval)
carp_stored++
icon_state = "carp_rift_carpspawn"
if(light_color != LIGHT_COLOR_PURPLE)
set_light_color(LIGHT_COLOR_PURPLE)
update_light()
notify_ghosts("The carp rift can summon an additional carp!", source = src, action = NOTIFY_ORBIT, flashwindow = FALSE, header = "Carp Spawn Available")
last_carp_inc -= carp_interval
// Is the rift now fully charged?
if(time_charged >= max_charge)
charge_state = CHARGE_COMPLETED
var/area/A = get_area(src)
priority_announce("Spatial object has reached peak energy charge in [initial(A.name)], please stand-by.", "Central Command Wildlife Observations")
update_integrity(INFINITY)
icon_state = "carp_rift_charged"
set_light_color(LIGHT_COLOR_YELLOW)
update_light()
armor = list(MELEE = 100, BULLET = 100, LASER = 100, ENERGY = 100, BOMB = 100, BIO = 100, RAD = 100, FIRE = 100, ACID = 100)
resistance_flags = INDESTRUCTIBLE
dragon.rifts_charged += 1
if(dragon.rifts_charged != 3 && !dragon.objective_complete)
dragon.rift_ability = new()
dragon.rift_ability.Grant(dragon.owner.current)
dragon.riftTimer = 0
dragon.rift_empower()
// Early return, nothing to do after this point.
return
// Do we need to give a final warning to the station at the halfway mark?
if(charge_state < CHARGE_FINALWARNING && time_charged >= (max_charge * 0.5))
charge_state = CHARGE_FINALWARNING
var/area/A = get_area(src)
priority_announce("A rift is causing an unnaturally large energy flux in [initial(A.name)]. Stop it at all costs!", "Central Command Wildlife Observations", ANNOUNCER_SPANOMALIES)
/**
* Used to create carp controlled by ghosts when the option is available.
*
* Creates a carp for the ghost to control if we have a carp spawn available.
* Gives them prompt to control a carp, and if our circumstances still allow if when they hit yes, spawn them in as a carp.
* Also add them to the list of carps in Space Dragon's antgonist datum, so they'll be displayed as having assisted him on round end.
* Arguments:
* * mob/user - The ghost which will take control of the carp.
*/
/obj/structure/carp_rift/proc/summon_carp(mob/user)
if(carp_stored <= 0)//Not enough carp points
return FALSE
var/is_listed = FALSE
if (user.ckey in ckey_list)
if(carp_stored == 1)
to_chat(user, span_warning("You've already become a carp using this rift! Either wait for a backlog of carp spawns or until the next rift!"))
return FALSE
is_listed = TRUE
var/carp_ask = tgui_alert(user, "Become a carp?", "Carp Rift", list("Yes", "No"))
if(carp_ask != "Yes" || QDELETED(src) || QDELETED(user))
return FALSE
if(carp_stored <= 0)
to_chat(user, span_warning("The rift already summoned enough carp!"))
return FALSE
if(!dragon)
return
var/mob/living/simple_animal/hostile/carp/newcarp = new dragon.minion_to_spawn(loc)
newcarp.faction = dragon.owner.current.faction
if(!is_listed)
ckey_list += user.ckey
newcarp.key = user.key
var/datum/antagonist/space_carp/carp_antag = new(src)
newcarp.mind.add_antag_datum(carp_antag)
dragon.carp += newcarp.mind
to_chat(newcarp, span_boldwarning("You have arrived in order to assist the space dragon with securing the rifts. Do not jeopardize the mission, and protect the rifts at all costs!"))
carp_stored--
if(carp_stored <= 0 && charge_state < CHARGE_COMPLETED)
icon_state = "carp_rift"
set_light_color(LIGHT_COLOR_BLUE)
update_light()
return TRUE
#undef CHARGE_ONGOING
#undef CHARGE_FINALWARNING
#undef CHARGE_COMPLETED