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

soundssssss

git-svn-id: http://svn.net-core.org/repos/t-engine4@507 51575b47-30f0-44d4-a5cc-537603b46e54
parent a831b482
No related branches found
No related tags found
No related merge requests found
Showing
with 33 additions and 7 deletions
......@@ -34,16 +34,22 @@ end
function _M:playSound(name)
local s = self.loaded_sounds[name]
if not s then
local f = loadfile("/data/sound/"..name..".lua")
setfenv(f, setmetatable({}, {__index=_G}))
local def = f()
print("[SOUND] loading from", "/data/sound/"..name..".lua", ":=:", def.file)
def.file = core.sound.newSound("/data/sound/"..def.file)
if def.volume then def.file:setVolume(def.volume) end
local def
if fs.exists("/data/sound/"..name..".lua") then
local f = loadfile("/data/sound/"..name..".lua")
setfenv(f, setmetatable({}, {__index=_G}))
def = f()
print("[SOUND] loading from", "/data/sound/"..name..".lua", ":=:", def.file)
def.file = core.sound.newSound("/data/sound/"..def.file)
if def.volume then def.file:setVolume(def.volume) end
else
def = {file = core.sound.newSound("/data/sound/"..name..".wav")}
end
self.loaded_sounds[name] = def
s = self.loaded_sounds[name]
end
if not s then return end
s.file:play(s.loop, s.timed)
local chan = s.file:play(s.loop, s.timed)
if chan and s.fadeout then core.sound.channelFadeOut(chan, s.fadeout) end
end
......@@ -64,6 +64,7 @@ function _M:use(who, typ)
if typ == "use" then
who:useEnergy()
if self.use_sound then game:playSound(self.use_sound) end
return self:useObject(who)
end
end
......
......@@ -60,6 +60,7 @@ The ToME combat system has the following attributes:
]]
function _M:attackTarget(target, damtype, mult, noenergy)
local speed, hit = nil, false
local sound, sound_miss = nil, nil
if self:attr("feared") then
if not noenergy then
......@@ -84,6 +85,8 @@ function _M:attackTarget(target, damtype, mult, noenergy)
local s, h = self:attackTargetWith(target, o.combat, damtype, mult)
speed = math.max(speed or 0, s)
hit = hit or h
if hit and not sound then sound = o.combat.sound
elseif not hit and not sound_miss then sound_miss = o.combat.sound_miss end
end
end
end
......@@ -99,6 +102,8 @@ function _M:attackTarget(target, damtype, mult, noenergy)
local s, h = self:attackTargetWith(target, o.combat, damtype, offmult)
speed = math.max(speed or 0, s)
hit = hit or h
if hit and not sound then sound = o.combat.sound
elseif not hit and not sound_miss then sound_miss = o.combat.sound_miss end
end
end
end
......@@ -108,6 +113,8 @@ function _M:attackTarget(target, damtype, mult, noenergy)
local s, h = self:attackTargetWith(target, self.combat, damtype, mult)
speed = math.max(speed or 0, s)
hit = hit or h
if hit and not sound then sound = self.combat.sound
elseif not hit and not sound_miss then sound_miss = self.combat.sound_miss end
end
-- We use up our own energy
......@@ -116,6 +123,9 @@ function _M:attackTarget(target, damtype, mult, noenergy)
self.did_energy = true
end
if sound then game:playSound(sound)
elseif sound_miss then game:playSound(sound_miss) end
-- Cancel stealth!
self:breakStealth()
return hit
......
......@@ -24,6 +24,7 @@ newEntity{
type = "weapon", subtype="battleaxe",
add_name = " (#COMBAT#)",
display = "/", color=colors.SLATE,
sound = "actions/melee", sound_miss = "actions/melee_miss",
encumber = 3,
rarity = 5,
combat = { talented = "axe", damrange = 1.5 },
......
......@@ -24,6 +24,7 @@ newEntity{
type = "weapon", subtype="greatmaul",
add_name = " (#COMBAT#)",
display = "\\", color=colors.SLATE,
sound = "actions/melee", sound_miss = "actions/melee_miss",
encumber = 5,
rarity = 5,
combat = { talented = "mace", damrange = 1.5, physspeed=1.2 },
......
......@@ -24,6 +24,7 @@ newEntity{
type = "weapon", subtype="greatsword",
add_name = " (#COMBAT#)",
display = "/", color=colors.SLATE,
sound = "actions/melee", sound_miss = "actions/melee_miss",
encumber = 3,
rarity = 5,
combat = { talented = "sword", damrange = 1.6 },
......
......@@ -23,6 +23,7 @@ newEntity{
type = "weapon", subtype="waraxe",
add_name = " (#COMBAT#)",
display = "/", color=colors.SLATE,
sound = "actions/melee", sound_miss = "actions/melee_miss",
encumber = 3,
rarity = 3,
combat = { talented = "axe", damrange = 1.4},
......
......@@ -23,6 +23,7 @@ newEntity{
type = "weapon", subtype="dagger",
add_name = " (#COMBAT#)",
display = "/", color=colors.WHITE,
sound = "actions/melee", sound_miss = "actions/melee_miss",
encumber = 1,
rarity = 5,
combat = { talented = "knife", damrange = 1.3 },
......
......@@ -23,6 +23,7 @@ newEntity{
type = "weapon", subtype="mace",
add_name = " (#COMBAT#)",
display = "/", color=colors.SLATE,
sound = "actions/melee", sound_miss = "actions/melee_miss",
encumber = 3,
rarity = 5,
combat = { talented = "mace", damrange = 1.4},
......
......@@ -22,6 +22,7 @@ newEntity{
type = "potion", subtype="potion",
unided_name = "potion", id_by_type = true,
display = "!", color=colors.WHITE, image="object/potion-0x0.png",
use_sound = "actions/quaff",
encumber = 0.2,
stacking = true,
acid_destroy = 20,
......
......@@ -24,6 +24,7 @@ newEntity{
display = "?", color=colors.WHITE, image="object/scroll-0x0.png",
encumber = 0.1,
stacking = true,
use_sound = "actions/read",
fire_destroy = 20,
desc = [[Magical scrolls can have wildly different effects! Most of them function better with a high Magic score]],
egos = "/data/general/objects/egos/scrolls.lua", egos_chance = resolvers.mbonus(10, 5),
......
......@@ -23,6 +23,7 @@ newEntity{
type = "weapon", subtype="longsword",
add_name = " (#COMBAT#)",
display = "/", color=colors.SLATE,
sound = "actions/melee", sound_miss = "actions/melee_miss",
encumber = 3,
rarity = 5,
combat = { talented = "sword", damrange = 1.4},
......
File added
File added
File added
File added
File added
File added
File added
File added
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