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/HTZ/HPlatform.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: H 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.value0 : object.stood
13
private alias object.value1 : object.centerPos.x
14
private alias object.value2 : object.centerPos.y
15
private alias object.value3 : object.collisionOffset.x
16
private alias object.value4 : object.collisionOffset.y
17
private alias object.value5 : object.stoodAngle
18
19
// Player Aliases
20
private alias object.xpos : player.xpos
21
private alias object.ypos : player.ypos
22
23
24
// ========================
25
// Function Declarations
26
// ========================
27
28
reserve function HPlatform_DebugDraw
29
reserve function HPlatform_DebugSpawn
30
31
32
// ========================
33
// Function Definitions
34
// ========================
35
36
private function HPlatform_DebugDraw
37
DrawSprite(0)
38
end function
39
40
41
private function HPlatform_DebugSpawn
42
CreateTempObject(TypeName[H Platform], 0, object.xpos, object.ypos)
43
object[tempObjectPos].centerPos.x = object.xpos
44
object[tempObjectPos].centerPos.y = object.ypos
45
object[tempObjectPos].propertyValue = object.direction
46
end function
47
48
49
// ========================
50
// Events
51
// ========================
52
53
event ObjectUpdate
54
temp6 = object.xpos
55
temp7 = object.ypos
56
GetTableValue(temp0, 12, StageSetup_oscillationTable)
57
if object.propertyValue == 1
58
FlipSign(temp0)
59
temp0 += 0x4000
60
else
61
temp0 -= 0x4000
62
end if
63
temp0 <<= 8
64
65
object.xpos = object.centerPos.x
66
object.xpos -= temp0
67
if object.stood == true
68
if object.stoodAngle < 64
69
object.stoodAngle += 4
70
end if
71
else
72
if object.stoodAngle > 0
73
object.stoodAngle -= 4
74
end if
75
end if
76
77
temp0 = object.stoodAngle
78
temp0 <<= 1
79
Sin(temp1, temp0)
80
temp1 <<= 9
81
object.ypos = object.centerPos.y
82
object.ypos += temp1
83
84
object.stood = false
85
temp0 = object.xpos
86
temp1 = object.ypos
87
temp6 &= 0xFFFF0000
88
temp7 &= 0xFFFF0000
89
object.collisionOffset.x = object.xpos
90
object.collisionOffset.x &= 0xFFFF0000
91
object.collisionOffset.x -= temp6
92
object.collisionOffset.y = object.ypos
93
object.collisionOffset.y &= 0xFFFF0000
94
object.collisionOffset.y -= temp7
95
96
object.xpos = temp6
97
object.ypos = temp7
98
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
99
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
100
if checkResult == true
101
object.stood = true
102
player[currentPlayer].xpos += object.collisionOffset.x
103
player[currentPlayer].ypos += object.collisionOffset.y
104
end if
105
next
106
object.xpos = temp0
107
object.ypos = temp1
108
end event
109
110
111
event ObjectDraw
112
DrawSprite(0)
113
end event
114
115
116
event ObjectStartup
117
LoadSpriteSheet("HTZ/Objects.gif")
118
SpriteFrame(-32, -12, 64, 32, 191, 223)
119
120
foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)
121
object[arrayPos0].centerPos.x = object[arrayPos0].xpos
122
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
123
next
124
125
SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)
126
SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
127
SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
128
DebugMode_ObjCount++
129
end event
130
131
132
// ========================
133
// Editor Events
134
// ========================
135
136
event RSDKEdit
137
if editor.returnVariable == true
138
switch editor.variableID
139
case EDIT_VAR_PROPVAL // property value
140
checkResult = object.propertyValue
141
break
142
143
case 0 // startDir
144
checkResult = object.propertyValue
145
checkResult &= 1
146
break
147
148
end switch
149
else
150
switch editor.variableID
151
case EDIT_VAR_PROPVAL // property value
152
object.propertyValue = editor.variableValue
153
break
154
155
case 0 // startDir
156
object.propertyValue = editor.variableValue
157
object.propertyValue &= 1
158
break
159
160
end switch
161
end if
162
end event
163
164
165
event RSDKDraw
166
DrawSprite(0)
167
end event
168
169
170
event RSDKLoad
171
LoadSpriteSheet("HTZ/Objects.gif")
172
SpriteFrame(-32, -12, 64, 32, 191, 223)
173
174
AddEditorVariable("startDir")
175
SetActiveVariable("startDir")
176
AddEnumVariable("Left", 0)
177
AddEnumVariable("Right", 1)
178
end event
179
180