Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/WFZ/Launcher.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Launcher Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.startPos.x
13
private alias object.value1 : object.endPos.x
14
private alias object.value2 : object.velIncrease
15
private alias object.value3 : object.stoodPlayers
16
17
// States
18
private alias 0 : LAUNCHER_IDLE
19
private alias 1 : LAUNCHER_LAUNCHING
20
private alias 2 : LAUNCHER_RETRACTING
21
22
// Player Aliases
23
private alias object.state : player.state
24
private alias object.xpos : player.xpos
25
private alias object.xvel : player.xvel
26
private alias object.yvel : player.yvel
27
private alias object.speed : player.speed
28
private alias object.direction : player.direction
29
private alias object.gravity : player.gravity
30
private alias object.animation : player.animation
31
32
private alias object.value17 : debugMode.currentSelection
33
34
35
// ========================
36
// Function Declarations
37
// ========================
38
39
reserve function Launcher_DebugDraw
40
reserve function Launcher_DebugSpawn
41
42
43
// ========================
44
// Static Values
45
// ========================
46
47
private value Launcher_startDebugID = 0
48
49
50
// ========================
51
// Function Definitions
52
// ========================
53
54
private function Launcher_DebugDraw
55
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
56
end function
57
58
59
private function Launcher_DebugSpawn
60
temp0 = debugMode[0].currentSelection
61
temp0 -= Launcher_startDebugID
62
temp0++
63
64
temp0 <<= 2
65
CreateTempObject(TypeName[Launcher], temp0, object.xpos, object.ypos)
66
67
object[tempObjectPos].startPos.x = object.xpos
68
object[tempObjectPos].endPos.x = object.xpos
69
object[tempObjectPos].direction = object.direction
70
temp0 <<= 20
71
if object.direction == FACING_RIGHT
72
object[tempObjectPos].endPos.x -= temp0
73
object[tempObjectPos].velIncrease = -0x8000
74
else
75
object[tempObjectPos].endPos.x += temp0
76
object[tempObjectPos].velIncrease = 0x8000
77
end if
78
end function
79
80
81
// ========================
82
// Events
83
// ========================
84
85
event ObjectUpdate
86
switch object.state
87
case LAUNCHER_IDLE
88
break
89
90
case LAUNCHER_LAUNCHING
91
object.xvel += object.velIncrease
92
object.xpos += object.xvel
93
94
temp0 = false
95
if object.direction == FLIP_NONE
96
if object.xpos <= object.endPos.x
97
temp0 = true
98
end if
99
else
100
if object.xpos >= object.endPos.x
101
temp0 = true
102
end if
103
end if
104
105
if temp0 == true
106
temp2 = 0
107
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
108
GetBit(temp0, object.stoodPlayers, temp2)
109
if temp0 == true
110
if player[currentPlayer].yvel >= 0
111
player[currentPlayer].xvel = object.xvel
112
player[currentPlayer].speed = object.xvel
113
player[currentPlayer].yvel = -0x40000
114
player[currentPlayer].gravity = 1
115
#platform: USE_STANDALONE
116
player[currentPlayer].state = Player_State_Air
117
#endplatform
118
#platform: USE_ORIGINS
119
player[currentPlayer].state = Player_State_Air_NoDropDash
120
#endplatform
121
player[currentPlayer].direction = object.direction
122
player[currentPlayer].direction ^= FACING_LEFT
123
end if
124
end if
125
temp2++
126
next
127
object.state = LAUNCHER_RETRACTING
128
end if
129
break
130
131
case LAUNCHER_RETRACTING
132
if object.direction == FLIP_NONE
133
object.xpos += 0x40000
134
if object.xpos >= object.startPos.x
135
object.xpos = object.startPos.x
136
object.priority = PRIORITY_BOUNDS
137
object.state = LAUNCHER_IDLE
138
end if
139
else
140
object.xpos -= 0x40000
141
if object.xpos <= object.startPos.x
142
object.xpos = object.startPos.x
143
object.priority = PRIORITY_BOUNDS
144
object.state = LAUNCHER_IDLE
145
end if
146
end if
147
break
148
149
end switch
150
151
temp2 = 0
152
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
153
GetBit(temp0, object.stoodPlayers, temp2)
154
if temp0 == true
155
if player[currentPlayer].yvel >= 0
156
player[currentPlayer].xpos = object.xpos
157
player[currentPlayer].xvel = 0
158
player[currentPlayer].speed = 0
159
player[currentPlayer].animation = ANI_STOPPED
160
player[currentPlayer].state = Player_State_Ground
161
player[currentPlayer].direction = object.direction
162
player[currentPlayer].direction ^= FACING_LEFT
163
end if
164
end if
165
166
SetBit(object.stoodPlayers, temp2, false)
167
BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -16, 16, -8, currentPlayer, -1, C_BOX, 1, C_BOX)
168
if checkResult == true
169
SetBit(object.stoodPlayers, temp2, true)
170
if object.state == LAUNCHER_IDLE
171
PlaySfx(SfxName[Launch], false)
172
if object.direction == FLIP_NONE
173
object.xvel = -0xC0000
174
else
175
object.xvel = 0xC0000
176
end if
177
object.priority = PRIORITY_ACTIVE
178
object.state = LAUNCHER_LAUNCHING
179
end if
180
end if
181
temp2++
182
next
183
end event
184
185
186
event ObjectDraw
187
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
188
end event
189
190
191
event ObjectStartup
192
CheckCurrentStageFolder("Zone11")
193
if checkResult == true
194
LoadSpriteSheet("SCZ/Objects.gif")
195
SpriteFrame(-16, -31, 32, 16, 152, 74)
196
else
197
LoadSpriteSheet("MBZ/Objects.gif")
198
SpriteFrame(-16, -31, 32, 16, 445, 403)
199
end if
200
201
foreach (TypeName[Launcher], arrayPos0, ALL_ENTITIES)
202
object[arrayPos0].startPos.x = object[arrayPos0].xpos
203
object[arrayPos0].endPos.x = object[arrayPos0].xpos
204
205
temp0 = object[arrayPos0].propertyValue
206
temp0 <<= 20
207
if object[arrayPos0].direction == FLIP_NONE
208
object[arrayPos0].endPos.x -= temp0
209
object[arrayPos0].velIncrease = -0x8000
210
else
211
object[arrayPos0].endPos.x += temp0
212
object[arrayPos0].velIncrease = 0x8000
213
end if
214
next
215
216
temp0 = 0
217
Launcher_startDebugID = DebugMode_ObjCount
218
while temp0 < 4
219
SetTableValue(TypeName[Launcher], DebugMode_ObjCount, DebugMode_TypesTable)
220
SetTableValue(Launcher_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
221
SetTableValue(Launcher_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
222
DebugMode_ObjCount++
223
temp0++
224
loop
225
end event
226
227
228
// ========================
229
// Editor Events
230
// ========================
231
232
event RSDKEdit
233
if editor.returnVariable == true
234
switch editor.variableID
235
case EDIT_VAR_PROPVAL // property value
236
checkResult = object.propertyValue
237
break
238
239
case 0 // distance
240
checkResult = object.propertyValue
241
break
242
243
end switch
244
else
245
switch editor.variableID
246
case EDIT_VAR_PROPVAL // property value
247
object.propertyValue = editor.variableValue
248
break
249
250
case 0 // distance
251
object.propertyValue = editor.variableValue
252
break
253
254
end switch
255
end if
256
end event
257
258
259
event RSDKDraw
260
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
261
262
if editor.showGizmos == true
263
temp0 = object.propertyValue
264
temp0 <<= 20
265
266
object.endPos.x = object.xpos
267
if object.direction == FLIP_NONE
268
object.endPos.x -= temp0
269
else
270
object.endPos.x += temp0
271
end if
272
273
DrawArrow(object.xpos, object.ypos, object.endPos.x, object.ypos, 0xFF, 0xFF, 0x00)
274
end if
275
end event
276
277
278
event RSDKLoad
279
CheckCurrentStageFolder("Zone11")
280
if checkResult == true
281
LoadSpriteSheet("SCZ/Objects.gif")
282
SpriteFrame(-16, -31, 32, 16, 152, 74)
283
else
284
LoadSpriteSheet("MBZ/Objects.gif")
285
SpriteFrame(-16, -31, 32, 16, 445, 403)
286
end if
287
288
AddEditorVariable("distance")
289
SetActiveVariable("distance")
290
end event
291
292