Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Animals/R3_Rabbit.txt
1319 views
1
//-------------------Sonic CD Rabbit 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
#alias Object.Value1 : Object.Hops
8
9
// HUD alias
10
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
11
12
// States
13
#alias 0 : RABBIT_HOPRIGHT
14
#alias 1 : RABBIT_HOPLEFT
15
16
// Collision Side Aliases
17
#alias 0 : CSIDE_FLOOR
18
19
// Time Period Aliases
20
#alias 2 : TIME_GOOD_FUTURE
21
22
23
sub ObjectMain
24
Object.YPos += Object.YVelocity
25
26
// Apply a Gravity of about 0.17px per frame
27
Object.YVelocity += 0x2C00
28
29
switch Object.State
30
case RABBIT_HOPRIGHT
31
32
// Move the Rabbit right by a pixel
33
Object.XPos += 0x10000
34
35
// Only check for the floor if the Rabbit's falling at a rate faster than 4px per frame
36
if Object.YVelocity > 0x40000
37
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
38
39
if CheckResult == true
40
// Bounce back up, at a rate of 5px upwards per frame
41
Object.YVelocity = -0x50000
42
43
Object.Hops++
44
45
// Upon landing from the third hop, the Rabbit should turn around
46
if Object.Hops == 2
47
Object.Hops = 0
48
Object.State = RABBIT_HOPLEFT
49
Object.Direction = FACING_LEFT
50
end if
51
end if
52
end if
53
break
54
55
case RABBIT_HOPLEFT
56
57
// Move the Rabbit a pixel left
58
Object.XPos -= 0x10000
59
60
// Only check for ground collision if falling faster than 4px a frame
61
if Object.YVelocity > 0x40000
62
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
63
64
if CheckResult == true
65
// Bounce back up!
66
67
// Starting YVel of 5px per frame
68
Object.YVelocity = -0x50000
69
70
// After hopping thrice, turn right around
71
Object.Hops++
72
if Object.Hops == 2
73
Object.Hops = 0
74
Object.State = RABBIT_HOPRIGHT
75
Object.Direction = FACING_RIGHT
76
end if
77
end if
78
end if
79
break
80
81
end switch
82
83
end sub
84
85
86
sub ObjectDraw
87
if MetalSonic_Destroyed == true
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
else
94
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
95
if Object.YVelocity < 0
96
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
97
else
98
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
99
end if
100
end if
101
end if
102
103
end sub
104
105
106
sub ObjectStartup
107
LoadSpriteSheet("R3/Objects3.gif")
108
109
SpriteFrame(-8, -12, 16, 24, 149, 1)
110
SpriteFrame(-8, -12, 16, 24, 166, 1)
111
112
// Used to be below LoadSpriteSheet, moved here for consistency
113
// Loop through all Objects in the stage and setup all Rabbits
114
ArrayPos0 = 32
115
while ArrayPos0 < 1056
116
if Object[ArrayPos0].Type == TypeName[Rabbit]
117
118
// Make the Rabbit start at a rising rate of 5px per frame
119
Object[ArrayPos0].YVelocity = -0x50000
120
121
// Start facing right
122
Object[ArrayPos0].Direction = FACING_RIGHT
123
124
end if
125
126
ArrayPos0++
127
loop
128
129
end sub
130
131
132
// ========================
133
// Editor Subs
134
// ========================
135
136
sub RSDKDraw
137
DrawSprite(0)
138
end sub
139
140
141
sub RSDKLoad
142
LoadSpriteSheet("R3/Objects3.gif")
143
SpriteFrame(-8, -12, 16, 24, 149, 1)
144
145
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
146
end sub
147
148