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/Enemies/Splats.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Splats 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.flipDir
13
private alias object.value1 : object.startPos.x
14
private alias object.value2 : object.startPos.y
15
16
private alias object.value17 : debugMode.currentSelection
17
18
// Player aliases
19
private alias object.value40 : player.hitboxLeft
20
private alias object.value38 : player.hitboxTop
21
private alias object.value41 : player.hitboxRight
22
private alias object.value39 : player.hitboxBottom
23
24
// Path ID Aliases
25
private alias 0 : PATH_A
26
27
28
// ========================
29
// Function Declarations
30
// ========================
31
32
reserve function Splats_DebugDraw
33
reserve function Splats_DebugSpawn
34
35
// ========================
36
// Static Values
37
// ========================
38
39
private value Splats_startDebugID = 0
40
41
42
// ========================
43
// Function Definitions
44
// ========================
45
46
private function Splats_DebugDraw
47
temp0 = debugMode[0].currentSelection
48
temp0 -= Splats_startDebugID
49
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
50
end function
51
52
53
private function Splats_DebugSpawn
54
temp0 = debugMode[0].currentSelection
55
temp0 -= Splats_startDebugID
56
temp0 <<= 1
57
58
CreateTempObject(TypeName[Splats], temp0, object.xpos, object.ypos)
59
60
object[tempObjectPos].direction = object.direction
61
object[tempObjectPos].startPos.x = object.xpos
62
object[tempObjectPos].startPos.y = object.ypos
63
64
if object[tempObjectPos].direction == FLIP_NONE
65
object[tempObjectPos].xvel = -0x10000
66
else
67
object[tempObjectPos].xvel = 0x10000
68
end if
69
end function
70
71
72
// ========================
73
// Events
74
// ========================
75
76
event ObjectUpdate
77
object.priority = PRIORITY_ACTIVE
78
object.xpos += object.xvel
79
object.ypos += object.yvel
80
object.yvel += 0x3800
81
82
if object.yvel > 0
83
ObjectTileCollision(CSIDE_FLOOR, 0, 16, PATH_A)
84
temp0 = checkResult
85
ObjectTileCollision(CSIDE_FLOOR, 0, 17, PATH_A)
86
temp0 |= checkResult
87
ObjectTileCollision(CSIDE_FLOOR, 0, 18, PATH_A)
88
temp0 |= checkResult
89
ObjectTileCollision(CSIDE_FLOOR, 0, 19, PATH_A)
90
temp0 |= checkResult
91
ObjectTileCollision(CSIDE_FLOOR, 0, 20, PATH_A)
92
temp0 |= checkResult
93
if temp0 == true
94
GetBit(temp0, object.propertyValue, 1)
95
if temp0 == true
96
if object.flipDir == true
97
FlipSign(object.xvel)
98
object.direction ^= FLIP_X
99
end if
100
101
object.flipDir ^= true
102
end if
103
104
object.yvel = -0x40000
105
end if
106
end if
107
108
if object.outOfBounds == true
109
temp0 = object.xpos
110
temp1 = object.ypos
111
object.xpos = object.startPos.x
112
object.ypos = object.startPos.y
113
114
if object.outOfBounds == true
115
GetBit(temp0, object.propertyValue, 0)
116
if temp0 == FLIP_NONE
117
object.direction = FLIP_NONE
118
object.xvel = -0x10000
119
else
120
object.direction = FLIP_X
121
object.xvel = 0x10000
122
end if
123
object.priority = PRIORITY_BOUNDS
124
object.state = 0
125
else
126
object.xpos = temp0
127
object.ypos = temp1
128
end if
129
end if
130
131
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
132
BoxCollisionTest(C_TOUCH, object.entityPos, -10, -20, 6, 20, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
133
if checkResult == true
134
CallFunction(Player_BadnikBreak)
135
end if
136
next
137
end event
138
139
140
event ObjectDraw
141
if object.yvel < 0
142
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
143
else
144
DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)
145
end if
146
end event
147
148
149
event ObjectStartup
150
CheckCurrentStageFolder("Zone01")
151
if checkResult == true
152
LoadSpriteSheet("GHZ/Objects.gif")
153
SpriteFrame(-11, -15, 21, 40, 214, 211)
154
SpriteFrame(-11, -19, 21, 40, 192, 211)
155
end if
156
157
CheckCurrentStageFolder("Zone07")
158
if checkResult == true
159
LoadSpriteSheet("MBZ/Objects.gif")
160
SpriteFrame(-11, -15, 21, 40, 220, 254)
161
SpriteFrame(-11, -19, 21, 40, 198, 254)
162
end if
163
164
foreach (TypeName[Splats], arrayPos0, ALL_ENTITIES)
165
object[arrayPos0].startPos.x = object[arrayPos0].xpos
166
object[arrayPos0].startPos.y = object[arrayPos0].ypos
167
168
GetBit(temp0, object[arrayPos0].propertyValue, 0)
169
if temp0 == false
170
object[arrayPos0].direction = FLIP_NONE
171
object[arrayPos0].xvel = -0x10000
172
else
173
object[arrayPos0].direction = FLIP_X
174
object[arrayPos0].xvel = 0x10000
175
end if
176
next
177
178
temp0 = 0
179
Splats_startDebugID = DebugMode_ObjCount
180
while temp0 < 2
181
SetTableValue(TypeName[Splats], DebugMode_ObjCount, DebugMode_TypesTable)
182
SetTableValue(Splats_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
183
SetTableValue(Splats_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
184
DebugMode_ObjCount++
185
temp0++
186
loop
187
end event
188
189
190
// ========================
191
// Editor Events
192
// ========================
193
194
event RSDKEdit
195
if editor.returnVariable == true
196
switch editor.variableID
197
case EDIT_VAR_PROPVAL // property value
198
checkResult = object.propertyValue
199
checkResult &= 3
200
break
201
202
case 0 // direction
203
GetBit(checkResult, object.propertyValue, 0)
204
break
205
206
case 1 // behaviour
207
GetBit(checkResult, object.propertyValue, 1)
208
break
209
210
end switch
211
else
212
switch editor.variableID
213
case EDIT_VAR_PROPVAL // property value
214
object.propertyValue = editor.variableValue
215
break
216
217
case 0 // direction
218
CheckNotEqual(editor.variableValue, false)
219
SetBit(object.propertyValue, 0, checkResult)
220
break
221
222
case 1 // behaviour
223
CheckNotEqual(editor.variableValue, false)
224
SetBit(object.propertyValue, 1, checkResult)
225
break
226
227
end switch
228
end if
229
end event
230
231
232
event RSDKDraw
233
GetBit(object.direction, object.propertyValue, 0)
234
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
235
end event
236
237
238
event RSDKLoad
239
CheckCurrentStageFolder("Zone07")
240
if checkResult == true
241
LoadSpriteSheet("MBZ/Objects.gif")
242
SpriteFrame(-11, -15, 21, 40, 220, 254)
243
else
244
LoadSpriteSheet("GHZ/Objects.gif")
245
SpriteFrame(-11, -15, 21, 40, 214, 211)
246
end if
247
248
AddEditorVariable("direction")
249
SetActiveVariable("direction")
250
AddEnumVariable("Left", 0)
251
AddEnumVariable("Right", 1)
252
253
AddEditorVariable("behaviour")
254
SetActiveVariable("behaviour")
255
AddEnumVariable("Never Change Directions", 0)
256
AddEnumVariable("Change Direction On Each Bounce", 1)
257
end event
258
259