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/HarpoonHoriz.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Harpoon H 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.hitboxL
14
private alias object.value2 : object.hitboxR
15
16
// ========================
17
// Function Declarations
18
// ========================
19
20
reserve function HarpoonH_DebugDraw
21
reserve function HarpoonH_DebugSpawn
22
23
24
// ========================
25
// Tables
26
// ========================
27
28
private table HarpoonH_delayTable
29
66, 4, 66, 4
30
end table
31
32
private table HarpoonH_frameTable
33
0, 1, 2, 1
34
end table
35
36
private table HarpoonH_sizeTable
37
8, 24, 40, 24
38
end table
39
40
41
// ========================
42
// Function Definitions
43
// ========================
44
45
private function HarpoonH_DebugDraw
46
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
47
end function
48
49
50
private function HarpoonH_DebugSpawn
51
CreateTempObject(TypeName[Harpoon H], 0, object.xpos, object.ypos)
52
object[tempObjectPos].direction = object.direction
53
end function
54
55
56
// ========================
57
// Events
58
// ========================
59
60
event ObjectUpdate
61
if object.animationTimer == 0
62
object.timer++
63
if object.timer >= 4
64
object.timer = 0
65
end if
66
GetTableValue(object.animationTimer, object.timer, HarpoonH_delayTable)
67
GetTableValue(object.frame, object.timer, HarpoonH_frameTable)
68
else
69
object.animationTimer--
70
end if
71
72
object.hitboxL = -8
73
GetTableValue(object.hitboxR, object.timer, HarpoonH_sizeTable)
74
GetBit(temp0, object.direction, 0)
75
76
if temp0 == FLIP_X
77
FlipSign(object.hitboxL)
78
FlipSign(object.hitboxR)
79
temp0 = object.hitboxR
80
object.hitboxR = object.hitboxL
81
object.hitboxL = temp0
82
end if
83
84
// Check interaction with players
85
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
86
BoxCollisionTest(C_TOUCH, object.entityPos, object.hitboxL, -4, object.hitboxR, 4, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
87
if checkResult == true
88
CallFunction(Player_Hit)
89
end if
90
next
91
end event
92
93
94
event ObjectDraw
95
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
96
end event
97
98
99
event ObjectStartup
100
LoadSpriteSheet("LZ/Objects.gif")
101
102
// Harpoon frames
103
SpriteFrame(-8, -4, 16, 8, 196, 129)
104
SpriteFrame(-8, -4, 32, 8, 158, 163)
105
SpriteFrame(-8, -4, 48, 8, 94, 115)
106
107
// Add this object to the debug item list
108
SetTableValue(TypeName[Harpoon H], DebugMode_ObjCount, DebugMode_TypesTable)
109
SetTableValue(HarpoonH_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
110
SetTableValue(HarpoonH_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
111
DebugMode_ObjCount++
112
end event
113
114
115
// ========================
116
// Editor Events
117
// ========================
118
119
event RSDKDraw
120
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
121
end event
122
123
124
event RSDKLoad
125
LoadSpriteSheet("LZ/Objects.gif")
126
SpriteFrame(-8, -4, 48, 8, 94, 115)
127
128
// Direction attr should be used
129
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
130
end event
131
132