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/LZ/Cork.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Cork 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.ypos : player.ypos
14
private alias object.yvel : player.yvel
15
private alias object.gravity : player.gravity
16
17
// Path ID Aliases
18
private alias 0 : PATH_A
19
20
21
// ========================
22
// Function Declarations
23
// ========================
24
25
reserve function Cork_DebugDraw
26
reserve function Cork_DebugSpawn
27
28
29
// ========================
30
// Function Definitions
31
// ========================
32
33
private function Cork_DebugDraw
34
DrawSprite(0)
35
end function
36
37
38
private function Cork_DebugSpawn
39
CreateTempObject(TypeName[Cork], 0, object.xpos, object.ypos)
40
object[tempObjectPos].ypos &= 0xFFFF0000
41
GetBit(temp0, object.ypos, 16)
42
if temp0 == true
43
object[tempObjectPos].ypos++
44
end if
45
46
// As with the foreach in the ObjectStartup, this line was similarly only added after initial release, in an update
47
object[tempObjectPos].drawOrder = 4
48
end function
49
50
51
// ========================
52
// Events
53
// ========================
54
55
event ObjectUpdate
56
temp4 = stage.waterLevel
57
temp4 <<= 16
58
temp3 = object.ypos
59
if temp3 != temp4
60
if temp3 < temp4
61
temp3 += 0x10000
62
if temp3 < temp4
63
temp3 += 0x10000
64
end if
65
else
66
temp3 -= 0x10000
67
if temp3 > temp4
68
temp3 -= 0x10000
69
end if
70
end if
71
end if
72
73
object.yvel = temp3
74
object.yvel -= object.ypos
75
if object.yvel > 0
76
ObjectTileCollision(CSIDE_FLOOR, 0, 16, PATH_A)
77
else
78
ObjectTileCollision(CSIDE_ROOF, 0, -16, PATH_A)
79
end if
80
81
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
82
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
83
84
if checkResult == COL_TOP
85
player[currentPlayer].ypos += object.yvel
86
end if
87
88
if checkResult == COL_BOTTOM
89
if player[currentPlayer].gravity == GRAVITY_GROUND
90
CallFunction(Player_Kill)
91
end if
92
end if
93
next
94
95
object.ypos += object.yvel
96
end event
97
98
99
event ObjectDraw
100
// this part is kinda weird..
101
// - in mobile S1, the number in the check is 39
102
// - in Origins 1.0.0, it's 43
103
// - in Origins 1.0.4, it's 46
104
// - in Origins 2.0.0 and later, it's 48
105
106
// maybe it's a function ID? 39/43/46 all match Player_HandleSuperPalette_Sonic in their respective game versions... but then Plus's 48 is Player_HandleAmyHitbox??
107
// if that's somehow what it is, then why is stage state being compared to a function anyways?? and where's that arrayPos0 even coming from??
108
// so many unanswered questions...
109
110
if stage.state == 48
111
object[arrayPos0].priority = PRIORITY_ACTIVE
112
end if
113
114
DrawSprite(0)
115
end event
116
117
118
event ObjectStartup
119
LoadSpriteSheet("LZ/Objects.gif")
120
SpriteFrame(-16, -16, 32, 32, 1, 51)
121
122
// Interesting note - this wasn't in the initial versions of S1, this was only introduced later in an update
123
foreach (TypeName[Cork], arrayPos0, ALL_ENTITIES)
124
object[arrayPos0].drawOrder = 4
125
next
126
127
SetTableValue(TypeName[Cork], DebugMode_ObjCount, DebugMode_TypesTable)
128
SetTableValue(Cork_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
129
SetTableValue(Cork_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
130
DebugMode_ObjCount++
131
end event
132
133
134
// ========================
135
// Editor Events
136
// ========================
137
138
event RSDKDraw
139
DrawSprite(0)
140
end event
141
142
143
event RSDKLoad
144
LoadSpriteSheet("LZ/Objects.gif")
145
SpriteFrame(-16, -16, 32, 32, 1, 51)
146
147
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
148
end event
149
150