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/Enemies/BeeShot.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Bee Shot Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Bridge Aliases
13
private alias object.value2 : bridge.stoodPos
14
private alias object.value4 : bridge.bridgeDepth
15
private alias object.value6 : bridge.startPos
16
private alias object.value7 : bridge.endPos
17
18
// Burning Log aliases
19
private alias object.value0 : burningLog.timer
20
21
22
// ========================
23
// Events
24
// ========================
25
26
event ObjectUpdate
27
object.xpos += object.xvel
28
object.ypos += object.yvel
29
30
if object.outOfBounds == true
31
object.type = TypeName[Blank Object]
32
end if
33
34
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
35
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
36
if checkResult == true
37
CallFunction(Player_ProjectileHit)
38
end if
39
next
40
41
// Check if we touched a bridge... and if we did, burn that sucka to the ground
42
foreach (TypeName[Bridge], arrayPos0, ACTIVE_ENTITIES)
43
if object.xpos > bridge[arrayPos0].startPos
44
if object.xpos < bridge[arrayPos0].endPos
45
temp0 = object[arrayPos0].ypos
46
temp0 -= 0x80000
47
if object.ypos >= temp0
48
temp0 += 0x100000
49
if object.ypos <= temp0
50
temp7 = object.xpos
51
temp7 -= bridge[arrayPos0].startPos
52
temp7 >>= 20
53
temp7 *= 15
54
temp7 -= 15
55
temp6 = -15
56
57
temp0 = 0
58
temp1 = bridge[arrayPos0].startPos
59
temp1 += 0x80000
60
temp4 = 0x80000
61
temp5 = bridge[arrayPos0].stoodPos
62
temp5 >>= 20
63
while temp0 < temp5
64
temp3 = temp4
65
temp3 <<= 7
66
temp3 /= bridge[arrayPos0].stoodPos
67
Sin(temp2, temp3)
68
temp2 *= bridge[arrayPos0].bridgeDepth
69
temp2 >>= 9
70
temp2 += object[arrayPos0].ypos
71
72
CreateTempObject(TypeName[Burning Log], 0, temp1, temp2)
73
burningLog[tempObjectPos].timer = temp7
74
75
temp7 += temp6
76
if temp7 == 15
77
FlipSign(temp6)
78
end if
79
80
temp1 += 0x100000
81
temp4 += 0x100000
82
temp0++
83
loop
84
85
temp2 = bridge[arrayPos0].bridgeDepth
86
temp2 += object[arrayPos0].ypos
87
CreateTempObject(TypeName[Burning Log], 0, temp1, temp2)
88
burningLog[tempObjectPos].timer = temp7
89
90
temp7 += temp6
91
if temp7 == 15
92
FlipSign(temp6)
93
end if
94
temp1 += 0x100000
95
96
temp0++
97
temp5 = bridge[arrayPos0].endPos
98
temp5 -= bridge[arrayPos0].startPos
99
temp5 -= bridge[arrayPos0].stoodPos
100
temp1 = bridge[arrayPos0].endPos
101
temp1 -= 0x80000
102
temp4 = 0x80000
103
temp7 = object[arrayPos0].propertyValue
104
temp7 -= temp0
105
temp7 *= 15
106
temp6 = -15
107
while temp0 < object[arrayPos0].propertyValue
108
temp3 = temp4
109
temp3 <<= 7
110
temp3 /= temp5
111
Sin(temp2, temp3)
112
temp2 *= bridge[arrayPos0].bridgeDepth
113
temp2 >>= 9
114
temp2 += object[arrayPos0].ypos
115
116
CreateTempObject(TypeName[Burning Log], 0, temp1, temp2)
117
burningLog[tempObjectPos].timer = temp7
118
119
temp7 += temp6
120
if temp7 == 15
121
FlipSign(temp6)
122
end if
123
temp1 -= 0x100000
124
temp4 += 0x100000
125
temp0++
126
loop
127
128
object[arrayPos0].type = TypeName[Blank Object]
129
end if
130
end if
131
end if
132
end if
133
next
134
end event
135
136
137
event ObjectDraw
138
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
139
end event
140
141
142
event ObjectStartup
143
// Interestingly this object checks for both of its folders explicitly, while most other objects instead check for their primary zone and then MBZ's within a simple `else` instead
144
// Given that the MBZ frame data is a duplicate of the EHZ frame data, it is kinda confusing why it's structered like this...
145
// Perhaps this object was based off an S1 badnik shot, where individual checks are the norm?
146
147
CheckCurrentStageFolder("Zone01")
148
if checkResult == true
149
LoadSpriteSheet("EHZ/Objects.gif")
150
SpriteFrame(-12, -3, 8, 10, 1, 50)
151
SpriteFrame(-12, -3, 8, 10, 10, 50)
152
SpriteFrame(-8, -8, 16, 24, 110, 19)
153
end if
154
155
CheckCurrentStageFolder("ZoneM")
156
if checkResult == true
157
LoadSpriteSheet("MBZ/Objects.gif")
158
159
// This is just duplicated EHZ frame data, so it doesn't quite look right in-game
160
// (The correct sprites are present on the MBZ sheet, though, and those sprites are even used by the MBZ Buzzer too!)
161
SpriteFrame(-12, -3, 8, 10, 1, 50)
162
SpriteFrame(-12, -3, 8, 10, 10, 50)
163
SpriteFrame(-8, -8, 16, 24, 110, 19)
164
end if
165
end event
166
167
168
// ========================
169
// Editor Events
170
// ========================
171
172
event RSDKDraw
173
DrawSprite(0)
174
end event
175
176
177
event RSDKLoad
178
CheckCurrentStageFolder("Zone01")
179
if checkResult == true
180
LoadSpriteSheet("EHZ/Objects.gif")
181
SpriteFrame(-12, -3, 8, 10, 1, 50)
182
else
183
LoadSpriteSheet("MBZ/Objects.gif")
184
SpriteFrame(-12, -3, 8, 10, 66, 302) // Decomp note - using fixed frame here
185
end if
186
187
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
188
end event
189
190