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/Special/GemBlock.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Gem Block 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.propertyValue : object.color
13
14
private alias object.value0 : object.timer
15
private alias object.value1 : object.storedColor
16
17
private alias 0 : BLOCK_GEM_IDLE
18
private alias 1 : BLOCK_GEM_ACTIVATED
19
20
// Player aliases
21
private alias object.value10 : debugMode.currentSelection
22
23
24
// ========================
25
// Function Declarations
26
// ========================
27
28
reserve function GemBlock_DebugDraw
29
reserve function GemBlock_DebugSpawn
30
31
32
// ========================
33
// Static Values
34
// ========================
35
36
private value GemBlock_startDebugID = 0
37
38
39
// ========================
40
// Function Definitions
41
// ========================
42
43
private function GemBlock_DebugDraw
44
temp4 = debugMode[0].currentSelection
45
temp4 -= GemBlock_startDebugID
46
DrawSprite(temp4)
47
end function
48
49
50
private function GemBlock_DebugSpawn
51
temp4 = debugMode[0].currentSelection
52
temp4 -= GemBlock_startDebugID
53
temp5 = TypeName[Gem Block]
54
CallFunction(DebugMode_PlaceBlock)
55
object[arrayPos0].drawOrder = 4
56
object[arrayPos0].groupID = GROUP_BLOCKS
57
end function
58
59
60
// ========================
61
// Events
62
// ========================
63
64
event ObjectUpdate
65
if object.state == BLOCK_GEM_ACTIVATED
66
object.color = object.timer
67
object.color >>= 1
68
object.color &= 3
69
object.timer++
70
if object.timer == 16
71
object.priority = PRIORITY_BOUNDS
72
object.timer = 0
73
object.color = object.storedColor
74
object.color++
75
if object.color == 4
76
object.type = TypeName[Blank Object]
77
else
78
object.state = BLOCK_GEM_IDLE
79
end if
80
81
SpecialSetup_gemBlockBusy = false
82
end if
83
84
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
85
CallFunction(SpecialSetup_PlayerBlockCol)
86
next
87
else
88
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
89
CallFunction(SpecialSetup_PlayerBlockCol)
90
if SpecialSetup_gemBlockBusy == false
91
if checkResult > 0
92
object.state = BLOCK_GEM_ACTIVATED
93
object.priority = PRIORITY_ACTIVE
94
SpecialSetup_gemBlockBusy = true
95
object.storedColor = object.color
96
if Player_isWinner == false
97
PlaySfx(SfxName[Gem Block], false)
98
end if
99
end if
100
end if
101
next
102
end if
103
end event
104
105
106
event ObjectDraw
107
CallFunction(SpecialSetup_GetBlockPos)
108
temp2 = SpecialSetup_gemBlockTimer
109
temp2 /= 5
110
switch temp2
111
case 0
112
object.direction = FLIP_NONE
113
break
114
115
case 1
116
object.direction = FLIP_X
117
break
118
119
case 2
120
object.direction = FLIP_XY
121
break
122
123
case 3
124
object.direction = FLIP_Y
125
break
126
127
end switch
128
129
DrawSpriteFX(object.propertyValue, FX_FLIP, temp0, temp1)
130
end event
131
132
133
event ObjectStartup
134
LoadSpriteSheet("Special/Objects.gif")
135
136
// Gem frames
137
SpriteFrame(-12, -12, 24, 24, 301, 76)
138
SpriteFrame(-12, -12, 24, 24, 326, 76)
139
SpriteFrame(-12, -12, 24, 24, 351, 76)
140
SpriteFrame(-12, -12, 24, 24, 376, 76)
141
142
foreach (TypeName[Gem Block], arrayPos0, ALL_ENTITIES)
143
object[arrayPos0].groupID = GROUP_BLOCKS
144
next
145
146
// Add this to the debug object list four times for the four types of gems
147
temp0 = 0
148
GemBlock_startDebugID = DebugMode_ObjCount
149
while temp0 < 4
150
SetTableValue(TypeName[Gem Block], DebugMode_ObjCount, DebugMode_TypeTable)
151
SetTableValue(GemBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
152
SetTableValue(GemBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
153
DebugMode_ObjCount++
154
temp0++
155
loop
156
end event
157
158
159
// ========================
160
// Editor Events
161
// ========================
162
163
event RSDKEdit
164
if editor.returnVariable == true
165
switch editor.variableID
166
case EDIT_VAR_PROPVAL // property value
167
checkResult = object.propertyValue
168
checkResult &= 3
169
break
170
171
case 0 // color
172
checkResult = object.propertyValue
173
checkResult &= 3
174
break
175
176
end switch
177
else
178
switch editor.variableID
179
case EDIT_VAR_PROPVAL // property value
180
object.propertyValue = editor.variableValue
181
object.propertyValue &= 3
182
break
183
184
case 0 // color
185
object.propertyValue = temp0
186
object.propertyValue &= 3
187
break
188
189
end switch
190
end if
191
end event
192
193
194
event RSDKDraw
195
DrawSprite(object.propertyValue)
196
end event
197
198
199
event RSDKLoad
200
LoadSpriteSheet("Special/Objects.gif")
201
SpriteFrame(-12, -12, 24, 24, 301, 76)
202
SpriteFrame(-12, -12, 24, 24, 326, 76)
203
SpriteFrame(-12, -12, 24, 24, 351, 76)
204
SpriteFrame(-12, -12, 24, 24, 376, 76)
205
206
AddEditorVariable("color")
207
SetActiveVariable("color")
208
AddEnumVariable("Blue", 0)
209
AddEnumVariable("Green", 1)
210
AddEnumVariable("Yellow", 2)
211
AddEnumVariable("Pink", 3)
212
end event
213
214