Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/FanElevator.txt
1319 views
1
//----------------Sonic CD Fan Elevator Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.MinHeight
7
#alias Object.Value2 : Object.YVelocity
8
9
// HUD alias
10
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
11
12
// States
13
#alias 0 : FAN_ELEVATOR_CLOSED
14
#alias 1 : FAN_ELEVATOR_OPEN
15
16
// Stage SFX
17
#alias 8 : SFX_S_SWITCH
18
19
// Time Periods
20
#alias 0 : TIME_PRESENT
21
#alias 1 : TIME_PAST
22
#alias 2 : TIME_GOOD_FUTURE
23
#alias 3 : TIME_BAD_FUTURE
24
25
// Priority
26
#alias 3 : PRIORITY_XBOUNDS
27
28
29
sub ObjectMain
30
if Object.State == FAN_ELEVATOR_CLOSED
31
if Object.YVelocity < 0x10000
32
Object.YVelocity += 0x2000
33
end if
34
if Object.YPos == Object.MinHeight
35
TempValue0 = Player.YPos
36
TempValue0 -= Object.YPos
37
if TempValue0 < 0xA00000
38
Object.YVelocity = 0
39
end if
40
else
41
TempValue0 = Object.YPos
42
TempValue0 -= Object.MinHeight
43
if TempValue0 > 0x2A00000
44
Object.YPos = Object.MinHeight
45
end if
46
end if
47
end if
48
Object.YPos += Object.YVelocity
49
end sub
50
51
52
sub ObjectPlayerInteraction
53
PlayerObjectCollision(C_PLATFORM, -32, -28, 32, 8)
54
if CheckResult == true
55
Object.YVelocity = -0x20000
56
if Object.State == FAN_ELEVATOR_CLOSED
57
PlayStageSfx(SFX_S_SWITCH, false)
58
end if
59
Object.State = FAN_ELEVATOR_OPEN
60
else
61
if Object.YVelocity < 0
62
Object.YVelocity = 0
63
end if
64
Object.State = FAN_ELEVATOR_CLOSED
65
end if
66
end sub
67
68
69
sub ObjectDraw
70
if Object.State == FAN_ELEVATOR_CLOSED
71
DrawSprite(0)
72
DrawSprite(1)
73
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
74
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
75
else
76
DrawSprite(2)
77
DrawSprite(3)
78
DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)
79
DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)
80
end if
81
end sub
82
83
84
sub ObjectStartup
85
LoadSpriteSheet("R4/Objects3.gif")
86
if HUD.CurrentTimePeriod < 2 // Present or Past
87
SpriteFrame(-32, -32, 32, 48, 84, 46) // #0 - Fan Elevator Body
88
SpriteFrame(-32, 16, 32, 16, 110, 144) // #1 - Fan closed looking down
89
SpriteFrame(-32, -32, 32, 48, 84, 95) // #2 - Fan Elevator Body pressed
90
SpriteFrame(-32, 16, 32, 16, 110, 161) // #3 - Fan open looking down
91
else
92
SpriteFrame(-32, -32, 32, 48, 84, 46) // #0 - Fan Elevator Body
93
SpriteFrame(-32, 16, 32, 16, 126, 228) // #1 - Fan closed looking down
94
SpriteFrame(-32, -32, 32, 48, 84, 95) // #2 - Fan Elevator Body pressed
95
SpriteFrame(-32, 16, 32, 16, 158, 228) // #3 - Fan open looking down
96
end if
97
98
ArrayPos0 = 32
99
while ArrayPos0 < 1056
100
if Object[ArrayPos0].Type == TypeName[Fan Elevator]
101
Object[ArrayPos0].Direction = FACING_LEFT
102
Object[ArrayPos0].Priority = PRIORITY_XBOUNDS
103
Object[ArrayPos0].MinHeight = Object[ArrayPos0].YPos
104
end if
105
ArrayPos0++
106
loop
107
end sub
108
109
110
// ========================
111
// Editor Subs
112
// ========================
113
114
sub RSDKDraw
115
DrawSprite(0)
116
DrawSprite(1)
117
Object.Direction = FACING_LEFT
118
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
119
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
120
end sub
121
122
123
sub RSDKLoad
124
LoadSpriteSheet("R4/Objects3.gif")
125
CallFunction(EditorHelpers_FindTimePeriod)
126
if CheckResult < 2 // Present or Past
127
SpriteFrame(-32, -32, 32, 48, 84, 46) // #0 - Fan Elevator Body
128
SpriteFrame(-32, 16, 32, 16, 110, 144) // #1 - Fan closed looking down
129
SpriteFrame(-32, -32, 32, 48, 84, 95) // #2 - Fan Elevator Body pressed
130
SpriteFrame(-32, 16, 32, 16, 110, 161) // #3 - Fan open looking down
131
else
132
SpriteFrame(-32, -32, 32, 48, 84, 46) // #0 - Fan Elevator Body
133
SpriteFrame(-32, 16, 32, 16, 126, 228) // #1 - Fan closed looking down
134
SpriteFrame(-32, -32, 32, 48, 84, 95) // #2 - Fan Elevator Body pressed
135
SpriteFrame(-32, 16, 32, 16, 158, 228) // #3 - Fan open looking down
136
end if
137
138
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
139
end sub
140
141