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/CPZ/SpeedBooster.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Speed Booster 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.boostSpeed
13
private alias object.value1 : object.timer
14
15
// Player Aliases
16
private alias object.state : player.state
17
private alias object.speed : player.speed
18
private alias object.direction : player.direction
19
private alias object.gravity : player.gravity
20
private alias object.animation : player.animation
21
private alias object.controlLock : player.controlLock
22
23
private alias object.value1 : player.timer
24
private alias object.value14 : player.skidding
25
private alias object.value17 : debugMode.currentSelection
26
27
28
// ========================
29
// Function Declarations
30
// ========================
31
32
reserve function SpeedBooster_DebugDraw
33
reserve function SpeedBooster_DebugSpawn
34
35
36
// ========================
37
// Static Values
38
// ========================
39
40
private value SpeedBooster_startDebugID = 0
41
42
43
// ========================
44
// Function Definitions
45
// ========================
46
47
private function SpeedBooster_DebugDraw
48
DrawSprite(0)
49
end function
50
51
52
private function SpeedBooster_DebugSpawn
53
CreateTempObject(TypeName[Speed Booster], 0, object.xpos, object.ypos)
54
55
GetBit(temp0, object.direction, 0)
56
if temp0 == FLIP_NONE
57
object[tempObjectPos].direction = FLIP_NONE
58
else
59
object[tempObjectPos].direction = FLIP_X
60
end if
61
62
temp0 = debugMode[0].currentSelection
63
temp0 -= SpeedBooster_startDebugID
64
if temp0 == 0
65
object[tempObjectPos].boostSpeed = 0x100000
66
else
67
object[tempObjectPos].boostSpeed = 0x0A0000
68
end if
69
70
object[tempObjectPos].drawOrder = 5
71
end function
72
73
74
// ========================
75
// Events
76
// ========================
77
78
event ObjectUpdate
79
if object.timer != 0
80
object.timer--
81
end if
82
83
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
84
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, 0, 0, 0, 0)
85
if checkResult == true
86
if player[currentPlayer].gravity == GRAVITY_GROUND
87
if object.timer == 0
88
object.timer = 2
89
PlaySfx(SfxName[Spring], false)
90
end if
91
92
temp1 = false
93
temp0 = object.boostSpeed
94
if object.direction == FLIP_X
95
FlipSign(object.boostSpeed)
96
if player[currentPlayer].speed > temp0
97
temp1 = true
98
end if
99
else
100
if player[currentPlayer].speed < temp0
101
temp1 = true
102
end if
103
end if
104
105
if temp1 == true
106
player[currentPlayer].state = Player_State_Ground
107
if player[currentPlayer].animation != ANI_JUMPING
108
if player[currentPlayer].animation != ANI_RUNNING
109
player[currentPlayer].animation = ANI_WALKING
110
end if
111
end if
112
113
player[currentPlayer].timer = 0
114
player[currentPlayer].controlLock = 0
115
player[currentPlayer].skidding = 0
116
player[currentPlayer].controlLock = 15
117
player[currentPlayer].speed = object.boostSpeed
118
player[currentPlayer].direction = object.direction
119
if object.direction == FLIP_X
120
FlipSign(player[currentPlayer].speed)
121
end if
122
end if
123
end if
124
end if
125
next
126
end event
127
128
129
event ObjectDraw
130
GetBit(temp0, oscillation, 1)
131
if temp0 == false
132
DrawSprite(0)
133
end if
134
end event
135
136
137
event ObjectStartup
138
// Note - the majority of the speed booster sprite is built into the level tiles itself
139
// All that's drawn here is the overlay spinning frame, and even then, it's only drawn sometimes
140
141
CheckCurrentStageFolder("Zone02")
142
if checkResult == true
143
LoadSpriteSheet("CPZ/Objects.gif")
144
SpriteFrame(-24, -8, 48, 16, 91, 25)
145
else
146
LoadSpriteSheet("MBZ/Objects.gif")
147
SpriteFrame(-24, -8, 48, 16, 474, 321)
148
end if
149
150
foreach (TypeName[Speed Booster], arrayPos0, ALL_ENTITIES)
151
if object[arrayPos0].propertyValue == 0
152
object[arrayPos0].boostSpeed = 0x100000
153
else
154
object[arrayPos0].boostSpeed = 0x0A0000
155
end if
156
157
object[arrayPos0].drawOrder = 5
158
next
159
160
temp0 = 0
161
SpeedBooster_startDebugID = DebugMode_ObjCount
162
while temp0 < 2
163
SetTableValue(TypeName[Speed Booster], DebugMode_ObjCount, DebugMode_TypesTable)
164
SetTableValue(SpeedBooster_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
165
SetTableValue(SpeedBooster_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
166
DebugMode_ObjCount++
167
temp0++
168
loop
169
end event
170
171
172
// ========================
173
// Editor Events
174
// ========================
175
176
event RSDKEdit
177
if editor.returnVariable == true
178
switch editor.variableID
179
case EDIT_VAR_PROPVAL // property value
180
checkResult = object.propertyValue
181
break
182
183
case 0 // boostSpeed
184
GetBit(checkResult, object.propertyValue, 0)
185
break
186
187
end switch
188
else
189
switch editor.variableID
190
case EDIT_VAR_PROPVAL // property value
191
object.propertyValue = editor.variableValue
192
break
193
194
case 0 // boostSpeed
195
CheckNotEqual(editor.variableValue, 0)
196
SetBit(object.propertyValue, 0, checkResult)
197
break
198
199
end switch
200
end if
201
end event
202
203
204
event RSDKDraw
205
DrawSprite(0)
206
end event
207
208
209
event RSDKLoad
210
CheckCurrentStageFolder("Zone02")
211
if checkResult == true
212
LoadSpriteSheet("CPZ/Objects.gif")
213
SpriteFrame(-24, -8, 48, 16, 91, 25)
214
else
215
LoadSpriteSheet("MBZ/Objects.gif")
216
SpriteFrame(-24, -8, 48, 16, 474, 321)
217
end if
218
219
AddEditorVariable("boostSpeed")
220
SetActiveVariable("boostSpeed")
221
AddEnumVariable("Faster", 0)
222
AddEnumVariable("Slower", 1)
223
end event
224
225