Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Animals/R8_Sheep.txt
1319 views
1
//------------------Sonic CD Sheep 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 : SHEEP_HOPRIGHT
13
#alias 1 : SHEEP_HOPLEFT
14
15
// Collision Side Aliases
16
#alias 0 : CSIDE_FLOOR
17
18
// Time Period Aliases
19
#alias 2 : TIME_GOOD_FUTURE
20
21
22
sub ObjectMain
23
Object.YPos += Object.YVelocity
24
25
// Gravity of around 0.156px
26
Object.YVelocity += 0x2800
27
28
switch Object.State
29
case SHEEP_HOPRIGHT
30
31
// Advance at a rate of 1px per frame
32
Object.XPos += 0x10000
33
34
// Only check for collision when going down
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_LEFT
42
43
// Bounce back up with a velocity of 5px per frame
44
Object.YVelocity = -0x50000
45
46
Object.State = SHEEP_HOPLEFT
47
end if
48
end if
49
break
50
51
case SHEEP_HOPLEFT
52
53
// Go left at a rate of 1px per frame
54
Object.XPos -= 0x10000
55
56
// Collision is only to be checked when falling
57
if Object.YVelocity > 0
58
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
59
60
if CheckResult == true
61
// Turn around again
62
63
Object.Direction = FACING_RIGHT
64
65
// Initial Y Velocity of 5px upwards again
66
Object.YVelocity = -0x50000
67
68
Object.State = SHEEP_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
95
end sub
96
97
98
sub ObjectStartup
99
LoadSpriteSheet("R8/Objects2.gif")
100
101
SpriteFrame(-10, -8, 24, 16, 160, 110)
102
SpriteFrame(-10, -8, 24, 16, 160, 127)
103
104
// Used to be below LoadSpriteSheet, moved here for consistency
105
// Setup all Sheep in the level
106
ArrayPos0 = 32
107
while ArrayPos0 < 1056
108
if Object[ArrayPos0].Type == TypeName[Sheep]
109
110
// Start the Sheep going upwards at 5px per frame
111
Object[ArrayPos0].YVelocity = -0x50000
112
113
end if
114
115
ArrayPos0++
116
loop
117
118
end sub
119
120
121
// ========================
122
// Editor Subs
123
// ========================
124
125
sub RSDKDraw
126
DrawSprite(0)
127
end sub
128
129
130
sub RSDKLoad
131
LoadSpriteSheet("R8/Objects2.gif")
132
SpriteFrame(-10, -8, 24, 16, 160, 110)
133
134
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
135
end sub
136
137