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

music maestro!

and sounds


git-svn-id: http://svn.net-core.org/repos/t-engine4@506 51575b47-30f0-44d4-a5cc-537603b46e54
parent 031f5556
No related branches found
No related tags found
No related merge requests found
Showing
with 123 additions and 99 deletions
......@@ -41,14 +41,22 @@ function _M:playMusic(name)
m = self.loaded_musics[name]
end
if not m then return end
if self.current_music == name and self.playing_music then return end
if self.current_music then
self:stopMusic()
core.sound.musicStop()
end
m:play()
self.current_music = name
self.playing_music = true
end
function _M:stopMusic()
if not self.loaded_musics[self.current_music] then return end
self.loaded_musics[self.current_music]:stop()
core.sound.musicStop()
self.current_music = nil
self.playing_music = false
end
function _M:volumeMusic(vol)
core.sound.musicVolume(vol or 100)
end
......@@ -34,9 +34,16 @@ end
function _M:playSound(name)
local s = self.loaded_sounds[name]
if not s then
self.loaded_sounds[name] = core.sound.newSound("/data/sound/"..name)
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
self.loaded_sounds[name] = def
s = self.loaded_sounds[name]
end
if not s then return end
s:play()
s.file:play(s.loop, s.timed)
end
......@@ -98,6 +98,7 @@ function _M:run()
self:setCurrent()
-- Run the current music if any
self:volumeMusic(30)
self:playMusic()
if self.level then self:setupDisplayMode() end
......@@ -253,7 +254,11 @@ function _M:changeLevel(lev, zone)
end
if self.level.data.ambiant_music then
self:playMusic(self.level.data.ambiant_music)
if self.level.data.ambiant_music ~= "last" then
self:playMusic(self.level.data.ambiant_music)
end
else
self:stopMusic()
end
end
......
......@@ -67,7 +67,7 @@ newBirthDescriptor{
talents = {
[ActorTalents.T_MANATHRUST] = 1,
[ActorTalents.T_FLAME] = 1,
[ActorTalents.T_FREEZE] = 1,
[ActorTalents.T_CORROSIVE_VAPOUR] = 1,
[ActorTalents.T_PHASE_DOOR] = 1,
},
copy = {
......@@ -132,45 +132,3 @@ newBirthDescriptor{
},
},
}
newBirthDescriptor{
type = "subclass",
name = "Necromancer",
desc = {
"Their most important stats are: Magic and Willpower",
},
stats = { mag=3, wil=2, cun=1, },
talents_types = {
["spell/arcane"]={true, 0.3},
["spell/fire"]={true, 0.3},
["spell/earth"]={true, 0.3},
["spell/water"]={true, 0.3},
["spell/air"]={true, 0.3},
["spell/phantasm"]={true, 0.3},
["spell/temporal"]={false, 0.3},
["spell/meta"]={false, 0.3},
["spell/divination"]={true, 0.3},
["spell/conveyance"]={true, 0.3},
["spell/nature"]={true, 0.3},
["spell/necromancy"]={true, 0.3},
["cunning/survival"]={false, -0.1},
},
talents = {
[ActorTalents.T_ABSORB_SOUL] = 1,
[ActorTalents.T_FLAME] = 1,
[ActorTalents.T_FREEZE] = 1,
[ActorTalents.T_PHASE_DOOR] = 1,
},
copy = {
max_life = 80,
life_rating = 7,
resolvers.equip{ id=true,
{type="weapon", subtype="staff", name="elm staff", autoreq=true},
{type="armor", subtype="cloth", name="robe", autoreq=true}
},
resolvers.inventory{ id=true,
{type="potion", subtype="potion", name="potion of lesser mana"},
{type="potion", subtype="potion", name="potion of lesser mana"},
},
},
}
......@@ -63,7 +63,7 @@ newEntity{ base = "BASE_NPC_WIGHT",
combat_armor = 7, combat_def = 6,
resolvers.talents{
[Talents.T_FLAMESHOCK]=1, [Talents.T_LIGHTNING]=1, [Talents.T_NOXIOUS_CLOUD]=1,
[Talents.T_FLAMESHOCK]=1, [Talents.T_LIGHTNING]=1, [Talents.T_CORROSIVE_VAPOUR]=1,
[Talents.T_MIND_DISRUPTION]=1,
},
}
......@@ -76,7 +76,7 @@ newEntity{ base = "BASE_NPC_WIGHT",
max_life = resolvers.rngavg(70,80),
combat_armor = 9, combat_def = 6,
resolvers.talents{ [Talents.T_MANA_POOL]=1, [Talents.T_FLAMESHOCK]=2, [Talents.T_LIGHTNING]=2, [Talents.T_NOXIOUS_CLOUD]=2,
resolvers.talents{ [Talents.T_MANA_POOL]=1, [Talents.T_FLAMESHOCK]=2, [Talents.T_LIGHTNING]=2, [Talents.T_CORROSIVE_VAPOUR]=2,
[Talents.T_MIND_DISRUPTION]=2,
},
}
......@@ -89,7 +89,7 @@ newEntity{ base = "BASE_NPC_WIGHT",
max_life = resolvers.rngavg(80,90),
combat_armor = 10, combat_def = 8,
resolvers.talents{ [Talents.T_MANA_POOL]=1, [Talents.T_FLAMESHOCK]=3, [Talents.T_LIGHTNING]=3, [Talents.T_NOXIOUS_CLOUD]=3,
resolvers.talents{ [Talents.T_MANA_POOL]=1, [Talents.T_FLAMESHOCK]=3, [Talents.T_LIGHTNING]=3, [Talents.T_CORROSIVE_VAPOUR]=3,
[Talents.T_MIND_DISRUPTION]=3,
},
}
......@@ -101,7 +101,7 @@ newEntity{ base = "BASE_NPC_WIGHT",
rarity = 9,
max_life = resolvers.rngavg(100,150),
combat_armor = 12, combat_def = 10,
resolvers.talents{ [Talents.T_MANA_POOL]=3, [Talents.T_FLAMESHOCK]=3, [Talents.T_LIGHTNING]=4, [Talents.T_NOXIOUS_CLOUD]=3, [Talents.T_THUNDERSTORM]=2,
resolvers.talents{ [Talents.T_MANA_POOL]=3, [Talents.T_FLAMESHOCK]=3, [Talents.T_LIGHTNING]=4, [Talents.T_CORROSIVE_VAPOUR]=3, [Talents.T_THUNDERSTORM]=2,
[Talents.T_MIND_DISRUPTION]=4,
},
}
......@@ -34,6 +34,7 @@ newTalent{
local x, y = self:getTarget(tg)
if not x or not y then return nil end
self:project(tg, x, y, DamageType.LIGHTNING, rng.avg(1, self:spellCrit(20 + self:combatSpellpower(0.8) * self:getTalentLevel(t)), 3), {type="lightning"})
game:playSound("talents/lightning")
return true
end,
info = function(self, t)
......@@ -86,6 +87,7 @@ newTalent{
end
fork(fx, fy)
game:playSound("talents/lightning")
return true
end,
......@@ -101,38 +103,27 @@ newTalent{
}
newTalent{
name = "Noxious Cloud",
name = "Wings of Wind",
type = {"spell/air",3},
require = spells_req3,
points = 5,
mana = 25,
cooldown = 8,
mode = "sustained",
sustain_mana = 100,
tactical = {
ATTACKAREA = 10,
MOVEMENT = 10,
},
range = 15,
action = function(self, t)
local duration = self:getTalentLevel(t) + 2
local radius = 3
local dam = 4 + self:combatSpellpower(0.17) * self:getTalentLevel(t)
local tg = {type="ball", range=self:getTalentRange(t), radius=radius}
local x, y = self:getTarget(tg)
if not x or not y then return nil end
local _ _, x, y = self:canProject(tg, x, y)
-- Add a lasting map effect
game.level.map:addEffect(self,
x, y, duration,
DamageType.NATURE, dam,
radius,
5, nil,
engine.Entity.new{alpha=100, display='', color_br=30, color_bg=180, color_bb=60},
nil, self:spellFriendlyFire()
)
activate = function(self, t)
return {
fly = self:addTemporaryValue("fly", math.floor(self:getTalentLevel(t))),
}
end,
deactivate = function(self, t, p)
self:removeTemporaryValue("fly", p.fly)
return true
end,
info = function(self, t)
return ([[Noxious fumes rises from the ground doing %0.2f nature damage in a radius of 3 each turn for %d turns.
The damage and duration will increase with the Magic stat]]):format(4 + self:combatSpellpower(0.17) * self:getTalentLevel(t), self:getTalentLevel(t) + 2)
return ([[Grants the caster a pair of wings made of pure wind, allowing her to fly up to %d height.]]):
format(math.floor(self:getTalentLevel(t)))
end,
}
......@@ -174,6 +165,7 @@ newTalent{
table.remove(tgts, id)
self:project(tg, a.x, a.y, DamageType.LIGHTNING, rng.avg(1, self:spellCrit(20 + self:combatSpellpower(0.2) * self:getTalentLevel(t)), 3), {type="lightning"})
game:playSound("talents/lightning")
end
end,
activate = function(self, t)
......
......@@ -35,6 +35,7 @@ newTalent{
local x, y = self:getTarget(tg)
if not x or not y then return nil end
self:project(tg, x, y, DamageType.ARCANE, self:spellCrit(20 + self:combatSpellpower(0.5) * self:getTalentLevel(t)), {type="manathrust"})
game:playSound("talents/arcane")
return true
end,
info = function(self, t)
......@@ -57,6 +58,7 @@ newTalent{
action = function(self, t)
if not self:hasEffect(self.EFF_MANAFLOW) then
self:setEffect(self.EFF_MANAFLOW, 10, {power=5+self:combatSpellpower(0.06) * self:getTalentLevel(t)})
game:playSound("talents/arcane")
end
return true
end,
......@@ -96,6 +98,7 @@ newTalent{
activate = function(self, t)
local power = math.max(0.8, 3 - (self:combatSpellpower(1) * self:getTalentLevel(t)) / 280)
self.disruption_shield_absorb = 0
game:playSound("talents/arcane")
return {
shield = self:addTemporaryValue("disruption_shield", power),
}
......
......@@ -34,6 +34,7 @@ newTalent{
local x, y = self:getTarget(tg)
if not x or not y then return nil end
self:project(tg, x, y, DamageType.FIREBURN, self:spellCrit(25 + self:combatSpellpower(1.2) * self:getTalentLevel(t)), {type="flame"})
game:playSound("talents/fire")
return true
end,
info = function(self, t)
......@@ -58,6 +59,7 @@ newTalent{
local x, y = self:getTarget(tg)
if not x or not y then return nil end
self:project(tg, x, y, DamageType.FLAMESHOCK, {dur=self:getTalentLevelRaw(t) + 2, dam=self:spellCrit(10 + self:combatSpellpower(0.6) * self:getTalentLevel(t))}, {type="flame"})
game:playSound("talents/fire")
return true
end,
info = function(self, t)
......@@ -82,6 +84,7 @@ newTalent{
local x, y = self:getTarget(tg)
if not x or not y then return nil end
self:project(tg, x, y, DamageType.FIRE, self:spellCrit(28 + self:combatSpellpower(0.6) * self:getTalentLevel(t)), {type="flame"})
game:playSound("talents/fireflash")
return true
end,
info = function(self, t)
......@@ -118,6 +121,7 @@ newTalent{
engine.Entity.new{alpha=100, display='', color_br=180, color_bg=30, color_bb=60},
nil, self:spellFriendlyFire()
)
game:playSound("talents/fire")
return true
end,
info = function(self, t)
......
......@@ -18,44 +18,64 @@
-- darkgod@te4.org
newTalent{
name = "Freeze",
type = {"spell/water", 1},
name = "Corrosive Vapour",
type = {"spell/water",1},
require = spells_req1,
points = 5,
mana = 14,
cooldown = 3,
mana = 25,
cooldown = 8,
tactical = {
ATTACK = 10,
ATTACKAREA = 10,
},
range = 20,
reflectable = true,
range = 15,
action = function(self, t)
local tg = {type="hit", range=self:getTalentRange(t), talent=t}
local duration = self:getTalentLevel(t) + 2
local radius = 3
local dam = 4 + self:combatSpellpower(0.17) * self:getTalentLevel(t)
local tg = {type="ball", range=self:getTalentRange(t), radius=radius}
local x, y = self:getTarget(tg)
if not x or not y then return nil end
self:project(tg, x, y, DamageType.COLD, self:spellCrit(12 + self:combatSpellpower(0.25) * self:getTalentLevel(t)), {type="freeze"})
self:project(tg, x, y, DamageType.FREEZE, 3 + math.floor(self:getTalentLevel(t) / 3))
local _ _, x, y = self:canProject(tg, x, y)
-- Add a lasting map effect
game.level.map:addEffect(self,
x, y, duration,
DamageType.ACID, dam,
radius,
5, nil,
engine.Entity.new{alpha=100, display='', color_br=30, color_bg=180, color_bb=60},
nil, self:spellFriendlyFire()
)
return true
end,
info = function(self, t)
return ([[Condenses ambient water on a target, freezing it for a short while and damaging it for %0.2f.
The damage will increase with the Magic stat]]):format(12 + self:combatSpellpower(0.25) * self:getTalentLevel(t))
return ([[Corrosive fumes rises from the ground doing %0.2f acid damage in a radius of 3 each turn for %d turns.
The damage and duration will increase with the Magic stat]]):format(4 + self:combatSpellpower(0.17) * self:getTalentLevel(t), self:getTalentLevel(t) + 2)
end,
}
newTalent{
name = "Ent-draught",
name = "Freeze",
type = {"spell/water", 2},
require = spells_req2,
points = 5,
mana = 30,
cooldown = 100,
mana = 14,
cooldown = 3,
tactical = {
ATTACK = 10,
},
range = 20,
reflectable = true,
action = function(self, t)
self:setEffect(self.EFF_ALL_STAT, 20, {power=1+self:combatSpellpower(0.01) * self:getTalentLevel(t)})
local tg = {type="hit", range=self:getTalentRange(t), talent=t}
local x, y = self:getTarget(tg)
if not x or not y then return nil end
self:project(tg, x, y, DamageType.COLD, self:spellCrit(12 + self:combatSpellpower(0.25) * self:getTalentLevel(t)), {type="freeze"})
self:project(tg, x, y, DamageType.FREEZE, 3 + math.floor(self:getTalentLevel(t) / 3))
return true
end,
info = function(self, t)
return ([[Confures some Ent-draught to fill your stomach and boost your stats by %d for 20 turns.]]):format(1+self:combatSpellpower(0.01) * self:getTalentLevel(t))
return ([[Condenses ambient water on a target, freezing it for a short while and damaging it for %0.2f.
The damage will increase with the Magic stat]]):format(12 + self:combatSpellpower(0.25) * self:getTalentLevel(t))
end,
}
......
......@@ -36,7 +36,8 @@ newEntity{
define_as = "MAZE_WALL",
name = "wall", image = "terrain/granite_wall_lichen.png",
display = '#', color_r=255, color_g=255, color_b=255,
block_move = true,
always_remember = true,
does_block_move = true,
block_sight = true,
air_level = -20,
}
......@@ -57,6 +57,7 @@ newEntity{ define_as = "SANDWORM_QUEEN",
stats = { str=25, dex=10, cun=8, mag=20, wil=20, con=20 },
stun_immune = 1,
no_breath = 1,
resists = { [DamageType.FIRE] = 30, [DamageType.COLD] = -30 },
......
......@@ -28,6 +28,7 @@ return {
-- all_remembered = true,
-- all_lited = true,
persistant = "zone",
ambiant_music = "cirith-ungol.ogg",
generator = {
map = {
class = "engine.generator.map.Roomer",
......
......@@ -28,6 +28,7 @@ return {
-- all_remembered = true,
all_lited = true,
persistant = "zone",
ambiant_music = "elven_town.ogg",
generator = {
map = {
class = "engine.generator.map.Roomer",
......
......@@ -25,6 +25,7 @@ return {
all_remembered = true,
all_lited = true,
persistant = "memory",
ambiant_music = "last",
generator = {
map = {
class = "mod.class.generator.map.Wilderness",
......
No preview for this file type
......@@ -66,12 +66,19 @@ static int music_play(lua_State *L)
static int music_stop(lua_State *L)
{
Mix_Music **m = (Mix_Music**)auxiliar_checkclass(L, "core{music}", 1);
int fadeout = lua_isnumber(L, 2) ? lua_tonumber(L, 2) : 0;
int fadeout = lua_isnumber(L, 1) ? lua_tonumber(L, 1) : 0;
Mix_FadeOutMusic(fadeout);
return 0;
}
static int music_volume(lua_State *L)
{
int vol = lua_isnumber(L, 1) ? lua_tonumber(L, 1) : 100;
Mix_VolumeMusic(SDL_MIX_MAXVOLUME * vol / 100);
return 0;
}
static int sound_new(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
......@@ -86,7 +93,7 @@ static int sound_new(lua_State *L)
}
*m = Mix_LoadWAV_RW(rops, 1);
if (!*m) return 0;
Mix_VolumeChunk(m, SDL_MIX_MAXVOLUME);
Mix_VolumeChunk(*m, SDL_MIX_MAXVOLUME);
return 1;
}
......@@ -102,7 +109,20 @@ static int sound_free(lua_State *L)
static int sound_play(lua_State *L)
{
Mix_Chunk **m = (Mix_Chunk**)auxiliar_checkclass(L, "core{sound}", 1);
Mix_PlayChannel(-1, m, 0);
int loop = lua_isnumber(L, 2) ? lua_tonumber(L, 2) : 0;
int ms = lua_isnumber(L, 3) ? lua_tonumber(L, 3) : 0;
if (!ms)
Mix_PlayChannel(-1, *m, loop);
else
Mix_PlayChannelTimed(-1, *m, loop , ms);
return 0;
}
static int sound_volume(lua_State *L)
{
Mix_Chunk **m = (Mix_Chunk**)auxiliar_checkclass(L, "core{sound}", 1);
int vol = lua_isnumber(L, 2) ? lua_tonumber(L, 2) : 100;
Mix_VolumeChunk(*m, SDL_MIX_MAXVOLUME * vol / 100);
return 0;
}
......@@ -110,6 +130,8 @@ static const struct luaL_reg soundlib[] =
{
{"newMusic", music_new},
{"newSound", sound_new},
{"musicStop", music_stop},
{"musicVolume", music_volume},
{NULL, NULL},
};
......@@ -117,7 +139,6 @@ static const struct luaL_reg music_reg[] =
{
{"__gc", music_free},
{"play", music_play},
{"stop", music_stop},
{NULL, NULL},
};
......@@ -125,6 +146,7 @@ static const struct luaL_reg sound_reg[] =
{
{"__gc", sound_free},
{"play", sound_play},
{"setVolume", sound_volume},
{NULL, NULL},
};
......
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