Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/DEZ/DERHand.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: DER Hand Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
private alias object.value1 : object.originPos.y
14
15
// States
16
// Some are shared with other body parts
17
private alias 1 : BODYPART_DESTROYED
18
private alias 2 : BODYPART_ACTIVE
19
20
private alias 0 : DERHAND_NONE
21
private alias 3 : DERHAND_FIRE
22
private alias 4 : DERHAND_FIRED
23
private alias 5 : DERHAND_COMINGBACK
24
25
// Player aliases
26
private alias 0 : SLOT_PLAYER1
27
private alias object.ypos : player.ypos
28
29
30
// ========================
31
// Tables
32
// ========================
33
34
private table DERHand_velocities
35
0x20000, 0x10000, 0x8000, 0x0000
36
end table
37
38
39
// ========================
40
// Events
41
// ========================
42
43
event ObjectUpdate
44
switch object.state
45
case DERHAND_NONE
46
case BODYPART_ACTIVE
47
break
48
49
case BODYPART_DESTROYED
50
object.xpos += object.xvel
51
object.ypos += object.yvel
52
object.yvel += 0x3800
53
if object.outOfBounds == true
54
object.type = TypeName[Blank Object]
55
end if
56
break
57
58
case DERHAND_FIRE
59
object.timer--
60
if object.timer < 0
61
object.timer = 32
62
63
temp0 = object.ypos
64
temp0 -= player[SLOT_PLAYER1].ypos
65
Abs(temp0)
66
if temp0 >= 0x1000000
67
temp0 = 0xFF0000
68
end if
69
temp0 >>= 6
70
71
GetTableValue(object.yvel, temp0, DERHand_velocities)
72
if player[SLOT_PLAYER1].ypos < object.ypos
73
FlipSign(object.yvel)
74
end if
75
76
if object.direction == FLIP_NONE
77
object.xvel = -0x80000
78
else
79
object.xvel = 0x80000
80
end if
81
82
PlaySfx(SfxName[Release], false)
83
object.state = DERHAND_FIRED
84
else
85
object.yvel += 0x2000
86
object.ypos += object.yvel
87
end if
88
break
89
90
case DERHAND_FIRED
91
object.timer--
92
if object.timer < 0
93
object.timer = 32
94
FlipSign(object.xvel)
95
object.yvel = object.originPos.y
96
object.yvel -= object.ypos
97
object.yvel >>= 5
98
object.state = DERHAND_COMINGBACK
99
else
100
object.xpos += object.xvel
101
object.ypos += object.yvel
102
end if
103
break
104
105
case DERHAND_COMINGBACK
106
object.timer--
107
if object.timer < 0
108
object.timer = 0
109
object.xvel = 0
110
object.yvel = 0
111
object.state = BODYPART_ACTIVE
112
else
113
object.xpos += object.xvel
114
object.ypos += object.yvel
115
end if
116
break
117
118
end switch
119
120
if object.state > BODYPART_DESTROYED
121
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
122
BoxCollisionTest(C_TOUCH, object.entityPos, -24, -4, 24, 4, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
123
if checkResult == true
124
CallFunction(Player_Hit)
125
end if
126
next
127
end if
128
end event
129
130
131
event ObjectDraw
132
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
133
end event
134
135
136
event ObjectStartup
137
CheckCurrentStageFolder("Zone12")
138
if checkResult == true
139
LoadSpriteSheet("DEZ/Objects.gif")
140
SpriteFrame(-32, -12, 64, 24, 430, 100)
141
else
142
LoadSpriteSheet("MBZ/Objects.gif")
143
SpriteFrame(-32, -12, 64, 24, 942, 100)
144
end if
145
end event
146
147
148
// ========================
149
// Editor Events
150
// ========================
151
152
event RSDKDraw
153
DrawSprite(0)
154
end event
155
156
157
event RSDKLoad
158
CheckCurrentStageFolder("Zone12")
159
if checkResult == true
160
LoadSpriteSheet("DEZ/Objects.gif")
161
SpriteFrame(-32, -12, 64, 24, 430, 100)
162
else
163
LoadSpriteSheet("MBZ/Objects.gif")
164
SpriteFrame(-32, -12, 64, 24, 942, 100)
165
end if
166
167
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
168
end event
169
170