Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Animals/R4_RedFish.txt
1319 views
1
//-----------------Sonic CD Red Fish Script-------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.Angle
8
9
// HUD alias
10
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
11
12
// States
13
#alias 0 : REDFISH_SWIMRIGHT
14
#alias 1 : REDFISH_SWIMLEFT
15
16
// Time Period Aliases
17
#alias 2 : TIME_GOOD_FUTURE
18
19
20
sub ObjectMain
21
switch Object.State
22
case REDFISH_SWIMRIGHT
23
if Object.Angle < 512
24
Object.Angle += 2
25
26
// Move a pixel right
27
Object.XPos += 0x10000
28
else
29
// Apex reached, turn around
30
Object.State = REDFISH_SWIMLEFT
31
Object.Direction = FACING_LEFT
32
end if
33
break
34
35
case REDFISH_SWIMLEFT
36
if Object.Angle > 0
37
Object.Angle -= 2
38
39
// Just keep swimming, move a pixel left now
40
Object.XPos -= 0x10000
41
else
42
// Other side's apex reached, turn right back around again
43
Object.State = REDFISH_SWIMRIGHT
44
Object.Direction = FACING_RIGHT
45
end if
46
break
47
48
end switch
49
50
// Animate the Fish
51
Object.Timer++
52
if Object.Timer > 19
53
Object.Timer = 0
54
Object.Frame++
55
Object.Frame &= 1
56
end if
57
58
end sub
59
60
61
sub ObjectDraw
62
// With this current system set up, that does indeed mean the sprite gets drawn twice if
63
// in the Good Future and the Metal Sonic Projector has been destroyed
64
65
if MetalSonic_Destroyed == true
66
Sin(TempValue1, Object.Angle)
67
TempValue1 <<= 12
68
TempValue1 += Object.YPos
69
70
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, TempValue1)
71
end if
72
73
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
74
Sin(TempValue1, Object.Angle)
75
TempValue1 <<= 12
76
TempValue1 += Object.YPos
77
78
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, TempValue1)
79
end if
80
81
end sub
82
83
84
sub ObjectStartup
85
86
LoadSpriteSheet("R4/Objects3.gif")
87
88
// Fishy Frames
89
90
SpriteFrame(-8, -12, 16, 24, 1, 67)
91
SpriteFrame(-8, -12, 16, 24, 18, 67)
92
93
end sub
94
95
96
// ========================
97
// Editor Subs
98
// ========================
99
100
sub RSDKDraw
101
DrawSprite(0)
102
end sub
103
104
105
sub RSDKLoad
106
LoadSpriteSheet("R4/Objects3.gif")
107
SpriteFrame(-8, -12, 16, 24, 1, 67)
108
109
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
110
end sub
111
112