Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Global/TailsStuck.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Tails Stuck 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.width
13
private alias object.value1 : object.height
14
private alias object.value2 : object.timer
15
16
// Player Aliases
17
private alias 0 : SLOT_PLAYER1
18
private alias 1 : SLOT_PLAYER2
19
20
private alias object.type : player.type
21
private alias object.state : player.state
22
private alias object.xpos : player.xpos
23
private alias object.ypos : player.ypos
24
private alias object.xvel : player.xvel
25
private alias object.yvel : player.yvel
26
private alias object.speed : player.speed
27
private alias object.controlMode : player.controlMode
28
private alias object.interaction : player.interaction
29
private alias object.tileCollisions : player.tileCollisions
30
private alias object.value3 : player.drownTimer
31
private alias object.value4 : player.drownLevel
32
33
34
// ========================
35
// Events
36
// ========================
37
38
event ObjectUpdate
39
temp0 = object.width
40
FlipSign(temp0)
41
temp1 = object.height
42
FlipSign(temp1)
43
if player[SLOT_PLAYER2].type == TypeName[Player 2 Object]
44
BoxCollisionTest(C_TOUCH, object.entityPos, temp0, temp1, object.width, object.height, SLOT_PLAYER2, 4, 4, 4, 4)
45
if checkResult == true
46
object.timer++
47
if object.timer >= 240
48
player[SLOT_PLAYER2].state = Player2_State_FlyToPlayer
49
player[SLOT_PLAYER2].xpos = player[SLOT_PLAYER1].xpos
50
player[SLOT_PLAYER2].ypos = screen.yoffset
51
player[SLOT_PLAYER2].ypos -= 128
52
player[SLOT_PLAYER2].ypos <<= 16
53
player[SLOT_PLAYER2].xvel = 0
54
player[SLOT_PLAYER2].yvel = 0
55
player[SLOT_PLAYER2].speed = 0
56
player[SLOT_PLAYER2].tileCollisions = false
57
player[SLOT_PLAYER2].interaction = false
58
player[SLOT_PLAYER2].controlMode = CONTROLMODE_P2
59
player[SLOT_PLAYER2].drownTimer = 0
60
player[SLOT_PLAYER2].drownLevel = 0
61
end if
62
else
63
object.timer = 0
64
end if
65
end if
66
end event
67
68
69
event ObjectDraw
70
if player[SLOT_PLAYER1].type == TypeName[Debug Mode]
71
temp0 = object.xpos
72
temp1 = object.ypos
73
temp2 = object.propertyValue
74
temp4 = temp2
75
temp4 &= 0xF0
76
temp4 <<= 15
77
temp2 >>= 4
78
temp2++
79
temp6 = temp2
80
temp3 = object.propertyValue
81
temp3 &= 0x0F
82
temp5 = temp3
83
temp5 <<= 19
84
temp3++
85
temp0 -= temp4
86
temp4 = temp0
87
temp1 -= temp5
88
while temp3 > 0
89
while temp2 > 0
90
DrawSpriteXY(0, temp0, temp1)
91
temp0 += 0x100000
92
temp2--
93
loop
94
temp2 = temp6
95
temp0 = temp4
96
temp1 += 0x100000
97
temp3--
98
loop
99
end if
100
end event
101
102
103
event ObjectStartup
104
LoadSpriteSheet("Global/Display.gif")
105
106
// Tails's life icon
107
SpriteFrame(-8, -7, 16, 14, 60, 108)
108
109
foreach (TypeName[Tails Stuck], arrayPos0, ALL_ENTITIES)
110
object[arrayPos0].drawOrder = 5
111
112
object[arrayPos0].width = object[arrayPos0].propertyValue
113
object[arrayPos0].width &= 0xF0
114
object[arrayPos0].width += 16
115
object[arrayPos0].width >>= 1
116
117
object[arrayPos0].height = object[arrayPos0].propertyValue
118
object[arrayPos0].height &= 0x0F
119
object[arrayPos0].height++
120
object[arrayPos0].height <<= 3
121
next
122
end event
123
124
125
// ========================
126
// Editor Events
127
// ========================
128
129
event RSDKEdit
130
if editor.returnVariable == true
131
switch editor.variableID
132
case EDIT_VAR_PROPVAL // property value
133
checkResult = object.propertyValue
134
break
135
136
case 0 // width
137
checkResult = object.propertyValue
138
checkResult >>= 4
139
checkResult &= 0xF
140
break
141
142
case 1 // height
143
checkResult = object.propertyValue
144
checkResult &= 0xF
145
break
146
147
end switch
148
else
149
switch editor.variableID
150
case EDIT_VAR_PROPVAL // property value
151
object.propertyValue = editor.variableValue
152
break
153
154
case 0 // width
155
temp0 = editor.variableValue
156
temp0 &= 0xF
157
temp0 <<= 4
158
159
object.propertyValue &= 0x0F
160
object.propertyValue |= temp0
161
break
162
163
case 1 // height
164
temp0 = editor.variableValue
165
temp0 &= 0xF
166
167
object.propertyValue &= 0xF0
168
object.propertyValue |= temp0
169
break
170
171
end switch
172
end if
173
end event
174
175
176
event RSDKDraw
177
temp0 = object.xpos
178
temp1 = object.ypos
179
temp2 = object.propertyValue
180
temp4 = temp2
181
temp4 &= 0xF0
182
temp4 <<= 15
183
temp2 >>= 4
184
temp2++
185
temp6 = temp2
186
temp3 = object.propertyValue
187
temp3 &= 0x0F
188
temp5 = temp3
189
temp5 <<= 19
190
temp3++
191
temp0 -= temp4
192
temp4 = temp0
193
temp1 -= temp5
194
while temp3 > 0
195
while temp2 > 0
196
DrawSpriteXY(0, temp0, temp1)
197
temp0 += 0x100000
198
temp2--
199
loop
200
temp2 = temp6
201
temp0 = temp4
202
temp1 += 0x100000
203
temp3--
204
loop
205
end event
206
207
208
event RSDKLoad
209
LoadSpriteSheet("Global/Display.gif")
210
SpriteFrame(-8, -7, 16, 14, 60, 108)
211
212
AddEditorVariable("width")
213
AddEditorVariable("height")
214
end event
215
216