Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/LZ/HarpoonVert.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Harpoon V 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.hitboxT
14
private alias object.value2 : object.hitboxB
15
16
17
// ========================
18
// Function Declarations
19
// ========================
20
21
reserve function HarpoonV_DebugDraw
22
reserve function HarpoonV_DebugSpawn
23
24
25
// ========================
26
// Tables
27
// ========================
28
29
private table HarpoonV_frameTable
30
0, 1, 2, 1
31
end table
32
33
private table HarpoonV_delayTable
34
66, 4, 66, 4
35
end table
36
37
private table HarpoonV_sizeTable
38
-8, -24, -40, -24
39
end table
40
41
42
// ========================
43
// Function Definitions
44
// ========================
45
46
private function HarpoonV_DebugDraw
47
temp0 = object.direction
48
if object.direction == FLIP_X
49
object.direction = FLIP_Y
50
end if
51
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
52
object.direction = temp0
53
end function
54
55
56
private function HarpoonV_DebugSpawn
57
CreateTempObject(TypeName[Harpoon V], 0, object.xpos, object.ypos)
58
object[tempObjectPos].direction = object.direction
59
object[tempObjectPos].direction <<= 1
60
end function
61
62
63
// ========================
64
// Events
65
// ========================
66
67
event ObjectUpdate
68
if object.animationTimer == 0
69
object.timer++
70
if object.timer >= 4
71
object.timer = 0
72
end if
73
GetTableValue(object.animationTimer, object.timer, HarpoonV_delayTable)
74
GetTableValue(object.frame, object.timer, HarpoonV_frameTable)
75
else
76
object.animationTimer--
77
end if
78
79
GetTableValue(object.hitboxT, object.timer, HarpoonV_sizeTable)
80
object.hitboxB = 8
81
GetBit(temp2, object.direction, 1)
82
if temp2 == true // Is FLIP_Y set?
83
FlipSign(object.hitboxT)
84
FlipSign(object.hitboxB)
85
temp0 = object.hitboxB
86
object.hitboxB = object.hitboxT
87
object.hitboxT = temp0
88
end if
89
90
// Check interaction with players
91
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
92
BoxCollisionTest(C_TOUCH, object.entityPos, -4, object.hitboxT, 4, object.hitboxB, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
93
if checkResult == true
94
CallFunction(Player_Hit)
95
end if
96
next
97
end event
98
99
100
event ObjectDraw
101
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
102
end event
103
104
105
event ObjectStartup
106
LoadSpriteSheet("LZ/Objects.gif")
107
108
// Harpoon frames
109
SpriteFrame(-4, -8, 8, 16, 231, 239)
110
SpriteFrame(-4, -24, 8, 32, 222, 223)
111
SpriteFrame(-4, -40, 8, 48, 213, 207)
112
113
// Add this object to the debug item list
114
SetTableValue(TypeName[Harpoon V], DebugMode_ObjCount, DebugMode_TypesTable)
115
SetTableValue(HarpoonV_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
116
SetTableValue(HarpoonV_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
117
DebugMode_ObjCount++
118
end event
119
120
121
// ========================
122
// Editor Events
123
// ========================
124
125
event RSDKDraw
126
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
127
end event
128
129
130
event RSDKLoad
131
LoadSpriteSheet("LZ/Objects.gif")
132
SpriteFrame(-4, -40, 8, 48, 213, 207)
133
134
// dir is set from scene
135
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
136
end event
137
138