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/Mission/FallSignPost.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: FallSignPost Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Variables
13
private alias object.value0 : object.spinCount
14
private alias object.value1 : object.spinTimer
15
private alias object.value2 : object.clearTimer
16
private alias object.value3 : object.signPostLanded
17
18
// States
19
private alias 0 : FALLSIGNPOST_AWAITMISSIONCLEAR
20
private alias 1 : FALLSIGNPOST_FALLTOGROUND
21
private alias 2 : FALLSIGNPOST_SPINNINGONGROUND
22
private alias 3 : FALLSIGNPOST_LOCKPLAYERCONTROL
23
24
// Player Aliases
25
private alias object.xpos : player.xpos
26
private alias object.ixpos : player.ixpos
27
private alias object.outOfBounds : player.outOfBounds
28
private alias object.state : player.state
29
private alias object.controlMode : player.controlMode
30
private alias object.interaction : player.interaction
31
private alias object.up : player.up
32
private alias object.down : player.down
33
private alias object.left : player.left
34
private alias object.right : player.right
35
private alias object.jumpHold : player.jumpHold
36
private alias object.jumpPress : player.jumpPress
37
private alias object.xvel : player.xvel
38
private alias object.yvel : player.yvel
39
private alias object.speed : player.speed
40
private alias object.animation : player.animation
41
private alias object.value3 : player.drownTimer
42
private alias object.value7 : player.invincibleTimer
43
44
// Track Aliases
45
private alias 1 : TRACK_ACTFINISH
46
47
// Reserved Object Slot Aliases
48
private alias 30 : SLOT_ACTFINISH
49
50
// Path ID Aliases
51
private alias 0 : PATH_A
52
53
54
// ========================
55
// Events
56
// ========================
57
58
event ObjectUpdate
59
switch object.state
60
case FALLSIGNPOST_AWAITMISSIONCLEAR
61
if game.missionCondition == MISSION_CONDITION_CLEAR
62
game.missionCondition = 0
63
64
object.xpos = player[0].xpos
65
object.xpos -= 0x80000
66
object.ypos = screen.yoffset
67
object.ypos += 24
68
object.ypos <<= 16
69
70
screen.cameraStyle = CAMERASTYLE_HLOCKED
71
72
ObjectTileCollision(CSIDE_FLOOR, 0, 32, PATH_A)
73
if checkResult == true
74
object.signPostLanded = true
75
end if
76
77
object.state = FALLSIGNPOST_FALLTOGROUND
78
PlaySfx(SfxName[Sign Post], false)
79
end if
80
break
81
82
case FALLSIGNPOST_FALLTOGROUND
83
object.clearTimer++
84
object.ypos += object.yvel
85
object.yvel += 0xC00
86
87
ObjectTileCollision(CSIDE_FLOOR, 0, 32, PATH_A)
88
if checkResult == true
89
if object.signPostLanded == false
90
object.spinCount = 4
91
object.state = FALLSIGNPOST_SPINNINGONGROUND
92
end if
93
else
94
object.signPostLanded = false
95
end if
96
97
if object.outOfBounds == true
98
object.spinCount = 4
99
object.state = FALLSIGNPOST_SPINNINGONGROUND
100
end if
101
102
object.spinTimer++
103
if object.spinTimer == 2
104
object.spinTimer = 0
105
object.frame++
106
if object.frame == 5
107
Rand(temp0, 48)
108
temp0 <<= 16
109
temp0 += object.xpos
110
temp0 -= 0x180000
111
Rand(temp1, 32)
112
temp1 <<= 16
113
temp1 += object.ypos
114
temp1 -= 0x140000
115
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
116
end if
117
118
if object.frame == 9
119
object.frame = 1
120
Rand(temp0, 48)
121
temp0 <<= 16
122
temp0 += object.xpos
123
temp0 -= 0x180000
124
Rand(temp1, 32)
125
temp1 <<= 16
126
temp1 += object.ypos
127
temp1 -= 0x140000
128
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
129
end if
130
end if
131
break
132
133
case FALLSIGNPOST_SPINNINGONGROUND
134
object.clearTimer++
135
if stage.timeEnabled == true
136
music.volume -= 2
137
end if
138
139
object.spinTimer++
140
if object.spinTimer == 2
141
object.spinTimer = 0
142
object.frame++
143
if object.frame == 5
144
Rand(temp0, 48)
145
temp0 <<= 16
146
temp0 += object.xpos
147
temp0 -= 0x180000
148
Rand(temp1, 32)
149
temp1 <<= 16
150
temp1 += object.ypos
151
temp1 -= 0x140000
152
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
153
end if
154
155
if object.frame == 9
156
object.frame = 1
157
Rand(temp0, 48)
158
temp0 <<= 16
159
temp0 += object.xpos
160
temp0 -= 0x180000
161
Rand(temp1, 32)
162
temp1 <<= 16
163
temp1 += object.ypos
164
temp1 -= 0x140000
165
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
166
object.spinCount--
167
if object.spinCount == 0
168
object.frame = 5
169
object.state = 3
170
end if
171
end if
172
end if
173
break
174
175
case 3
176
player[0].controlMode = CONTROLMODE_NONE
177
player[0].interaction = false
178
player[0].up = false
179
player[0].down = false
180
player[0].left = false
181
player[0].right = false
182
player[0].jumpHold = false
183
player[0].jumpPress = false
184
185
CheckEqual(player[0].state, Player_State_Ground)
186
temp0 = checkResult
187
CheckEqual(player[0].state, Player_State_Static)
188
temp0 |= checkResult
189
CheckEqual(player[0].outOfBounds, true)
190
temp0 |= checkResult
191
temp1 = screen.xoffset
192
temp1 += screen.xsize
193
temp1 += 32
194
CheckGreater(player[0].ixpos, temp1)
195
temp0 |= checkResult
196
if temp0 == true
197
player[0].state = Player_State_Static
198
player[0].controlMode = CONTROLMODE_NONE
199
player[0].interaction = false
200
player[0].up = false
201
player[0].down = false
202
player[0].left = false
203
player[0].right = false
204
player[0].jumpHold = false
205
player[0].jumpPress = false
206
player[0].xvel = 0
207
player[0].yvel = 0
208
player[0].speed = 0
209
player[0].animation = ANI_WAITING
210
screen.cameraEnabled = false
211
end if
212
break
213
214
end switch
215
216
if object.clearTimer > 0
217
player[0].drownTimer = 0
218
player[0].invincibleTimer = 80
219
end if
220
221
CheckGreater(object.clearTimer, 60)
222
temp0 = checkResult
223
CheckEqual(object[SLOT_ACTFINISH].type, TypeName[Blank Object])
224
temp0 &= checkResult
225
if temp0 == true
226
CallNativeFunction2(NotifyCallback, NOTIFY_TOUCH_SIGNPOST, 0)
227
stage.timeEnabled = false
228
PlayMusic(TRACK_ACTFINISH)
229
object[SLOT_ACTFINISH].type = TypeName[Act Finish]
230
object[SLOT_ACTFINISH].drawOrder = 6
231
object[SLOT_ACTFINISH].priority = PRIORITY_ACTIVE
232
end if
233
end event
234
235
236
event ObjectDraw
237
if object.state > FALLSIGNPOST_AWAITMISSIONCLEAR
238
DrawSprite(0)
239
DrawSprite(object.frame)
240
end if
241
end event
242
243
244
event ObjectStartup
245
LoadSpriteSheet("Global/Items2.gif")
246
SpriteFrame(-24, 16, 48, 16, 34, 214)
247
SpriteFrame(-24, -16, 48, 32, 34, 182)
248
SpriteFrame(-16, -16, 32, 32, 1, 150)
249
SpriteFrame(-4, -16, 8, 32, 189, 131)
250
SpriteFrame(-16, -16, 32, 32, 1, 183)
251
SpriteFrame(-24, -16, 48, 32, 34, 83)
252
SpriteFrame(-16, -16, 32, 32, 1, 150)
253
SpriteFrame(-4, -16, 8, 32, 189, 131)
254
SpriteFrame(-16, -16, 32, 32, 1, 183)
255
256
foreach (TypeName[FallSignPost], arrayPos0, ALL_ENTITIES)
257
object[arrayPos0].frame = 1
258
object[arrayPos0].spinCount = 16
259
object[arrayPos0].priority = PRIORITY_ACTIVE
260
next
261
end event
262
263
264
// ========================
265
// Editor Events
266
// ========================
267
268
event RSDKDraw
269
DrawSprite(0)
270
end event
271
272
273
event RSDKLoad
274
LoadSpriteSheet("Global/Items2.gif")
275
SpriteFrame(-24, 16, 48, 16, 34, 214)
276
SpriteFrame(-24, -16, 48, 32, 34, 182)
277
278
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
279
end event
280
281