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/ARZ/HPlatform.txt
1480 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
57
GetTableValue(temp0, 12, StageSetup_oscillationTable)
58
if object.propertyValue == 1
59
FlipSign(temp0)
60
temp0 += 0x4000
61
else
62
temp0 -= 0x4000
63
end if
64
temp0 <<= 8
65
object.xpos = object.centerPos.x
66
object.xpos -= temp0
67
68
if object.stood == true
69
if object.stoodAngle < 64
70
object.stoodAngle += 4
71
end if
72
else
73
if object.stoodAngle > 0
74
object.stoodAngle -= 4
75
end if
76
end if
77
78
temp0 = object.stoodAngle
79
temp0 <<= 1
80
Sin(temp1, temp0)
81
temp1 <<= 9
82
object.ypos = object.centerPos.y
83
object.ypos += temp1
84
85
object.stood = false
86
temp0 = object.xpos
87
temp1 = object.ypos
88
temp6 &= 0xFFFF0000
89
temp7 &= 0xFFFF0000
90
object.collisionOffset.x = object.xpos
91
object.collisionOffset.x &= 0xFFFF0000
92
object.collisionOffset.x -= temp6
93
object.collisionOffset.y = object.ypos
94
object.collisionOffset.y &= 0xFFFF0000
95
object.collisionOffset.y -= temp7
96
97
object.xpos = temp6
98
object.ypos = temp7
99
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
100
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
101
if checkResult == true
102
object.stood = true
103
player[currentPlayer].xpos += object.collisionOffset.x
104
player[currentPlayer].ypos += object.collisionOffset.y
105
end if
106
next
107
object.xpos = temp0
108
object.ypos = temp1
109
end event
110
111
112
event ObjectDraw
113
DrawSprite(0)
114
end event
115
116
117
event ObjectStartup
118
LoadSpriteSheet("ARZ/Objects.gif")
119
SpriteFrame(-32, -13, 64, 45, 126, 145)
120
121
foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)
122
object[arrayPos0].centerPos.x = object[arrayPos0].xpos
123
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
124
next
125
126
SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)
127
SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
128
SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
129
DebugMode_ObjCount++
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 // startDir
145
checkResult = object.propertyValue
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
break
158
159
end switch
160
end if
161
end event
162
163
164
event RSDKDraw
165
DrawSprite(0)
166
end event
167
168
169
event RSDKLoad
170
LoadSpriteSheet("ARZ/Objects.gif")
171
SpriteFrame(-32, -13, 64, 45, 126, 145)
172
173
AddEditorVariable("startDir")
174
SetActiveVariable("startDir")
175
AddEnumVariable("Left", 0)
176
AddEnumVariable("Right", 1)
177
end event
178
179