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/Mission/FallSignPost.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
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
// Just like the normal Sign Post, value0 is unused
14
private alias object.value1 : object.spinCount
15
private alias object.value2 : object.spinTimer
16
// value3 is kinda unused - it's reset by Eggman SignPost, but doesn't see much use beyond that
17
private alias object.value4 : object.signpostCharYPos
18
19
// States
20
private alias 0 : FALLSIGNPOST_AWAITMISSIONCLEAR
21
private alias 1 : FALLSIGNPOST_FALLTOGROUND
22
private alias 2 : FALLSIGNPOST_SPINNINGONGROUND
23
private alias 3 : FALLSIGNPOST_RESETSIGNPOST
24
private alias 4 : FALLSIGNPOST_LANDONGROUND
25
26
// Path ID Aliases
27
private alias 0 : PATH_A
28
29
30
// ========================
31
// Events
32
// ========================
33
34
event ObjectUpdate
35
switch object.state
36
case FALLSIGNPOST_AWAITMISSIONCLEAR
37
if game.missionCondition == MISSION_CONDITION_CLEAR
38
game.missionCondition = 0
39
object.xpos = screen.xoffset
40
object.xpos += screen.xcenter
41
object.xpos <<= 16
42
object.ypos = screen.yoffset
43
object.ypos += 24
44
object.ypos <<= 16
45
screen.cameraStyle = CAMERASTYLE_HLOCKED // Huh? They lock the camera like this?
46
object.state = FALLSIGNPOST_FALLTOGROUND
47
end if
48
break
49
50
case FALLSIGNPOST_FALLTOGROUND
51
// Fall down
52
object.xpos += object.xvel
53
object.ypos += object.yvel
54
object.yvel += 0xC00
55
56
// Check if we hit the ground and stop falling if we did
57
ObjectTileCollision(CSIDE_FLOOR, 0, 32, PATH_A)
58
if checkResult == true
59
PlaySfx(SfxName[Sliding], false)
60
object.spinCount = 4
61
object.state = FALLSIGNPOST_SPINNINGONGROUND
62
end if
63
64
// Spin!!
65
object.spinTimer++
66
if object.spinTimer == 2
67
object.spinTimer = 0
68
object.frame++
69
if object.frame == 5
70
Rand(temp0, 48)
71
temp0 <<= 16
72
temp0 += object.xpos
73
temp0 -= 0x180000
74
Rand(temp1, 32)
75
temp1 <<= 16
76
temp1 += object.ypos
77
temp1 -= 0x140000
78
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
79
end if
80
81
if object.frame == 9
82
object.frame = 1
83
Rand(temp0, 48)
84
temp0 <<= 16
85
temp0 += object.xpos
86
temp0 -= 0x180000
87
Rand(temp1, 32)
88
temp1 <<= 16
89
temp1 += object.ypos
90
temp1 -= 0x140000
91
92
object.signpostCharYPos += 33
93
if object.signpostCharYPos > 67
94
object.signpostCharYPos = 1
95
end if
96
EditFrame(5, -24, -16, 48, 32, 34, object.signpostCharYPos)
97
98
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
99
end if
100
end if
101
break
102
103
case FALLSIGNPOST_SPINNINGONGROUND
104
music.volume -= 2
105
object.spinTimer++
106
if object.spinTimer == 2
107
object.spinTimer = 0
108
109
object.frame++
110
if object.frame == 5
111
Rand(temp0, 48)
112
temp0 <<= 16
113
temp0 += object.xpos
114
temp0 -= 0x180000
115
Rand(temp1, 32)
116
temp1 <<= 16
117
temp1 += object.ypos
118
temp1 -= 0x140000
119
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
120
end if
121
122
if object.frame == 9
123
Rand(temp0, 48)
124
temp0 <<= 16
125
temp0 += object.xpos
126
temp0 -= 0x180000
127
Rand(temp1, 32)
128
temp1 <<= 16
129
temp1 += object.ypos
130
temp1 -= 0x140000
131
132
object.signpostCharYPos += 33
133
if object.signpostCharYPos > 67
134
object.signpostCharYPos = 1
135
end if
136
EditFrame(5, -24, -16, 48, 32, 34, object.signpostCharYPos)
137
138
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
139
140
object.spinCount--
141
if object.spinCount == 0
142
object.frame = 5
143
object.state = FALLSIGNPOST_RESETSIGNPOST
144
else
145
object.frame = 1
146
end if
147
end if
148
end if
149
break
150
151
case FALLSIGNPOST_RESETSIGNPOST
152
ResetObjectEntity(object.entityPos, TypeName[Sign Post], 0, object.xpos, object.ypos) // Become a real Sign Post!
153
object.frame = 1
154
object.spinCount = 16
155
object.priority = PRIORITY_XBOUNDS
156
break
157
158
case FALLSIGNPOST_LANDONGROUND // Only set by other objects such as Eggman Sign Post
159
PlaySfx(SfxName[Sliding], false)
160
object.spinCount = 4
161
object.state = FALLSIGNPOST_SPINNINGONGROUND
162
break
163
164
end switch
165
end event
166
167
168
event ObjectDraw
169
if object.state > FALLSIGNPOST_AWAITMISSIONCLEAR
170
DrawSprite(0)
171
if object.spinCount > 8
172
DrawSprite(object.frame)
173
else
174
temp0 = object.frame
175
temp0 += 4
176
DrawSprite(temp0)
177
end if
178
end if
179
end event
180
181
182
event ObjectStartup
183
LoadSpriteSheet("Global/Items2.gif")
184
SpriteFrame(-24, 16, 48, 16, 34, 132)
185
SpriteFrame(-24, -16, 48, 32, 34, 100)
186
SpriteFrame(-16, -16, 32, 32, 149, 99)
187
SpriteFrame(-4, -16, 8, 32, 247, 2)
188
SpriteFrame(-16, -16, 32, 32, 116, 99)
189
SpriteFrame(-24, -16, 48, 32, 34, 1)
190
SpriteFrame(-16, -16, 32, 32, 149, 99)
191
SpriteFrame(-4, -16, 8, 32, 247, 2)
192
SpriteFrame(-16, -16, 32, 32, 116, 99)
193
194
foreach (TypeName[FallSignPost], arrayPos0, ALL_ENTITIES)
195
object[arrayPos0].frame = 1
196
object[arrayPos0].spinCount = 16
197
object[arrayPos0].priority = PRIORITY_ACTIVE
198
next
199
end event
200
201
202
// ========================
203
// Editor Events
204
// ========================
205
206
event RSDKDraw
207
DrawSprite(0)
208
DrawSprite(1)
209
end event
210
211
212
event RSDKLoad
213
LoadSpriteSheet("Global/Items2.gif")
214
SpriteFrame(-24, 16, 48, 16, 34, 132)
215
SpriteFrame(-24, -16, 48, 32, 34, 100)
216
217
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
218
end event
219
220