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/Mission/MissionBlock.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: MissionBlock 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.propertyValue : object.disableCrush
13
14
private alias object.value0 : object.ledgePullFlag // set from editor - determines if knuckles is able to pull himself up onto a block
15
16
// Player Aliases
17
private alias object.state : player.state
18
private alias object.speed : player.speed
19
private alias object.xvel : player.xvel
20
private alias object.yvel : player.yvel
21
private alias object.gravity : player.gravity
22
private alias object.animation : player.animation
23
private alias object.frame : player.frame
24
25
private alias object.value1 : player.timer
26
private alias object.value44 : player.missionBlockID
27
28
// Reserved Object Slot Aliases
29
private alias 0 : SLOT_PLAYER1
30
31
32
// ========================
33
// Events
34
// ========================
35
36
event ObjectUpdate
37
CheckNotEqual(player[SLOT_PLAYER1].state, Player_State_Drown) // drowning is checked against but not death? if you really wanna, ig
38
temp0 = checkResult
39
CheckNotEqual(player[SLOT_PLAYER1].state, Player_State_LPullUp_Mission)
40
temp0 &= checkResult
41
CheckNotEqual(player[SLOT_PLAYER1].state, Player_State_LedgePullUp)
42
checkResult &= temp0
43
if checkResult == true
44
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, SLOT_PLAYER1, C_BOX, C_BOX, C_BOX, C_BOX)
45
if player[SLOT_PLAYER1].state == Player_State_Climb_Mission
46
checkResult = COL_NONE
47
end if
48
if player[SLOT_PLAYER1].state == Player_State_Climb
49
checkResult = COL_NONE
50
end if
51
52
if checkResult == COL_BOTTOM
53
if object.disableCrush == false // value set from editor
54
// ...it looks like this crush code was copied from SYZ's VBlock for some reason? it's not too hard to just make your own...
55
56
if player[currentPlayer].gravity == GRAVITY_GROUND // btw currentPlayer is never set in this script
57
if object.angle > 384 // this object's angle is never set???
58
CallFunction(Player_Kill)
59
end if
60
61
if object.angle < 128 // This object's angle is always 0 so this check always passes
62
CallFunction(Player_Kill)
63
end if
64
end if
65
end if
66
end if
67
68
// Store what collision type the block got
69
temp0 = checkResult
70
71
// See if the Player hit the left side of a block, while gliding right
72
CheckEqual(temp0, COL_LEFT)
73
temp1 = checkResult
74
CheckEqual(player[SLOT_PLAYER1].state, Player_State_GlideRight)
75
temp1 &= checkResult
76
77
// And then see if the Player hit the right side of a block, while gliding left
78
CheckEqual(temp0, COL_RIGHT)
79
temp2 = checkResult
80
CheckEqual(player[SLOT_PLAYER1].state, Player_State_GlideLeft)
81
temp2 &= checkResult
82
83
// See if either checks passed
84
temp1 |= temp2
85
if temp1 != false
86
CheckEqual(object.ledgePullFlag, false) // value set from editor
87
temp0 = checkResult
88
89
temp1 = object.ypos
90
temp1 -= 0x100000
91
CheckLower(temp1, object[SLOT_PLAYER1].ypos)
92
checkResult |= temp0
93
94
if checkResult != false
95
// Allow Knuckles to pull himself up this block
96
97
player[SLOT_PLAYER1].animation = ANI_CLIMBING
98
player[SLOT_PLAYER1].frame = 0
99
player[SLOT_PLAYER1].missionBlockID = TypeName[MissionBlock]
100
player[SLOT_PLAYER1].state = Player_State_Climb_Mission
101
player[SLOT_PLAYER1].speed = 0
102
player[SLOT_PLAYER1].xvel = 0
103
player[SLOT_PLAYER1].yvel = 0
104
player[SLOT_PLAYER1].timer = 0
105
106
PlaySfx(SfxName[Catch], false)
107
end if
108
end if
109
end if
110
111
// Little bit of code added in Origins Plus to make extra sure that the player's Mission Block ID is set
112
BoxCollisionTest(C_TOUCH, object.entityPos, -20, -20, 20, 20, SLOT_PLAYER1, C_BOX, C_BOX, C_BOX, C_BOX)
113
if checkResult != false
114
player[SLOT_PLAYER1].missionBlockID = TypeName[MissionBlock]
115
end if
116
end event
117
118
119
event ObjectDraw
120
DrawSprite(0)
121
end event
122
123
124
event ObjectStartup
125
// Load what's essentially the Labyrinth Zone sheet...
126
LoadSpriteSheet("Mission/Objects.gif")
127
128
// And of course, only use a tiny portion of it
129
SpriteFrame(-16, -16, 32, 32, 1, 18)
130
end event
131
132
133
// ========================
134
// Editor Events
135
// ========================
136
137
event RSDKEdit
138
if editor.returnVariable == true
139
switch editor.variableID
140
case EDIT_VAR_PROPVAL // property value
141
checkResult = object.propertyValue
142
break
143
144
case 0 // disableCrush
145
CheckNotEqual(object.disableCrush, false)
146
break
147
148
case 1 // ledgePullFlag
149
CheckNotEqual(object.ledgePullFlag, false)
150
break
151
152
end switch
153
else
154
switch editor.variableID
155
case EDIT_VAR_PROPVAL // property value
156
object.propertyValue = editor.variableValue
157
break
158
159
case 0 // disableCrush
160
object.disableCrush = editor.variableValue
161
break
162
163
case 1 // ledgePullFlag
164
object.ledgePullFlag = editor.variableValue
165
break
166
167
end switch
168
end if
169
end event
170
171
172
event RSDKDraw
173
DrawSprite(0)
174
end event
175
176
177
event RSDKLoad
178
LoadSpriteSheet("Mission/Objects.gif")
179
SpriteFrame(-16, -16, 32, 32, 1, 18)
180
181
AddEditorVariable("disableCrush")
182
SetActiveVariable("disableCrush")
183
AddEnumVariable("False", false)
184
AddEnumVariable("True", true)
185
186
AddEditorVariable("ledgePullFlag")
187
SetActiveVariable("ledgePullFlag")
188
AddEnumVariable("False", false)
189
AddEnumVariable("True", true)
190
end event
191
192