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