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/HPZ/SinkingPlatform.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Sinking Platform 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.value1 : object.sinkPos.y
13
private alias object.value2 : object.collisionOffset.y
14
private alias object.value3 : object.stood
15
16
// States
17
private alias 0 : SINKINGPLATFORM_IDLE
18
private alias 1 : SINKINGPLATFORM_SINKING
19
20
// Player Aliases
21
private alias object.ypos : player.ypos
22
private alias object.yvel : player.yvel
23
24
25
// ========================
26
// Function Declarations
27
// ========================
28
29
reserve function SinkingPlatform_DebugDraw
30
reserve function SinkingPlatform_DebugSpawn
31
32
33
// ========================
34
// Function Definitions
35
// ========================
36
37
private function SinkingPlatform_DebugDraw
38
DrawSprite(0)
39
end function
40
41
42
private function SinkingPlatform_DebugSpawn
43
CreateTempObject(TypeName[Sinking Platform], 0, object.xpos, object.ypos)
44
object[tempObjectPos].sinkPos.y = object[tempObjectPos].ypos
45
end function
46
47
48
// ========================
49
// Events
50
// ========================
51
52
event ObjectUpdate
53
temp6 = object.ypos
54
55
switch object.state
56
case SINKINGPLATFORM_IDLE
57
if object.ypos <= object.sinkPos.y
58
object.ypos = object.sinkPos.y
59
object.yvel = 0
60
if object.stood == true
61
object.yvel = 0x10000
62
object.state = SINKINGPLATFORM_SINKING
63
end if
64
else
65
object.yvel -= 0x3800
66
if object.yvel < -0x80000
67
object.yvel = -0x80000
68
end if
69
object.ypos += object.yvel
70
end if
71
break
72
73
case SINKINGPLATFORM_SINKING
74
object.ypos += object.yvel
75
if object.stood == false
76
object.state = SINKINGPLATFORM_IDLE
77
end if
78
break
79
80
end switch
81
object.stood = false
82
83
temp0 = object.ypos
84
temp6 &= 0xFFFF0000
85
object.collisionOffset.y = object.ypos
86
object.collisionOffset.y &= 0xFFFF0000
87
object.collisionOffset.y -= temp6
88
object.ypos = temp6
89
90
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
91
if player[currentPlayer].yvel < 0
92
if object.yvel < player[currentPlayer].yvel
93
temp1 = true
94
else
95
temp1 = false
96
end if
97
else
98
temp1 = false
99
end if
100
101
if temp1 == true
102
temp1 = player[currentPlayer].yvel
103
BoxCollisionTest(C_TOUCH, object.entityPos, -32, -20, 32, 20, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
104
if checkResult == true
105
player[currentPlayer].yvel = 0x10000
106
end if
107
108
BoxCollisionTest(C_SOLID2, object.entityPos, -32, -20, 32, -4, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
109
if checkResult == COL_TOP
110
player[currentPlayer].ypos += object.collisionOffset.y
111
object.stood |= true
112
else
113
player[currentPlayer].yvel = temp1
114
end if
115
else
116
BoxCollisionTest(C_SOLID2, object.entityPos, -32, -20, 32, 20, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
117
if checkResult == COL_TOP
118
player[currentPlayer].yvel = 0x70000
119
player[currentPlayer].ypos += object.collisionOffset.y
120
object.stood |= true
121
end if
122
end if
123
next
124
125
object.ypos = temp0
126
end event
127
128
129
event ObjectDraw
130
DrawSprite(0)
131
end event
132
133
134
event ObjectStartup
135
LoadSpriteSheet("HPZ/Objects.gif")
136
SpriteFrame(-32, -20, 64, 40, 1, 183)
137
138
foreach (TypeName[Sinking Platform], arrayPos0, ALL_ENTITIES)
139
object[arrayPos0].sinkPos.y = object[arrayPos0].ypos
140
next
141
142
SetTableValue(TypeName[Sinking Platform], DebugMode_ObjCount, DebugMode_TypesTable)
143
SetTableValue(SinkingPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
144
SetTableValue(SinkingPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
145
DebugMode_ObjCount++
146
end event
147
148
149
// ========================
150
// Editor Events
151
// ========================
152
153
event RSDKDraw
154
DrawSprite(0)
155
end event
156
157
158
event RSDKLoad
159
LoadSpriteSheet("HPZ/Objects.gif")
160
SpriteFrame(-32, -20, 64, 40, 1, 183)
161
162
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
163
end event
164
165