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/FallingLava.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Falling Lava 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.splashAnimTimer
14
private alias object.value2 : object.splashFrame
15
private alias object.value3 : object.splashPos.y
16
17
private alias 0 : FALLINGLAVA_FALLING
18
private alias 1 : FALLINGLAVA_SPLASHING
19
20
// ========================
21
// Function Declarations
22
// ========================
23
24
reserve function FallingLava_DebugDraw
25
reserve function FallingLava_DebugSpawn
26
27
private function FallingLava_DebugDraw
28
DrawSprite(0)
29
end function
30
31
32
private function FallingLava_DebugSpawn
33
CreateTempObject(TypeName[Falling Lava], 0, object.xpos, object.ypos)
34
end function
35
36
37
// ========================
38
// Events
39
// ========================
40
41
event ObjectUpdate
42
if object.propertyValue == 0
43
BoxCollisionTest(C_TOUCH, object.entityPos, -256, -256, 256, 128, 0, C_BOX, C_BOX, C_BOX, C_BOX)
44
if checkResult == true
45
object.timer--
46
47
if object.timer <= 0
48
object.timer = 240
49
50
CreateTempObject(TypeName[Falling Lava], 1, object.xpos, object.ypos)
51
object[tempObjectPos].drawOrder = 4
52
object[tempObjectPos].ypos -= 0x1600000
53
object[tempObjectPos].splashPos.y = object.ypos
54
55
PlaySfx(SfxName[Fire Burn], false)
56
end if
57
end if
58
else
59
switch object.state
60
case FALLINGLAVA_FALLING
61
object.yvel += 0x1800
62
object.ypos += object.yvel
63
64
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
65
BoxCollisionTest(C_TOUCH, object.entityPos, -32, -128, 32, 128, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
66
67
if checkResult == true
68
CallFunction(Player_FireHit)
69
end if
70
next
71
72
if object.ypos >= object.splashPos.y
73
CreateTempObject(TypeName[Lava Splash], 0, object.xpos, object.ypos)
74
object[tempObjectPos].ypos += 0x800000
75
object[tempObjectPos].drawOrder = 5
76
object.state++
77
end if
78
break
79
80
case FALLINGLAVA_SPLASHING
81
object.yvel += 0x1800
82
object.ypos += object.yvel
83
84
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
85
BoxCollisionTest(C_TOUCH, object.entityPos, -32, -128, 32, 128, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
86
if checkResult == true
87
CallFunction(Player_FireHit)
88
end if
89
next
90
91
object.timer++
92
if object.timer == 60
93
object.type = TypeName[Blank Object]
94
end if
95
break
96
97
end switch
98
99
object.splashFrame = object.splashAnimTimer
100
object.splashFrame /= 3
101
object.splashFrame += 2
102
object.splashAnimTimer++
103
object.splashAnimTimer %= 6
104
105
object.frame = object.animationTimer
106
object.frame >>= 3
107
object.animationTimer++
108
object.animationTimer &= 15
109
end if
110
end event
111
112
113
event ObjectDraw
114
if object.propertyValue > 0
115
DrawSprite(object.frame)
116
DrawSprite(object.splashFrame)
117
118
object.direction = FLIP_Y
119
DrawSpriteFX(object.splashFrame, FX_FLIP, object.xpos, object.ypos)
120
end if
121
end event
122
123
124
event ObjectStartup
125
LoadSpriteSheet("MZ/Objects.gif")
126
127
// Lava frames
128
SpriteFrame(-32, -128, 64, 256, 317, 1) // Falling Lava - #0
129
SpriteFrame(-32, -128, 64, 256, 382, 1) // Falling Lava - #1
130
SpriteFrame(-32, -144, 64, 32, 382, 363) // Lava Splash - #2
131
SpriteFrame(-32, -144, 64, 32, 447, 363) // Lava Splash - #3
132
133
// Add Lava to the debug mode item list
134
SetTableValue(TypeName[Falling Lava], DebugMode_ObjCount, DebugMode_TypesTable)
135
SetTableValue(FallingLava_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
136
SetTableValue(FallingLava_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
137
DebugMode_ObjCount++
138
end event
139
140
141
// ========================
142
// Editor Events
143
// ========================
144
145
event RSDKDraw
146
DrawSprite(0)
147
end event
148
149
150
event RSDKLoad
151
152
LoadSpriteSheet("MZ/Objects.gif")
153
154
// Lava frames
155
SpriteFrame(-32, -128, 64, 256, 317, 1) // Falling Lava - #0
156
SpriteFrame(-32, -128, 64, 256, 382, 1) // Falling Lava - #1
157
SpriteFrame(-32, -144, 64, 32, 382, 363) // Lava Splash - #2
158
SpriteFrame(-32, -144, 64, 32, 447, 363) // Lava Splash - #3
159
160
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
161
end event
162
163