From 2502be16e7676834bd9ef1a330da3f1ae2d7d239 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Wed, 29 Dec 2010 14:43:49 +0000 Subject: [PATCH] Smooth movement can now also be used to do a "motion blur", this is used for Rush and Disengage (and Lightning Speed on a smalelr scale) git-svn-id: http://svn.net-core.org/repos/t-engine4@2224 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/engine/Entity.lua | 24 +++++- game/modules/tome/class/Actor.lua | 15 +++- game/modules/tome/class/Game.lua | 70 +----------------- .../tome/data/general/grids/underground.lua | 25 +++++++ .../data/gfx/terrain/ladder_down_green.png | Bin 0 -> 971 bytes .../talents/techniques/combat-techniques.lua | 5 ++ .../tome/data/zones/grushnak-pride/grids.lua | 2 +- .../tome/data/zones/grushnak-pride/zone.lua | 6 +- .../modules/tome/dialogs/debug/ChangeZone.lua | 2 +- game/modules/tome/dialogs/debug/DebugMain.lua | 22 +++++- src/map.c | 51 ++++++++++--- src/map.h | 2 +- 12 files changed, 133 insertions(+), 91 deletions(-) create mode 100644 game/modules/tome/data/gfx/terrain/ladder_down_green.png diff --git a/game/engines/default/engine/Entity.lua b/game/engines/default/engine/Entity.lua index c6d3e19247..e3f5317239 100644 --- a/game/engines/default/engine/Entity.lua +++ b/game/engines/default/engine/Entity.lua @@ -226,15 +226,33 @@ end --- Setup movement animation for the entity -- The entity is supposed to posses a correctly set x and y pair of fields - set to the current (new) position -function _M:setMoveAnim(oldx, oldy, speed) +-- @param oldx the coords from where the animation will seem to come from +-- @param oldy the coords from where the animation will seem to come from +-- @param speed the number of frames the animation lasts (frames are normalized to 30/sec no matter the actual FPS) +-- @param blur apply a motion blur effect of this number of frames +function _M:setMoveAnim(oldx, oldy, speed, blur) if not self._mo then return end - self._mo:setMoveAnim(oldx, oldy, self.x, self.y, speed) + self._mo:setMoveAnim(oldx, oldy, self.x, self.y, speed, blur) if not self.add_displays then return end for i = 1, #self.add_displays do if self.add_displays[i]._mo then - self.add_displays[i]._mo:setMoveAnim(oldx, oldy, self.x, self.y, speed) + self.add_displays[i]._mo:setMoveAnim(oldx, oldy, self.x, self.y, speed, blur) + end + end +end + +--- Reset movement animation for the entity - removes any anim +function _M:resetMoveAnim() + if not self._mo then return end + self._mo:resetMoveAnim() + + if not self.add_displays then return end + + for i = 1, #self.add_displays do + if self.add_displays[i]._mo then + self.add_displays[i]._mo:resetMoveAnim() end end end diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 3e2c9a3e5f..3998998efb 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -390,12 +390,25 @@ function _M:move(x, y, force) end if moved and not force and ox and oy and (ox ~= self.x or oy ~= self.y) and config.settings.tome.smooth_move > 0 then - self:setMoveAnim(ox, oy, config.settings.tome.smooth_move) + local blur = 0 + if self:attr("lightning_speed") then blur = 3 end + self:setMoveAnim(ox, oy, config.settings.tome.smooth_move, blur) end return moved end +--- Knock back the actor +-- Overloaded to add move anim +function _M:knockback(srcx, srcy, dist, recursive) + local ox, oy = self.x, self.y + engine.Actor.knockback(self, srcx, srcy, dist, recursive) + if config.settings.tome.smooth_move > 0 then + self:resetMoveAnim() + self:setMoveAnim(ox, oy, 9, 5) + end +end + --- Get the "path string" for this actor -- See Map:addPathString() for more info function _M:getPathString() diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index fed9211b37..22394d7989 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -710,77 +710,11 @@ function _M:setupCommands() -- Helper function to not allow some actions on the wilderness map local not_wild = function(f) return function() if self.zone and not self.zone.wilderness then f() else self.logPlayer(self.player, "You cannot do that on the world map.") end end end + -- Debug mode self.key:addCommands{ [{"_a","ctrl"}] = function() if config.settings.cheat then game:registerDialog(require("mod.dialogs.debug.DebugMain").new()) end end, - [{"_d","ctrl"}] = function() - if config.settings.cheat then - self.player:forceLevelup(50) - self.player.no_breath = 1 - self.player.invulnerable = 1 - self.player.esp.all = 1 - self.player.esp.range = 50 - self.player.inc_damage.all = 100000 - self.player.wild_x = 162 - self.player.wild_y = 31 --- self:changeLevel(5, "gorbat-pride") --- self:changeLevel(1, "town-gates-of-morning") - self:changeLevel(1, "wilderness") - self.memory_levels["wilderness-1"] = self.level - self.player:grantQuest("strange-new-world") - self.player:setQuestStatus("strange-new-world", engine.Quest.COMPLETED, "helped-fillarel") - self.player:setQuestStatus("strange-new-world", engine.Quest.COMPLETED) - self.player:grantQuest("orc-pride") - self.player:setQuestStatus("orc-pride", engine.Quest.COMPLETED) --- self.player:grantQuest("escort-duty") - end - end, - [{"_z","ctrl"}] = function() - if config.settings.cheat then - self.player:forceLevelup(50) - self.player.no_breath = 1 --- self.player.invulnerable = 1 - self.player.esp.all = 1 - self.player.esp.range = 50 --- self.player.inc_damage.all = 100000 - end - end, - [{"_f","ctrl"}] = function() - if config.settings.cheat then - self.player:incStat("str", 100) self.player:incStat("dex", 100) self.player:incStat("mag", 100) self.player:incStat("wil", 100) self.player:incStat("cun", 100) self.player:incStat("con", 100) - self.player:learnTalent(self.player.T_HEAVY_ARMOUR_TRAINING, true) self.player:learnTalent(self.player.T_MASSIVE_ARMOUR_TRAINING, true) --- [[ - for i, e in ipairs(self.zone.object_list) do - if e.unique and e.define_as ~= "VOICE_SARUMAN" and e.define_as ~= "ORB_MANY_WAYS_DEMON" then - local a = self.zone:finishEntity(self.level, "object", e) - a.no_unique_lore = true -- to not spam - a:identify(true) - if a.name == a.unided_name then print("=================", a.name) end - self.zone:addEntity(self.level, a, "object", self.player.x, self.player.y) - end - end ---]] ---[[ - for i = 1, 50 do - local a = self.zone:makeEntity(self.level, "object", {type="ammo", ego_chance=0, add_levels=50}, nil, true) - if a then - a:identify(true) - self.zone:addEntity(self.level, a, "object", self.player.x, self.player.y) - end - end ---]] - self.logPlayer(self.player, "All world artifacts created.") - end - end, - [{"_g","ctrl"}] = function() - if config.settings.cheat then --- local m = game.zone:makeEntityByName(game.level, "actor", "TEST") --- game.zone:addEntity(game.level, m, "actor", game.player.x, game.player.y+1) --- self.player:grantQuest("anti-antimagic") - game:changeLevel(1,"shertul-fortress") --- game.player:magicMap(50) - end - end, } + self.key:addBinds { -- Movements diff --git a/game/modules/tome/data/general/grids/underground.lua b/game/modules/tome/data/general/grids/underground.lua index a178ea94cc..ae5e69a8ba 100644 --- a/game/modules/tome/data/general/grids/underground.lua +++ b/game/modules/tome/data/general/grids/underground.lua @@ -38,3 +38,28 @@ newEntity{ dig = "UNDERGROUND_FLOOR", } end + +newEntity{ + define_as = "UNDERGROUND_LADDER_DOWN", + name = "ladder to the next level", image = "terrain/underground_floor.png", add_displays = {class.new{image="terrain/ladder_down.png"}}, + display = '>', color_r=255, color_g=255, color_b=0, + notice = true, + always_remember = true, + change_level = 1, +} +newEntity{ + define_as = "UNDERGROUND_LADDER_UP", + name = "ladder to the previous level", image = "terrain/underground_floor.png", add_displays = {class.new{image="terrain/ladder_up.png"}}, + display = '<', color_r=255, color_g=255, color_b=0, + notice = true, + always_remember = true, + change_level = -1, +} +newEntity{ + define_as = "UNDERGROUND_LADDER_UP_WILDERNESS", + name = "ladder to worldmap", image = "terrain/underground_floor.png", add_displays = {class.new{image="terrain/ladder_up_wild.png"}}, + display = '<', color_r=255, color_g=255, color_b=0, + notice = true, + change_level = 1, + change_zone = "wilderness", +} diff --git a/game/modules/tome/data/gfx/terrain/ladder_down_green.png b/game/modules/tome/data/gfx/terrain/ladder_down_green.png new file mode 100644 index 0000000000000000000000000000000000000000..f6b16f71110aab206890b9ee6d461a60c9f1ea0f GIT binary patch literal 971 zcmV;+12p`JP)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F800001b5ch_0Itp) z=>Px#24YJ`L;z+0W&mafx=L*T000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igoB z4IL@1^pJ@F00T=&L_t(o!|hegYg|<n|DAL0dvE3?X~x0S52y}U+EUOGmqJmy?8bjU zD0JbfB~%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V1i=Z!6^U$ literal 0 HcmV?d00001 diff --git a/game/modules/tome/data/talents/techniques/combat-techniques.lua b/game/modules/tome/data/talents/techniques/combat-techniques.lua index 740430a1c4..5730399f1a 100644 --- a/game/modules/tome/data/talents/techniques/combat-techniques.lua +++ b/game/modules/tome/data/talents/techniques/combat-techniques.lua @@ -80,7 +80,12 @@ newTalent{ lx, ly = l() end + local ox, oy = self.x, self.y self:move(tx, ty, true) + if config.settings.tome.smooth_move > 0 then + self:resetMoveAnim() + self:setMoveAnim(ox, oy, 8, 5) + end -- Attack ? if math.floor(core.fov.distance(self.x, self.y, x, y)) == 1 then diff --git a/game/modules/tome/data/zones/grushnak-pride/grids.lua b/game/modules/tome/data/zones/grushnak-pride/grids.lua index ecc84038a7..c7bb6f2ab9 100644 --- a/game/modules/tome/data/zones/grushnak-pride/grids.lua +++ b/game/modules/tome/data/zones/grushnak-pride/grids.lua @@ -26,7 +26,7 @@ load("/data/general/grids/forest.lua") newEntity{ define_as = "SLIME_TUNNELS", name = "entrance to a slimy pit", - display = '>', color=colors.LIGHT_GREEN, + display = '>', color=colors.LIGHT_GREEN, image = "terrain/underground_floor.png", add_displays = {class.new{image="terrain/ladder_down_green.png"}}, always_remember = true, notice = true, change_level = 1, diff --git a/game/modules/tome/data/zones/grushnak-pride/zone.lua b/game/modules/tome/data/zones/grushnak-pride/zone.lua index cdaa3d6921..2dce05cc0f 100644 --- a/game/modules/tome/data/zones/grushnak-pride/zone.lua +++ b/game/modules/tome/data/zones/grushnak-pride/zone.lua @@ -38,8 +38,8 @@ return { rooms_config = {pit={filters={{subtype="orc"},{subtype="troll"}}}}, ['.'] = "UNDERGROUND_FLOOR", ['#'] = {"UNDERGROUND_TREE","UNDERGROUND_TREE2","UNDERGROUND_TREE3","UNDERGROUND_TREE4","UNDERGROUND_TREE5","UNDERGROUND_TREE6","UNDERGROUND_TREE7","UNDERGROUND_TREE8","UNDERGROUND_TREE9","UNDERGROUND_TREE10","UNDERGROUND_TREE11","UNDERGROUND_TREE12","UNDERGROUND_TREE13","UNDERGROUND_TREE14","UNDERGROUND_TREE15","UNDERGROUND_TREE16","UNDERGROUND_TREE17","UNDERGROUND_TREE18","UNDERGROUND_TREE19","UNDERGROUND_TREE20",}, - up = "UP", - down = "DOWN", + up = "UNDERGROUND_LADDER_UP", + down = "UNDERGROUND_LADDER_DOWN", door = "UNDERGROUND_FLOOR", ['+'] = "UNDERGROUND_FLOOR", }, @@ -60,7 +60,7 @@ return { { [1] = { generator = { map = { - up = "UP_WILDERNESS", + up = "UNDERGROUND_LADDER_UP_WILDERNESS", }, }, }, [5] = { diff --git a/game/modules/tome/dialogs/debug/ChangeZone.lua b/game/modules/tome/dialogs/debug/ChangeZone.lua index 48d429d7e9..e19b23fa0a 100644 --- a/game/modules/tome/dialogs/debug/ChangeZone.lua +++ b/game/modules/tome/dialogs/debug/ChangeZone.lua @@ -28,7 +28,7 @@ function _M:init() self:generateList() engine.ui.Dialog.init(self, "Debug/Cheat! It's BADDDD!", 1, 1) - local list = List.new{width=200, height=500, list=self.list, fct=function(item) self:use(item) end} + local list = List.new{width=400, height=500, list=self.list, fct=function(item) self:use(item) end} self:loadUI{ {left=0, top=0, ui=list}, diff --git a/game/modules/tome/dialogs/debug/DebugMain.lua b/game/modules/tome/dialogs/debug/DebugMain.lua index bdbcaf1a0d..45782e9336 100644 --- a/game/modules/tome/dialogs/debug/DebugMain.lua +++ b/game/modules/tome/dialogs/debug/DebugMain.lua @@ -20,6 +20,7 @@ require "engine.class" require "engine.ui.Dialog" local List = require "engine.ui.List" +local GetQuantity = require "engine.dialogs.GetQuantity" module(..., package.seeall, class.inherit(engine.ui.Dialog)) @@ -27,7 +28,7 @@ function _M:init() self:generateList() engine.ui.Dialog.init(self, "Debug/Cheat! It's BADDDD!", 1, 1) - local list = List.new{width=200, height=500, list=self.list, fct=function(item) self:use(item) end} + local list = List.new{width=400, height=500, list=self.list, fct=function(item) self:use(item) end} self:loadUI{ {left=0, top=0, ui=list}, @@ -57,15 +58,29 @@ function _M:use(item) game.player.invulnerable = 1 game.player.esp.all = 1 game.player.esp.range = 50 - game.player.inc_damage.all = 100000 game.player.no_breath = 1 game.player.invulnerable = 1 game.player.esp.all = 1 game.player.esp.range = 50 game.player.inc_damage.all = 100000 + game.player:incStat("str", 100) game.player:incStat("dex", 100) game.player:incStat("mag", 100) game.player:incStat("wil", 100) game.player:incStat("cun", 100) game.player:incStat("con", 100) + elseif act == "all_arts" then + for i, e in ipairs(game.zone.object_list) do + if e.unique and e.define_as ~= "VOICE_SARUMAN" and e.define_as ~= "ORB_MANY_WAYS_DEMON" then + local a = game.zone:finishEntity(game.level, "object", e) + a.no_unique_lore = true -- to not spam + a:identify(true) + if a.name == a.unided_name then print("=================", a.name) end + game.zone:addEntity(game.level, a, "object", game.player.x, game.player.y) + end + end elseif act == "magic_map" then game.level.map:liteAll(0, 0, game.level.map.w, game.level.map.h) game.level.map:rememberAll(0, 0, game.level.map.w, game.level.map.h) + elseif act == "change_level" then + game:registerDialog(GetQuantity.new("Zone: "..game.zone.name, "Level 1-"..game.zone.max_level.max, game.level.level, game.zone.max_level, function(qty) + game:changeLevel(qty) + end), 1) end end @@ -73,9 +88,10 @@ function _M:generateList() local list = {} list[#list+1] = {name="Change Zone", dialog="ChangeZone"} - list[#list+1] = {name="Change Level", dialog="ChangeLevel"} + list[#list+1] = {name="Change Level", action="change_level"} list[#list+1] = {name="Reveal all map", action="magic_map"} list[#list+1] = {name="Godmode", action="godmode"} + list[#list+1] = {name="Create all artifacts", action="all_arts"} local chars = {} for i, v in ipairs(list) do diff --git a/src/map.c b/src/map.c index d51d4b5e8d..6d3147f3fc 100644 --- a/src/map.c +++ b/src/map.c @@ -155,6 +155,12 @@ static int map_object_invalid(lua_State *L) return 0; } +static int map_object_reset_move_anim(lua_State *L) +{ + map_object *obj = (map_object*)auxiliar_checkclass(L, "core{mapobj}", 1); + obj->move_max = 0; +} + static int map_object_set_move_anim(lua_State *L) { map_object *obj = (map_object*)auxiliar_checkclass(L, "core{mapobj}", 1); @@ -176,6 +182,7 @@ static int map_object_set_move_anim(lua_State *L) } obj->move_step = 0; obj->move_max = luaL_checknumber(L, 6); + obj->move_blur = lua_tonumber(L, 7); // defaults to 0 return 0; } @@ -669,6 +676,16 @@ void display_map_quad(map_type *map, int dx, int dy, float dz, map_object *m, in } } + // Setup for display + a = (a > 1) ? 1 : ((a < 0) ? 0 : a); + int z; + if (m->shader) useShader(m->shader, i, j, map->tile_w, map->tile_h, r, g, b, a); + for (z = (!shaders_active) ? 0 : (m->nb_textures - 1); z >= 0; z--) + { + if (multitexture_active && shaders_active) tglActiveTexture(GL_TEXTURE0+z); + glBindTexture(m->textures_is3d[z] ? GL_TEXTURE_3D : GL_TEXTURE_2D, m->textures[z]); + } + // Handle move anim float animdx = 0, animdy = 0; if (m->move_max) @@ -680,22 +697,35 @@ void display_map_quad(map_type *map, int dx, int dy, float dz, map_object *m, in { float adx = (float)i - m->oldx; float ady = (float)j - m->oldy; + + // Motion bluuuurr! + if (m->move_blur) + { + int step; + for (z = 1; z <= m->move_blur; z++) + { + step = m->move_step - z; + if (step >= 0) + { + animdx = map->tile_w * (adx * step / (float)m->move_max - adx); + animdy = map->tile_h * (ady * step / (float)m->move_max - ady); + tglColor4f(r, g, b, a * 2 / (3 + z)); + DO_QUAD(dx + m->dx + animdx, dy + m->dy + animdy, 0, m->scale); + } + } + } + + // Final step animdx = map->tile_w * (adx * m->move_step / (float)m->move_max - adx); animdy = map->tile_h * (ady * m->move_step / (float)m->move_max - ady); } } - tglColor4f(r, g, b, (a > 1) ? 1 : ((a < 0) ? 0 : a)); - - int z; - if (m->shader) useShader(m->shader, i, j, map->tile_w, map->tile_h, r, g, b, a); - for (z = (!shaders_active) ? 0 : (m->nb_textures - 1); z >= 0; z--) - { - if (multitexture_active && shaders_active) tglActiveTexture(GL_TEXTURE0+z); - glBindTexture(m->textures_is3d[z] ? GL_TEXTURE_3D : GL_TEXTURE_2D, m->textures[z]); - } - DO_QUAD(dx + m->dx + animdx, dy + m->dy + animdy, z, m->scale); + // Final display + tglColor4f(r, g, b, a); + DO_QUAD(dx + m->dx + animdx, dy + m->dy + animdy, 0, m->scale); + // Unbind any shaders if (m->shader) glUseProgramObjectARB(0); } @@ -938,6 +968,7 @@ static const struct luaL_reg map_object_reg[] = {"invalidate", map_object_invalid}, {"isValid", map_object_is_valid}, {"onSeen", map_object_on_seen}, + {"resetMoveAnim", map_object_reset_move_anim}, {"setMoveAnim", map_object_set_move_anim}, {"getMoveAnim", map_object_get_move_anim}, {NULL, NULL}, diff --git a/src/map.h b/src/map.h index 2eabb2221a..398ddfc491 100644 --- a/src/map.h +++ b/src/map.h @@ -38,7 +38,7 @@ typedef struct { bool on_unknown; bool valid; float oldx, oldy; - int move_step, move_max; + int move_step, move_max, move_blur; long uid; } map_object; -- GitLab