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/LampPost.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Lamp Post 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.ballAngle
13
private alias object.value1 : object.ballPos.x
14
private alias object.value2 : object.ballPos.y
15
16
private alias 0 : LAMPPOST_INACTIVE
17
private alias 1 : LAMPPOST_SPINNING
18
private alias 2 : LAMPPOST_ACTIVE
19
20
// Player Aliases
21
private alias object.xpos : player.xpos
22
private alias object.ypos : player.ypos
23
private alias object.ixpos : player.ixpos
24
private alias object.iypos : player.iypos
25
private alias object.value0 : player.rings
26
27
private alias 0 : SLOT_PLAYER1
28
29
30
// ========================
31
// Function Declarations
32
// ========================
33
34
reserve function LampPost_DebugDraw
35
reserve function LampPost_DebugSpawn
36
37
38
// ========================
39
// Editor Events
40
// ========================
41
42
private function LampPost_DebugDraw
43
DrawSprite(0)
44
end function
45
46
47
private function LampPost_DebugSpawn
48
CreateTempObject(TypeName[Lamp Post], 0, object.xpos, object.ypos)
49
end function
50
51
52
// ========================
53
// Events
54
// ========================
55
56
event ObjectUpdate
57
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
58
if object.state == LAMPPOST_INACTIVE
59
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -44, 8, 20, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
60
if checkResult == true
61
lampPostID = object.entityPos
62
#platform: USE_ORIGINS
63
recScore = player.score
64
recRing = player[0].rings
65
#endplatform
66
recMilliSeconds = stage.milliSeconds
67
recSeconds = stage.seconds
68
recMinutes = stage.minutes
69
recWaterState = stage.waterState
70
recWaterLevel = stage.waterLevel
71
#platform: USE_ORIGINS
72
StatsUsabilityParam1 = StageStatsUsabilityParam1
73
StatsUsabilityParam2 = StageStatsUsabilityParam2
74
StatsUsabilityParam3 = StageStatsUsabilityParam3
75
StatsUsabilityParam4 = StageStatsUsabilityParam4
76
StatsUsabilityParam5 = StageStatsUsabilityParam5
77
#endplatform
78
object.state = LAMPPOST_SPINNING
79
object.ballAngle = 0x180
80
if object.priority != PRIORITY_XBOUNDS_DESTROY
81
object.priority = PRIORITY_ACTIVE
82
end if
83
PlaySfx(SfxName[Lamp Post], false)
84
#platform: USE_ORIGINS
85
if options.attractMode == false
86
// That little autosave icon, I sure hope you like it...
87
CallNativeFunction2(NotifyCallback, NOTIFY_TOUCH_CHECKPOINT, 0)
88
end if
89
#endplatform
90
end if
91
end if
92
next
93
94
if object.state == LAMPPOST_SPINNING
95
Cos(object.ballPos.x, object.ballAngle)
96
object.ballPos.x *= -0x500
97
98
Sin(object.ballPos.y, object.ballAngle)
99
object.ballPos.y *= 0x500
100
101
object.ballPos.x += object.xpos
102
object.ballPos.y += object.ypos
103
object.ballPos.y -= 0x1A0000
104
105
object.ballAngle += 0x20
106
if object.ballAngle > 0x580
107
object.ballAngle = 0
108
object.state = LAMPPOST_ACTIVE
109
if object.priority != PRIORITY_XBOUNDS_DESTROY
110
object.priority = PRIORITY_BOUNDS
111
end if
112
end if
113
end if
114
end event
115
116
117
event ObjectDraw
118
switch object.state
119
case LAMPPOST_INACTIVE
120
DrawSprite(0)
121
break
122
123
case LAMPPOST_SPINNING
124
DrawSprite(1)
125
DrawSpriteXY(3, object.ballPos.x, object.ballPos.y)
126
break
127
128
case LAMPPOST_ACTIVE
129
DrawSprite(1)
130
object.ballAngle++
131
if object.ballAngle == 8
132
object.ballAngle = 0
133
end if
134
135
temp0 = object.ypos
136
temp0 -= 0x240000
137
DrawSpriteXY(3, object.xpos, temp0)
138
break
139
140
end switch
141
end event
142
143
144
event ObjectStartup
145
LoadSpriteSheet("Global/Items.gif")
146
147
SpriteFrame(-8, -44, 16, 64, 1, 137) // 0 - Full checkpoint sprite
148
SpriteFrame(-8, -28, 16, 48, 1, 153) // 1 - Checkpoint body sprite
149
SpriteFrame(-8, -8, 16, 16, 1, 137) // 2 - Blue ball sprite
150
SpriteFrame(-8, -8, 16, 16, 1, 236) // 3 - Red ball sprite
151
// (Weird green ball next to these on the sheet is unused)
152
153
SetTableValue(TypeName[Lamp Post], DebugMode_ObjCount, DebugMode_TypesTable)
154
SetTableValue(LampPost_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
155
SetTableValue(LampPost_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
156
DebugMode_ObjCount++
157
158
if lampPostID > 31
159
arrayPos0 = lampPostID
160
161
// Move all Players to the Lamp Post
162
currentPlayer = SLOT_PLAYER1
163
while currentPlayer < playerCount
164
player[currentPlayer].xpos = object[arrayPos0].xpos
165
player[currentPlayer].ypos = object[arrayPos0].ypos
166
currentPlayer++
167
loop
168
169
#platform: USE_ORIGINS
170
player.score = recScore
171
172
if player.deadResetRings == true
173
player[0].rings = 0
174
player.deadResetRings = false
175
else
176
player[0].rings = recRing
177
end if
178
179
ringExtraLife = 100
180
ringExtraLife += player[0].rings
181
temp0 = player[0].rings
182
temp0 %= 100
183
ringExtraLife -= temp0
184
if ringExtraLife > 300
185
ringExtraLife = 1000
186
end if
187
#endplatform
188
189
camera[0].xpos = player[0].ixpos
190
camera[0].ypos = player[0].iypos
191
192
object[arrayPos0].state = LAMPPOST_ACTIVE
193
194
stage.milliSeconds = recMilliSeconds
195
stage.seconds = recSeconds
196
stage.minutes = recMinutes
197
198
#platform: USE_ORIGINS
199
StageStatsUsabilityParam1 = StatsUsabilityParam1
200
StageStatsUsabilityParam2 = StatsUsabilityParam2
201
StageStatsUsabilityParam3 = StatsUsabilityParam3
202
StageStatsUsabilityParam4 = StatsUsabilityParam4
203
StageStatsUsabilityParam5 = StatsUsabilityParam5
204
else
205
game.timeOver = false
206
#endplatform
207
end if
208
end event
209
210
211
// ========================
212
// Editor Events
213
// ========================
214
215
event RSDKDraw
216
DrawSprite(0)
217
end event
218
219
220
event RSDKLoad
221
LoadSpriteSheet("Global/Items.gif")
222
SpriteFrame(-8, -44, 16, 64, 1, 137)
223
224
// unused, BUT there are values in the editor which suggest it's supposed to be "lampPostID"
225
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
226
end event
227
228