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/ZoneBlock.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Zone 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.value0 : object.timer
13
14
private alias 0 : BLOCK_ZONE_IDLE
15
private alias 1 : BLOCK_ZONE_ACTIVATED
16
17
// Player aliases
18
private alias object.value10 : debugMode.currentSelection
19
20
// ========================
21
// Function Declarations
22
// ========================
23
24
reserve function ZoneBlock_DebugDraw
25
reserve function ZoneBlock_DebugSpawn
26
27
28
// ========================
29
// Static Values
30
// ========================
31
32
private value ZoneBlock_startDebugID = 0
33
34
35
// ========================
36
// Function Definitions
37
// ========================
38
39
private function ZoneBlock_DebugDraw
40
temp4 = debugMode[0].currentSelection
41
temp4 -= ZoneBlock_startDebugID
42
DrawSprite(temp4)
43
end function
44
45
46
private function ZoneBlock_DebugSpawn
47
temp4 = debugMode[0].currentSelection
48
temp4 -= ZoneBlock_startDebugID
49
temp5 = TypeName[Zone Block]
50
CallFunction(DebugMode_PlaceBlock)
51
object[arrayPos0].drawOrder = 4
52
object[arrayPos0].groupID = GROUP_BLOCKS
53
end function
54
55
56
// ========================
57
// Events
58
// ========================
59
60
event ObjectUpdate
61
if object.state == BLOCK_ZONE_ACTIVATED
62
object.frame = object.timer
63
object.frame >>= 3
64
object.timer++
65
if object.timer == 32
66
object.timer = 0
67
object.state = BLOCK_ZONE_IDLE
68
object.frame = 0
69
end if
70
end if
71
72
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
73
CallFunction(SpecialSetup_PlayerBlockCol)
74
next
75
end event
76
77
78
event ObjectDraw
79
CallFunction(SpecialSetup_GetBlockPos)
80
#platform: USE_ORIGINS
81
// This object isn't even used normally, but it's cool to see them update it regardless
82
if game.playMode == BOOT_PLAYMODE_MIRRORING
83
object.direction = FLIP_X
84
DrawSpriteFX(object.propertyValue, FX_FLIP, temp0, temp1)
85
else
86
DrawSpriteXY(object.propertyValue, temp0, temp1)
87
end if
88
#endplatform
89
#platform: USE_STANDALONE
90
DrawSpriteXY(object.propertyValue, temp0, temp1)
91
#endplatform
92
end event
93
94
95
event ObjectStartup
96
LoadSpriteSheet("Special/Objects.gif")
97
98
// Zone block frames
99
SpriteFrame(-12, -12, 24, 24, 326, 176)
100
SpriteFrame(-12, -12, 24, 24, 351, 176)
101
SpriteFrame(-12, -12, 24, 24, 376, 176)
102
SpriteFrame(-12, -12, 24, 24, 426, 176)
103
SpriteFrame(-12, -12, 24, 24, 451, 176)
104
SpriteFrame(-12, -12, 24, 24, 476, 176)
105
SpriteFrame(-12, -12, 24, 24, 476, 276)
106
107
foreach (TypeName[Zone Block], arrayPos0, ALL_ENTITIES)
108
object[arrayPos0].groupID = GROUP_BLOCKS
109
next
110
111
// Add the Zone Block to the debug object list seven times for the seven different zones
112
temp0 = 0
113
ZoneBlock_startDebugID = DebugMode_ObjCount
114
while temp0 < 7
115
SetTableValue(TypeName[Zone Block], DebugMode_ObjCount, DebugMode_TypeTable)
116
SetTableValue(ZoneBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
117
SetTableValue(ZoneBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
118
DebugMode_ObjCount++
119
temp0++
120
loop
121
end event
122
123
124
// ========================
125
// Editor Events
126
// ========================
127
128
event RSDKEdit
129
if editor.returnVariable == true
130
switch editor.variableID
131
case EDIT_VAR_PROPVAL // property value
132
checkResult = object.propertyValue
133
break
134
135
case 0 // zoneID
136
checkResult = object.propertyValue
137
break
138
139
end switch
140
else
141
switch editor.variableID
142
case EDIT_VAR_PROPVAL // property value
143
object.propertyValue = editor.variableValue
144
break
145
146
case 0 // zoneID
147
object.propertyValue = temp0
148
break
149
150
end switch
151
end if
152
end event
153
154
155
event RSDKDraw
156
DrawSprite(object.propertyValue)
157
end event
158
159
160
event RSDKLoad
161
LoadSpriteSheet("Special/Objects.gif")
162
SpriteFrame(-12, -12, 24, 24, 326, 176)
163
SpriteFrame(-12, -12, 24, 24, 351, 176)
164
SpriteFrame(-12, -12, 24, 24, 376, 176)
165
SpriteFrame(-12, -12, 24, 24, 426, 176)
166
SpriteFrame(-12, -12, 24, 24, 451, 176)
167
SpriteFrame(-12, -12, 24, 24, 476, 176)
168
SpriteFrame(-12, -12, 24, 24, 476, 276)
169
170
AddEditorVariable("zoneID")
171
SetActiveVariable("zoneID")
172
AddEnumVariable("Zone 1", 0)
173
AddEnumVariable("Zone 2", 1)
174
AddEnumVariable("Zone 3", 2)
175
AddEnumVariable("Zone 4", 3)
176
AddEnumVariable("Zone 5", 4)
177
AddEnumVariable("Zone 6", 5)
178
AddEnumVariable("Zone 7", 6)
179
end event
180
181