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/CNZ/SlotPrize.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Slot Prize 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.originPos.x
13
private alias object.value1 : object.originPos.y
14
private alias object.value2 : object.timer
15
16
// States
17
private alias 0 : SLOTPRIZE_WINNER
18
private alias 1 : SLOTPRIZE_LOSER
19
20
// Player Aliases
21
private alias object.value0 : player.rings
22
private alias object.value16 : player.isSidekick
23
24
// Game Modes
25
private alias 2 : MODE_TIMEATTACK
26
27
// Music Events
28
private alias 25 : SLOT_MUSICEVENT_CHANGE
29
30
private alias 2 : MUSICEVENT_TRANSITION
31
32
33
// ========================
34
// Static Values
35
// ========================
36
37
private value SlotPrize_SpikeSfxTimer = 0
38
39
40
// ========================
41
// Events
42
// ========================
43
44
event ObjectUpdate
45
temp0 = object.xpos
46
temp0 -= object.originPos.x
47
temp0 >>= 4
48
object.xpos -= temp0
49
50
temp0 = object.ypos
51
temp0 -= object.originPos.y
52
temp0 >>= 4
53
object.ypos -= temp0
54
55
if object.alpha < 0x100
56
object.alpha += 0x20
57
end if
58
59
if object.state == SLOTPRIZE_WINNER
60
object.frame++
61
object.frame &= 7
62
end if
63
64
object.timer--
65
if object.timer == 0
66
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
67
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
68
if player[currentPlayer].isSidekick == true
69
if object.type != TypeName[Slot Prize]
70
checkResult = false
71
end if
72
end if
73
74
if checkResult == true
75
if object.state == SLOTPRIZE_WINNER
76
player[currentPlayer].rings++
77
if player[currentPlayer].rings > 999
78
player[currentPlayer].rings = 999
79
end if
80
81
if player[0].rings >= ringExtraLife
82
if options.gameMode != MODE_TIMEATTACK
83
#platform: USE_STANDALONE
84
player.lives++
85
#endplatform
86
#platform: USE_ORIGINS
87
if game.coinMode == false
88
player.lives++
89
else
90
CallNativeFunction2(NotifyCallback, NOTIFY_ADD_COIN, 1)
91
end if
92
#endplatform
93
PlaySfx(SfxName[Life], false)
94
PauseMusic()
95
ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
96
object[25].priority = PRIORITY_ACTIVE
97
end if
98
99
ringExtraLife += 100
100
if ringExtraLife > 300
101
ringExtraLife = 1000
102
end if
103
end if
104
105
if ringPan == 0
106
PlaySfx(SfxName[Ring L], false)
107
SetSfxAttributes(SfxName[Ring L], -1, -100)
108
ringPan = 1
109
else
110
PlaySfx(SfxName[Ring R], false)
111
SetSfxAttributes(SfxName[Ring R], -1, 100)
112
ringPan = 0
113
end if
114
115
ResetObjectEntity(object.entityPos, TypeName[Ring Sparkle], 0, object.xpos, object.ypos)
116
else
117
if player[currentPlayer].rings > 0
118
player[currentPlayer].rings--
119
end if
120
121
if SlotPrize_SpikeSfxTimer == 0
122
PlaySfx(SfxName[Spike], false)
123
end if
124
125
SlotPrize_SpikeSfxTimer++
126
SlotPrize_SpikeSfxTimer %= 3
127
object.type = TypeName[Blank Object]
128
end if
129
else
130
if object.type == TypeName[Slot Prize]
131
object.type = TypeName[Blank Object]
132
end if
133
end if
134
next
135
end if
136
end event
137
138
139
event ObjectDraw
140
DrawSpriteFX(object.frame, FX_INK, object.xpos, object.ypos)
141
end event
142
143
144
event ObjectStartup
145
LoadSpriteSheet("CNZ/Objects.gif")
146
147
// 0-7 - Ring frames :D
148
SpriteFrame(-8, -8, 16, 16, 110, 256)
149
SpriteFrame(-8, -8, 16, 16, 110, 273)
150
SpriteFrame(-8, -8, 16, 16, 110, 290)
151
SpriteFrame(-8, -8, 16, 16, 110, 307)
152
SpriteFrame(-8, -8, 16, 16, 110, 324)
153
SpriteFrame(-8, -8, 16, 16, 110, 341)
154
SpriteFrame(-8, -8, 16, 16, 110, 358)
155
SpriteFrame(-8, -8, 16, 16, 110, 375)
156
157
// 8 - Spike ball frame D:
158
SpriteFrame(-8, -8, 15, 15, 226, 34)
159
160
SlotPrize_SpikeSfxTimer = 0
161
end event
162
163
164
// ========================
165
// Editor Events
166
// ========================
167
168
event RSDKDraw
169
DrawSprite(0)
170
end event
171
172
173
event RSDKLoad
174
LoadSpriteSheet("CNZ/Objects.gif")
175
SpriteFrame(-8, -8, 16, 16, 110, 256)
176
177
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
178
end event
179
180