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/LZ/SBZ3Exit.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: SBZ3 Exit 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
// Player values
15
private alias object.type : player.type
16
private alias object.groupID : player.groupID
17
private alias object.controlMode : player.controlMode
18
private alias object.animation : player.animation
19
private alias object.direction : player.direction
20
private alias object.value0 : player.rings
21
22
private alias 0 : SBZ3EXIT_WAIT
23
private alias 1 : SBZ3EXIT_FINISH_NORMAL
24
private alias 2 : SBZ3EXIT_FINISH_TATTACK
25
26
// Game Modes
27
private alias 0 : MODE_NOSAVE
28
private alias 1 : MODE_SAVEGAME
29
private alias 2 : MODE_TIMEATTACK
30
31
// Tracks
32
private alias 1 : TRACK_ACTFINISH
33
34
// Reserved Object Slot Aliases
35
private alias 30 : SLOT_ACTFINISH
36
37
38
// ========================
39
// Events
40
// ========================
41
42
event ObjectUpdate
43
switch object.state
44
case SBZ3EXIT_WAIT
45
// Check for player collision
46
BoxCollisionTest(C_TOUCH, object.entityPos, -128, -16, 128, 16, 0, C_BOX, C_BOX, C_BOX, C_BOX)
47
if checkResult == true
48
// First, erase the player object (by turning them into a ring!)
49
player[0].type = TypeName[Ring]
50
player[0].groupID = TypeName[Blank Object]
51
player[0].controlMode = CONTROLMODE_NONE
52
53
#platform: USE_STANDALONE
54
//Check for time attack
55
if options.gameMode == MODE_TIMEATTACK
56
#endplatform
57
#platform: USE_ORIGINS
58
CheckEqual(options.gameMode, MODE_TIMEATTACK)
59
temp0 = checkResult
60
CheckNotEqual(game.oneStageFlag, false)
61
temp0 |= checkResult
62
if temp0 != false
63
#endplatform
64
// Go into special time attack variant (Origins uses it too for single-stage mode)
65
object.state = SBZ3EXIT_FINISH_TATTACK
66
stage.timeEnabled = false
67
else
68
// Normal variant
69
object.state++ // SBZ3EXIT_FINISH_NORMAL
70
end if
71
72
recAnimation = 0
73
temp0 = 0
74
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
75
temp1 = player[currentPlayer].animation
76
temp1 <<= 8
77
temp1 |= player[currentPlayer].direction
78
temp1 <<= temp0
79
80
recAnimation |= temp1
81
temp0 += 16
82
next
83
end if
84
break
85
86
case SBZ3EXIT_FINISH_NORMAL
87
// Normal variant - start fading out
88
if object.timer < 512
89
object.timer += 8
90
music.volume -= 2
91
else
92
#platform: USE_ORIGINS
93
CallNativeFunction4(NotifyCallback, NOTIFY_STATS_ENEMY, StageStatsUsabilityParam1, StageStatsUsabilityParam2, StageStatsUsabilityParam3)
94
CallNativeFunction2(NotifyCallback, NOTIFY_STATS_RING, player[0].rings)
95
CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 0)
96
StageStatsUsabilityParam1 = 0
97
StageStatsUsabilityParam2 = 0
98
StageStatsUsabilityParam3 = 0
99
StageStatsUsabilityParam4 = 0
100
StageStatsUsabilityParam5 = 0
101
StatsUsabilityParam1 = 0
102
StatsUsabilityParam2 = 0
103
StatsUsabilityParam3 = 0
104
StatsUsabilityParam4 = 0
105
StatsUsabilityParam5 = 0
106
#endplatform
107
108
// Fade done, go to SBZ3
109
object.direction = FACING_RIGHT // ???
110
lampPostID = 0
111
stage.listPos++
112
113
if options.gameMode == MODE_SAVEGAME
114
// There aren't any act results in this stage so save the game here (even if already on a completed save...)
115
arrayPos1 = options.saveSlot
116
arrayPos1 <<= 3
117
if stage.player2Enabled == true
118
#platform: USE_STANDALONE
119
saveRAM[arrayPos1] = PLAYER_SONIC_TAILS_A
120
#endplatform
121
#platform: USE_ORIGINS
122
switch stage.playerListPos
123
case PLAYER_SONIC_A
124
saveRAM[arrayPos1] = PLAYER_SONIC_TAILS
125
break
126
case PLAYER_AMY_A
127
saveRAM[arrayPos1] = PLAYER_AMY_TAILS
128
break
129
end switch
130
#endplatform
131
else
132
saveRAM[arrayPos1] = stage.playerListPos
133
end if
134
arrayPos1++
135
saveRAM[arrayPos1] = player.lives
136
arrayPos1++
137
saveRAM[arrayPos1] = player.score
138
arrayPos1++
139
saveRAM[arrayPos1] = player.scoreBonus
140
arrayPos1++
141
142
// Bug Details:
143
// This is missing the check for if your save file is already past the next act
144
// This means the save file's act will be overwritten to Final Zone, even if you're on a Complete save file...
145
saveRAM[arrayPos1] = stage.listPos
146
saveRAM[arrayPos1]++
147
148
arrayPos1++
149
saveRAM[arrayPos1] = specialStage.emeralds
150
arrayPos1++
151
saveRAM[arrayPos1] = specialStage.listPos
152
153
WriteSaveRAM()
154
end if
155
156
LoadStage()
157
end if
158
159
SetScreenFade(0, 0, 0, object.timer)
160
break
161
162
case SBZ3EXIT_FINISH_TATTACK
163
// Time attack variant - no fade out and instead show Act Results after a second
164
// Origins also uses this to display results when not in normal gameplay
165
166
if object.timer < 60
167
object.timer++
168
music.volume -= 2
169
else
170
object.type = TypeName[Blank Object]
171
172
object[SLOT_ACTFINISH].type = TypeName[Act Finish]
173
object[SLOT_ACTFINISH].drawOrder = 6
174
object[SLOT_ACTFINISH].priority = PRIORITY_ACTIVE
175
PlayMusic(TRACK_ACTFINISH)
176
end if
177
break
178
179
end switch
180
end event
181
182
183
// ========================
184
// Editor Events
185
// ========================
186
187
event RSDKDraw
188
DrawSprite(0)
189
end event
190
191
192
event RSDKLoad
193
LoadSpriteSheet("Global/Display.gif")
194
SpriteFrame(-8, -8, 16, 16, 239, 239) // "Trigger" - #0
195
196
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
197
end event
198
199