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/Enemies/Masher.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Masher 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.value1 : object.startPos.y
13
14
// Player Aliases
15
private alias object.value38 : player.hitboxLeft
16
private alias object.value39 : player.hitboxRight
17
private alias object.value40 : player.hitboxTop
18
private alias object.value41 : player.hitboxBottom
19
20
21
// ========================
22
// Function Declarations
23
// ========================
24
25
reserve function Masher_DebugDraw
26
reserve function Masher_DebugSpawn
27
28
29
// ========================
30
// Function Definitions
31
// ========================
32
33
private function Masher_DebugDraw
34
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
35
end function
36
37
38
private function Masher_DebugSpawn
39
CreateTempObject(TypeName[Masher], 0, object.xpos, object.ypos)
40
41
// Mashers don't normally have the capability to be turned around in the scene (aside from the actual dir attr), but they made it so that they can be turned around in Debug Mode
42
// Neat
43
GetBit(temp0, object.direction, 0)
44
object[tempObjectPos].direction = temp0
45
46
object[tempObjectPos].startPos.y = object.ypos
47
object[tempObjectPos].yvel = -0x50000
48
end function
49
50
51
// ========================
52
// Events
53
// ========================
54
55
event ObjectUpdate
56
object.ypos += object.yvel
57
object.yvel += 0x1800
58
59
if object.ypos > object.startPos.y
60
object.ypos = object.startPos.y
61
object.yvel = -0x50000
62
end if
63
64
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
65
BoxCollisionTest(C_TOUCH, object.entityPos, -12, -14, 12, 14, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
66
if checkResult == true
67
CallFunction(Player_BadnikBreak)
68
end if
69
next
70
71
if object.yvel < 0
72
object.frame = object.animationTimer
73
object.frame >>= 3
74
object.animationTimer++
75
object.animationTimer &= 15
76
else
77
object.frame = 0
78
object.animationTimer = 0
79
end if
80
end event
81
82
83
event ObjectDraw
84
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
85
end event
86
87
88
event ObjectStartup
89
CheckCurrentStageFolder("Zone01")
90
if checkResult == true
91
LoadSpriteSheet("EHZ/Objects.gif")
92
SpriteFrame(-10, -16, 20, 32, 105, 67)
93
SpriteFrame(-11, -16, 26, 30, 100, 100)
94
else
95
LoadSpriteSheet("MBZ/Objects.gif")
96
SpriteFrame(-10, -16, 20, 32, 66, 313)
97
SpriteFrame(-11, -16, 26, 30, 66, 346)
98
end if
99
100
foreach (TypeName[Masher], arrayPos0, ALL_ENTITIES)
101
object[arrayPos0].startPos.y = object[arrayPos0].ypos
102
object[arrayPos0].yvel = -0x50000
103
next
104
105
SetTableValue(TypeName[Masher], DebugMode_ObjCount, DebugMode_TypesTable)
106
SetTableValue(Masher_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
107
SetTableValue(Masher_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
108
DebugMode_ObjCount++
109
end event
110
111
112
// ========================
113
// Editor Events
114
// ========================
115
116
event RSDKDraw
117
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
118
end event
119
120
121
event RSDKLoad
122
CheckCurrentStageFolder("Zone01")
123
if checkResult == true
124
LoadSpriteSheet("EHZ/Objects.gif")
125
SpriteFrame(-10, -16, 20, 32, 105, 67)
126
else
127
LoadSpriteSheet("MBZ/Objects.gif")
128
SpriteFrame(-10, -16, 20, 32, 66, 313)
129
end if
130
131
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
132
end event
133
134