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/Jaws.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Jaws 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.swimTimer
13
private alias object.value1 : object.swimDuration
14
private alias object.value3 : object.startPos.x
15
16
// Player Aliases
17
private alias object.value40 : player.hitboxLeft
18
private alias object.value38 : player.hitboxTop
19
private alias object.value41 : player.hitboxRight
20
private alias object.value39 : player.hitboxBottom
21
22
23
// ========================
24
// Function Declarations
25
// ========================
26
27
reserve function Jaws_DebugDraw
28
reserve function Jaws_DebugSpawn
29
30
31
// ========================
32
// Function Definitions
33
// ========================
34
35
private function Jaws_DebugDraw
36
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
37
end function
38
39
40
private function Jaws_DebugSpawn
41
CreateTempObject(TypeName[Jaws], 0, object.xpos, object.ypos)
42
object[tempObjectPos].direction = object.direction
43
object[tempObjectPos].startPos.x = object.xpos
44
if object[tempObjectPos].direction == FLIP_NONE
45
object[tempObjectPos].xvel = -0x4000
46
else
47
object[tempObjectPos].xvel = 0x4000
48
end if
49
object[tempObjectPos].swimTimer = 120
50
end function
51
52
53
// ========================
54
// Events
55
// ========================
56
57
event ObjectUpdate
58
object.priority = PRIORITY_ACTIVE
59
object.xpos += object.xvel
60
61
object.swimTimer--
62
if object.swimTimer == 0
63
object.direction ^= FLIP_X
64
FlipSign(object.xvel)
65
object.swimTimer = object.swimDuration
66
end if
67
68
if object.outOfBounds == true
69
temp0 = object.xpos
70
object.xpos = object.startPos.x
71
if object.outOfBounds == true
72
object.xpos = object.startPos.x
73
object.priority = PRIORITY_BOUNDS
74
object.direction = object.propertyValue
75
object.direction >>= 7
76
if object.direction == FLIP_NONE
77
object.xvel = -0x4000
78
else
79
object.xvel = 0x4000
80
end if
81
object.swimTimer = object.propertyValue
82
object.swimTimer &= 0x7F
83
object.swimTimer <<= 6
84
object.swimDuration = object.swimTimer
85
else
86
object.xpos = temp0
87
end if
88
end if
89
90
// Check interaction with players
91
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
92
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -12, 16, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
93
if checkResult == true
94
CallFunction(Player_BadnikBreak)
95
end if
96
next
97
98
object.frame = object.animationTimer
99
object.frame >>= 3
100
object.animationTimer++
101
object.animationTimer &= 15
102
end event
103
104
105
event ObjectDraw
106
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
107
end event
108
109
110
event ObjectStartup
111
// Load sheet and sprites depending on which zone the player is currently in
112
CheckCurrentStageFolder("Zone04")
113
if checkResult == true
114
LoadSpriteSheet("LZ/Objects.gif")
115
SpriteFrame(-16, -12, 48, 24, 1, 105)
116
SpriteFrame(-16, -12, 45, 24, 1, 130)
117
SpriteFrame(-16, -12, 48, 24, 1, 155)
118
SpriteFrame(-16, -12, 45, 24, 47, 129)
119
end if
120
121
CheckCurrentStageFolder("Zone07")
122
if checkResult == true
123
LoadSpriteSheet("MBZ/Objects.gif")
124
SpriteFrame(-16, -12, 48, 24, 1, 264)
125
SpriteFrame(-16, -12, 45, 24, 99, 264)
126
SpriteFrame(-16, -12, 48, 24, 50, 264)
127
SpriteFrame(-16, -12, 45, 24, 145, 264)
128
end if
129
130
foreach (TypeName[Jaws], arrayPos0, ALL_ENTITIES)
131
object[arrayPos0].startPos.x = object[arrayPos0].xpos
132
object[arrayPos0].direction = object[arrayPos0].propertyValue
133
object[arrayPos0].direction >>= 7
134
if object[arrayPos0].direction == FLIP_NONE
135
object[arrayPos0].xvel = -0x4000
136
else
137
object[arrayPos0].xvel = 0x4000
138
end if
139
140
object[arrayPos0].swimTimer = object[arrayPos0].propertyValue
141
object[arrayPos0].swimTimer &= 0x7F
142
object[arrayPos0].swimTimer <<= 6
143
object[arrayPos0].swimDuration = object[arrayPos0].swimTimer
144
next
145
146
// Add Jaws to the debug object list
147
SetTableValue(TypeName[Jaws], DebugMode_ObjCount, DebugMode_TypesTable)
148
SetTableValue(Jaws_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
149
SetTableValue(Jaws_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
150
DebugMode_ObjCount++
151
end event
152
153
154
// ========================
155
// Editor Events
156
// ========================
157
158
event RSDKEdit
159
if editor.returnVariable == true
160
switch editor.variableID
161
case EDIT_VAR_PROPVAL // property value
162
checkResult = object.propertyValue
163
break
164
165
case 0 // swimDuration
166
checkResult = object.propertyValue
167
checkResult &= 0x7F
168
break
169
170
case 1 // direction
171
GetBit(checkResult, object.propertyValue, 7)
172
break
173
174
end switch
175
else
176
switch editor.variableID
177
case EDIT_VAR_PROPVAL // property value
178
object.propertyValue = editor.variableValue
179
break
180
181
case 0 // swimDuration
182
object.propertyValue &= 0x80
183
editor.variableValue &= 0x7F
184
185
object.propertyValue |= editor.variableValue
186
break
187
188
case 1 // direction
189
CheckNotEqual(editor.variableValue, false)
190
SetBit(object.propertyValue, 7, checkResult)
191
break
192
193
end switch
194
end if
195
end event
196
197
198
event RSDKDraw
199
GetBit(object.direction, object.propertyValue, 7)
200
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
201
202
if editor.showGizmos == true
203
editor.drawingOverlay = true
204
205
temp0 = object.propertyValue
206
temp0 &= 0x7C
207
temp0 <<= 20
208
GetBit(checkResult, object.propertyValue, 7)
209
SetBit(temp0, 31, checkResult)
210
temp0 += object.xpos
211
DrawLine(object.xpos, object.ypos, temp0, object.ypos, 0xFF, 0xFF, 0x00)
212
213
editor.drawingOverlay = false
214
end if
215
end event
216
217
218
event RSDKLoad
219
CheckCurrentStageFolder("Zone07")
220
if checkResult == true
221
LoadSpriteSheet("MBZ/Objects.gif")
222
SpriteFrame(-16, -12, 48, 24, 1, 264)
223
else
224
LoadSpriteSheet("LZ/Objects.gif")
225
SpriteFrame(-16, -12, 48, 24, 1, 105)
226
end if
227
228
AddEditorVariable("swimDuration")
229
SetActiveVariable("swimDuration")
230
231
AddEditorVariable("direction")
232
SetActiveVariable("direction")
233
AddEnumVariable("Left", 0)
234
AddEnumVariable("Right", 1)
235
end event
236
237