Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/SBZ/FlameThrower.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Flame Thrower 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.onTime
14
private alias object.value2 : object.offTime
15
private alias object.value3 : object.loopPoint
16
private alias object.value4 : object.lastFrame
17
private alias object.value5 : object.frameCount
18
19
20
// ========================
21
// Function Declarations
22
// ========================
23
24
reserve function FlameThrower_DebugDraw
25
reserve function FlameThrower_DebugSpawn
26
27
28
// ========================
29
// Tables
30
// ========================
31
32
private table FlameThrower_hitboxTable
33
-8, 23, 7, 40
34
-8, 14, 7, 40
35
-11, 2, 11, 40
36
-11, -14, 11, 40
37
end table
38
39
40
// ========================
41
// Function Definitions
42
// ========================
43
44
private function FlameThrower_DebugDraw
45
temp0 = object.direction
46
temp0 *= 11
47
object.direction <<= 1
48
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
49
object.direction >>= 1
50
end function
51
52
53
private function FlameThrower_DebugSpawn
54
CreateTempObject(TypeName[Flame Thrower], 0, object.xpos, object.ypos)
55
object[tempObjectPos].drawOrder = 5
56
object[tempObjectPos].onTime = 128
57
object[tempObjectPos].offTime = 128
58
if object.direction == FLIP_NONE
59
object[tempObjectPos].loopPoint = 0
60
object[tempObjectPos].lastFrame = 11
61
else
62
object[tempObjectPos].loopPoint = 11
63
object[tempObjectPos].lastFrame = 22
64
object[tempObjectPos].frame = 11
65
object[tempObjectPos].direction = FLIP_Y
66
end if
67
object[tempObjectPos].frameCount = object[tempObjectPos].loopPoint
68
object[tempObjectPos].frameCount += 3
69
end function
70
71
72
// ========================
73
// Events
74
// ========================
75
76
event ObjectUpdate
77
object.timer--
78
if object.timer < 0
79
if object.animation == 0
80
object.timer = object.offTime
81
else
82
object.timer = object.onTime
83
end if
84
85
object.animation ^= 1
86
if object.animation == 0
87
PlaySfx(SfxName[Flame Thrower], false)
88
end if
89
end if
90
91
if object.animation == 0
92
if object.frame < object.lastFrame
93
object.animationTimer++
94
if object.animationTimer >= 4
95
object.animationTimer = 0
96
object.frame++
97
if object.frame == object.lastFrame
98
object.frame -= 2
99
end if
100
end if
101
end if
102
else
103
if object.frame > object.loopPoint
104
object.frame--
105
end if
106
end if
107
108
if object.frame >= object.frameCount
109
temp4 = object.frame
110
temp4 -= object.frameCount
111
temp4 <<= 1
112
temp4 &= 252
113
GetTableValue(temp0, temp4, FlameThrower_hitboxTable)
114
temp4++
115
GetTableValue(temp1, temp4, FlameThrower_hitboxTable)
116
temp4++
117
GetTableValue(temp2, temp4, FlameThrower_hitboxTable)
118
temp4++
119
GetTableValue(temp3, temp4, FlameThrower_hitboxTable)
120
121
// See if the object is Y flipped or not
122
GetBit(temp4, object.direction, 1)
123
if temp4 == true
124
FlipSign(temp1)
125
FlipSign(temp3)
126
temp4 = temp1
127
temp1 = temp3
128
temp3 = temp4
129
end if
130
131
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
132
BoxCollisionTest(C_TOUCH, object.entityPos, temp0, temp1, temp2, temp3, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
133
if checkResult == true
134
CallFunction(Player_FireHit)
135
end if
136
next
137
end if
138
end event
139
140
141
event ObjectDraw
142
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
143
end event
144
145
146
event ObjectStartup
147
LoadSpriteSheet("SBZ/Objects.gif")
148
SpriteFrame(-5, 40, 16, 16, 77, 460)
149
SpriteFrame(-5, 32, 16, 24, 94, 452)
150
SpriteFrame(-5, 32, 16, 24, 111, 452)
151
SpriteFrame(-8, 17, 19, 39, 128, 437)
152
SpriteFrame(-7, 17, 18, 39, 148, 437)
153
SpriteFrame(-8, 9, 19, 47, 167, 429)
154
SpriteFrame(-7, 9, 18, 47, 187, 429)
155
SpriteFrame(-11, -6, 22, 62, 207, 414)
156
SpriteFrame(-11, -6, 22, 62, 230, 414)
157
SpriteFrame(-11, -22, 22, 78, 253, 398)
158
SpriteFrame(-11, -23, 22, 79, 276, 397)
159
160
SpriteFrame(-7, 40, 16, 16, 299, 460)
161
SpriteFrame(-7, 32, 16, 24, 316, 452)
162
SpriteFrame(-7, 32, 16, 24, 333, 452)
163
SpriteFrame(-8, 17, 17, 39, 350, 437)
164
SpriteFrame(-7, 17, 16, 39, 368, 437)
165
SpriteFrame(-8, 9, 17, 47, 385, 429)
166
SpriteFrame(-7, 9, 16, 47, 403, 429)
167
SpriteFrame(-11, -6, 22, 62, 420, 414)
168
SpriteFrame(-11, -6, 22, 62, 443, 414)
169
SpriteFrame(-11, -22, 22, 78, 466, 398)
170
SpriteFrame(-11, -23, 22, 79, 489, 397)
171
172
foreach (TypeName[Flame Thrower], arrayPos0, ALL_ENTITIES)
173
object[arrayPos0].drawOrder = 5
174
object[arrayPos0].onTime = object[arrayPos0].propertyValue
175
object[arrayPos0].onTime &= 0xF0
176
object[arrayPos0].onTime <<= 1
177
object[arrayPos0].offTime = object[arrayPos0].propertyValue
178
object[arrayPos0].offTime &= 0x0F
179
object[arrayPos0].offTime <<= 5
180
GetBit(temp0, object[arrayPos0].direction, 1)
181
if temp0 == FLIP_NONE
182
object[arrayPos0].loopPoint = 0
183
object[arrayPos0].lastFrame = 11
184
else
185
object[arrayPos0].loopPoint = 11
186
object[arrayPos0].lastFrame = 22
187
object[arrayPos0].frame = 11
188
end if
189
object[arrayPos0].frameCount = object[arrayPos0].loopPoint
190
object[arrayPos0].frameCount += 3
191
next
192
193
SetTableValue(TypeName[Flame Thrower], DebugMode_ObjCount, DebugMode_TypesTable)
194
SetTableValue(FlameThrower_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
195
SetTableValue(FlameThrower_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
196
DebugMode_ObjCount++
197
end event
198
199
200
// ========================
201
// Editor Events
202
// ========================
203
204
event RSDKEdit
205
if editor.returnVariable == true
206
switch editor.variableID
207
case EDIT_VAR_PROPVAL // property value
208
checkResult = object.propertyValue
209
break
210
211
case 0 // onTime
212
checkResult = object.propertyValue
213
checkResult &= 0xF0
214
checkResult >>= 4
215
break
216
217
case 1 // offTime
218
checkResult = object.propertyValue
219
checkResult &= 0x0F
220
break
221
222
end switch
223
else
224
switch editor.variableID
225
case EDIT_VAR_PROPVAL // property value
226
object.propertyValue = editor.variableValue
227
break
228
229
case 0 // onTime
230
temp0 = editor.variableValue
231
temp0 &= 0xF
232
temp0 <<= 4
233
234
object.propertyValue &= 0x0F
235
object.propertyValue |= temp0
236
break
237
238
case 1 // offTime
239
temp0 = editor.variableValue
240
temp0 &= 0xF
241
242
object.propertyValue &= 0xF0
243
object.propertyValue |= temp0
244
break
245
246
end switch
247
end if
248
end event
249
250
251
event RSDKDraw
252
GetBit(temp0, object.direction, 1)
253
if temp0 == 0
254
object.frame = 0
255
else
256
object.frame = 11
257
end if
258
259
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
260
end event
261
262
263
event RSDKLoad
264
LoadSpriteSheet("SBZ/Objects.gif")
265
SpriteFrame(-5, 40, 16, 16, 77, 460)
266
SpriteFrame(-5, 32, 16, 24, 94, 452)
267
SpriteFrame(-5, 32, 16, 24, 111, 452)
268
SpriteFrame(-8, 17, 19, 39, 128, 437)
269
SpriteFrame(-7, 17, 18, 39, 148, 437)
270
SpriteFrame(-8, 9, 19, 47, 167, 429)
271
SpriteFrame(-7, 9, 18, 47, 187, 429)
272
SpriteFrame(-11, -6, 22, 62, 207, 414)
273
SpriteFrame(-11, -6, 22, 62, 230, 414)
274
SpriteFrame(-11, -22, 22, 78, 253, 398)
275
SpriteFrame(-11, -23, 22, 79, 276, 397)
276
277
SpriteFrame(-7, 40, 16, 16, 299, 460)
278
SpriteFrame(-7, 32, 16, 24, 316, 452)
279
SpriteFrame(-7, 32, 16, 24, 333, 452)
280
SpriteFrame(-8, 17, 17, 39, 350, 437)
281
SpriteFrame(-7, 17, 16, 39, 368, 437)
282
SpriteFrame(-8, 9, 17, 47, 385, 429)
283
SpriteFrame(-7, 9, 16, 47, 403, 429)
284
SpriteFrame(-11, -6, 22, 62, 420, 414)
285
SpriteFrame(-11, -6, 22, 62, 443, 414)
286
SpriteFrame(-11, -22, 22, 78, 466, 398)
287
SpriteFrame(-11, -23, 22, 79, 489, 397)
288
289
AddEditorVariable("onTime")
290
SetActiveVariable("onTime")
291
AddEnumVariable("0 Frames", 0)
292
AddEnumVariable("32 Frames", 1)
293
AddEnumVariable("64 Frames", 2)
294
AddEnumVariable("96 Frames", 3)
295
AddEnumVariable("128 Frames", 4)
296
AddEnumVariable("160 Frames", 5)
297
AddEnumVariable("192 Frames", 6)
298
AddEnumVariable("224 Frames", 7)
299
AddEnumVariable("256 Frames", 8)
300
AddEnumVariable("288 Frames", 9)
301
AddEnumVariable("320 Frames", 10)
302
AddEnumVariable("352 Frames", 11)
303
AddEnumVariable("384 Frames", 12)
304
AddEnumVariable("416 Frames", 13)
305
AddEnumVariable("448 Frames", 14)
306
AddEnumVariable("480 Frames", 15)
307
308
AddEditorVariable("offTime")
309
SetActiveVariable("offTime")
310
AddEnumVariable("0 Frames", 0)
311
AddEnumVariable("32 Frames", 1)
312
AddEnumVariable("64 Frames", 2)
313
AddEnumVariable("96 Frames", 3)
314
AddEnumVariable("128 Frames", 4)
315
AddEnumVariable("160 Frames", 5)
316
AddEnumVariable("192 Frames", 6)
317
AddEnumVariable("224 Frames", 7)
318
AddEnumVariable("256 Frames", 8)
319
AddEnumVariable("288 Frames", 9)
320
AddEnumVariable("320 Frames", 10)
321
AddEnumVariable("352 Frames", 11)
322
AddEnumVariable("384 Frames", 12)
323
AddEnumVariable("416 Frames", 13)
324
AddEnumVariable("448 Frames", 14)
325
AddEnumVariable("480 Frames", 15)
326
end event
327
328