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/MPZ/WallBumper.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Wall Bumper 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.hitboxT
13
private alias object.value1 : object.hitboxB
14
15
// Player aliases
16
private alias object.type : player.type
17
private alias object.xvel : player.xvel
18
private alias object.yvel : player.yvel
19
private alias object.direction : player.direction
20
private alias object.state : player.state
21
private alias object.tileCollisions : player.tileCollisions
22
private alias object.gravity : player.gravity
23
private alias object.speed : player.speed
24
private alias object.collisionMode : player.collisionMode
25
private alias object.pushing : player.pushing
26
private alias object.controlLock : player.controlLock
27
private alias object.animation : player.animation
28
private alias object.prevAnimation : player.prevAnimation
29
private alias object.animationSpeed : player.animationSpeed
30
private alias object.frame : player.frame
31
private alias object.value1 : player.timer
32
private alias object.value25 : player.gravityStrength
33
34
35
// ========================
36
// Events
37
// ========================
38
39
event ObjectUpdate
40
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
41
// Check if the player's on the ground or in the air
42
CheckEqual(player[currentPlayer].gravity, 0)
43
temp0 = checkResult
44
CheckNotEqual(player[currentPlayer].collisionMode, 0)
45
temp0 &= checkResult
46
47
if temp0 == false
48
BoxCollisionTest(C_TOUCH, object.entityPos, -10, object.hitboxT, 10, object.hitboxB, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
49
else
50
BoxCollisionTest(C_TOUCH, object.entityPos, -20, object.hitboxT, 20, object.hitboxB, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
51
end if
52
53
if checkResult == true
54
if object.direction == FLIP_NONE
55
player[currentPlayer].xvel = 0x80000
56
else
57
player[currentPlayer].xvel = -0x80000
58
end if
59
60
player[currentPlayer].yvel = -0x80000
61
player[currentPlayer].yvel -= player[currentPlayer].gravityStrength
62
player[currentPlayer].direction = object.direction
63
#platform: USE_STANDALONE
64
player[currentPlayer].state = Player_State_Air
65
#endplatform
66
#platform: USE_ORIGINS
67
player[currentPlayer].state = Player_State_Air_NoDropDash
68
#endplatform
69
player[currentPlayer].tileCollisions = true
70
player[currentPlayer].gravity = 1
71
player[currentPlayer].speed = player[currentPlayer].xvel
72
player[currentPlayer].timer = 1
73
player[currentPlayer].collisionMode = 0
74
player[currentPlayer].pushing = 0
75
player[currentPlayer].controlLock = 15
76
player[currentPlayer].animation = ANI_TWIRL
77
player[currentPlayer].prevAnimation = ANI_TWIRL
78
player[currentPlayer].frame = 0
79
player[currentPlayer].animationSpeed = 90
80
81
PlaySfx(SfxName[Spring], false)
82
end if
83
next
84
end event
85
86
87
event ObjectDraw
88
if player[0].type == TypeName[Debug Mode]
89
temp1 = object.propertyValue
90
temp1 &= 0x70
91
if temp1 == 0
92
temp0 = -0x400000
93
temp1 = 8
94
else
95
temp0 = -0x800000
96
temp1 = 16
97
end if
98
99
temp0 += object.ypos
100
temp0 += 0x80000
101
temp4 = 0
102
while temp4 < temp1
103
DrawSpriteXY(0, object.xpos, temp0)
104
temp0 += 0x100000
105
temp4++
106
loop
107
end if
108
end event
109
110
111
event ObjectStartup
112
LoadSpriteSheet("Global/Display.gif")
113
SpriteFrame(-8, -8, 16, 16, 93, 113) // #0 - Blank control circle
114
115
foreach (TypeName[Wall Bumper], arrayPos0, ALL_ENTITIES)
116
temp0 = object[arrayPos0].propertyValue
117
temp0 &= 0x70
118
if temp0 == 0
119
object[arrayPos0].hitboxT = 64
120
else
121
object[arrayPos0].hitboxT = 128
122
end if
123
object[arrayPos0].hitboxB = object[arrayPos0].hitboxT
124
FlipSign(object[arrayPos0].hitboxT)
125
object[arrayPos0].drawOrder = 5
126
next
127
end event
128
129
130
// ========================
131
// Editor Events
132
// ========================
133
134
event RSDKEdit
135
if editor.returnVariable == true
136
switch editor.variableID
137
case EDIT_VAR_PROPVAL // property value
138
checkResult = object.propertyValue
139
break
140
141
case 0 // type
142
checkResult = object.propertyValue
143
checkResult &= 0x70
144
checkResult >>= 4
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 // type
155
editor.variableValue &= 7
156
editor.variableValue <<= 4
157
158
temp0 = 0x70
159
Not(temp0)
160
object.propertyValue &= temp0
161
162
object.propertyValue |= editor.variableValue
163
break
164
165
end switch
166
end if
167
end event
168
169
170
event RSDKDraw
171
temp1 = object.propertyValue
172
temp1 &= 0x70
173
if temp1 == 0
174
temp0 = -0x400000
175
temp1 = 8
176
else
177
temp0 = -0x800000
178
temp1 = 16
179
end if
180
181
temp0 += object.ypos
182
temp0 += 0x80000
183
temp4 = 0
184
while temp4 < temp1
185
DrawSpriteXY(0, object.xpos, temp0)
186
temp0 += 0x100000
187
temp4++
188
loop
189
// TODO: Draw a rectangle of the object's hitbox
190
end event
191
192
193
event RSDKLoad
194
LoadSpriteSheet("Global/Display.gif")
195
SpriteFrame(-8, -8, 16, 16, 93, 113) // #0 - Blank control circle
196
197
// First bit is unused
198
199
AddEditorVariable("type")
200
SetActiveVariable("type")
201
AddEnumVariable("4 Bumpers", 0)
202
AddEnumVariable("8 Bumpers", 1)
203
204
// Direction is set via the attribute
205
end event
206
207