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/TiltPlatformM.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Tilt Platform M 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
// States
15
private alias 0 : TILTPLATFORM_M_IDLE
16
private alias 1 : TILTPLATFORM_M_ACTIVATED
17
private alias 2 : TILTPLATFORM_M_FLIPPING
18
private alias 3 : TILTPLATFORM_M_FLIPPED
19
private alias 4 : TILTPLATFORM_M_REVERT
20
21
// Player Aliases
22
private alias object.xpos : player.xpos
23
24
25
// ========================
26
// Function Declarations
27
// ========================
28
29
reserve function TiltPlatformM_DebugDraw
30
reserve function TiltPlatformM_DebugSpawn
31
32
33
// ========================
34
// Function Definitions
35
// ========================
36
37
private function TiltPlatformM_DebugDraw
38
DrawSprite(0)
39
end function
40
41
42
private function TiltPlatformM_DebugSpawn
43
CreateTempObject(TypeName[Tilt Platform M], 0, object.xpos, object.ypos)
44
object[tempObjectPos].direction = object.direction
45
end function
46
47
48
// ========================
49
// Events
50
// ========================
51
52
event ObjectUpdate
53
switch object.state
54
case TILTPLATFORM_M_IDLE
55
break
56
57
case TILTPLATFORM_M_ACTIVATED
58
object.timer--
59
if object.timer == 0
60
object.animationTimer = 0
61
object.frame = 1
62
object.state = TILTPLATFORM_M_FLIPPING
63
end if
64
break
65
66
case TILTPLATFORM_M_FLIPPING
67
object.animationTimer++
68
if object.animationTimer == 4
69
object.frame = 2
70
object.timer = 74
71
object.state = TILTPLATFORM_M_FLIPPED
72
end if
73
break
74
75
case TILTPLATFORM_M_FLIPPED
76
object.timer--
77
if object.timer == 0
78
object.animationTimer = 0
79
object.frame = 1
80
object.state = TILTPLATFORM_M_REVERT
81
end if
82
break
83
84
case TILTPLATFORM_M_REVERT
85
object.animationTimer++
86
if object.animationTimer == 4
87
object.frame = 0
88
object.state = TILTPLATFORM_M_IDLE
89
end if
90
break
91
92
end switch
93
94
if object.frame == 0
95
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
96
BoxCollisionTest(C_SOLID, object.entityPos, -24, -2, 24, 6, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
97
if object.state == TILTPLATFORM_M_IDLE
98
if checkResult == COL_TOP
99
if player[currentPlayer].xpos < object.xpos
100
object.direction = FLIP_X
101
else
102
object.direction = FLIP_NONE
103
end if
104
object.timer = 16
105
object.state = TILTPLATFORM_M_ACTIVATED
106
object.priority = PRIORITY_ACTIVE
107
end if
108
end if
109
next
110
end if
111
112
if object.outOfBounds == true
113
object.frame = 0
114
object.state = TILTPLATFORM_M_IDLE
115
object.priority = PRIORITY_BOUNDS
116
end if
117
end event
118
119
120
event ObjectDraw
121
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
122
end event
123
124
125
event ObjectStartup
126
LoadSpriteSheet("SCZ/Objects.gif")
127
SpriteFrame(-24, -4, 48, 8, 320, 99) // Flat (H) - #0
128
SpriteFrame(-16, -16, 32, 32, 320, 108) // Diagonal (Down Right) - #1
129
SpriteFrame(-4, -24, 8, 48, 311, 99) // Diagonal (Down Left) - #2
130
SpriteFrame(-16, -16, 32, 32, 353, 108) // Flat (V) - #3
131
132
SetTableValue(TypeName[Tilt Platform M], DebugMode_ObjCount, DebugMode_TypesTable)
133
SetTableValue(TiltPlatformM_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
134
SetTableValue(TiltPlatformM_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
135
DebugMode_ObjCount++
136
end event
137
138
139
// ========================
140
// Editor Events
141
// ========================
142
143
event RSDKDraw
144
DrawSprite(0)
145
end event
146
147
148
event RSDKLoad
149
LoadSpriteSheet("SCZ/Objects.gif")
150
SpriteFrame(-24, -4, 48, 8, 320, 99) // Flat (H)
151
152
SetVariableAlias(ALIAS_VAR_PROPVAL, "intervalOffset")
153
end event
154
155