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/UpDownBlock.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Up Down Block Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Player Aliases
13
private alias object.value10 : debugMode.currentSelection
14
private alias object.value15 : player.upDownBlockTimer
15
16
17
// ========================
18
// Function Declarations
19
// ========================
20
21
reserve function UpDownBlock_DebugDraw
22
reserve function UpDownBlock_DebugSpawn
23
24
25
// ========================
26
// Static Values
27
// ========================
28
29
private value UpDownBlock_startDebugID = 0
30
31
32
// ========================
33
// Function Definitions
34
// ========================
35
36
private function UpDownBlock_DebugDraw
37
temp4 = debugMode[0].currentSelection
38
temp4 -= UpDownBlock_startDebugID
39
DrawSprite(temp4)
40
end function
41
42
43
private function UpDownBlock_DebugSpawn
44
temp4 = debugMode[0].currentSelection
45
temp4 -= UpDownBlock_startDebugID
46
temp5 = TypeName[Up Down Block]
47
CallFunction(DebugMode_PlaceBlock)
48
object[arrayPos0].drawOrder = 4
49
object[arrayPos0].groupID = GROUP_BLOCKS
50
end function
51
52
53
// ========================
54
// Events
55
// ========================
56
57
event ObjectUpdate
58
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
59
CallFunction(SpecialSetup_PlayerBlockCol)
60
if checkResult != false
61
if player[currentPlayer].upDownBlockTimer == 0
62
player[currentPlayer].upDownBlockTimer = 30
63
if object.propertyValue == 0
64
if Player_rotateSpeed < 1
65
Player_rotateSpeed++
66
object.propertyValue = 1
67
PlaySfx(SfxName[Rotate Block], false)
68
end if
69
else
70
if Player_rotateSpeed > 0
71
Player_rotateSpeed--
72
object.propertyValue = 0
73
PlaySfx(SfxName[Rotate Block], false)
74
end if
75
end if
76
end if
77
end if
78
next
79
end event
80
81
82
event ObjectDraw
83
CallFunction(SpecialSetup_GetBlockPos)
84
temp2 = oscillation
85
temp2 &= 15
86
temp2 >>= 3
87
#platform: USE_ORIGINS
88
if game.playMode == BOOT_PLAYMODE_MIRRORING
89
object.direction = FLIP_X
90
if temp2 == 0
91
DrawSpriteFX(object.propertyValue, FX_FLIP, temp0, temp1)
92
else
93
DrawSpriteFX(2, FX_FLIP, temp0, temp1)
94
end if
95
else
96
if temp2 == 0
97
DrawSpriteXY(object.propertyValue, temp0, temp1)
98
else
99
DrawSpriteXY(2, temp0, temp1)
100
end if
101
end if
102
#endplatform
103
#platform: USE_STANDALONE
104
if temp2 == 0
105
DrawSpriteXY(object.propertyValue, temp0, temp1)
106
else
107
DrawSpriteXY(2, temp0, temp1)
108
end if
109
#endplatform
110
end event
111
112
113
event ObjectStartup
114
LoadSpriteSheet("Special/Objects.gif")
115
116
// Up and down 'n all around frames
117
SpriteFrame(-12, -12, 24, 24, 226, 76)
118
SpriteFrame(-12, -12, 24, 24, 226, 176)
119
SpriteFrame(-12, -12, 24, 24, 251, 76)
120
121
foreach (TypeName[Up Down Block], arrayPos0, ALL_ENTITIES)
122
object[arrayPos0].groupID = GROUP_BLOCKS
123
next
124
125
// Add this object to the debug item list twice
126
UpDownBlock_startDebugID = DebugMode_ObjCount
127
SetTableValue(TypeName[Up Down Block], DebugMode_ObjCount, DebugMode_TypeTable)
128
SetTableValue(UpDownBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
129
SetTableValue(UpDownBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
130
DebugMode_ObjCount++
131
132
SetTableValue(TypeName[Up Down Block], DebugMode_ObjCount, DebugMode_TypeTable)
133
SetTableValue(UpDownBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
134
SetTableValue(UpDownBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
135
DebugMode_ObjCount++
136
end event
137
138
139
// ========================
140
// Editor Events
141
// ========================
142
143
event RSDKEdit
144
if editor.returnVariable == true
145
switch editor.variableID
146
case EDIT_VAR_PROPVAL // property value
147
checkResult = object.propertyValue
148
break
149
150
case 0 // type
151
checkResult = object.propertyValue
152
break
153
154
end switch
155
else
156
switch editor.variableID
157
case EDIT_VAR_PROPVAL // property value
158
object.propertyValue = editor.variableValue
159
break
160
161
case 0 // type
162
object.propertyValue = temp0
163
break
164
165
end switch
166
end if
167
end event
168
169
170
event RSDKDraw
171
DrawSprite(object.propertyValue)
172
end event
173
174
175
event RSDKLoad
176
LoadSpriteSheet("Special/Objects.gif")
177
SpriteFrame(-12, -12, 24, 24, 226, 76)
178
SpriteFrame(-12, -12, 24, 24, 226, 176)
179
SpriteFrame(-12, -12, 24, 24, 251, 76)
180
181
AddEditorVariable("type")
182
SetActiveVariable("type")
183
AddEnumVariable("Speed Up", 0)
184
AddEnumVariable("Slow Down", 1)
185
end event
186
187