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/RockCrusher.txt
1487 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Rock Crusher 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.origin.y // Unused
14
15
private alias 0 : ROCKCRUSHER_RISE
16
private alias 1 : ROCKCRUSHER_FALL
17
18
// Player aliases
19
private alias object.type : player.type
20
private alias object.ypos : player.ypos
21
private alias object.gravity : player.gravity
22
23
24
// ========================
25
// Function Declarations
26
// ========================
27
28
reserve function RockCrusher_DebugDraw
29
reserve function RockCrusher_DebugSpawn
30
31
32
// ========================
33
// Function Definitions
34
// ========================
35
36
private function RockCrusher_DebugDraw
37
DrawSprite(0)
38
end function
39
40
41
private function RockCrusher_DebugSpawn
42
CreateTempObject(TypeName[Rock Crusher], 0, object.xpos, object.ypos)
43
object[tempObjectPos].origin.y = object[tempObjectPos].ypos
44
object[tempObjectPos].yvel = -0x10000
45
end function
46
47
48
// ========================
49
// Events
50
// ========================
51
52
event ObjectUpdate
53
if object.state == ROCKCRUSHER_RISE
54
object.timer++
55
if object.timer == 96
56
object.timer = 0
57
object.yvel = 0x80000
58
object.state = ROCKCRUSHER_FALL
59
end if
60
else
61
object.timer++
62
if object.timer == 12
63
object.timer = 0
64
object.yvel = -0x10000
65
object.state = ROCKCRUSHER_RISE
66
end if
67
68
if object.timer == 6
69
PlaySfx(SfxName[Ground Impact], false)
70
end if
71
end if
72
73
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
74
BoxCollisionTest(C_SOLID2, object.entityPos, -15, -64, 15, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
75
switch checkResult
76
case COL_TOP
77
player[currentPlayer].ypos += object.yvel
78
break
79
80
case COL_BOTTOM
81
if player[currentPlayer].gravity == GRAVITY_GROUND
82
#platform: USE_STANDALONE
83
if object.yvel > 0
84
#endplatform
85
// If the rock's going down, then crush the player!
86
CallFunction(Player_Kill)
87
#platform: USE_ORIGINS
88
// If we're in a mission and P2 was just killed, then force P1 to die too
89
// (Part of the Bodyguard mission)
90
if game.playMode == BOOT_PLAYMODE_MISSION
91
if player[1].type == TypeName[Player 2 Object]
92
game.forceKillPlayer = true
93
end if
94
end if
95
#endplatform
96
#platform: USE_STANDALONE
97
end if
98
#endplatform
99
end if
100
break
101
102
end switch
103
next
104
105
object.ypos += object.yvel
106
end event
107
108
109
event ObjectDraw
110
DrawSprite(0)
111
end event
112
113
114
event ObjectStartup
115
LoadSpriteSheet("MCZ/Objects.gif")
116
SpriteFrame(-15, -74, 30, 148, 201, 0)
117
118
foreach (TypeName[Rock Crusher], arrayPos0, ALL_ENTITIES)
119
object[arrayPos0].origin.y = object[arrayPos0].ypos // even if this is stored, it's never referenced again
120
object[arrayPos0].yvel = -0x10000
121
next
122
123
// Add this object to the debug object list
124
SetTableValue(TypeName[Rock Crusher], DebugMode_ObjCount, DebugMode_TypesTable)
125
SetTableValue(RockCrusher_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
126
SetTableValue(RockCrusher_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
127
DebugMode_ObjCount++
128
end event
129
130
131
// ========================
132
// Editor Events
133
// ========================
134
135
event RSDKDraw
136
DrawSprite(0)
137
138
if editor.showGizmos == true
139
editor.drawingOverlay = true
140
141
object.inkEffect = INK_BLEND
142
temp0 = object.ypos
143
temp0 -= 0x5F0000
144
DrawSpriteFX(0, FX_INK, object.xpos, temp0)
145
146
editor.drawingOverlay = false
147
end if
148
end event
149
150
151
event RSDKLoad
152
LoadSpriteSheet("MCZ/Objects.gif")
153
SpriteFrame(-15, -74, 30, 148, 201, 0)
154
155
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
156
end event
157
158