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

sound (broken)

delete Wings of Wind spell
add Chain Lightning


git-svn-id: http://svn.net-core.org/repos/t-engine4@504 51575b47-30f0-44d4-a5cc-537603b46e54
parent 40feeebc
No related branches found
No related tags found
No related merge requests found
......@@ -104,16 +104,18 @@ function _M:project(t, x, y, damtype, dam, particles)
grids[x][y] = true
end
local srcx, srcy = t.x or self.x, t.y or self.y
-- Stop at range or on block
local lx, ly = x, y
local l = line.new(self.x, self.y, x, y)
local l = line.new(srcx, srcy, x, y)
lx, ly = l()
local initial_dir = lx and coord_to_dir[lx - self.x][ly - self.y] or 5
local initial_dir = lx and coord_to_dir[lx - srcx][ly - srcy] or 5
while lx and ly do
if not typ.no_restrict then
if typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then break
elseif game.level.map:checkEntity(lx, ly, Map.TERRAIN, "block_move") then break end
if typ.range and math.sqrt((self.x-lx)^2 + (self.y-ly)^2) > typ.range then break end
if typ.range and math.sqrt((srcx-lx)^2 + (srcy-ly)^2) > typ.range then break end
end
-- Deam damage: beam
......@@ -145,13 +147,15 @@ function _M:project(t, x, y, damtype, dam, particles)
-- Now project on each grid, one type
if type(damtype) == "function" then
local stop = false
for px, ys in pairs(grids) do
for py, _ in pairs(ys) do
damtype(px, py)
if particles then
game.level.map:particleEmitter(px, py, 1, particles.type)
end
if damtype(px, py) then stop=true break end
end
if stop then break end
end
else
for px, ys in pairs(grids) do
......
......@@ -22,8 +22,7 @@ require "engine.class"
--- Handles music in the game
module(..., package.seeall, class.make)
--- Initializes running
-- We check the direction sides to know if we are in a tunnel, along a wall or in open space.
--- Initializes musics
function _M:init()
self.current_music = nil
self.loaded_musics = {}
......
-- TE4 - T-Engine 4
-- Copyright (C) 2009, 2010 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
--- Handles sounds in the game
module(..., package.seeall, class.make)
--- Initializes
function _M:init()
self.loaded_sounds = {}
end
function _M:loaded()
self.loaded_sounds = self.loaded_sounds or {}
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)
s = self.loaded_sounds[name]
end
if not s then return end
s:play()
end
......@@ -20,6 +20,7 @@
require "engine.class"
require "engine.GameTurnBased"
require "engine.interface.GameMusic"
require "engine.interface.GameSound"
require "engine.KeyBind"
local Savefile = require "engine.Savefile"
local DamageType = require "engine.DamageType"
......@@ -52,11 +53,12 @@ local Calendar = require "engine.Calendar"
local QuitDialog = require "mod.dialogs.Quit"
module(..., package.seeall, class.inherit(engine.GameTurnBased, engine.interface.GameMusic))
module(..., package.seeall, class.inherit(engine.GameTurnBased, engine.interface.GameMusic, engine.interface.GameSound))
function _M:init()
engine.GameTurnBased.init(self, engine.KeyBind.new(), 1000, 100)
engine.interface.GameMusic.init(self)
engine.interface.GameSound.init(self)
-- Same init as when loaded from a savefile
self:loaded()
......@@ -127,6 +129,7 @@ end
function _M:loaded()
engine.GameTurnBased.loaded(self)
engine.interface.GameMusic.loaded(self)
engine.interface.GameSound.loaded(self)
Zone:setup{npc_class="mod.class.NPC", grid_class="mod.class.Grid", object_class="mod.class.Object", trap_class="mod.class.Trap"}
Map:setViewerActor(self.player)
Map:setViewPort(200, 20, self.w - 200, math.floor(self.h * 0.80) - 20, 32, 32, nil, 20, true)
......
......@@ -43,10 +43,68 @@ newTalent{
}
newTalent{
name = "Noxious Cloud",
type = {"spell/air",2},
name = "Chain Lightning",
type = {"spell/air", 2},
require = spells_req2,
points = 5,
mana = 20,
cooldown = 8,
tactical = {
ATTACK = 10,
},
range = 20,
reflectable = true,
action = function(self, t)
local tg = {type="bolt", range=self:getTalentRange(t), talent=t}
local fx, fy = self:getTarget(tg)
if not fx or not fy then return nil end
local nb = 3 + self:getTalentLevelRaw(t)
local affected = {[self]=true}
local fork fork = function(x, y, sx, sy)
self:project(tg, x, y, function(dx, dy)
local actor = game.level.map(dx, dy, Map.ACTOR)
if actor and not affected[actor] then
local tgr = {type="beam", range=self:getTalentRange(t), talent=t, x=sx, y=sy}
self:project(tgr, dx, dy, DamageType.LIGHTNING, rng.avg(1, self:spellCrit(20 + self:combatSpellpower(0.8) * self:getTalentLevel(t)), 5), {type="lightning"})
affected[actor] = true
nb = nb - 1
if nb <= 0 then return true end
self:project({type="ball", friendlyfire=false, x=dx, y=dy, radius=10, range=0}, dx, dy, function(bx, by)
local actor = game.level.map(bx, by, Map.ACTOR)
if actor and not affected[actor] then
fork(bx, by, dx, dy)
return true
end
end)
return true
end
end)
end
fork(fx, fy)
return true
end,
info = function(self, t)
return ([[Invokes a forking beam of lightning doing 1 to %0.2f damage and forking to an other target.
It can hit up to %d targets and will never hit the same one twice, neither will it hit the caster.
The damage will increase with the Magic stat]]):
format(
20 + self:combatSpellpower(0.8) * self:getTalentLevel(t),
3 + self:getTalentLevelRaw(t)
)
end,
}
newTalent{
name = "Noxious Cloud",
type = {"spell/air",3},
require = spells_req3,
points = 5,
mana = 25,
cooldown = 8,
tactical = {
......@@ -56,7 +114,7 @@ newTalent{
action = function(self, t)
local duration = self:getTalentLevel(t) + 2
local radius = 3
local dam = 4 + self:combatSpellpower(0.11) * self:getTalentLevel(t)
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
......@@ -74,32 +132,7 @@ newTalent{
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.11) * self:getTalentLevel(t), self:getTalentLevel(t) + 2)
end,
}
newTalent{
name = "Wings of Wind",
type = {"spell/air",3},
require = spells_req3,
points = 5,
mode = "sustained",
sustain_mana = 100,
tactical = {
MOVEMENT = 10,
},
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 ([[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)))
The damage and duration will increase with the Magic stat]]):format(4 + self:combatSpellpower(0.17) * self:getTalentLevel(t), self:getTalentLevel(t) + 2)
end,
}
......@@ -116,6 +149,14 @@ newTalent{
},
range = 5,
do_storm = function(self, t)
if self:getMana() <= 0 then
local old = self.energy.value
self.energy.value = 100000
self:useTalent(self.T_THUNDERSTORM)
self.energy.value = old
return
end
local tgts = {}
local grids = core.fov.circle_grids(self.x, self.y, 5, true)
for x, yy in pairs(grids) do for y, _ in pairs(grids[x]) do
......
......@@ -28,7 +28,7 @@ return {
-- all_remembered = true,
-- all_lited = true,
persistant = "zone",
-- ambiant_music = "10_23.ogg",
ambiant_music = "3_8.ogg",
generator = {
map = {
class = "engine.generator.map.Roomer",
......
......@@ -476,7 +476,7 @@ int main(int argc, char *argv[])
SDL_EnableUNICODE(TRUE);
SDL_EnableKeyRepeat(300, 10);
TTF_Init();
if (Mix_OpenAudio(22050, AUDIO_S16, 2, 4096) == -1)
if (Mix_OpenAudio(22050, AUDIO_S16, 2, 512) == -1)
{
no_sound = TRUE;
}
......@@ -484,6 +484,7 @@ int main(int argc, char *argv[])
{
Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
Mix_Volume(-1, SDL_MIX_MAXVOLUME);
Mix_AllocateChannels(16);
}
/* Sets up OpenGL double buffering */
......
......@@ -72,9 +72,44 @@ static int music_stop(lua_State *L)
return 0;
}
static int sound_new(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
Mix_Chunk **m = (Mix_Chunk**)lua_newuserdata(L, sizeof(Mix_Chunk*));
auxiliar_setclass(L, "core{sound}", -1);
SDL_RWops *rops = PHYSFSRWOPS_openRead(name);
if (!rops)
{
return 0;
}
*m = Mix_LoadWAV_RW(rops, 1);
if (!*m) return 0;
Mix_VolumeChunk(m, SDL_MIX_MAXVOLUME);
return 1;
}
static int sound_free(lua_State *L)
{
Mix_Chunk **m = (Mix_Chunk**)auxiliar_checkclass(L, "core{sound}", 1);
Mix_FreeChunk(*m);
lua_pushnumber(L, 1);
return 1;
}
static int sound_play(lua_State *L)
{
Mix_Chunk **m = (Mix_Chunk**)auxiliar_checkclass(L, "core{sound}", 1);
Mix_PlayChannel(-1, m, 0);
return 0;
}
static const struct luaL_reg soundlib[] =
{
{"newMusic", music_new},
{"newSound", sound_new},
{NULL, NULL},
};
......@@ -86,9 +121,17 @@ static const struct luaL_reg music_reg[] =
{NULL, NULL},
};
static const struct luaL_reg sound_reg[] =
{
{"__gc", sound_free},
{"play", sound_play},
{NULL, NULL},
};
int luaopen_sound(lua_State *L)
{
auxiliar_newclass(L, "core{music}", music_reg);
auxiliar_newclass(L, "core{sound}", sound_reg);
luaL_openlib(L, "core.sound", soundlib, 0);
return 1;
}
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