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/Balkiry.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Balkiry 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.value1 : object.startPos.x
13
14
// Player aliases
15
private alias object.value40 : player.hitboxLeft
16
private alias object.value38 : player.hitboxTop
17
private alias object.value41 : player.hitboxRight
18
private alias object.value39 : player.hitboxBottom
19
20
21
// ========================
22
// Function Declarations
23
// ========================
24
25
reserve function Balkiry_DebugDraw
26
reserve function Balkiry_DebugSpawn
27
28
29
// ========================
30
// Function Definitions
31
// ========================
32
33
private function Balkiry_DebugDraw
34
DrawSprite(2)
35
end function
36
37
38
private function Balkiry_DebugSpawn
39
CreateTempObject(TypeName[Balkiry], 0, object.xpos, object.ypos)
40
object[tempObjectPos].xvel = -0x30000
41
end function
42
43
44
// ========================
45
// Events
46
// ========================
47
48
event ObjectUpdate
49
if object.priority != PRIORITY_XBOUNDS_DESTROY
50
object.priority = PRIORITY_ACTIVE
51
end if
52
53
object.xpos += object.xvel
54
if object.outOfBounds == true
55
temp0 = object.xpos
56
object.xpos = object.startPos.x
57
if object.outOfBounds == true
58
if object.priority != PRIORITY_XBOUNDS_DESTROY
59
object.priority = PRIORITY_BOUNDS
60
end if
61
else
62
object.xpos = temp0
63
end if
64
end if
65
66
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
67
BoxCollisionTest(C_TOUCH, object.entityPos, -24, -12, 24, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
68
if checkResult == true
69
CallFunction(Player_BadnikBreak)
70
end if
71
next
72
73
object.frame = object.animationTimer
74
object.frame >>= 1
75
object.animationTimer++
76
object.animationTimer &= 3
77
end event
78
79
80
event ObjectDraw
81
DrawSprite(3)
82
DrawSprite(object.frame)
83
end event
84
85
86
event ObjectStartup
87
CheckCurrentStageFolder("Zone10")
88
if checkResult == true
89
LoadSpriteSheet("SCZ/Objects.gif")
90
SpriteFrame(27, -5, 16, 8, 186, 90)
91
SpriteFrame(27, -5, 7, 8, 186, 99)
92
SpriteFrame(-36, -20, 64, 32, 1, 1)
93
SpriteFrame(-36, -20, 69, 34, 1, 34)
94
else
95
LoadSpriteSheet("MBZ/Objects.gif")
96
SpriteFrame(27, -5, 16, 8, 186, 90)
97
SpriteFrame(27, -5, 7, 8, 186, 99)
98
SpriteFrame(-36, -20, 64, 32, 1, 1)
99
SpriteFrame(-36, -20, 69, 34, 1, 34)
100
end if
101
102
foreach (TypeName[Balkiry], arrayPos0, ALL_ENTITIES)
103
object[arrayPos0].startPos.x = object[arrayPos0].xpos
104
if object[arrayPos0].propertyValue == 0
105
object[arrayPos0].xvel = -0x30000
106
else
107
object[arrayPos0].xvel = -0x50000
108
end if
109
next
110
111
SetTableValue(TypeName[Balkiry], DebugMode_ObjCount, DebugMode_TypesTable)
112
SetTableValue(Balkiry_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
113
SetTableValue(Balkiry_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
114
DebugMode_ObjCount++
115
end event
116
117
118
// ========================
119
// Editor Events
120
// ========================
121
122
event RSDKEdit
123
if editor.returnVariable == true
124
switch editor.variableID
125
case EDIT_VAR_PROPVAL // property value
126
checkResult = object.propertyValue
127
break
128
129
case 0 // speed
130
checkResult = object.propertyValue
131
break
132
133
end switch
134
else
135
switch editor.variableID
136
case EDIT_VAR_PROPVAL // property value
137
object.propertyValue = editor.variableValue
138
break
139
140
case 0 // speed
141
object.propertyValue = editor.variableValue
142
break
143
144
end switch
145
end if
146
end event
147
148
149
event RSDKDraw
150
DrawSprite(2)
151
end event
152
153
154
event RSDKLoad
155
CheckCurrentStageFolder("Zone10")
156
if checkResult == true
157
LoadSpriteSheet("SCZ/Objects.gif")
158
SpriteFrame(27, -5, 16, 8, 186, 90)
159
SpriteFrame(27, -5, 7, 8, 186, 99)
160
SpriteFrame(-36, -20, 64, 32, 1, 1)
161
SpriteFrame(-36, -20, 69, 34, 1, 34)
162
else
163
LoadSpriteSheet("MBZ/Objects.gif")
164
SpriteFrame(27, -5, 16, 8, 186, 90)
165
SpriteFrame(27, -5, 7, 8, 186, 99)
166
SpriteFrame(-36, -20, 64, 32, 1, 1)
167
SpriteFrame(-36, -20, 69, 34, 1, 34)
168
end if
169
170
AddEditorVariable("speed")
171
SetActiveVariable("speed")
172
AddEnumVariable("Slow", 0)
173
AddEnumVariable("Fast", 1)
174
end event
175
176