Repository navigation
Expand file tree
/
Copy pathattacks.lua
More file actions
144 lines (120 loc) · 4.41 KB
/
Copy pathattacks.lua
File metadata and controls
144 lines (120 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
basicAttackSound = audio.loadSound("_audio/Basic Attack.ogg")
jumpSound = audio.loadSound("_audio/Jump.ogg")
local screams = {}
for i = 1, 5,1 do
screams[i] = audio.loadSound("_audio/ManScream0"..i..".ogg")
end
function scream()
audio.play(screams[math.random(5)])
end
-- All attacks should be under 1000 ms
function attack( attacker, attacked, attackType, direction )
attackAnimation[attackType]( attacker, attacked, direction )
end
-- BASIC STRIKE ANIMATIONS
function basicStrike( obj, attacked, direction )
local origin = obj.x
transition.to( obj, { time = 500, x = 300*direction, delta = true, onComplete = function( )
transition.to( obj, { time = 50, x = 300*direction, delta = true, onComplete = function( )
audio.play(basicAttackSound)
transition.to( obj, {time = 300, x = origin } )
do_shake_obj( attacked, 3 )
scream()
end } )
end } )
end
function leapAttack( obj, attacked, direction )
local returnpoint = {obj.x,obj.y}
local curve = generate_curve(8,{
{x = obj.x, y = obj.y},
{x = obj.x, y = obj.y-100},
{x = obj.x+(100*direction), y = obj.y-300},
{x = obj.x+(400*direction),y = obj.y-300} })
audio.play(jumpSound)
transition_curve(obj,curve,{ time = 400, speed = 0.1, onComplete = function()
transition.to(obj,{time = 70, x = attacked.x,y = attacked.y,onComplete = function()
transition.to( obj, { time = 300, x = returnpoint[1], y = returnpoint[2]})
audio.play(basicAttackSound)
do_shake_obj( attacked, 3 )
scream()
end } )
end },1 )
end
function groundPound( obj, attacked, direction )
local origin = obj.x
poundSound = audio.loadSound("_audio/GroundPound.ogg")
audio.play(poundSound)
transition.to( obj, { time = 300, y = -200, delta = true, onComplete = function()
transition.to( obj, { time = 50, y = 200, delta = true, onComplete = function()
transition.to( obj, {time = 200, x = origin } )
do_shake_obj( attacked, 5 )
scream()
end } )
end } )
end
function dashAttack( obj, attacked, direction )
local origin = obj.x
transition.to( obj, { time = 200, x = 300*direction, delta = true, onComplete = function( )
transition.to( obj, { time = 20, x = 300*direction, delta = true, onComplete = function( )
transition.to( obj, {time = 200, x = origin } )
do_shake_obj( attacked, 3 )
scream()
end } )
end } )
end
function growthAttack( obj, attacked, direction )
local origin = obj.x
grunt = audio.loadSound("_audio/maleGrunt03.ogg")
audio.play(grunt)
transition.scaleTo( obj, { xScale = 1.2,yScale = 1.2,time = 200, onComplete = function( )
transition.scaleTo(obj,{time = 200,xScale = 1,yScale = 1})
end } )
end
function CHARGE(obj, attacked, direction)
local origin = obj.x
local lance = display.newImageRect(obj,"_gfx/action/players/lance"..1+direction..".png",544,56)
lance.fill.effect = "filter.brightness"
lance.fill.effect.intensity = 1
lance.alpha = 0
lance.anchorX = direction*-1
lance.x = -66*direction
lance.y = -56
CHARGESOUND = audio.loadSound("_audio/CHARGE.ogg")
audio.play(CHARGESOUND)
transition.to(lance, {time = 200, alpha = 1, onComplete = function()
transition.to(lance.fill.effect, {time = 200,intensity = 0 })
end } )
transition.to( obj, { time = 800, x = -100*direction, delta = true, onComplete = function( )
transition.to( obj, { time = 100, x = 800*direction, delta = true, onComplete = function( )
audio.play(basicAttackSound)
transition.to( obj, {time = 200, x = origin } )
do_shake_obj( attacked, 3 )
scream()
lance:removeSelf()
lance = nil
end } )
end } )
end
function do_shake_obj( obj, count )
if not count then count = 1 end
if count > 0 then
shake_obj( obj, function( ) do_shake_obj( obj, count-1 ) end )
end
end
function shake_obj( obj, onComplete )
local origin = obj.x
transition.to( obj, { time = 20, x = 10, delta = true, onComplete = function( )
transition.to( obj, { time = 40, x = -20, delta = true, onComplete = function( )
transition.to( obj, {time = 20, x = origin, onComplete = onComplete } )
end } )
end } )
end
attackAnimation = {
--LEAP ATTACK ANIMATION
["Basic Strike"] = basicStrike,
["Leap Attack"] = leapAttack,
["Ground Pound"] = groundPound,
["Dash"] = dashAttack,
["Rage"] = growthAttack,
["CHARGE"] = CHARGE
}