yupplemayham/Resources/scripts/weapons/shotgun_script.lua
Ethan Adams 1f38730c96 Added normal parameter for easier knockback implemention script-side
Moved scripts to more descriptive location
2024-06-25 15:40:17 -04:00

21 lines
624 B
Lua

function length(vec)
return math.sqrt(vec.x^2 + vec.y^2)
end
-- How bullets are produced make sure to generate bullet data, then pass it through createBullet
function onShoot()
rot = weapon.wielder.rotation
data = weapon:genBulletData()
for i=-20, 20, 10 do
spread = i
data.direction.x = math.cos(math.rad(rot + spread))
data.direction.y = math.sin(math.rad(rot + spread))
weapon:createBullet(data)
end
end
-- How the bullet, target or wielder respond when the bullet hits a target.
function onHit(target, bullet, normal)
target.physics.rigidBody:applyForce(vec3.new(normal.x, normal.y, 0.0), 5000.0);
end