Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/IcdBlockCollision.txt
1319 views
1
//------------Sonic CD Ice Block Collision Script-------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
//----------Used on Mission "M086 - Twinkle Toes"-------------//
5
6
// Aliases
7
#alias Object.Value0 : Object.IceBlockEntity
8
9
// Aliases
10
#alias Object.Value1 : Object.XVelocity
11
#alias Object.Value2 : Object.YVelocity
12
13
// States
14
#alias 0 : ICEBLOCK_FALLING
15
#alias 1 : ICEBLOCK_BREAKICE
16
17
// Property Values
18
#alias 0 : CHARACTER_ICEBLOCK
19
20
// Priority
21
#alias 0 : PRIORITY_BOUNDS
22
#alias 1 : PRIORITY_ACTIVE
23
24
// Stage SFX
25
#alias 4 : SFX_S_GLASSSMASH
26
27
28
sub ObjectMain
29
if Object.IceBlockEntity == 0
30
// Search through Temp objects
31
ArrayPos0 = 1056
32
while ArrayPos0 < 1184
33
CheckEqual(Object[ArrayPos0].Type, TypeName[Ice Block])
34
TempValue0 = CheckResult
35
CheckEqual(Object[ArrayPos0].PropertyValue, CHARACTER_ICEBLOCK)
36
TempValue0 &= CheckResult
37
CheckEqual(Object[ArrayPos0].State, ICEBLOCK_FALLING)
38
TempValue0 &= CheckResult
39
if TempValue0 == true
40
Object.IceBlockEntity = ArrayPos0
41
Object.Priority = PRIORITY_ACTIVE
42
ArrayPos0 = 10000
43
end if
44
ArrayPos0++
45
loop
46
end if
47
48
if Object.IceBlockEntity != 0
49
ArrayPos1 = Object.IceBlockEntity
50
ArrayPos0 = 32
51
if Object[ArrayPos1].State == ICEBLOCK_BREAKICE
52
Object.IceBlockEntity = 0
53
Object.Priority = PRIORITY_BOUNDS
54
ArrayPos0 = 10000
55
end if
56
57
while ArrayPos0 < 1056
58
CheckEqual(Object[ArrayPos0].Type, TypeName[MissionBlock])
59
TempValue0 = CheckResult
60
CheckEqual(Object[ArrayPos0].Type, TypeName[Moving Blocks])
61
TempValue0 |= CheckResult
62
if TempValue0 == true
63
TempValue1 = Object[ArrayPos0].YPos
64
TempValue1 -= Object[ArrayPos1].YPos
65
// Check vertical distance between mission/moving blocks and the ice block
66
CheckLower(TempValue1, 0x280000)
67
TempValue0 = CheckResult
68
CheckGreater(TempValue1, -0x200000)
69
TempValue0 &= CheckResult
70
if TempValue0 == true
71
TempValue1 = Object[ArrayPos0].XPos
72
TempValue1 -= Object[ArrayPos1].XPos
73
// Check horizontal distance between mission/moving blocks and the ice block
74
CheckLower(TempValue1, 0x200000)
75
TempValue0 = CheckResult
76
CheckGreater(TempValue1, -0x200000)
77
TempValue0 &= CheckResult
78
if TempValue0 == true
79
// Turns out you collided with a block, must hurt
80
Object[ArrayPos1].YPos = Object[ArrayPos0].YPos
81
Object[ArrayPos1].YPos -= 0x280000
82
Object[ArrayPos1].State = ICEBLOCK_BREAKICE
83
Object[ArrayPos1].YVelocity = 0
84
85
PlayStageSfx(SFX_S_GLASSSMASH,0)
86
Object.IceBlockEntity = 0
87
Object.Priority = PRIORITY_BOUNDS
88
ArrayPos0 = 10000
89
end if
90
end if
91
end if
92
ArrayPos0++
93
loop
94
end if
95
end sub
96
97
98
// ========================
99
// Editor Subs
100
// ========================
101
102
sub RSDKDraw
103
DrawSprite(0)
104
end sub
105
106
107
sub RSDKLoad
108
LoadSpriteSheet("Global/Display.gif")
109
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
110
111
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
112
end sub
113
114
115
116