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

fix colors

add actor ranks (critter, normal, elite, boss, elite boss)


git-svn-id: http://svn.net-core.org/repos/t-engine4@548 51575b47-30f0-44d4-a5cc-537603b46e54
parent 3d41d1ac
No related branches found
No related tags found
No related merge requests found
Showing
with 66 additions and 10 deletions
......@@ -189,8 +189,9 @@ function string.parseHex(str)
if hexcache[str] then return hexcache[str] end
local res = 0
local power = 1
str = str:lower()
for i = 1, #str do
res = res + power * (hex_to_dec[str:sub(#str-i+1,#str-i+1):lower()] or 0)
res = res + power * (hex_to_dec[str:sub(#str-i+1,#str-i+1)] or 0)
power = power * 16
end
hexcache[str] = res
......@@ -200,16 +201,15 @@ end
local tmps = core.display.newSurface(1, 1)
getmetatable(tmps).__index.drawColorString = function(s, font, str, x, y, r, g, b)
local Pcolorname = (lpeg.R"AZ" + "_")^3
local Pcode = (lpeg.R"az" + lpeg.R"09" + lpeg.R"AZ")
local Pcode = (lpeg.R"af" + lpeg.R"09" + lpeg.R"AF")
local Pcolorcode = Pcode * Pcode
local list = str:split("#" * (Pcolorname + (Pcolorcode * Pcolorcode * Pcolorcode)) * "#", true)
local list = str:split("#" * ((Pcolorcode * Pcolorcode * Pcolorcode) + Pcolorname) * "#", true)
r = r or 255
g = g or 255
b = b or 255
local oldr, oldg, oldb = r, g, b
for i, v in ipairs(list) do
-- print("LSIT", i, v)
local nr, ng, nb = lpeg.match("#" * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * "#", v)
local col = lpeg.match("#" * lpeg.C(Pcolorname) * "#", v)
if nr and ng and nb then
......@@ -224,7 +224,6 @@ getmetatable(tmps).__index.drawColorString = function(s, font, str, x, y, r, g,
end
else
local w, h = font:size(v)
-- print("DRAW", v,r,g,b)
s:drawString(font, v, x, y, r, g, b)
x = x + w
end
......
......@@ -76,6 +76,9 @@ function _M:init(t, no_default)
self.unused_talents = self.unused_talents or 0
self.unused_talents_types = self.unused_talents_types or 0
t.size_category = t.size_category or 3
t.rank = t.rank or 2
t.life_rating = t.life_rating or 10
t.mana_rating = t.mana_rating or 10
t.stamina_rating = t.stamina_rating or 4
......@@ -246,14 +249,40 @@ function _M:magicMap(radius, x, y)
end end
end
function _M:TextRank()
local rank, color = "normal", "#ANTIQUE_WHITE#"
if self.rank == 1 then rank, color = "critter", "#A09090#"
elseif self.rank == 2 then rank, color = "normal", "#ANTIQUE_WHITE#"
elseif self.rank == 3 then rank, color = "elite", "#YELLOW#"
elseif self.rank == 4 then rank, color = "boss", "#ORANGE#"
elseif self.rank >= 5 then rank, color = "elite boss", "#GOLD#"
end
return rank, color
end
function _M:TextSizeCategory()
local sizecat = "medium"
if self.size_category <= 1 then sizecat = "tiny"
elseif self.size_category == 2 then sizecat = "small"
elseif self.size_category == 3 then sizecat = "medium"
elseif self.size_category == 4 then sizecat = "big"
elseif self.size_category >= 5 then sizecat = "huge"
end
return sizecat
end
function _M:tooltip()
return ([[%s
local rank, rank_color = self:TextRank()
return ([[%s%s
Rank: %s%s
#00ffff#Level: %d
Exp: %d/%d
#ff0000#HP: %d (%d%%)
Stats: %d / %d / %d / %d / %d / %d
Size: #ANTIQUE_WHITE#%s
%s]]):format(
self.name,
rank_color, self.name,
rank_color, rank,
self.level,
self.exp,
self:getExpChart(self.level+1) or "---",
......@@ -264,6 +293,7 @@ Stats: %d / %d / %d / %d / %d / %d
self:getWil(),
self:getCun(),
self:getCon(),
self:TextSizeCategory(),
self.desc or ""
)
end
......@@ -734,6 +764,8 @@ end
-- This does not check LOS or such, only the actual ability to see it.<br/>
-- Check for telepathy, invisibility, stealth, ...
function _M:canSee(actor, def, def_pct)
if not actor then return false, 0 end
-- ESP, see all, or only types/subtypes
if self:attr("esp") then
local esp = self:attr("esp")
......
......@@ -105,7 +105,7 @@ end
function _M:getDisplayColor()
if not self:isIdentified() then return {180, 180, 180}, "#B4B4B4#" end
if self.egoed then return {0, 255, 128}, "#00FF80#"
elseif self.unique then return {255, 255, 0}, "#1FFF00#"
elseif self.unique then return {255, 255, 0}, "#FFFF00#"
else return {255, 255, 255}, "#FFFFFF#"
end
end
......
......@@ -73,6 +73,8 @@ function _M:init(t, no_default)
t.lite = t.lite or 0
t.rank = t.rank or 3
mod.class.Actor.init(self, t, no_default)
engine.interface.PlayerHotkeys.init(self, t)
......@@ -364,7 +366,7 @@ end
function _M:playerUseItem(object, item, inven)
if game.zone.short_name == "wilderness" then game.logPlayer(self, "You can not use items on the world map.") return end
local use_fct = function(o, item, inven)
local use_fct = function(o, inven, item)
self.changed = true
local ret, no_id = o:use(self)
if not no_id then
......@@ -384,7 +386,7 @@ function _M:playerUseItem(object, item, inven)
self.changed = true
end
if object and item then return use_fct(object, item, inven) end
if object and item then return use_fct(object, inven, item) end
local titleupdator = self:getEncumberTitleUpdator("Use object")
self:showEquipInven(titleupdator(),
......
......@@ -33,6 +33,7 @@ newEntity{
combat_armor = 1, combat_def = 1,
combat = { dam=5, atk=15, apr=7 },
max_life = resolvers.rngavg(10,20),
rank = 1,
size_category = 1,
}
......
......@@ -33,6 +33,7 @@ newEntity{
ai = "dumb_talented_simple", ai_state = { talent_in=5, },
energy = { mod=0.9 },
stats = { str=18, dex=13, mag=5, con=15 },
rank = 2,
size_category = 4,
combat_armor = 1, combat_def = 1,
......
......@@ -28,6 +28,7 @@ newEntity{
body = { INVEN = 10 },
max_stamina = 150,
rank = 1,
size_category = 2,
autolevel = "warrior",
......
......@@ -32,6 +32,7 @@ newEntity{
ai = "dumb_talented_simple", ai_state = { talent_in=2, ai_move="move_ghoul", },
energy = { mod=1 },
stats = { str=14, dex=12, mag=10, con=12 },
rank = 2,
size_category = 3,
resolvers.tmasteries{ ["technique/other"]=1, },
......@@ -78,6 +79,8 @@ newEntity{ base = "BASE_NPC_GHOUL",
combat_armor = 3, combat_def = 10,
ai_state = { talent_in=2, ai_pause=20 },
rank = 3,
combat = { dam=10, atk=8, apr=4, dammod={str=0.6} },
summon = {
......
......@@ -33,6 +33,7 @@ newEntity{
energy = { mod=1 },
combat_armor = 1, combat_def = 1,
never_move = 1,
rank = 2,
size_category = 3,
drops = resolvers.drops{chance=60, nb=1, {type="money"} },
......
......@@ -33,6 +33,7 @@ newEntity{
max_stamina = 100,
life_rating = 13,
max_life = resolvers.rngavg(100,120),
rank = 2,
size_category = 4,
autolevel = "warrior",
......
......@@ -32,6 +32,7 @@ newEntity{
combat_armor = 1, combat_def = 1,
never_move = 1,
fear_immune = 1,
rank = 1,
size_category = 1,
}
......
......@@ -32,6 +32,7 @@ newEntity{
stats = { str=10, dex=15, mag=3, con=10 },
energy = { mod=0.7 },
combat_armor = 1, combat_def = 1,
rank = 1,
size_category = 3,
resolvers.drops{chance=90, nb=1, {} },
......
......@@ -31,6 +31,7 @@ newEntity{
resolvers.drops{chance=20, nb=1, {type="money"} },
life_rating = 11,
rank = 2,
size_category = 3,
autolevel = "warrior",
......
......@@ -32,6 +32,7 @@ newEntity{
stats = { str=10, dex=10, mag=3, con=10 },
energy = { mod=1 },
combat_armor = 1, combat_def = 1,
rank = 1,
size_category = 1,
never_move = 1,
fear_immune = 1,
......@@ -55,6 +56,7 @@ newEntity{ base = "BASE_NPC_PLANT",
life_rating = 15,
combat = { dam=resolvers.rngavg(8,13), atk=15, apr=5 },
never_move = 0,
rank = 2,
size_category = 5,
}
......@@ -78,6 +80,7 @@ newEntity{ base = "BASE_NPC_PLANT",
max_life = resolvers.rngavg(100,130),
life_rating = 15,
combat = false,
rank = 2,
size_category = 5,
summon = {
......
......@@ -31,6 +31,7 @@ newEntity{ --rodent base
energy = { mod=1 },
stats = { str=8, dex=15, mag=3, con=5 },
combat_armor = 1, combat_def = 1,
rank = 1,
size_category = 1,
}
......
......@@ -30,6 +30,7 @@ newEntity{
max_stamina = 85,
max_mana = 85,
resists = { [DamageType.FIRE] = 30, [DamageType.COLD] = -30 },
rank = 2,
size_category = 2,
drops = resolvers.drops{chance=20, nb=1, {type="potion"}, {type="scroll"} },
......@@ -64,6 +65,7 @@ newEntity{ base = "BASE_NPC_SANDWORM",
color={r=204,g=255,b=95},
desc = [[This unholy creature looks like a wingless dragon in shape but ressembles a sandworm in color.]],
rarity = 8,
rank = 3,
size_category = 5,
resolvers.talents{
......
......@@ -29,6 +29,7 @@ newEntity{
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
resolvers.drops{chance=20, nb=1, {} },
resolvers.drops{chance=60, nb=1, {type="money"} },
rank = 2,
size_category = 3,
autolevel = "warrior",
......@@ -112,6 +113,7 @@ newEntity{ base = "BASE_NPC_SKELETON",
rarity = 8,
max_life = resolvers.rngavg(90,100),
combat_armor = 5, combat_def = 1,
rank = 3,
resolvers.talents{
[Talents.T_HEAVY_ARMOUR_TRAINING]=1,
[Talents.T_SHIELD_PUMMEL]=1,
......
......@@ -26,6 +26,7 @@ newEntity{
body = { INVEN = 10 },
max_stamina = 110,
rank = 2,
size_category = 2,
autolevel = "warrior",
......@@ -108,6 +109,7 @@ newEntity{ base = "BASE_NPC_SNAKE",
desc = [[You recoil in fear as you notice this huge, 10 meter long snake. It seeks to crush the life out of you.]],
level_range = {10, 50}, exp_worth = 1,
rarity = 11,
rank = 3,
max_life = resolvers.rngavg(100,120),
combat_armor = 14, combat_def = 5,
combat = { dam=12, atk=10, apr=10 },
......
......@@ -33,6 +33,7 @@ newEntity{
stats = { str=1, dex=20, mag=3, con=1 },
energy = { mod=2 },
combat_armor = 1, combat_def = 10,
rank = 1,
size_category = 1,
}
......
......@@ -32,6 +32,7 @@ newEntity{
resolvers.drops{chance=100, nb=2, {type="money"} },
max_stamina = 100,
rank = 2,
size_category = 3,
autolevel = "rogue",
......
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