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/OOZ/VFan.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: V Fan 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.timer
13
private alias object.value1 : object.fanOffset.y
14
private alias object.value2 : object.hitboxT
15
private alias object.value3 : object.hitboxB
16
17
// States
18
private alias 0 : VFAN_DEACTIVATE
19
private alias 1 : VFAN_IDLE
20
private alias 2 : VFAN_ACTIVE
21
22
// Player Aliases
23
private alias object.state : player.state
24
private alias object.ypos : player.ypos
25
private alias object.xvel : player.xvel
26
private alias object.yvel : player.yvel
27
private alias object.speed : player.speed
28
private alias object.gravity : player.gravity
29
private alias object.animationSpeed : player.animationSpeed
30
private alias object.animation : player.animation
31
private alias object.scrollTracking : player.scrollTracking
32
private alias object.tileCollisions : player.tileCollisions
33
34
private alias object.value1 : player.timer
35
36
37
// ========================
38
// Function Declarations
39
// ========================
40
41
reserve function VFan_DebugDraw
42
reserve function VFan_DebugSpawn
43
44
45
// ========================
46
// Function Definitions
47
// ========================
48
49
private function VFan_DebugDraw
50
DrawSprite(0)
51
end function
52
53
54
private function VFan_DebugSpawn
55
CreateTempObject(TypeName[V Fan], 0, object.xpos, object.ypos)
56
object[tempObjectPos].speed = 48
57
end function
58
59
60
// ========================
61
// Events
62
// ========================
63
64
event ObjectUpdate
65
switch object.state
66
case VFAN_DEACTIVATE
67
if object.speed > 0
68
object.speed--
69
else
70
object.state++
71
end if
72
object.frame = object.animationTimer
73
object.frame /= 48
74
object.animationTimer += object.speed
75
object.animationTimer %= 288
76
break
77
78
case VFAN_IDLE
79
object.timer++
80
if object.timer == 30
81
object.timer = 0
82
object.speed = 48
83
object.state++
84
end if
85
break
86
87
case VFAN_ACTIVE
88
object.frame = object.animationTimer
89
object.frame /= 48
90
object.animationTimer += object.speed
91
object.animationTimer %= 288
92
93
object.timer++
94
if object.timer == 180
95
object.timer = 0
96
object.state = VFAN_DEACTIVATE
97
end if
98
99
// (This little thing done with temp0, the result isn't actually used anywhere else in this script)
100
// Perhaps this object used to use this variable for oscillation rather than the oscillation table itself?
101
temp0 = oscillation
102
temp0 <<= 2
103
104
GetTableValue(object.hitboxT, 10, StageSetup_oscillationTable)
105
object.hitboxT >>= 8
106
object.hitboxB = object.hitboxT
107
object.hitboxT -= 112
108
object.hitboxB += 32
109
object.fanOffset.y = object.hitboxT
110
object.fanOffset.y <<= 16
111
object.fanOffset.y += object.ypos
112
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
113
BoxCollisionTest(C_TOUCH, object.entityPos, -64, object.hitboxT, 64, object.hitboxB, currentPlayer, 0, 0, 0, 0)
114
if checkResult == true
115
player[currentPlayer].animation = ANI_TWIRL
116
player[currentPlayer].animationSpeed = 0x50
117
player[currentPlayer].scrollTracking = true
118
player[currentPlayer].gravity = GRAVITY_AIR
119
#platform: USE_STANDALONE
120
player[currentPlayer].state = Player_State_Air
121
#endplatform
122
#platform: USE_ORIGINS
123
player[currentPlayer].state = Player_State_Air_NoDropDash
124
#endplatform
125
player[currentPlayer].tileCollisions = true
126
player[currentPlayer].speed = player[currentPlayer].xvel
127
player[currentPlayer].timer = 0
128
player[currentPlayer].yvel = 0
129
temp1 = object.fanOffset.y
130
temp1 -= player[currentPlayer].ypos
131
temp1 >>= 4
132
player[currentPlayer].ypos += temp1
133
end if
134
next
135
break
136
137
end switch
138
end event
139
140
141
event ObjectDraw
142
DrawSprite(object.frame)
143
end event
144
145
146
event ObjectStartup
147
CheckCurrentStageFolder("Zone07")
148
if checkResult == true
149
LoadSpriteSheet("OOZ/Objects.gif")
150
SpriteFrame(-16, -12, 32, 24, 206, 181)
151
SpriteFrame(-16, -12, 32, 24, 239, 181)
152
SpriteFrame(-16, -12, 32, 24, 206, 206)
153
SpriteFrame(-16, -12, 32, 24, 239, 206)
154
SpriteFrame(-16, -12, 32, 24, 206, 231)
155
SpriteFrame(-16, -12, 32, 24, 239, 231)
156
else
157
LoadSpriteSheet("MBZ/Objects.gif")
158
SpriteFrame(-16, -12, 32, 24, 376, 820)
159
SpriteFrame(-16, -12, 32, 24, 409, 820)
160
SpriteFrame(-16, -12, 32, 24, 376, 845)
161
SpriteFrame(-16, -12, 32, 24, 409, 845)
162
SpriteFrame(-16, -12, 32, 24, 376, 870)
163
SpriteFrame(-16, -12, 32, 24, 409, 870)
164
end if
165
166
foreach (TypeName[V Fan], arrayPos0, ALL_ENTITIES)
167
object[arrayPos0].speed = 36
168
next
169
170
SetTableValue(TypeName[V Fan], DebugMode_ObjCount, DebugMode_TypesTable)
171
SetTableValue(VFan_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
172
SetTableValue(VFan_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
173
DebugMode_ObjCount++
174
end event
175
176
177
// ========================
178
// Editor Events
179
// ========================
180
181
event RSDKDraw
182
DrawSprite(0)
183
184
if editor.showGizmos == true
185
editor.drawingOverlay = true
186
187
// The hitbox oscillates a bit, but it's only by a few pixels, so this is okay
188
temp0 = 64; temp1 = 112; temp2 = 64; temp3 = 32;
189
CallFunction(EditorHelpers_DrawHitbox)
190
191
editor.drawingOverlay = false
192
end if
193
end event
194
195
196
event RSDKLoad
197
CheckCurrentStageFolder("Zone07")
198
if checkResult == true
199
LoadSpriteSheet("OOZ/Objects.gif")
200
SpriteFrame(-16, -12, 32, 24, 206, 181)
201
else
202
LoadSpriteSheet("MBZ/Objects.gif")
203
SpriteFrame(-16, -12, 32, 24, 376, 820)
204
end if
205
206
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
207
end event
208
209