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/LZ/GrabBar.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Grab Bar 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.grabDuration
13
14
// Player Aliases
15
private alias object.type : player.type
16
private alias object.xpos : player.xpos
17
private alias object.ypos : player.ypos
18
private alias object.state : player.state
19
private alias object.jumpPress : player.jumpPress
20
private alias object.direction : player.direction
21
private alias object.animation : player.animation
22
private alias object.gravity : player.gravity
23
24
25
// ========================
26
// Function Declarations
27
// ========================
28
29
reserve function GrabBar_DebugDraw
30
reserve function GrabBar_DebugSpawn
31
32
33
// ========================
34
// Function Definitions
35
// ========================
36
37
private function GrabBar_DebugDraw
38
DrawSprite(0)
39
end function
40
41
42
private function GrabBar_DebugSpawn
43
CreateTempObject(TypeName[Grab Bar], 0, object.xpos, object.ypos)
44
object[tempObjectPos].grabDuration = 60
45
end function
46
47
48
// ========================
49
// Events
50
// ========================
51
52
event ObjectUpdate
53
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
54
temp2 = false
55
56
if player[currentPlayer].type == TypeName[Tails Object]
57
// Tails can't reach as far as Sonic & Knuckles
58
temp3 = 0xF0000
59
else
60
temp3 = 0x140000
61
end if
62
63
temp0 = object.xpos
64
temp0 += temp3
65
temp0 -= player[currentPlayer].xpos
66
Abs(temp0)
67
if temp0 <= 0x40000
68
temp0 = object.ypos
69
temp0 -= player[currentPlayer].ypos
70
temp1 = temp0
71
Abs(temp0)
72
if temp0 <= 0x120000
73
player[currentPlayer].animation = ANI_CLINGING
74
player[currentPlayer].direction = FACING_RIGHT
75
player[currentPlayer].xpos = object.xpos
76
player[currentPlayer].xpos += temp3
77
temp2 = true
78
else
79
if player[currentPlayer].animation == ANI_CLINGING
80
player[currentPlayer].ypos = object.ypos
81
if temp1 < 0
82
player[currentPlayer].ypos += 0x120000
83
else
84
player[currentPlayer].ypos -= 0x120000
85
end if
86
temp2 = true
87
end if
88
end if
89
90
if temp2 != false
91
if player[currentPlayer].jumpPress != false
92
player[currentPlayer].animation = ANI_FANROTATE
93
end if
94
95
if object.frame == 1
96
player[currentPlayer].animation = ANI_FANROTATE
97
else
98
if currentPlayer == 0
99
object.grabDuration--
100
if object.grabDuration == 0
101
object.frame = 1
102
end if
103
end if
104
end if
105
end if
106
end if
107
next
108
end event
109
110
111
event ObjectDraw
112
DrawSprite(object.frame)
113
end event
114
115
116
event ObjectStartup
117
LoadSpriteSheet("LZ/Objects.gif")
118
SpriteFrame(-4, -32, 8, 64, 35, 1)
119
SpriteFrame(-4, -32, 14, 64, 44, 1)
120
121
foreach (TypeName[Grab Bar], arrayPos0, ALL_ENTITIES)
122
object[arrayPos0].grabDuration = object[arrayPos0].propertyValue
123
object[arrayPos0].grabDuration *= 60
124
next
125
126
SetTableValue(TypeName[Grab Bar], DebugMode_ObjCount, DebugMode_TypesTable)
127
SetTableValue(GrabBar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
128
SetTableValue(GrabBar_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 // grabDuration
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 // grabDuration
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("LZ/Objects.gif")
171
SpriteFrame(-4, -32, 8, 64, 35, 1)
172
173
AddEditorVariable("grabDuration")
174
SetActiveVariable("grabDuration")
175
end event
176
177