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/Enemies/Chopper.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Chopper 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
private alias 0 : CHOPPER_ANI_JUMP
15
private alias 1 : CHOPPER_ANI_BITE
16
private alias 2 : CHOPPER_ANI_FALL
17
18
// Player Aliases
19
private alias object.value40 : player.hitboxLeft
20
private alias object.value38 : player.hitboxTop
21
private alias object.value41 : player.hitboxRight
22
private alias object.value39 : player.hitboxBottom
23
24
25
// ========================
26
// Function Declarations
27
// ========================
28
29
reserve function Chopper_DebugDraw
30
reserve function Chopper_DebugSpawn
31
32
33
// ========================
34
// Function Definitions
35
// ========================
36
37
private function Chopper_DebugDraw
38
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
39
end function
40
41
42
private function Chopper_DebugSpawn
43
CreateTempObject(TypeName[Chopper], 0, object.xpos, object.ypos)
44
45
// Choppers 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
46
// Neat
47
GetBit(temp0, object.direction, 0)
48
object[tempObjectPos].direction = temp0
49
50
object[tempObjectPos].startPos.y = object.ypos
51
object[tempObjectPos].yvel = -0x70000
52
end function
53
54
55
// ========================
56
// Events
57
// ========================
58
59
event ObjectUpdate
60
object.ypos += object.yvel
61
object.yvel += 0x1800
62
63
if object.yvel < -0x38000
64
object.animation = CHOPPER_ANI_JUMP
65
else
66
if object.yvel > 0x38000
67
object.animation = CHOPPER_ANI_FALL
68
else
69
object.animation = CHOPPER_ANI_BITE
70
end if
71
end if
72
73
if object.ypos > object.startPos.y
74
object.ypos = object.startPos.y
75
object.yvel = -0x70000
76
end if
77
78
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
79
BoxCollisionTest(C_TOUCH, object.entityPos, -12, -14, 12, 14, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
80
if checkResult == true
81
CallFunction(Player_BadnikBreak)
82
end if
83
next
84
85
switch object.animation
86
case CHOPPER_ANI_JUMP
87
object.frame = object.animationTimer
88
object.frame >>= 3
89
object.animationTimer++
90
object.animationTimer &= 15
91
break
92
93
case CHOPPER_ANI_BITE
94
object.frame = object.animationTimer
95
object.frame >>= 3
96
object.animationTimer += 2
97
object.animationTimer &= 15
98
break
99
100
case CHOPPER_ANI_FALL
101
object.frame = 0
102
break
103
104
end switch
105
end event
106
107
108
event ObjectDraw
109
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
110
end event
111
112
113
event ObjectStartup
114
CheckCurrentStageFolder("Zone01")
115
if checkResult == true
116
LoadSpriteSheet("GHZ/Objects.gif")
117
SpriteFrame(-14, -15, 30, 32, 98, 94)
118
SpriteFrame(-14, -15, 30, 32, 129, 94)
119
end if
120
121
CheckCurrentStageFolder("Zone07")
122
if checkResult == true
123
LoadSpriteSheet("MBZ/Objects.gif")
124
SpriteFrame(-14, -15, 30, 32, 106, 81)
125
SpriteFrame(-14, -15, 30, 32, 137, 81)
126
end if
127
128
foreach (TypeName[Chopper], arrayPos0, ALL_ENTITIES)
129
object[arrayPos0].startPos.y = object[arrayPos0].ypos
130
object[arrayPos0].yvel = -0x70000
131
next
132
133
SetTableValue(TypeName[Chopper], DebugMode_ObjCount, DebugMode_TypesTable)
134
SetTableValue(Chopper_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
135
SetTableValue(Chopper_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
136
DebugMode_ObjCount++
137
end event
138
139
140
// ========================
141
// Editor Events
142
// ========================
143
144
event RSDKDraw
145
DrawSprite(0)
146
end event
147
148
149
event RSDKLoad
150
CheckCurrentStageFolder("Zone07")
151
if checkResult == true
152
LoadSpriteSheet("MBZ/Objects.gif")
153
SpriteFrame(-14, -15, 30, 32, 106, 81)
154
else
155
LoadSpriteSheet("GHZ/Objects.gif")
156
SpriteFrame(-14, -15, 30, 32, 98, 94)
157
end if
158
159
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
160
end event
161
162