Skip to content
Snippets Groups Projects
Commit e747ee64 authored by dg's avatar dg
Browse files

sounds

git-svn-id: http://svn.net-core.org/repos/t-engine4@511 51575b47-30f0-44d4-a5cc-537603b46e54
parent 3425b474
No related branches found
No related tags found
No related merge requests found
......@@ -39,11 +39,15 @@ function _M:playSound(name)
local f = loadfile("/data/sound/"..name..".lua")
setfenv(f, setmetatable({}, {__index=_G}))
def = f()
print("[SOUND] loading from", "/data/sound/"..name..".lua", ":=:", def.file)
print("[SOUND] loading from", "/data/sound/"..name..".lua", ":=:", "/data/sound/"..def.file, ":>")
def.file = core.sound.newSound("/data/sound/"..def.file)
print("[SOUND] :=>", def.file)
if def.volume then def.file:setVolume(def.volume) end
else
elseif fs.exists("/data/sound/"..name..".wav") then
def = {file = core.sound.newSound("/data/sound/"..name..".wav")}
print("[SOUND] loading from", "/data/sound/"..name..".wav", ":=:", def.file)
else
def = {}
end
self.loaded_sounds[name] = def
......
......@@ -133,6 +133,7 @@ end
function _M:archeryShoot(damtype, mult, on_hit, tg, params)
local weapon, ammo = self:hasArcheryWeapon()
local sound, sound_miss = nil, nil
if not weapon then
game.logPlayer(self, "You must wield a bow or a sling (%s)!", ammo)
return nil
......@@ -140,6 +141,7 @@ function _M:archeryShoot(damtype, mult, on_hit, tg, params)
params = params or {}
print("[SHOOT WITH]", weapon.name, ammo.name)
local realweapon = weapon
weapon = weapon.combat
local ret = {}
......@@ -200,12 +202,18 @@ function _M:archeryShoot(damtype, mult, on_hit, tg, params)
end
end)
if ret.hitted and not sound then sound = realweapon.sound
elseif not ret.hitted and not sound_miss then sound_miss = realweapon.sound_miss end
print("[SHOOT] speed", ret.speed or 1, "=>", game.energy_to_act * (ret.speed or 1))
self:useEnergy(game.energy_to_act * (ret.speed or 1))
-- If we used only one arrow, use it
if params.one_shot then self:removeObject(self:getInven("QUIVER"), 1) end
if sound then game:playSoundNear(self, sound)
elseif sound_miss then game:playSoundNear(self, sound_miss) end
return ret.hitted
end
......
......@@ -23,6 +23,7 @@ newEntity{
slot_forbid = "OFFHAND",
type = "weapon", subtype="longbow",
display = "}", color=colors.UMBER,
sound = "actions/arrow", sound_miss = "actions/arrow",
encumber = 4,
rarity = 5,
combat = { talented = "bow", damrange = 1.4},
......
......@@ -22,6 +22,7 @@ newEntity{
slot = "MAINHAND",
type = "weapon", subtype="sling",
display = "}", color=colors.UMBER,
sound = "actions/arrow", sound_miss = "actions/arrow",
encumber = 4,
rarity = 5,
combat = { talented = "sling", },
......
return {
file = "talents/plc_hit_arrow.wav",
volume = 80,
}
File added
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment