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/OOZ/GasPlatform.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Gas Platform 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.timer
13
private alias object.value1 : object.centerPos.y
14
private alias object.value2 : object.collisionOffset.y
15
private alias object.value3 : object.launchPos.y
16
private alias object.value4 : object.flameActive
17
18
// States
19
private alias 0 : GASPLATFORM_AWAITINTERVAL
20
private alias 1 : GASPLATFORM_POPPED
21
private alias 2 : GASPLATFORM_AWAITCONTACT
22
private alias 3 : GASPLATFORM_CONTACT_LAUNCHED
23
private alias 4 : GASPLATFORM_CONTACT_IDLE
24
25
// Player Aliases
26
private alias object.state : player.state
27
private alias object.xpos : player.xpos
28
private alias object.ypos : player.ypos
29
private alias object.xvel : player.xvel
30
private alias object.yvel : player.yvel
31
private alias object.speed : player.speed
32
private alias object.gravity : player.gravity
33
private alias object.animationSpeed : player.animationSpeed
34
private alias object.animation : player.animation
35
36
private alias object.value1 : player.timer
37
private alias object.value5 : player.rollAnimationSpeed
38
39
40
// ========================
41
// Function Declarations
42
// ========================
43
44
reserve function GasPlatform_DebugDraw
45
reserve function GasPlatform_DebugSpawn
46
47
48
// ========================
49
// Function Definitions
50
// ========================
51
52
private function GasPlatform_DebugDraw
53
DrawSprite(7)
54
end function
55
56
57
private function GasPlatform_DebugSpawn
58
CreateTempObject(TypeName[Gas Platform], 0, object.xpos, object.ypos)
59
object[tempObjectPos].centerPos.y = object.ypos
60
end function
61
62
63
// ========================
64
// Events
65
// ========================
66
67
event ObjectUpdate
68
temp6 = object.ypos
69
switch object.state
70
case GASPLATFORM_AWAITINTERVAL
71
object.timer++
72
if object.timer == 120
73
object.timer = 0
74
object.yvel = -0x96800
75
PlaySfx(SfxName[Gas Pop], false)
76
if object.priority != PRIORITY_XBOUNDS_DESTROY
77
object.priority = PRIORITY_ACTIVE
78
end if
79
object.state++
80
end if
81
break
82
83
case GASPLATFORM_POPPED
84
object.ypos += object.yvel
85
object.yvel += 0x3800
86
87
if object.ypos >= object.centerPos.y
88
object.ypos = object.centerPos.y
89
if object.yvel < 0x10000
90
object.state = GASPLATFORM_AWAITINTERVAL
91
object.yvel = 0
92
else
93
object.yvel >>= 2
94
FlipSign(object.yvel)
95
end if
96
end if
97
break
98
99
case GASPLATFORM_AWAITCONTACT
100
if object.priority != PRIORITY_XBOUNDS_DESTROY
101
object.priority = PRIORITY_ACTIVE
102
end if
103
break
104
105
case GASPLATFORM_CONTACT_LAUNCHED
106
object.ypos += object.yvel
107
object.yvel += 0x3800
108
109
if object.ypos <= object.launchPos.y
110
object.ypos = object.launchPos.y
111
object.state++
112
PlaySfx(SfxName[Spring], false)
113
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
114
BoxCollisionTest(C_TOUCH, object.entityPos, -24, -10, 24, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
115
if checkResult == true
116
player[currentPlayer].xpos = object.xpos
117
player[currentPlayer].state = Player_State_Static
118
player[currentPlayer].gravity = 1
119
player[currentPlayer].timer = 0
120
player[currentPlayer].speed = 0
121
player[currentPlayer].xvel = 0
122
player[currentPlayer].yvel = -0x100000
123
player[currentPlayer].animation = ANI_JUMPING
124
player[currentPlayer].animationSpeed = 0xF0
125
player[currentPlayer].rollAnimationSpeed = 0xF0
126
end if
127
next
128
end if
129
break
130
131
case GASPLATFORM_CONTACT_IDLE
132
break
133
134
end switch
135
136
temp0 = object.centerPos.y
137
temp0 -= object.ypos
138
if temp0 > 0x180000
139
object.flameActive = true
140
else
141
object.flameActive = false
142
end if
143
144
temp0 = object.ypos
145
temp6 &= 0xFFFF0000
146
object.collisionOffset.y = object.ypos
147
object.collisionOffset.y &= 0xFFFF0000
148
object.collisionOffset.y -= temp6
149
150
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
151
object.ypos = object.centerPos.y
152
BoxCollisionTest(C_SOLID, object.entityPos, -32, 8, 32, 48, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
153
BoxCollisionTest(C_SOLID, object.entityPos, -16, 0, 16, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
154
if object.flameActive == true
155
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
156
if checkResult == true
157
CallFunction(Player_FireHit)
158
end if
159
end if
160
161
if object.yvel < -0x60000
162
temp7 = player[currentPlayer].yvel
163
temp7 -= 0x20000
164
else
165
temp7 = -0x80000
166
end if
167
168
if object.yvel < temp7
169
object.ypos = temp0
170
temp7 = player[currentPlayer].yvel
171
BoxCollisionTest(C_TOUCH, object.entityPos, -24, -10, 24, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
172
if checkResult == true
173
player[currentPlayer].yvel = 0x10000
174
end if
175
176
BoxCollisionTest(C_PLATFORM, object.entityPos, -24, -8, 24, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
177
switch checkResult
178
default
179
break
180
181
case 4
182
if player[currentPlayer].gravity == 0
183
if object.yvel > 0
184
CallFunction(Player_Kill)
185
end if
186
end if
187
break
188
end switch
189
player[currentPlayer].yvel = temp7
190
else
191
object.ypos = temp6
192
BoxCollisionTest(C_SOLID2, object.entityPos, -24, -8, 24, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
193
switch checkResult
194
case COL_NONE
195
BoxCollisionTest(C_PLATFORM, object.entityPos, -24, -8, 24, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
196
break
197
198
case COL_TOP
199
player[currentPlayer].ypos += object.collisionOffset.y
200
if object.state == GASPLATFORM_AWAITCONTACT
201
player[currentPlayer].speed = 0
202
player[currentPlayer].xvel = 0
203
object.yvel = -0x96800
204
PlaySfx(SfxName[Gas Pop], false)
205
object.state++
206
end if
207
break
208
209
case COL_BOTTOM
210
if player[currentPlayer].gravity == 0
211
if object.yvel > 0
212
CallFunction(Player_Kill)
213
end if
214
end if
215
break
216
end switch
217
end if
218
219
object.ypos = object.centerPos.y
220
BoxCollisionTest(C_SOLID, object.entityPos, -16, 0, 16, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
221
next
222
object.ypos = temp0
223
224
// Animate
225
object.frame = object.animationTimer
226
object.frame /= 3
227
object.animationTimer++
228
object.animationTimer %= 21
229
230
if object.outOfBounds == true
231
temp0 = object.ypos
232
object.ypos = object.centerPos.y
233
if object.outOfBounds == true
234
if object.priority != PRIORITY_XBOUNDS_DESTROY
235
object.priority = PRIORITY_BOUNDS
236
object.timer = 0
237
object.animationTimer = 0
238
object.flameActive = false
239
object.xvel = 0
240
object.yvel = 0
241
if object.propertyValue == 1
242
object.state = GASPLATFORM_AWAITCONTACT
243
else
244
object.state = GASPLATFORM_AWAITINTERVAL
245
end if
246
end if
247
else
248
object.ypos = temp0
249
end if
250
end if
251
end event
252
253
254
event ObjectDraw
255
if object.flameActive == true
256
DrawSpriteXY(object.frame, object.xpos, object.centerPos.y)
257
end if
258
DrawSprite(7)
259
end event
260
261
262
event ObjectStartup
263
LoadSpriteSheet("OOZ/Objects.gif")
264
SpriteFrame(-14, -15, 28, 15, 104, 191)
265
SpriteFrame(-15, -24, 30, 24, 102, 133)
266
SpriteFrame(-14, -15, 28, 15, 104, 191)
267
SpriteFrame(-15, -24, 30, 24, 102, 133)
268
SpriteFrame(-14, -15, 28, 15, 104, 191)
269
SpriteFrame(-15, -24, 30, 24, 102, 133)
270
SpriteFrame(-15, -32, 30, 32, 102, 158)
271
SpriteFrame(-24, -8, 48, 12, 84, 108)
272
273
foreach (TypeName[Gas Platform], arrayPos0, ALL_ENTITIES)
274
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
275
if object[arrayPos0].propertyValue == 1
276
object[arrayPos0].state = GASPLATFORM_AWAITCONTACT
277
object[arrayPos0].launchPos.y = object[arrayPos0].ypos
278
object[arrayPos0].launchPos.y -= 0x780000
279
end if
280
next
281
282
SetTableValue(TypeName[Gas Platform], DebugMode_ObjCount, DebugMode_TypesTable)
283
SetTableValue(GasPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
284
SetTableValue(GasPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
285
DebugMode_ObjCount++
286
end event
287
288
289
// ========================
290
// Editor Events
291
// ========================
292
293
event RSDKEdit
294
if editor.returnVariable == true
295
switch editor.variableID
296
case EDIT_VAR_PROPVAL // property value
297
checkResult = object.propertyValue
298
break
299
300
case 0 // type
301
checkResult = object.propertyValue
302
checkResult &= 1
303
break
304
305
end switch
306
else
307
switch editor.variableID
308
case EDIT_VAR_PROPVAL // property value
309
object.propertyValue = editor.variableValue
310
break
311
312
case 0 // type
313
editor.variableValue &= 1
314
object.propertyValue = editor.variableValue
315
break
316
317
end switch
318
end if
319
end event
320
321
322
event RSDKDraw
323
DrawSprite(7)
324
325
if editor.showGizmos == true
326
editor.drawingOverlay = true
327
328
if object.propertyValue == 1
329
// Pop on Contact
330
temp0 = -120
331
else
332
// Pop on Interval
333
temp0 = -206
334
end if
335
temp0 <<= 16
336
temp0 += object.ypos
337
338
object.inkEffect = INK_BLEND
339
DrawSpriteFX(7, FX_INK, object.xpos, temp0)
340
DrawArrow(object.xpos, object.ypos, object.xpos, temp0, 0x00, 0xFF, 0x00)
341
342
editor.drawingOverlay = false
343
end if
344
end event
345
346
347
event RSDKLoad
348
LoadSpriteSheet("OOZ/Objects.gif")
349
SpriteFrame(-14, -15, 28, 15, 104, 191)
350
SpriteFrame(-15, -24, 30, 24, 102, 133)
351
SpriteFrame(-14, -15, 28, 15, 104, 191)
352
SpriteFrame(-15, -24, 30, 24, 102, 133)
353
SpriteFrame(-14, -15, 28, 15, 104, 191)
354
SpriteFrame(-15, -24, 30, 24, 102, 133)
355
SpriteFrame(-15, -32, 30, 32, 102, 158)
356
SpriteFrame(-24, -8, 48, 12, 84, 108)
357
358
AddEditorVariable("type")
359
SetActiveVariable("type")
360
AddEnumVariable("Pop On Interval", 0)
361
AddEnumVariable("Pop On Contact", 1)
362
end event
363
364