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/Mission/M035Block.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: M035Block Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Player Aliases
13
private alias object.xpos : player.xpos
14
15
16
// ========================
17
// Events
18
// ========================
19
20
event ObjectUpdate
21
temp6 = PRIORITY_XBOUNDS
22
23
if object.propertyValue == 0
24
// Check for collision, all the way from this platform to the next
25
// Notably this is Platform collision, not Solid collision like the normal type of Mission Block
26
27
temp0 = object[+1].ixpos
28
temp0 -= object.ixpos
29
temp0 += 16 // (if the two blocks are far away enough from each other, the left block will stop providing collision as soon as p1's past the second block's midpoint, which would mean that this line doesn't matter)
30
BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -16, temp0, 16, 0, C_BOX, C_BOX, C_BOX, C_BOX)
31
end if
32
33
// (currentPlayer is never set in this script btw so i hope you don't have a p2 tails around...)
34
if object.propertyValue == 0
35
if object.xpos <= player[currentPlayer].xpos
36
temp6 = PRIORITY_ACTIVE
37
end if
38
else
39
if player[currentPlayer].xpos <= object.xpos
40
temp6 = PRIORITY_ACTIVE
41
end if
42
end if
43
44
object.priority = temp6
45
if object.propertyValue == 0
46
object[+1].priority = temp6
47
else
48
object[-1].priority = temp6
49
end if
50
end event
51
52
53
event ObjectDraw
54
if object.propertyValue == 0
55
CheckNotEqual(object[+1].type, TypeName[M035Block])
56
temp0 = checkResult
57
CheckNotEqual(object[+1].propertyValue, 1)
58
temp0 |= checkResult
59
if temp0 != false
60
// Setup isn't right, just draw a single block
61
62
DrawSprite(0)
63
else
64
temp0 = object.xpos
65
temp1 = object[+1].xpos
66
object[+1].ypos = object.ypos
67
temp2 = 32
68
temp2 <<= 16
69
while temp0 < temp1
70
DrawSpriteXY(0, temp0, object.ypos)
71
temp0 += temp2
72
loop
73
end if
74
else
75
CheckNotEqual(object[-1].type, TypeName[M035Block])
76
temp0 = checkResult
77
CheckNotEqual(object[-1].propertyValue, 0)
78
temp0 |= checkResult
79
if temp0 != false
80
// Setup isn't right, just draw a single block
81
82
DrawSprite(0)
83
else
84
temp0 = object[-1].xpos
85
temp1 = object.xpos
86
object.ypos = object[-1].ypos
87
temp2 = 32
88
temp2 <<= 16
89
while temp0 < temp1
90
DrawSpriteXY(0, temp0, object.ypos)
91
temp0 += temp2
92
loop
93
end if
94
end if
95
end event
96
97
98
event ObjectStartup
99
foreach (TypeName[M035Block], arrayPos0, ALL_ENTITIES)
100
object[arrayPos0].priority = PRIORITY_INACTIVE
101
if object[arrayPos0].propertyValue == 0
102
arrayPos1 = arrayPos0
103
arrayPos1++
104
if object[arrayPos1].type == TypeName[M035Block]
105
object[arrayPos0].priority = PRIORITY_XBOUNDS
106
object[arrayPos1].ypos = object[arrayPos0].ypos
107
end if
108
else
109
arrayPos1 = arrayPos0
110
arrayPos1--
111
if object[arrayPos1].type == TypeName[M035Block]
112
object[arrayPos0].priority = PRIORITY_XBOUNDS
113
object[arrayPos0].ypos = object[arrayPos1].ypos
114
end if
115
end if
116
next
117
118
// Normally loading sheets are the first thing done in a script, but this one's among the few exceptions
119
LoadSpriteSheet("Mission/Objects.gif")
120
121
// Mission Block Frame
122
SpriteFrame(-16, -16, 32, 32, 1, 18)
123
end event
124
125
126
// ========================
127
// Editor Events
128
// ========================
129
130
event RSDKEdit
131
if editor.returnVariable == true
132
switch editor.variableID
133
case EDIT_VAR_PROPVAL // property value
134
checkResult = object.propertyValue
135
break
136
137
case 0 // childType
138
checkResult = object.propertyValue
139
break
140
141
end switch
142
else
143
switch editor.variableID
144
case EDIT_VAR_PROPVAL // property value
145
object.propertyValue = editor.variableValue
146
break
147
148
case 0 // childType
149
object.propertyValue = editor.variableValue
150
break
151
152
end switch
153
end if
154
end event
155
156
157
event RSDKDraw
158
if object.propertyValue == 0
159
CheckNotEqual(object[+1].type, TypeName[M035Block])
160
temp0 = checkResult
161
CheckNotEqual(object[+1].propertyValue, 1)
162
temp0 |= checkResult
163
if temp0 == true
164
DrawSprite(0)
165
else
166
temp0 = object.xpos
167
temp1 = object[+1].xpos
168
temp2 = 32
169
temp2 <<= 16
170
while temp0 < temp1
171
DrawSpriteXY(0, temp0, object.ypos)
172
temp0 += temp2
173
loop
174
end if
175
else
176
CheckNotEqual(object[-1].type, TypeName[M035Block])
177
temp0 = checkResult
178
CheckNotEqual(object[-1].propertyValue, 0)
179
temp0 |= checkResult
180
if temp0 == true
181
DrawSprite(0)
182
else
183
temp0 = object[-1].xpos
184
temp1 = object.xpos
185
temp2 = 32
186
temp2 <<= 16
187
while temp0 < temp1
188
DrawSpriteXY(0, temp0, object[-1].ypos)
189
temp0 += temp2
190
loop
191
end if
192
end if
193
end event
194
195
196
event RSDKLoad
197
LoadSpriteSheet("Mission/Objects.gif")
198
SpriteFrame(-16, -16, 32, 32, 1, 18)
199
200
// objs should be in order of 0->1 xpos-wise, as well as object order-wise
201
AddEditorVariable("childType")
202
SetActiveVariable("childType")
203
AddEnumVariable("Next Slot", 0)
204
AddEnumVariable("Previous Slot", 1)
205
end event
206
207