Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Animals/Squirrel.txt
1319 views
1
//-----------------Sonic CD Squirrel Script-------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.YVelocity
7
8
// HUD alias
9
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
10
11
// States
12
#alias 0 : SQUIRREL_HOPRIGHT
13
#alias 1 : SQUIRREL_HOPLEFT
14
15
// Collision Side Aliases
16
#alias 0 : CSIDE_FLOOR
17
18
// Time Period
19
#alias 2 : TIME_GOOD_FUTURE
20
21
22
sub ObjectMain
23
Object.YPos += Object.YVelocity
24
25
// Apply a Gravity of about 0.156px
26
Object.YVelocity += 0x2800
27
28
switch Object.State
29
case SQUIRREL_HOPRIGHT
30
31
// Move a pixel right
32
Object.XPos += 0x10000
33
34
// Only check for collision when going downwards
35
if Object.YVelocity > 0
36
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
37
38
if CheckResult == true
39
// Turn around
40
41
Object.Direction = FACING_RIGHT
42
43
// Bounce back up, at a starting rate of 5px per frame
44
Object.YVelocity = -0x50000
45
46
Object.State = SQUIRREL_HOPLEFT
47
end if
48
end if
49
break
50
51
case SQUIRREL_HOPLEFT
52
53
// Move a pixel to the left
54
Object.XPos -= 0x10000
55
56
// Collision's only checked when falling
57
if Object.YVelocity > 0
58
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
59
60
if CheckResult == true
61
// Turn right back around
62
63
Object.Direction = FACING_LEFT
64
65
// Starting Y Velocity of 5px upwards per frame
66
Object.YVelocity = -0x50000
67
68
Object.State = SQUIRREL_HOPRIGHT
69
end if
70
end if
71
break
72
73
end switch
74
75
end sub
76
77
78
sub ObjectDraw
79
if MetalSonic_Destroyed == true
80
if Object.YVelocity < 0
81
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
82
else
83
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
84
end if
85
end if
86
87
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
88
if Object.YVelocity < 0
89
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
90
else
91
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
92
end if
93
end if
94
end sub
95
96
97
sub ObjectStartup
98
LoadSpriteSheet("Global/Items3.gif")
99
100
SpriteFrame(-10, -8, 24, 16, 150, 35) // #0 - Squirrel frame 0
101
SpriteFrame(-10, -8, 24, 16, 150, 52) // #1 - Squirrel frame 1
102
103
// Used to be below LoadSpriteSheet, moved here for consistency
104
// Locate all the stealthy Squirrels in the level
105
ArrayPos0 = 32
106
while ArrayPos0 < 1056
107
if Object[ArrayPos0].Type == TypeName[Squirrel]
108
109
// Give the Squirrel a starting Y Velocity of 5px up
110
Object[ArrayPos0].YVelocity = -0x50000
111
112
// Start the Squirrel facing Right
113
// (The base Sprite itself is facing towards the left, which is why this label may not seem right)
114
Object[ArrayPos0].Direction = FACING_LEFT
115
116
end if
117
118
ArrayPos0++
119
loop
120
121
end sub
122
123
124
// ========================
125
// Editor Subs
126
// ========================
127
128
sub RSDKDraw
129
DrawSprite(0)
130
end sub
131
132
133
sub RSDKLoad
134
LoadSpriteSheet("Global/Items3.gif")
135
SpriteFrame(-10, -8, 24, 16, 150, 35)
136
137
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
138
end sub
139
140