Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/Global/LoseRing.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
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
private alias object.value16 : player.isSidekick
15
16
private alias 0 : LOSERING_TYPE_HIGH
17
private alias 1 : LOSERING_TYPE_LOW
18
19
// Player Aliases
20
private alias object.state : player.state
21
private alias object.value0 : player.rings
22
23
// Game Modes
24
private alias 2 : MODE_TIMEATTACK
25
26
// Music Events
27
private alias 25 : SLOT_MUSICEVENT_CHANGE
28
29
private alias 2 : MUSICEVENT_TRANSITION
30
31
// Path ID Aliases
32
private alias 0 : PATH_A
33
34
35
// ========================
36
// Events
37
// ========================
38
39
event ObjectUpdate
40
object.yvel += 0x1800
41
object.xpos += object.xvel
42
object.ypos += object.yvel
43
44
if object.yvel >= 0
45
ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)
46
if checkResult == true
47
temp0 = object.yvel
48
temp0 >>= 2
49
object.yvel -= temp0
50
FlipSign(object.yvel)
51
if object.yvel > -0x10000
52
object.yvel = -0x10000
53
end if
54
end if
55
end if
56
57
object.timer++
58
if object.timer == 256
59
object.type = TypeName[Blank Object]
60
object.xvel = 0
61
object.yvel = 0
62
object.timer = 0
63
else
64
object.animationTimer += object.animationSpeed
65
if object.animationTimer >= 0x100
66
object.animationTimer -= 0x100
67
object.frame++
68
if object.frame == 8
69
object.frame = 0
70
if object.animationSpeed > 16
71
object.animationSpeed -= 16
72
end if
73
end if
74
end if
75
76
if object.timer >= 240
77
object.alpha -= 16
78
end if
79
end if
80
81
if object.timer >= 64
82
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
83
CheckEqual(player[currentPlayer].state, Player_State_Hurt)
84
temp0 = checkResult
85
CheckEqual(player[currentPlayer].state, Player_State_GotHit)
86
temp0 |= checkResult
87
if temp0 == false
88
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
89
if checkResult == true
90
object.type = TypeName[Ring Sparkle]
91
if object.propertyValue == LOSERING_TYPE_HIGH
92
object.drawOrder = 4
93
else
94
object.drawOrder = 2
95
end if
96
object.timer = 0
97
object.targetPlayer = 0
98
object.timer = 0
99
object.frame = 0
100
// Add it to the player's ring count
101
if player[currentPlayer].isSidekick == true
102
// P2 Tails in normal gameplay (not VS)
103
// So add it to P1's ring count
104
player[0].rings++
105
if player[0].rings > 999
106
player[0].rings = 999
107
end if
108
else
109
// Either P2 in VS or P1 in any mode
110
// In any case, give the ring to the player that collected it
111
player[currentPlayer].rings++
112
if player[currentPlayer].rings > 999
113
player[currentPlayer].rings = 999
114
end if
115
end if
116
if player[0].rings >= ringExtraLife
117
if options.gameMode != MODE_TIMEATTACK
118
#platform: USE_ORIGINS
119
if game.coinMode == false
120
player.lives++
121
else
122
CallNativeFunction2(NotifyCallback, NOTIFY_ADD_COIN, 1)
123
end if
124
#endplatform
125
#platform: USE_STANDALONE
126
player.lives++
127
#endplatform
128
PlaySfx(SfxName[Life], false)
129
PauseMusic()
130
ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
131
object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE
132
ringExtraLife += 100
133
if ringExtraLife > 300
134
ringExtraLife = 1000
135
end if
136
end if
137
end if
138
139
if ringPan == false
140
PlaySfx(SfxName[Ring L], false)
141
SetSfxAttributes(SfxName[Ring L], -1, -100)
142
ringPan = true
143
else
144
PlaySfx(SfxName[Ring R], false)
145
SetSfxAttributes(SfxName[Ring R], -1, 100)
146
ringPan = false
147
end if
148
end if
149
end if
150
next
151
end if
152
end event
153
154
155
event ObjectDraw
156
DrawSpriteFX(object.frame, FX_INK, object.xpos, object.ypos)
157
end event
158
159
160
event ObjectStartup
161
LoadSpriteSheet("Global/Items.gif")
162
SpriteFrame(-8, -8, 16, 16, 1, 1)
163
SpriteFrame(-8, -8, 16, 16, 1, 18)
164
SpriteFrame(-8, -8, 16, 16, 1, 35)
165
SpriteFrame(-8, -8, 16, 16, 1, 52)
166
SpriteFrame(-8, -8, 16, 16, 1, 69)
167
SpriteFrame(-8, -8, 16, 16, 1, 86)
168
SpriteFrame(-8, -8, 16, 16, 1, 103)
169
SpriteFrame(-8, -8, 16, 16, 1, 120)
170
end event
171
172
173
// ========================
174
// Editor Events
175
// ========================
176
177
event RSDKDraw
178
DrawSprite(0)
179
end event
180
181
182
event RSDKLoad
183
LoadSpriteSheet("Global/Items.gif")
184
SpriteFrame(-8, -8, 16, 16, 1, 1)
185
186
// used, but this shouldn't be placed down in the scene so it doesn't matter
187
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
188
end event
189
190