Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/RotatingLog.txt
1319 views
1
//----------------Sonic CD Rotating Log Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Angle
7
8
#alias Object.Value1 : Object.LogX
9
#alias Object.Value2 : Object.LogY
10
11
#alias Object.Value3 : Object.ChangeX
12
#alias Object.Value4 : Object.ChangeY
13
14
// Collision
15
#alias 1 : PLAYER_COL_FLOOR
16
17
// Time Period Aliases
18
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
19
20
#alias 0 : TIME_PRESENT
21
#alias 1 : TIME_PAST
22
#alias 2 : TIME_GOOD_FUTURE
23
#alias 3 : TIME_BAD_FUTURE
24
25
// Ink Effect
26
#alias 1 : INK_BLEND
27
28
// Property Values
29
#alias 0 : CHILD_OBJECT
30
#alias 1 : PARENT_OBJECT
31
32
33
sub ObjectMain
34
35
Object.Angle++
36
Object.Angle &= 511
37
38
// Radius value
39
TempValue1 = 96
40
41
// Get the X change for the platform
42
Cos(Object.ChangeX, Object.Angle)
43
Object.ChangeX *= TempValue1
44
Object.ChangeX <<= 7
45
Object.ChangeX += Object.XPos
46
Object.ChangeX &= 0xFFFF0000 // Truncate the value
47
Object.ChangeX -= Object.LogX
48
49
// And then get the Y change for the platform
50
Sin(Object.ChangeY, Object.Angle)
51
Object.ChangeY *= TempValue1
52
Object.ChangeY <<= 7
53
Object.ChangeY += Object.YPos
54
Object.ChangeY &= 0xFFFF0000 // Truncate the value
55
Object.ChangeY -= Object.LogY
56
57
end sub
58
59
60
sub ObjectPlayerInteraction
61
62
// Backup the Object's base position
63
TempValue0 = Object.XPos
64
TempValue1 = Object.YPos
65
66
// And move the object to where the Log Platform actually is
67
Object.XPos = Object.LogX
68
Object.YPos = Object.LogY
69
70
// Test to see if the Player's on the Log
71
PlayerObjectCollision(C_BOX, -8, -8, 8, 8)
72
if CheckResult == PLAYER_COL_FLOOR
73
74
// Move them along if needed
75
Player.XPos += Object.ChangeX
76
Player.YPos += Object.ChangeY
77
78
end if
79
80
// Restore the Object to its base position
81
Object.XPos = TempValue0
82
Object.YPos = TempValue1
83
84
end sub
85
86
87
sub ObjectDraw
88
89
// Radius value
90
TempValue1 = 96
91
92
// Get the X Position of the Log
93
Cos(Object.LogX, Object.Angle)
94
Object.LogX *= TempValue1
95
Object.LogX <<= 7
96
Object.LogX += Object.XPos
97
Object.LogX &= 0xFFFF0000 // Truncate the value
98
99
// Get the Y Position of the Log
100
Sin(Object.LogY, Object.Angle)
101
Object.LogY *= TempValue1
102
Object.LogY <<= 7
103
Object.LogY += Object.YPos
104
Object.LogY &= 0xFFFF0000 // Truncate the value
105
106
DrawSpriteXY(0, Object.LogX, Object.LogY)
107
108
end sub
109
110
111
sub ObjectStartup
112
LoadSpriteSheet("R5/Objects.gif")
113
114
// Rotating Log Frames
115
// Uses separate sprites for each time zone
116
switch HUD.CurrentTimePeriod
117
case TIME_PRESENT
118
SpriteFrame(-8, -8, 16, 16, 35, 1)
119
break
120
121
case TIME_PAST
122
SpriteFrame(-8, -8, 16, 16, 67, 174)
123
break
124
125
case TIME_GOOD_FUTURE
126
SpriteFrame(-8, -8, 16, 16, 83, 174)
127
break
128
129
case TIME_BAD_FUTURE
130
SpriteFrame(-8, -8, 16, 16, 83, 158)
131
break
132
133
end switch
134
135
// Cycle through all Rotating Log objects in the level
136
ArrayPos0 = 32
137
while ArrayPos0 < 1056
138
if Object[ArrayPos0].Type == TypeName[Rotating Log]
139
140
// See if the object is a Leading Log
141
switch Object[ArrayPos0].PropertyValue
142
case PARENT_OBJECT
143
// Set the starting angle of the next 7 Logs, as well as the current one
144
145
Object[ArrayPos0].Angle = 504
146
ArrayPos0++
147
148
Object[ArrayPos0].Angle = 8
149
ArrayPos0++
150
151
Object[ArrayPos0].Angle = 120
152
ArrayPos0++
153
154
Object[ArrayPos0].Angle = 136
155
ArrayPos0++
156
157
Object[ArrayPos0].Angle = 248
158
ArrayPos0++
159
160
Object[ArrayPos0].Angle = 264
161
ArrayPos0++
162
163
Object[ArrayPos0].Angle = 376
164
ArrayPos0++
165
166
Object[ArrayPos0].Angle = 392
167
break
168
end switch
169
end if
170
171
ArrayPos0++
172
loop
173
174
end sub
175
176
177
// ========================
178
// Editor Subs
179
// ========================
180
181
sub RSDKEdit
182
if Editor.ReturnVariable == true
183
switch Editor.VariableID
184
case EDIT_VAR_PROPVAL // Property Value
185
CheckResult = Object.PropertyValue
186
break
187
case 0 // IsLeader
188
CheckResult = Object.PropertyValue
189
break
190
end switch
191
else
192
switch Editor.VariableID
193
case EDIT_VAR_PROPVAL // Property Value
194
Object.PropertyValue = Editor.VariableValue
195
break
196
case 0 // IsLeader
197
Object.PropertyValue = Editor.VariableValue
198
break
199
end switch
200
end if
201
end sub
202
203
204
sub RSDKDraw
205
DrawSprite(0)
206
207
if Editor.ShowGizmos == true
208
Editor.DrawingOverlay = true
209
210
if Object.PropertyValue == 1
211
TempValue0 = 504
212
else
213
GetObjectType(TempValue1, "Rotating Log")
214
ArrayPos0 = Object.EntityNo
215
TempValue0 = 0
216
217
TempValue2 = false
218
219
while TempValue2 == false
220
if TempValue0 == 8
221
TempValue2 = true
222
end if
223
224
ArrayPos0--
225
TempValue0++
226
227
CheckEqual(Object[ArrayPos0].Type, TempValue1)
228
TempValue2 = CheckResult
229
CheckEqual(Object[ArrayPos0].PropertyValue, true)
230
TempValue2 &= CheckResult
231
loop
232
233
switch TempValue0
234
case 1
235
TempValue0 = 392; break
236
case 2
237
TempValue0 = 376; break
238
case 3
239
TempValue0 = 264; break
240
case 4
241
TempValue0 = 248; break
242
case 5
243
TempValue0 = 136; break
244
case 6
245
TempValue0 = 120; break
246
case 7
247
TempValue0 = 8; break
248
249
// should never get here!
250
case 0
251
default
252
TempValue0 = 504; break
253
254
end switch
255
end if
256
257
Cos(TempValue1, TempValue0)
258
TempValue1 *= 96
259
TempValue1 <<= 7
260
TempValue1 += Object.XPos
261
TempValue1 &= 0xFFFF0000 // Truncate the value
262
263
// Get the Y Position of the Log
264
Sin(TempValue2, TempValue0)
265
TempValue2 *= 96
266
TempValue2 <<= 7
267
TempValue2 += Object.YPos
268
TempValue2 &= 0xFFFF0000 // Truncate the value
269
270
Object.InkEffect = INK_BLEND
271
272
DrawSpriteFX(0, FX_INK, TempValue1, TempValue2)
273
274
Editor.DrawingOverlay = false
275
end if
276
end sub
277
278
279
sub RSDKLoad
280
LoadSpriteSheet("R5/Objects.gif")
281
282
// TODO: this is currently using the Present version of the sprite, with no heed for other time zones
283
// however, surely there's some better way to do this than 10 CheckCurrentStageFolder checks..?
284
SpriteFrame(-8, -8, 16, 16, 35, 1)
285
286
AddEditorVariable("IsLeader")
287
SetActiveVariable("IsLeader")
288
AddEnumVariable("false", 0)
289
AddEnumVariable("true", 1)
290
end sub
291
292