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

rng.percent always returns false on a negative number

git-svn-id: http://svn.net-core.org/repos/t-engine4@2483 51575b47-30f0-44d4-a5cc-537603b46e54
parent 52451fce
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,6 @@ Map.zdepth = 4
-- Setup the map to only display one entity
Map.updateMapDisplay = function(self, x, y, mos)
local mm = Map.MM_FLOOR
local g = self(x, y, Map.TERRAIN)
local o = self(x, y, Map.OBJECT)
local a = self(x, y, Map.ACTOR)
......@@ -36,15 +35,12 @@ Map.updateMapDisplay = function(self, x, y, mos)
self._fovcache.path_caches[ps]:set(x, y, g:check("block_move", x, y, ps, false, true))
end
mm = mm + (g:check("block_move") and Map.MM_BLOCK or 0)
mm = mm + (g:check("change_level") and Map.MM_LEVEL_CHANGE or 0)
g:getMapObjects(self.tiles, mos, 1)
end
if t then
-- Handles trap being known
if not self.actor_player or t:knownBy(self.actor_player) then
t:getMapObjects(self.tiles, mos, 2)
mm = mm + Map.MM_TRAP
end
end
if o then
......@@ -53,15 +49,12 @@ Map.updateMapDisplay = function(self, x, y, mos)
local mo = o:getMapStackMO(self, x, y)
if mo then mos[2] = mo end
end
mm = mm + Map.MM_OBJECT
end
if a then
-- Handles invisibility and telepathy and other such things
if not self.actor_player or self.actor_player:canSee(a) then
local r = self.actor_player:reactionToward(a)
mm = mm + (r > 0 and Map.MM_FRIEND or (r == 0 and Map.MM_NEUTRAL or Map.MM_HOSTILE))
a:getMapObjects(self.tiles, mos, 4)
end
end
return mm
end
......@@ -1620,7 +1620,8 @@ static int rng_chance(lua_State *L)
static int rng_percent(lua_State *L)
{
int x = luaL_checknumber(L, 1);
lua_pushboolean(L, rand_div(100) < x);
int res = rand_div(100);
lua_pushboolean(L, res < x);
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