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/Global/LoseRing.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Lose Ring 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
private alias object.value1 : object.targetPlayer
14
15
private alias 0 : LOSERING_TYPE_HIGH
16
private alias 1 : LOSERING_TYPE_LOW
17
18
// Player aliases
19
private alias object.state : player.state
20
private alias object.value0 : player.rings
21
22
// Game Mode Aliases
23
private alias 2 : MODE_TIMEATTACK
24
25
// Music Events
26
private alias 25 : SLOT_MUSICEVENT_CHANGE
27
28
private alias 2 : MUSICEVENT_TRANSITION
29
30
// Achievement Aliases
31
private alias 4 : ACHIEVEMENT_RINGKING
32
33
// Path ID Aliases
34
private alias 0 : PATH_A
35
36
37
// ========================
38
// Events
39
// ========================
40
41
event ObjectUpdate
42
object.yvel += 0x1800
43
object.xpos += object.xvel
44
object.ypos += object.yvel
45
46
if object.yvel >= 0
47
ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)
48
if checkResult == true
49
temp0 = object.yvel
50
temp0 >>= 2
51
object.yvel -= temp0
52
FlipSign(object.yvel)
53
if object.yvel > -0x10000
54
object.yvel = -0x10000
55
end if
56
end if
57
end if
58
59
object.timer++
60
if object.timer == 256
61
object.type = TypeName[Blank Object]
62
object.xvel = 0
63
object.yvel = 0
64
object.timer = 0
65
else
66
object.animationTimer += object.animationSpeed
67
if object.animationTimer >= 0x100
68
object.animationTimer -= 0x100
69
object.frame++
70
if object.frame == 8
71
object.frame = 0
72
if object.animationSpeed > 16
73
object.animationSpeed -= 16
74
end if
75
end if
76
end if
77
78
if object.timer >= 240
79
object.alpha -= 16
80
end if
81
end if
82
83
if object.timer >= 64
84
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
85
CheckEqual(player[currentPlayer].state, Player_State_Hurt)
86
temp0 = checkResult
87
CheckEqual(player[currentPlayer].state, Player_State_GotHit)
88
temp0 |= checkResult
89
if temp0 == false
90
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
91
if checkResult == true
92
object.type = TypeName[Ring Sparkle]
93
if object.propertyValue == LOSERING_TYPE_HIGH
94
object.drawOrder = 4
95
else
96
object.drawOrder = 2
97
end if
98
object.timer = 0
99
object.targetPlayer = 0
100
object.timer = 0
101
object.frame = 0
102
player[0].rings++
103
if player[0].rings > 999
104
// What the...?
105
// this is meant to be "player[0].rings" right...? we dont need to set this obj's value0 to 999...
106
player.rings = 999
107
end if
108
109
if player[0].rings >= ringExtraLife
110
if options.gameMode != MODE_TIMEATTACK
111
#platform: USE_ORIGINS
112
if game.coinMode == false
113
player.lives++
114
else
115
CallNativeFunction2(NotifyCallback, NOTIFY_ADD_COIN, 1)
116
end if
117
#endplatform
118
#platform: USE_STANDALONE
119
player.lives++
120
#endplatform
121
PlaySfx(SfxName[Life], false)
122
PauseMusic()
123
ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
124
object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE
125
126
ringExtraLife += 100
127
if ringExtraLife > 300
128
ringExtraLife = 1000
129
end if
130
end if
131
132
if stage.debugMode == false
133
if player[0].rings >= 200
134
// Grant the "Ring King" Achievement
135
CallNativeFunction2(SetAchievement, ACHIEVEMENT_RINGKING, 100)
136
end if
137
end if
138
end if
139
140
if ringPan == 0
141
PlaySfx(SfxName[Ring L], false)
142
SetSfxAttributes(SfxName[Ring L], -1, -100)
143
ringPan = 1
144
else
145
PlaySfx(SfxName[Ring R], false)
146
SetSfxAttributes(SfxName[Ring R], -1, 100)
147
ringPan = 0
148
end if
149
end if
150
end if
151
next
152
end if
153
end event
154
155
156
event ObjectDraw
157
DrawSpriteFX(object.frame, FX_INK, object.xpos, object.ypos)
158
end event
159
160
161
event ObjectStartup
162
LoadSpriteSheet("Global/Items.gif")
163
164
// Ring Frames, they're the same as the standard Ring object sprites
165
SpriteFrame(-8, -8, 16, 16, 1, 1)
166
SpriteFrame(-8, -8, 16, 16, 1, 18)
167
SpriteFrame(-8, -8, 16, 16, 1, 35)
168
SpriteFrame(-8, -8, 16, 16, 1, 52)
169
SpriteFrame(-8, -8, 16, 16, 1, 69)
170
SpriteFrame(-8, -8, 16, 16, 1, 86)
171
SpriteFrame(-8, -8, 16, 16, 1, 103)
172
SpriteFrame(-8, -8, 16, 16, 1, 120)
173
end event
174
175
// ========================
176
// Editor Events
177
// ========================
178
179
event RSDKDraw
180
DrawSprite(0)
181
end event
182
183
184
event RSDKLoad
185
LoadSpriteSheet("Global/Items.gif")
186
SpriteFrame(-8, -8, 16, 16, 1, 1)
187
188
// Although used by the object, it shouldn't be set here
189
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
190
end event
191
192