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/MZ/ButtonPillar.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Button Pillar 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.startPos.y
14
private alias object.value2 : object.shinePos.y
15
16
private alias 0 : BUTTONPILLAR_AWAITBUTTON
17
private alias 1 : BUTTONPILLAR_MOVING
18
private alias 2 : BUTTONPILLAR_MOVED
19
20
// Player Aliases
21
private alias object.ypos : player.ypos
22
23
// PushButton aliases
24
private alias object.propertyValue : pushButton.stood
25
26
// ========================
27
// Function Declarations
28
// ========================
29
30
reserve function ButtonPillar_DebugDraw
31
reserve function ButtonPillar_DebugSpawn
32
33
34
private function ButtonPillar_DebugDraw
35
DrawSprite(0)
36
end function
37
38
39
private function ButtonPillar_DebugSpawn
40
CreateTempObject(TypeName[Button Pillar], 0, object.xpos, object.ypos)
41
object[tempObjectPos].startPos.y = object.ypos
42
end function
43
44
45
// ========================
46
// Events
47
// ========================
48
49
event ObjectUpdate
50
switch object.state
51
case BUTTONPILLAR_AWAITBUTTON
52
if pushButton[-1].stood == true
53
object.state = BUTTONPILLAR_MOVING
54
object.priority = PRIORITY_ACTIVE
55
end if
56
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
57
BoxCollisionTest(C_SOLID, object.entityPos, -32, -56, 32, 56, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
58
next
59
break
60
61
case BUTTONPILLAR_MOVING
62
if object.timer < 144
63
object.timer += 2
64
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
65
BoxCollisionTest(C_SOLID, object.entityPos, -32, -56, 32, 56, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
66
if checkResult == COL_TOP
67
player[currentPlayer].ypos += 0x20000
68
end if
69
next
70
object.ypos += 0x20000
71
else
72
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
73
BoxCollisionTest(C_SOLID, object.entityPos, -32, -56, 32, 56, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
74
next
75
object.state++
76
end if
77
break
78
79
case BUTTONPILLAR_MOVED
80
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
81
BoxCollisionTest(C_SOLID, object.entityPos, -32, -56, 32, 56, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
82
next
83
break
84
85
end switch
86
87
object.angle = oscillation
88
object.angle <<= 1
89
Sin(object.shinePos.y, object.angle)
90
object.shinePos.y <<= 12
91
object.shinePos.y += object.ypos
92
object.shinePos.y &= 0xFFFF0000
93
94
if object.outOfBounds == true
95
temp0 = object.ypos
96
object.ypos = object.startPos.y
97
if object.outOfBounds == true
98
object.priority = PRIORITY_BOUNDS
99
object.state = BUTTONPILLAR_AWAITBUTTON
100
object.timer = 0
101
else
102
object.ypos = temp0
103
end if
104
end if
105
end event
106
107
108
event ObjectDraw
109
DrawSprite(0)
110
DrawSpriteXY(1, object.xpos, object.shinePos.y)
111
end event
112
113
114
event ObjectStartup
115
LoadSpriteSheet("MZ/Objects.gif")
116
SpriteFrame(-32, -56, 64, 112, 126, 1)
117
SpriteFrame(-16, -16, 31, 32, 159, 114)
118
119
foreach (TypeName[Button Pillar], arrayPos0, ALL_ENTITIES)
120
object[arrayPos0].startPos.y = object[arrayPos0].ypos
121
next
122
123
SetTableValue(TypeName[Button Pillar], DebugMode_ObjCount, DebugMode_TypesTable)
124
SetTableValue(ButtonPillar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
125
SetTableValue(ButtonPillar_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
126
DebugMode_ObjCount++
127
end event
128
129
130
// ========================
131
// Editor Events
132
// ========================
133
134
event RSDKDraw
135
DrawSprite(0)
136
DrawSprite(1)
137
138
if editor.showGizmos == true
139
editor.drawingOverlay = true
140
141
// Draw an arrow to link it to its activator button
142
DrawArrow(object.xpos, object.ypos, object[-1].xpos, object[-1].ypos, 255, 255, 255)
143
144
// Draw a preview of where the pillar will end up
145
temp0 = object.ixpos
146
temp0 -= 32
147
temp1 = 2
148
temp1 *= 144
149
temp1 += object.iypos
150
temp1 -= 56
151
DrawRectOutline(temp0, temp1, 64, 112, 255, 255, 255, 255)
152
// object.inkEffect = INK_BLEND
153
// DrawSpriteFX(0, FX_INK, object.xpos, temp1)
154
// DrawSpriteFX(1, FX_INK, object.xpos, temp1)
155
156
editor.drawingOverlay = false
157
end if
158
end event
159
160
161
event RSDKLoad
162
LoadSpriteSheet("MZ/Objects.gif")
163
SpriteFrame(-32, -56, 64, 112, 126, 1)
164
SpriteFrame(-16, -16, 31, 32, 159, 114)
165
166
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
167
end event
168
169