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/WFZ/TurretPlatform.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Turret 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
14
// Player Aliases
15
private alias object.value17 : debugMode.currentSelection
16
17
18
// ========================
19
// Function Declarations
20
// ========================
21
22
reserve function TurretPlatform_SetupPlatform
23
reserve function TurretPlatform_DebugDraw
24
reserve function TurretPlatform_DebugSpawn
25
26
27
// ========================
28
// Static Values
29
// ========================
30
31
private value TurretPlatform_startDebugID = 0
32
33
34
// ========================
35
// Function Definitions
36
// ========================
37
38
private function TurretPlatform_SetupPlatform
39
object[arrayPos0].timer = 0
40
object[arrayPos0].animationTimer = 0
41
object[arrayPos0].frame = 0
42
object[arrayPos0].state = 0
43
object[arrayPos0].priority = PRIORITY_ACTIVE
44
end function
45
46
47
private function TurretPlatform_DebugDraw
48
DrawSprite(0)
49
end function
50
51
52
private function TurretPlatform_DebugSpawn
53
temp0 = debugMode[0].currentSelection
54
temp0 -= TurretPlatform_startDebugID
55
temp0 *= 0x30
56
temp0 &= 0xF0
57
CreateTempObject(TypeName[Turret Platform], temp0, object.xpos, object.ypos)
58
59
arrayPos0 = object[tempObjectPos].entityPos
60
CallFunction(TurretPlatform_SetupPlatform)
61
end function
62
63
64
// ========================
65
// Events
66
// ========================
67
68
event ObjectUpdate
69
// TODO: add cool state names
70
switch object.state
71
case 0
72
temp0 = oscillation
73
temp0 &= 0xF0
74
if temp0 == object.propertyValue
75
object.priority = PRIORITY_ACTIVE
76
object.timer = 160
77
object.animationTimer = 6
78
object.state = 1
79
end if
80
break
81
82
case 1
83
object.animationTimer++
84
object.frame = object.animationTimer
85
object.frame /= 6
86
if object.frame == 4
87
object.state = 2
88
end if
89
break
90
91
case 2
92
object.timer--
93
if object.timer == 0
94
object.state = 3
95
end if
96
break
97
98
case 3
99
object.animationTimer--
100
object.frame = object.animationTimer
101
object.frame /= 6
102
if object.animationTimer == 0
103
object.state = 0
104
end if
105
break
106
107
end switch
108
109
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
110
if object.frame >= 3
111
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -24, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
112
end if
113
next
114
115
if object.outOfBounds == true
116
arrayPos0 = object.entityPos
117
CallFunction(TurretPlatform_SetupPlatform)
118
end if
119
end event
120
121
122
event ObjectDraw
123
DrawSprite(object.frame)
124
end event
125
126
127
event ObjectStartup
128
LoadSpriteSheet("SCZ/Objects.gif")
129
SpriteFrame(-24, -24, 48, 16, 130, 92)
130
SpriteFrame(-24, -24, 48, 16, 130, 109)
131
SpriteFrame(-24, -24, 48, 16, 130, 126)
132
SpriteFrame(-28, -24, 56, 21, 130, 143)
133
SpriteFrame(-32, -24, 64, 24, 130, 165)
134
135
foreach (TypeName[Turret Platform], arrayPos0, ALL_ENTITIES)
136
CallFunction(TurretPlatform_SetupPlatform)
137
next
138
139
temp0 = 0
140
TurretPlatform_startDebugID = DebugMode_ObjCount
141
while temp0 < 6
142
SetTableValue(TypeName[Turret Platform], DebugMode_ObjCount, DebugMode_TypesTable)
143
SetTableValue(TurretPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
144
SetTableValue(TurretPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
145
DebugMode_ObjCount++
146
temp0++
147
loop
148
end event
149
150
151
// ========================
152
// Editor Events
153
// ========================
154
155
event RSDKDraw
156
DrawSprite(0)
157
end event
158
159
160
event RSDKLoad
161
LoadSpriteSheet("SCZ/Objects.gif")
162
SpriteFrame(-24, -24, 48, 16, 130, 92)
163
164
SetVariableAlias(ALIAS_VAR_PROPVAL, "intervalOffset")
165
end event
166
167