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

Added a new wand artifact

git-svn-id: http://svn.net-core.org/repos/t-engine4@1341 51575b47-30f0-44d4-a5cc-537603b46e54
parent 28736c5a
No related branches found
No related tags found
No related merge requests found
......@@ -268,6 +268,35 @@ function _M:saveLevel(level, no_dialog)
if not no_dialog then game:unregisterDialog(popup) end
end
--- Get a savename for an entity
function _M:nameSaveEntity(e)
return ("entity-%s.teae"):format(e.name:gsub("[^a-zA-Z0-9_-.]", "_"):lower())
end
--- Get a savename for an entity
function _M:nameLoadEntity(name)
return ("entity-%s.teae"):format(name:gsub("[^a-zA-Z0-9_-.]", "_"):lower())
end
--- Save an entity
function _M:saveEntity(e, no_dialog)
fs.mkdir(self.save_dir)
local popup
if not no_dialog then
popup = Dialog:simplePopup("Saving entity", "Please wait while saving the entity...", nil, true)
popup.__showup = nil
end
core.display.forceRedraw()
local zip = fs.zipOpen(self.save_dir..self:nameSaveEntity(e)..".tmp")
self:saveObject(e, zip)
zip:close()
fs.delete(self.save_dir..self:nameSaveEntity(e))
fs.rename(self.save_dir..self:nameSaveEntity(e)..".tmp", self.save_dir..self:nameSaveEntity(e))
if not no_dialog then game:unregisterDialog(popup) end
end
local function resolveSelf(o, base, allow_object)
if o.__CLASSNAME and not allow_object then return end
......@@ -404,6 +433,31 @@ function _M:loadLevel(zone, level)
return loadedLevel
end
--- Loads an entity
function _M:loadEntity(name)
local path = fs.getRealPath(self.save_dir..self:nameLoadEntity(name))
if not path or path == "" then return false end
fs.mount(path, self.load_dir)
local popup = Dialog:simplePopup("Loading entity", "Please wait while loading the entity...")
popup.__showup = nil
core.display.forceRedraw()
local loadedEntity = self:loadReal("main")
-- Delay loaded must run
for i, o in ipairs(self.delayLoad) do
-- print("loader executed for class", o, o.__CLASSNAME)
o:loaded()
end
game:unregisterDialog(popup)
fs.umount(path)
return loadedEntity
end
--- Checks for existence
function _M:check()
return fs.exists(self.save_dir..self:nameLoadGame())
......
-- ToME - Tales of Middle-Earth
-- 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
local Stats = require "engine.interface.ActorStats"
local DamageType = require "engine.DamageType"
--[[
detection
teleportation
trap destruction
flame
lightning
digging (very rare)
healing
]]
newEntity{
name = " of detection", suffix=true, instant_resolve=true,
level_range = {1, 50},
rarity = 8,
cost_per_charge = 1,
use_power = { name = "teleport randomly", power = 6, use = function(self, who)
game.level.map:particleEmitter(who.x, who.y, 1, "teleport")
who:teleportRandom(who.x, who.y, 100)
game.level.map:particleEmitter(who.x, who.y, 1, "teleport")
game.logSeen(who, "%s uses %s!", who.name:capitalize(), self:getName{no_count=true})
return nil, true
end}
}
newEntity{
name = " of teleportation", suffix=true, instant_resolve=true,
level_range = {15, 50},
rarity = 10,
cost_per_charge = 1,
use_power = { name = "teleport randomly", power = 6, use = function(self, who)
game.level.map:particleEmitter(who.x, who.y, 1, "teleport")
who:teleportRandom(who.x, who.y, 100)
game.level.map:particleEmitter(who.x, who.y, 1, "teleport")
game.logSeen(who, "%s uses %s!", who.name:capitalize(), self:getName{no_count=true})
return nil, true
end}
}
......@@ -21,10 +21,56 @@ newEntity{
define_as = "BASE_WAND",
type = "wand", subtype="wand",
unided_name = "wand", id_by_type = true,
display = "_", color=colors.WHITE,
encumber = 0.7,
display = "-", color=colors.WHITE,
encumber = 2,
rarity = 18,
use_sound = "talents/spell_generic",
elec_destroy = {{10,1}, {20,2}, {40,5}, {60,10}, {120,20}},
desc = [[Magical wands are made by powerful alchemists to store spells. Anybody can use them to release the spells.]],
-- egos = "/data/general/objects/egos/wands.lua", egos_chance = resolvers.mbonus(10, 5),
elec_destroy = {{20,1}, {30,2}, {60,5}, {90,10}, {170,20}},
desc = [[Magical wands are made by powerful alchemists and archmages to store spells. Anybody can use them to release the spells.]],
egos = "/data/general/objects/egos/wands.lua", egos_chance = { prefix=resolvers.mbonus(20, 5), suffix=100 },
}
newEntity{ base = "BASE_WAND",
name = "elm wand",
color = colors.UMBER,
level_range = {1, 10},
cost = 10,
material_level = 1,
resolvers.charges(10, 30),
}
newEntity{ base = "BASE_WAND",
name = "ash wand",
color = colors.UMBER,
level_range = {10, 20},
cost = 20,
material_level = 2,
resolvers.charges(25, 45),
}
newEntity{ base = "BASE_WAND",
name = "yew wand",
color = colors.UMBER,
level_range = {20, 30},
cost = 30,
material_level = 3,
resolvers.charges(40, 60),
}
newEntity{ base = "BASE_WAND",
name = "elven-wood wand",
color = colors.UMBER,
level_range = {30, 40},
cost = 40,
material_level = 4,
resolvers.charges(55, 75),
}
newEntity{ base = "BASE_WAND",
name = "dragonbone wand",
color = colors.UMBER,
level_range = {40, 50},
cost = 50,
material_level = 5,
resolvers.charges(70, 90),
}
......@@ -712,6 +712,25 @@ newEntity{ base = "BASE_STAFF", define_as = "VOICE_SARUMAN",
},
}
newEntity{ base = "BASE_WAND",
unided_name = "glowing wand",
name = "Gwai's Burninator", color=colors.LIGHT_RED, unique=true,
cost = 50,
rarity = 220,
level_range = {15, 30},
elec_proof = true,
max_power = 75, power_regen = 1,
use_power = { name = "shoot a cone of fire", power = 30,
use = function(self, who)
local tg = {type="cone", range=0, radius=4, talent=t}
local x, y = who:getTarget(tg)
if not x or not y then return nil end
who:project(tg, x, y, engine.DamageType.FIRE, 80 + who:getMag(), {type="flame"})
end
},
}
--[=[
newEntity{
unique = true,
......
......@@ -211,6 +211,17 @@ function resolvers.calc.random_use_talent(tt, e)
return { id=tid, level=level, power=tt[2] }
end
--- Charges resolver
function resolvers.charges(min, max, cost)
return {__resolver="charges", __resolve_last=true, min, max, cost}
end
function resolvers.calc.charges(tt, e)
-- e.cost = e.cost + t.type[2] * 3 * level
-- e.recharge_cost = t.type[2] * 3 * level
e.max_power = rng.range(tt[1], tt[2])
return
end
--- Image based on material level
function resolvers.image_material(image, values)
return {__resolver="image_material", image, values}
......
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