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/BonusPoints.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Bonus Points 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.pointsAmount
14
15
private alias 0 : BONUSPOINTS_HIDDEN
16
private alias 1 : BONUSPOINTS_VISIBLE
17
18
19
// ========================
20
// Events
21
// ========================
22
23
event ObjectUpdate
24
if object.state == BONUSPOINTS_HIDDEN
25
// Interact with player(s)
26
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
27
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
28
if checkResult == true
29
// Show the object
30
object.state = BONUSPOINTS_VISIBLE
31
object.drawOrder = 5
32
object.inkEffect = INK_ALPHA
33
object.alpha = 0x100
34
PlaySfx(SfxName[Bonus Points], false)
35
player.score += object.pointsAmount
36
end if
37
next
38
else
39
object.timer++
40
41
if object.timer > 105
42
object.alpha -= 16
43
end if
44
45
if object.timer == 120
46
object.type = TypeName[Blank Object]
47
end if
48
end if
49
end event
50
51
52
event ObjectDraw
53
// Only show after the player has touched it
54
if object.state == BONUSPOINTS_VISIBLE
55
#platform: USE_ORIGINS
56
if game.playMode == BOOT_PLAYMODE_MIRRORING
57
object.direction = FLIP_X
58
// We lose the fade out in Mirror Mode, oh well
59
DrawSpriteFX(object.propertyValue, FX_FLIP, object.xpos, object.ypos)
60
else
61
DrawSpriteFX(object.propertyValue, FX_INK, object.xpos, object.ypos)
62
end if
63
#endplatform
64
#platform: USE_STANDALONE
65
DrawSpriteFX(object.propertyValue, FX_INK, object.xpos, object.ypos)
66
#endplatform
67
end if
68
end event
69
70
71
event ObjectStartup
72
LoadSpriteSheet("Global/Display.gif")
73
74
foreach (TypeName[Bonus Points], arrayPos0, ALL_ENTITIES)
75
// Choose point value based on property value
76
77
object[arrayPos0].propertyValue &= 3
78
switch object[arrayPos0].propertyValue
79
default
80
case 0
81
// No bonus at all (though, 10000 will still be displayed if this object is touched)
82
break
83
84
case 1
85
object[arrayPos0].pointsAmount = 10000
86
break
87
88
case 2
89
object[arrayPos0].pointsAmount = 1000
90
break
91
92
case 3
93
object[arrayPos0].pointsAmount = 100
94
break
95
96
end switch
97
next
98
99
// Sprite frames
100
SpriteFrame(-16, -12, 31, 23, 225, 49) // 10000 Points (No Points, functionality-wise) - #0
101
SpriteFrame(-16, -12, 31, 23, 225, 49) // 10000 Points - #1
102
SpriteFrame(-16, -12, 31, 23, 225, 25) // 1000 Points - #2
103
SpriteFrame(-16, -12, 31, 23, 225, 1) // 100 Points - #3
104
end event
105
106
107
// ========================
108
// Editor Events
109
// ========================
110
111
event RSDKEdit
112
if editor.returnVariable == true
113
switch editor.variableID
114
case EDIT_VAR_PROPVAL // property value
115
checkResult = object.propertyValue
116
checkResult &= 3
117
break
118
119
case 0 // pointsAmount
120
checkResult = object.propertyValue
121
checkResult &= 3
122
break
123
124
end switch
125
else
126
switch editor.variableID
127
case EDIT_VAR_PROPVAL // property value
128
object.propertyValue = editor.variableValue
129
object.propertyValue &= 3
130
break
131
132
case 0 // pointsAmount
133
object.propertyValue = editor.variableValue
134
object.propertyValue &= 3
135
break
136
137
end switch
138
end if
139
end event
140
141
142
event RSDKDraw
143
temp0 = object.propertyValue
144
temp0 &= 3
145
DrawSprite(temp0)
146
end event
147
148
149
event RSDKLoad
150
LoadSpriteSheet("Global/Display.gif")
151
SpriteFrame(-16, -12, 31, 23, 225, 49)
152
SpriteFrame(-16, -12, 31, 23, 225, 49)
153
SpriteFrame(-16, -12, 31, 23, 225, 25)
154
SpriteFrame(-16, -12, 31, 23, 225, 1)
155
156
AddEditorVariable("pointsAmount")
157
SetActiveVariable("pointsAmount")
158
AddEnumVariable("No Points", 0)
159
AddEnumVariable("10,000 Points", 1)
160
AddEnumVariable("1,000 Points", 2)
161
AddEnumVariable("100 Points", 3)
162
end event
163
164