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/Ring.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Ring 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.value0 : player.rings
14
15
// Music Events
16
private alias 25 : SLOT_MUSICEVENT_CHANGE
17
18
private alias 2 : MUSICEVENT_TRANSITION
19
20
21
// ========================
22
// Function Declarations
23
// ========================
24
25
reserve function Ring_DebugDraw
26
reserve function Ring_DebugSpawn
27
28
29
// ========================
30
// Function Definitions
31
// ========================
32
33
private function Ring_DebugDraw
34
DrawSprite(0)
35
end function
36
37
38
private function Ring_DebugSpawn
39
temp5 = TypeName[Ring]
40
temp4 = 0
41
CallFunction(DebugMode_PlaceBlock)
42
object[arrayPos0].drawOrder = 4
43
end function
44
45
46
// ========================
47
// Events
48
// ========================
49
50
event ObjectUpdate
51
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
52
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
53
if checkResult == true
54
object.type = TypeName[Ring Sparkle]
55
56
player[currentPlayer].rings++
57
if player[currentPlayer].rings > 999
58
player[currentPlayer].rings = 999
59
end if
60
61
if player[currentPlayer].rings >= ringExtraLife
62
if options.gameMode != MODE_TIMEATTACK
63
#platform: USE_STANDALONE
64
player.lives++
65
#endplatform
66
#platform: USE_ORIGINS
67
if game.coinMode == false
68
player.lives++
69
else
70
CallNativeFunction2(NotifyCallback, NOTIFY_ADD_COIN, 1)
71
end if
72
#endplatform
73
PlaySfx(SfxName[Life], false)
74
PauseMusic()
75
ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
76
object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE
77
end if
78
79
ringExtraLife += 100
80
if ringExtraLife >= 300
81
ringExtraLife = 1000
82
end if
83
end if
84
85
if Player_isWinner == false
86
if ringPan == 0
87
PlaySfx(SfxName[Ring L], false)
88
SetSfxAttributes(SfxName[Ring L], -1, -100)
89
ringPan = 1
90
else
91
PlaySfx(SfxName[Ring R], false)
92
SetSfxAttributes(SfxName[Ring R], -1, 100)
93
ringPan = 0
94
end if
95
end if
96
97
if player[currentPlayer].rings == 50
98
player.continues++
99
PlaySfx(SfxName[Continue], false)
100
end if
101
end if
102
next
103
end event
104
105
106
event ObjectDraw
107
CallFunction(SpecialSetup_GetBlockPos)
108
DrawSpriteXY(ringFrame, temp0, temp1)
109
end event
110
111
112
event ObjectStartup
113
LoadSpriteSheet("Special/Objects.gif")
114
115
// Loop through all objects, view this as a foreach
116
arrayPos0 = 32
117
while arrayPos0 < 0x420
118
if object[arrayPos0].type == TypeName[Ring]
119
object[arrayPos0].drawOrder = 4
120
end if
121
122
arrayPos0++
123
loop
124
125
// Ring frames
126
SpriteFrame(-8, -8, 16, 16, 172, 376)
127
SpriteFrame(-8, -8, 16, 16, 189, 376)
128
SpriteFrame(-8, -8, 16, 16, 206, 376)
129
SpriteFrame(-8, -8, 16, 16, 223, 376)
130
SpriteFrame(-8, -8, 16, 16, 240, 376)
131
SpriteFrame(-8, -8, 16, 16, 257, 376)
132
SpriteFrame(-8, -8, 16, 16, 274, 376)
133
SpriteFrame(-8, -8, 16, 16, 291, 376)
134
135
// Add this object to the stage's debug mode list
136
SetTableValue(TypeName[Ring], DebugMode_ObjCount, DebugMode_TypeTable)
137
SetTableValue(Ring_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
138
SetTableValue(Ring_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
139
DebugMode_ObjCount++
140
end event
141
142
143
// ========================
144
// Editor Events
145
// ========================
146
147
event RSDKDraw
148
DrawSprite(0)
149
end event
150
151
152
event RSDKLoad
153
LoadSpriteSheet("Special/Objects.gif")
154
SpriteFrame(-8, -8, 16, 16, 172, 376)
155
156
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
157
end event
158
159