-
Notifications
You must be signed in to change notification settings - Fork 555
/
shuttle_supply.dm
186 lines (162 loc) · 6.59 KB
/
shuttle_supply.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
/obj/effect/landmark/supply_elevator/Initialize(mapload, ...)
. = ..()
GLOB.supply_elevator = get_turf(src)
return INITIALIZE_HINT_QDEL
/datum/shuttle/ferry/supply
iselevator = 1
var/away_location = 1 //the location to hide at while pretending to be in-transit
var/late_chance = 0
var/max_late_time = 300
var/railing_id = "supply_elevator_railing"
var/gear_id = "supply_elevator_gear"
var/obj/effect/elevator/SW //elevator effects (four so the entire elevator doesn't vanish when
var/obj/effect/elevator/SE //there's one opaque obstacle between you and the actual elevator loc).
var/obj/effect/elevator/NW
var/obj/effect/elevator/NE
var/Elevator_x
var/Elevator_y
var/Elevator_z
var/elevator_loc
///Used to mirrors the turfs (and their contents) on the elevator when raising/lowering, so they don't instantly teleport or vanish.
var/obj/effect/elevator/animation_overlay/elevator_animation
/datum/shuttle/ferry/supply/proc/pick_loc()
RETURN_TYPE(/turf)
return GLOB.supply_elevator
/datum/shuttle/ferry/supply/New()
..()
elevator_animation = new()
elevator_animation.pixel_x = 160 //Matches the slope on the sprite.
elevator_animation.pixel_y = -80
if(pick_loc())
Elevator_x = pick_loc().x
Elevator_y = pick_loc().y
Elevator_z = pick_loc().z
SW = new /obj/effect/elevator(locate(Elevator_x-2,Elevator_y-2,Elevator_z))
SW.vis_contents += elevator_animation
SE = new /obj/effect/elevator(locate(Elevator_x+2,Elevator_y-2,Elevator_z))
SE.pixel_x = -128
SE.vis_contents += elevator_animation
NW = new /obj/effect/elevator(locate(Elevator_x-2,Elevator_y+2,Elevator_z))
NW.pixel_y = -128
NW.vis_contents += elevator_animation
NE = new /obj/effect/elevator(locate(Elevator_x+2,Elevator_y+2,Elevator_z))
NE.pixel_x = -128
NE.pixel_y = -128
NE.vis_contents += elevator_animation
/datum/shuttle/ferry/supply/short_jump(area/origin, area/destination)
if(moving_status != SHUTTLE_IDLE)
return
if(isnull(location))
return
recharging = 1
if(!destination)
destination = get_location_area(!location)
if(!origin)
origin = get_location_area(location)
//it would be cool to play a sound here
moving_status = SHUTTLE_WARMUP
spawn(warmup_time)
if (moving_status == SHUTTLE_IDLE)
return //someone cancelled the launch
if (at_station())
raise_railings()
sleep(12)
if(forbidden_atoms_check())
//cancel the launch because of forbidden atoms. announce over supply channel?
moving_status = SHUTTLE_IDLE
playsound(locate(Elevator_x,Elevator_y,Elevator_z), 'sound/machines/buzz-two.ogg', 50, 0)
lower_railings()
return
else //at centcom
GLOB.supply_controller.buy()
//We pretend it's a long_jump by making the shuttle stay at centcom for the "in-transit" period.
var/area/away_area = get_location_area(away_location)
moving_status = SHUTTLE_INTRANSIT
/*We attach the turfs in our starting area to the vis_contents overlay. The elevator effect procs will animate this. If we're going down, the stuff will instantly be
teleported and then cosmetically animated as lowering; otherwise, it will be animated as raising, then teleported afterwards. Either way, it's all on the admin level.*/
for(var/turf/T in away_area)
elevator_animation.vis_contents += T
//If we are at the away_area then we are just pretending to move, otherwise actually do the move
if (origin != away_area)
playsound(locate(Elevator_x,Elevator_y,Elevator_z), 'sound/machines/asrs_lowering.ogg', 50, 0)
move(origin, away_area)
SW.forceMove(locate(Elevator_x-2,Elevator_y-2,Elevator_z))
SE.forceMove(locate(Elevator_x+2,Elevator_y-2,Elevator_z))
NW.forceMove(locate(Elevator_x-2,Elevator_y+2,Elevator_z))
NE.forceMove(locate(Elevator_x+2,Elevator_y+2,Elevator_z))
SW.icon_state = "supply_elevator_lowering"
SE.icon_state = "supply_elevator_lowering"
NW.icon_state = "supply_elevator_lowering"
NE.icon_state = "supply_elevator_lowering"
animate(elevator_animation, pixel_x = 160, pixel_y = -80, time = 2 SECONDS)
start_gears(SOUTH)
sleep(21)
SW.icon_state = "supply_elevator_lowered"
SE.icon_state = "supply_elevator_lowered"
NW.icon_state = "supply_elevator_lowered"
NE.icon_state = "supply_elevator_lowered"
sleep(70)
else
playsound(locate(Elevator_x,Elevator_y,Elevator_z), 'sound/machines/asrs_raising.ogg', 50, 0)
start_gears(NORTH)
sleep(70)
SW.icon_state = "supply_elevator_raising"
SE.icon_state = "supply_elevator_raising"
NW.icon_state = "supply_elevator_raising"
NE.icon_state = "supply_elevator_raising"
animate(elevator_animation, pixel_x = 0, pixel_y = 0, time = 2 SECONDS)
sleep(2 SECONDS)
SW.moveToNullspace()
SE.moveToNullspace()
NW.moveToNullspace()
NE.moveToNullspace()
move(away_area, destination)
moving_status = SHUTTLE_IDLE
stop_gears()
elevator_animation.vis_contents.Cut()
if (!at_station()) //at centcom
handle_sell()
else
lower_railings()
spawn(0)
recharging = 0
/datum/shuttle/ferry/supply/proc/handle_sell()
GLOB.supply_controller.sell()
// returns 1 if the supply shuttle should be prevented from moving because it contains forbidden atoms
/datum/shuttle/ferry/supply/proc/forbidden_atoms_check()
if (!at_station())
return 0 //if badmins want to send mobs or a nuke on the supply shuttle from centcom we don't care
return GLOB.supply_controller.forbidden_atoms_check(get_location_area())
/datum/shuttle/ferry/supply/proc/at_station()
return (!location)
//returns 1 if the shuttle is idle and we can still mess with the cargo shopping list
/datum/shuttle/ferry/supply/proc/idle()
return (moving_status == SHUTTLE_IDLE)
/datum/shuttle/ferry/supply/proc/raise_railings()
var/effective = 0
for(var/obj/structure/machinery/door/poddoor/M in GLOB.machines)
if(M.id == railing_id && !M.density)
effective = 1
spawn()
M.close()
if(effective)
playsound(locate(Elevator_x,Elevator_y,Elevator_z), 'sound/machines/elevator_openclose.ogg', 50, 0)
/datum/shuttle/ferry/supply/proc/lower_railings()
var/effective = 0
for(var/obj/structure/machinery/door/poddoor/M in GLOB.machines)
if(M.id == railing_id && M.density)
effective = 1
INVOKE_ASYNC(M, TYPE_PROC_REF(/obj/structure/machinery/door, open))
if(effective)
playsound(locate(Elevator_x,Elevator_y,Elevator_z), 'sound/machines/elevator_openclose.ogg', 50, 0)
/datum/shuttle/ferry/supply/proc/start_gears(direction = 1)
for(var/obj/structure/machinery/gear/M in GLOB.machines)
if(M.id == gear_id)
spawn()
M.icon_state = "gear_moving"
M.setDir(direction)
/datum/shuttle/ferry/supply/proc/stop_gears()
for(var/obj/structure/machinery/gear/M in GLOB.machines)
if(M.id == gear_id)
spawn()
M.icon_state = "gear"