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

xorn tunnel throw walls

scrolls & potions have gradual chance of destruction based on damage done


git-svn-id: http://svn.net-core.org/repos/t-engine4@765 51575b47-30f0-44d4-a5cc-537603b46e54
parent ae0f0758
No related branches found
No related tags found
No related merge requests found
......@@ -88,4 +88,5 @@ end
function _M:clean()
self.repo = {}
self.texture_store = {}
collectgarbage("collect")
end
......@@ -76,14 +76,19 @@ setDefaultProjector(function(src, x, y, type, dam)
return 0
end)
local function tryDestroy(who, inven, destroy_prop, proof_prop, msg)
local function tryDestroy(who, inven, dam, destroy_prop, proof_prop, msg)
if not inven then return end
for i = #inven, 1, -1 do
local o = inven[i]
if o[destroy_prop] and rng.percent(o[destroy_prop]) and not o[proof_prop] then
game.logPlayer(who, msg, o:getName{do_color=true, no_count=true})
local obj = who:removeObject(inven, i)
obj:removed()
if o[destroy_prop] and not o[proof_prop] then
for j, test in ipairs(o[destroy_prop]) do
if realdam >= test[1] and rng.percent(test[2]) then
game.logPlayer(who, msg, o:getName{do_color=true, no_count=true})
local obj = who:removeObject(inven, i)
obj:removed()
break
end
end
end
end
end
......@@ -103,7 +108,7 @@ newDamageType{
local realdam = DamageType.defaultProjector(src, x, y, type, dam)
local target = game.level.map(x, y, Map.ACTOR)
if realdam > 0 and target and not target:attr("fire_proof") then
tryDestroy(target, target:getInven("INVEN"), "fire_destroy", "fire_proof", "The burst of heat destroys your %s!")
tryDestroy(target, target:getInven("INVEN"), realdam, "fire_destroy", "fire_proof", "The burst of heat destroys your %s!")
end
end,
}
......@@ -113,7 +118,7 @@ newDamageType{
local realdam = DamageType.defaultProjector(src, x, y, type, dam)
local target = game.level.map(x, y, Map.ACTOR)
if realdam > 0 and target and not target:attr("cold_proof") then
tryDestroy(target, target:getInven("INVEN"), "cold_destroy", "cold_proof", "The intense cold destroys your %s!")
tryDestroy(target, target:getInven("INVEN"), realdam, "cold_destroy", "cold_proof", "The intense cold destroys your %s!")
end
end,
}
......@@ -132,7 +137,7 @@ newDamageType{
local realdam = DamageType.defaultProjector(src, x, y, type, dam)
local target = game.level.map(x, y, Map.ACTOR)
if realdam > 0 and target and not target:attr("elec_proof") then
tryDestroy(target, target:getInven("INVEN"), "elec_destroy", "elec_proof", "The burst of lightning destroys your %s!")
tryDestroy(target, target:getInven("INVEN"), realdam, "elec_destroy", "elec_proof", "The burst of lightning destroys your %s!")
end
end,
}
......@@ -143,7 +148,7 @@ newDamageType{
local realdam = DamageType.defaultProjector(src, x, y, type, dam)
local target = game.level.map(x, y, Map.ACTOR)
if realdam > 0 and target and not target:attr("acid_proof") then
tryDestroy(target, target:getInven("INVEN"), "acid_destroy", "acid_proof", "The splash of acid destroys your %s!")
tryDestroy(target, target:getInven("INVEN"), realdam, "acid_destroy", "acid_proof", "The splash of acid destroys your %s!")
end
end,
}
......
......@@ -31,6 +31,7 @@ newEntity{
resolvers.drops{chance=60, nb=1, {type="money"} },
can_pass = {pass_wall=20},
move_project = {[DamageType.DIG]=1},
infravision = 20,
life_rating = 12,
......
......@@ -25,7 +25,7 @@ newEntity{
use_sound = "actions/quaff",
encumber = 0.2,
stacking = true,
acid_destroy = 20,
acid_destroy = {{10,1}, {20,2}, {40,5}, {60,10}, {120,20}},
desc = [[Magical potions can have wildly different effects, from healing to killing you, beware! Most of them function better with a high Magic score]],
egos = "/data/general/objects/egos/potions.lua", egos_chance = resolvers.mbonus(10, 5),
}
......
......@@ -25,7 +25,7 @@ newEntity{
encumber = 0.1,
stacking = true,
use_sound = "actions/read",
fire_destroy = 20,
fire_destroy = {{10,1}, {20,2}, {40,5}, {60,10}, {120,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),
}
......
......@@ -26,7 +26,7 @@
const char *get_self_executable(int argc, char **argv)
{
char res[PATH_MAX];
static char res[PATH_MAX];
// On linux systems /proc/self/exe is always a symlink to the real executable, so we jsut resolve it
realpath("/proc/self/exe", res);
return res;
......@@ -38,7 +38,7 @@ const char *get_self_executable(int argc, char **argv)
const char *get_self_executable(int argc, char **argv)
{
TCHAR szEXEPath[MAX_PATH];
static TCHAR szEXEPath[MAX_PATH];
GetModuleFileName(NULL,szEXEPath,MAX_PATH);
return szEXEPath;
}
......
......@@ -74,6 +74,7 @@ static int map_object_texture(lua_State *L)
bool is3d = lua_toboolean(L, 4);
if (i < 0 || i >= obj->nb_textures) return 0;
// printf("C Map Object setting texture %d = %d\n", i, *t);
obj->textures[i] = *t;
obj->textures_is3d[i] = is3d;
return 0;
......
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