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/CPZ/ChemicalDrop.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Chemical Drop Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Player Aliases
13
private alias object.entityPos : player.entityPos
14
private alias object.state : player.state
15
private alias object.xpos : player.xpos
16
private alias object.speed : player.speed
17
18
private alias object.value7 : player.invincibleTimer
19
private alias object.value8 : player.blinkTimer
20
private alias object.value37 : player.shield
21
22
// Shields
23
private alias 2 : SHIELD_BUBBLE
24
25
// Path ID Aliases
26
private alias 0 : PATH_A
27
28
29
// ========================
30
// Function Declarations
31
// ========================
32
33
reserve function ChemicalDrop_BubbleHit
34
reserve function ChemicalDrop_CreateSplash
35
36
37
// ========================
38
// Function Definitions
39
// ========================
40
41
private function ChemicalDrop_BubbleHit
42
if player[currentPlayer].shield != SHIELD_BUBBLE
43
if player[currentPlayer].state != Player_State_Death
44
arrayPos0 = player[currentPlayer].entityPos // So this arrayPos0 stuff moves the slot to P1's shield object but...
45
arrayPos0 += playerCount // nothing exactly happens with it..?
46
if player[currentPlayer].invincibleTimer == 0
47
if player[currentPlayer].blinkTimer == 0
48
player[currentPlayer].state = Player_State_GotHit
49
if player[currentPlayer].xpos > object.xpos
50
player[currentPlayer].speed = 0x20000
51
else
52
player[currentPlayer].speed = -0x20000
53
end if
54
end if
55
end if
56
end if
57
end if
58
end function
59
60
61
private function ChemicalDrop_CreateSplash
62
temp1 = object.yvel
63
temp1 >>= 1
64
FlipSign(temp1)
65
PlaySfx(SfxName[Chemical Splash], false)
66
object.type = TypeName[Blank Object]
67
temp0 = 0
68
while temp0 < 5
69
CreateTempObject(TypeName[Chemical Splash], 0, object.xpos, object.ypos)
70
object[tempObjectPos].drawOrder = 2
71
72
Rand(object[tempObjectPos].xvel, 0x200)
73
object[tempObjectPos].xvel -= 0x100
74
object[tempObjectPos].xvel <<= 10
75
if object[tempObjectPos].xvel < 0
76
object[tempObjectPos].xvel += 0x20000
77
end if
78
object[tempObjectPos].xvel -= 0x10000
79
80
if temp0 > 0
81
Rand(object[tempObjectPos].yvel, 0x7FE)
82
object[tempObjectPos].yvel -= 0x400
83
object[tempObjectPos].yvel <<= 8
84
end if
85
object[tempObjectPos].yvel += temp1
86
87
temp0++
88
loop
89
end function
90
91
92
// ========================
93
// Events
94
// ========================
95
96
event ObjectUpdate
97
object.ypos += object.yvel
98
object.yvel += 0x3800
99
100
temp1 = object.ypos
101
temp1 >>= 16
102
temp1 -= camera[0].ypos
103
Abs(temp1)
104
temp1 -= 15
105
if temp1 >= screen.ycenter
106
object.type = TypeName[Blank Object]
107
end if
108
109
ObjectTileCollision(CSIDE_FLOOR, 0, 11, PATH_A)
110
if checkResult == true
111
CallFunction(ChemicalDrop_CreateSplash)
112
end if
113
114
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
115
BoxCollisionTest(C_TOUCH, object.entityPos, -6, -6, 6, 6, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
116
if checkResult == true
117
CallFunction(ChemicalDrop_BubbleHit)
118
CallFunction(ChemicalDrop_CreateSplash)
119
end if
120
next
121
end event
122
123
124
event ObjectDraw
125
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
126
end event
127
128
129
event ObjectStartup
130
CheckCurrentStageFolder("Zone02")
131
if checkResult == true
132
LoadSpriteSheet("CPZ/Objects.gif")
133
SpriteFrame(-9, -18, 18, 29, 97, 189)
134
SpriteFrame(-9, -18, 18, 29, 117, 189)
135
else
136
LoadSpriteSheet("MBZ/Objects.gif")
137
SpriteFrame(-9, -18, 18, 29, 1, 64)
138
SpriteFrame(-9, -18, 18, 29, 21, 64)
139
end if
140
end event
141
142
143
// ========================
144
// Editor Events
145
// ========================
146
147
event RSDKDraw
148
DrawSprite(0)
149
end event
150
151
152
event RSDKLoad
153
CheckCurrentStageFolder("Zone02")
154
if checkResult == true
155
LoadSpriteSheet("CPZ/Objects.gif")
156
SpriteFrame(-9, -18, 18, 29, 97, 189)
157
else
158
LoadSpriteSheet("MBZ/Objects.gif")
159
SpriteFrame(-9, -18, 18, 29, 1, 64)
160
end if
161
162
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
163
end event
164
165