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/MovingSpikes.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Moving Spikes 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
14
15
// ========================
16
// Function Declarations
17
// ========================
18
19
reserve function MovingSpikes_DebugDraw
20
reserve function MovingSpikes_DebugSpawn
21
reserve function MovingSpikes_TryPlayClankSfx
22
23
24
// ========================
25
// Function Definitions
26
// ========================
27
28
private function MovingSpikes_DebugDraw
29
DrawSprite(0)
30
end function
31
32
33
private function MovingSpikes_DebugSpawn
34
CreateTempObject(TypeName[Moving Spikes], 0, object.xpos, object.ypos)
35
object[tempObjectPos].inkEffect = INK_BLEND
36
object[tempObjectPos].drawOrder = 5
37
if object.direction == FLIP_X
38
object[tempObjectPos].xpos += 0x680000
39
object[tempObjectPos].xvel = -0x10000
40
object[tempObjectPos].timer = 104
41
else
42
object[tempObjectPos].xpos -= 0x680000
43
object[tempObjectPos].xvel = 0x10000
44
object[tempObjectPos].timer = -104
45
end if
46
end function
47
48
49
private function MovingSpikes_TryPlayClankSfx
50
temp0 = screen.xcenter
51
temp0 += 32
52
CheckCameraProximity(object.ixpos, object.iypos, temp0, 160)
53
if checkResult == true
54
PlaySfx(SfxName[Clank], false)
55
end if
56
end function
57
58
59
// ========================
60
// Events
61
// ========================
62
63
event ObjectUpdate
64
object.xpos += object.xvel
65
if object.xvel > 0
66
object.timer++
67
if object.timer == 104
68
FlipSign(object.xvel)
69
CallFunction(MovingSpikes_TryPlayClankSfx)
70
else
71
foreach (TypeName[Moving Spikes], arrayPos0, ACTIVE_ENTITIES)
72
if arrayPos0 != object.entityPos
73
BoxCollisionTest(C_TOUCH, object.entityPos, 0, -40, 25, 40, arrayPos0, -25, -40, 0, 40)
74
if checkResult == true
75
FlipSign(object.xvel)
76
CallFunction(MovingSpikes_TryPlayClankSfx)
77
end if
78
end if
79
next
80
end if
81
else
82
object.timer--
83
if object.timer == -104
84
FlipSign(object.xvel)
85
CallFunction(MovingSpikes_TryPlayClankSfx)
86
else
87
foreach (TypeName[Moving Spikes], arrayPos0, ACTIVE_ENTITIES)
88
if arrayPos0 != object.entityPos
89
BoxCollisionTest(C_TOUCH, object.entityPos, -25, -40, 0, 40, arrayPos0, 0, -40, 25, 40)
90
if checkResult == true
91
FlipSign(object.xvel)
92
CallFunction(MovingSpikes_TryPlayClankSfx)
93
end if
94
end if
95
next
96
end if
97
end if
98
99
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
100
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -32, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
101
if checkResult == true
102
CallFunction(Player_Hit)
103
end if
104
next
105
end event
106
107
108
event ObjectDraw
109
DrawSpriteFX(1, FX_INK, object.xpos, object.ypos)
110
DrawSprite(0)
111
end event
112
113
114
event ObjectStartup
115
LoadSpriteSheet("OOZ/Objects.gif")
116
SpriteFrame(-24, -40, 48, 80, 206, 26)
117
SpriteFrame(8, -16, 4, 32, 239, 107)
118
119
foreach (TypeName[Moving Spikes], arrayPos0, ALL_ENTITIES)
120
object[arrayPos0].priority = PRIORITY_INACTIVE
121
object[arrayPos0].inkEffect = INK_BLEND
122
object[arrayPos0].drawOrder = 5
123
if object[arrayPos0].propertyValue == 1
124
object[arrayPos0].xpos += 0x680000
125
object[arrayPos0].xvel = -0x10000
126
object[arrayPos0].timer = 104
127
else
128
if object[arrayPos0].propertyValue == 0
129
object[arrayPos0].xpos -= 0x680000
130
object[arrayPos0].xvel = 0x10000
131
object[arrayPos0].timer = -104
132
else
133
object[arrayPos0].xvel = -0x10000
134
end if
135
end if
136
next
137
138
SetTableValue(TypeName[Moving Spikes], DebugMode_ObjCount, DebugMode_TypesTable)
139
SetTableValue(MovingSpikes_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
140
SetTableValue(MovingSpikes_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
141
DebugMode_ObjCount++
142
end event
143
144
145
// ========================
146
// Editor Events
147
// ========================
148
149
event RSDKEdit
150
if editor.returnVariable == true
151
switch editor.variableID
152
case EDIT_VAR_PROPVAL // property value
153
case 0 // type
154
checkResult = object.propertyValue
155
break
156
end switch
157
else
158
switch editor.variableID
159
case EDIT_VAR_PROPVAL // property value
160
case 0 // type
161
object.propertyValue = editor.variableValue
162
break
163
end switch
164
end if
165
end event
166
167
168
event RSDKDraw
169
object.inkEffect = INK_BLEND
170
171
DrawSpriteFX(1, FX_INK, object.xpos, object.ypos)
172
DrawSprite(0)
173
174
if editor.showGizmos == true
175
editor.drawingOverlay = true
176
177
temp0 = object.xpos
178
temp0 -= 0x680000
179
180
temp1 = object.xpos
181
temp1 += 0x680000
182
183
object.inkEffect = INK_NONE
184
DrawLine(temp0, object.ypos, temp1, object.ypos, 0x00, 0xFF, 0x00)
185
186
editor.drawingOverlay = false
187
end if
188
end event
189
190
191
event RSDKLoad
192
LoadSpriteSheet("OOZ/Objects.gif")
193
SpriteFrame(-24, -40, 48, 80, 206, 26)
194
SpriteFrame(8, -16, 4, 32, 239, 107)
195
196
AddEditorVariable("type")
197
SetActiveVariable("type")
198
AddEnumVariable("Left", 0)
199
AddEnumVariable("Right", 1)
200
AddEnumVariable("Center", 2)
201
end event
202
203