Commit 84c15aa527bbe8aa62ef99f581dfecb94575b28f

Authored by DarkGod
1 parent 326acc84

Add chat portraits to many things

Showing 45 changed files with 47 additions and 12 deletions
... ... @@ -81,7 +81,7 @@ He who felt great sorrow for this world. He who shall now shatter the barriers o
81 81 The staff has allowed us to drain enough energy from this world to open the portal to the Void and summon Him through!
82 82 It is already too late. He is coming through as we speak -- it is only a matter of hours!]],
83 83 answers = {
84   - {_t"I *WILL* stop you! The world will not end today!", jump="aeryn", switch_npc={name=_t"High Sun Paladin Aeryn"}, action=aeryn_comes, cond=aeryn_alive},
  84 + {_t"I *WILL* stop you! The world will not end today!", jump="aeryn", switch_npc={name=_t"High Sun Paladin Aeryn", image="npc/humanoid_human_high_sun_paladin_aeryn.png"}, action=aeryn_comes, cond=aeryn_alive},
85 85 {_t"I *WILL* stop you! The world will not end today!", cond=aeryn_dead},
86 86 }
87 87 }
... ... @@ -92,7 +92,7 @@ He who felt great sorrow for this world. He who shall now shatter the barriers o
92 92 The staff will allow us to drain enough energy from this world to open the portal to the Void and summon Him through!
93 93 You cannot stop us now!]],
94 94 answers = {
95   - {_t"I *WILL* stop you! The world will not end today!", jump="aeryn", switch_npc={name=_t"High Sun Paladin Aeryn"}, action=aeryn_comes, cond=aeryn_alive},
  95 + {_t"I *WILL* stop you! The world will not end today!", jump="aeryn", switch_npc={name=_t"High Sun Paladin Aeryn", image="npc/humanoid_human_high_sun_paladin_aeryn.png"}, action=aeryn_comes, cond=aeryn_alive},
96 96 {_t"I *WILL* stop you! The world will not end today!", cond=aeryn_dead},
97 97 }
98 98 }
... ...
... ... @@ -74,7 +74,7 @@ next_combat = function(self)
74 74
75 75 if not self:isEnded() then
76 76 local Chat = require "engine.Chat"
77   - local chat = Chat.new("antimagic-end", {name=_t"Grim-looking fighter"}, game.player)
  77 + local chat = Chat.new("antimagic-end", {name=_t"Grim-looking fighter", image="portrait/antimagic.png"}, game.player)
78 78 chat:invoke()
79 79 end
80 80 end
... ...
... ... @@ -77,7 +77,7 @@ kill_one = function(self)
77 77
78 78 if self.kill_count >= self.max_count then
79 79 local Chat = require "engine.Chat"
80   - local chat = Chat.new("derth-attack-over", {name=_t"Scared Halfling"}, game.player)
  80 + local chat = Chat.new("derth-attack-over", {name=_t"Scared Halfling", image="portrait/derth_attack_over.png"}, game.player)
81 81 chat:invoke()
82 82
83 83 if not game.zone.unclean_derth_savior then
... ...
... ... @@ -67,7 +67,7 @@ newEntity{ define_as = "UNGOLE", base = "BASE_NPC_SPIDER",
67 67
68 68 on_die = function(self, who)
69 69 local Chat = require"engine.Chat"
70   - local chat = Chat.new("ardhungol-end", {name=_t"Sun Paladin Rashim"}, game.player:resolveSource())
  70 + local chat = Chat.new("ardhungol-end", {name=_t"Sun Paladin Rashim", image="portrait/ardhungol_end.png"}, game.player:resolveSource())
71 71 chat:invoke()
72 72 end,
73 73 }
... ...
... ... @@ -198,7 +198,7 @@ newEntity{
198 198 game:changeLevel(11, nil, {direct_switch=true}) -- Special level, can not get to it any other way
199 199 if game.player:hasQuest("high-peak"):isCompleted("sanctum-chat") then return end
200 200 local Chat = require "engine.Chat"
201   - local chat = Chat.new("sorcerer-fight", {name=_t"Elandar"}, game.player)
  201 + local chat = Chat.new("sorcerer-fight", {name=_t"Elandar", image="npc/humanoid_shalore_elandar.png"}, game.player)
202 202 chat:invoke()
203 203 game.player:hasQuest("high-peak"):setStatus(engine.Quest.COMPLETED, "sanctum-chat")
204 204 game.player:hasQuest("high-peak"):start_end_combat()
... ...
... ... @@ -71,6 +71,7 @@ newEntity{ base = "BASE_STORE", define_as = "LIBRARY",
71 71 newEntity{ base = "BASE_STORE", define_as = "TRAINER",
72 72 name="Trainer",
73 73 display='1', color=colors.UMBER, image = "store/shop_door2.png", add_mos={{display_x=0.6, image="store/shop_sign_trainer.png"}},
  74 + chat_display = {name=_t"Grim-looking fighter", image="portrait/antimagic.png"},
74 75 resolvers.chatfeature("zigur-trainer", "zigur"),
75 76 }
76 77
... ...
... ... @@ -66,6 +66,10 @@ for i = 1, 20 do
66 66 {"small_willow_moss", {"shadow", "trunk", "foliage_spring"}},
67 67 {"willow", {tall=-1, "shadow", "trunk", "foliage_spring"}},
68 68 {"willow_moss", {tall=-1, "shadow", "trunk", "foliage_spring"}},
  69 + -- {"small_willow_02", {"shadow", "trunk", "foliage_bare"}},
  70 + -- {"willow_02", {tall=-1, "shadow", "trunk", "foliage_bare"}},
  71 + -- {"small_willow_02", {"shadow", "trunk", "foliage_spring"}},
  72 + -- {"willow_02", {tall=-1, "shadow", "trunk", "foliage_spring"}},
69 73 }, 1))
70 74 end
71 75
... ...
... ... @@ -39,8 +39,8 @@ end
39 39 function _M:makeUI()
40 40 self.c_desc = Textzone.new{has_box=true, ui="chat", font=self.chat.dialog_text_font, width=self.iw - 30, height=1, auto_height=true, text=self.text, can_focus=false}
41 41 self.c_list = VariableList.new{font=self.chat.dialog_answer_font, width=self.iw, max_height=game.h * 0.70 - self.c_desc.h, list=self.list, fct=function(item) self:use(item) end, select=function(item) self:select(item) end}
42   - local npc_frame = ChatPortrait.new{ui="chat", side="right", actor=self:getActorPortrait(self.chat.npc_force_display_entity or self.npc.chat_display_entity or self.npc)}
43   - local player_frame = ChatPortrait.new{ui="chat", side="left", actor=self:getActorPortrait(self.chat.player_force_display_entity or self.player.chat_display_entity or self.player)}
  42 + local npc_frame = ChatPortrait.new{ui="chat", side="right", actor=self:getActorPortraitFull(self.chat.npc_force_display_entity or self.npc.chat_display_entity or self.npc)}
  43 + local player_frame = ChatPortrait.new{ui="chat", side="left", actor=self:getActorPortraitFull(self.chat.player_force_display_entity or self.player.chat_display_entity or self.player)}
44 44
45 45 local uis = {
46 46 {hcenter=0, top=-12, ui=self.c_desc},
... ... @@ -69,6 +69,13 @@ function _M:makeUI()
69 69 player_frame:adjustHeight(self.h)
70 70 end
71 71
  72 +function _M:getActorPortraitFull(actor)
  73 + print("[ToME:CHAT] Grabbing portrait for ", actor.name, actor.image)
  74 + local e = self:getActorPortrait(actor)
  75 + print("[ToME:CHAT] Grabed portrait => ", e.image)
  76 + return e
  77 +end
  78 +
72 79 function _M:getActorPortrait(actor)
73 80 local actor = actor.replace_display or actor
74 81
... ... @@ -98,12 +105,35 @@ function _M:getActorPortrait(actor)
98 105 if actor.image:find("^portrait/") then return actor end
99 106
100 107 -- Find the portrait
101   - if actor.image == "invis.png" and actor.add_mos and actor.add_mos[1] and actor.add_mos[1].image and actor.add_mos[1].image:find("^npc/") and fs.exists("/data/gfx/shockbolt/"..actor.add_mos[1].image:gsub("^npc/", "portrait/")) then
  108 + if actor.isClassName and actor:isClassName("engine.Grid") and (actor.add_mos or actor.add_displays) then
  109 + -- First one to have a portrait
  110 + for i, mo in ripairs(actor.add_displays or {}) do
  111 + if mo.image:find("^terrain/") and fs.exists("/data/gfx/shockbolt/"..mo.image:gsub("^terrain/", "portrait/")) then
  112 + return Entity.new{name=actor.name, image=mo.image:gsub("^terrain/", "portrait/")}
  113 + end
  114 + end
  115 + for i, mo in ripairs(actor.add_mos or {}) do
  116 + if mo.image:find("^terrain/") and fs.exists("/data/gfx/shockbolt/"..mo.image:gsub("^terrain/", "portrait/")) then
  117 + return Entity.new{name=actor.name, image=mo.image:gsub("^terrain/", "portrait/")}
  118 + end
  119 + end
  120 + -- If not, first one
  121 + if actor.add_displays then local mo = actor.add_displays[#actor.add_displays]
  122 + if mo then return Entity.new{name=actor.name, image=mo.image} end
  123 + end
  124 + if actor.add_mos then local mo = actor.add_mos[#actor.add_mos]
  125 + if mo then return Entity.new{name=actor.name, image=mo.image} end
  126 + end
  127 + -- If not, the terrain itself (how? we checked for one of add_mos & add_displays but heh)
  128 + if actor.image:find("^terrain/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^terrain/", "portrait/")) then
  129 + return Entity.new{name=actor.name, image=actor.image:gsub("^terrain/", "portrait/")}
  130 + end
  131 + elseif actor.image == "invis.png" and actor.add_mos and actor.add_mos[1] and actor.add_mos[1].image and actor.add_mos[1].image:find("^npc/") and fs.exists("/data/gfx/shockbolt/"..actor.add_mos[1].image:gsub("^npc/", "portrait/")) then
102 132 return Entity.new{name=actor.name, image=actor.add_mos[1].image:gsub("^npc/", "portrait/")}
103 133 elseif actor.image:find("^npc/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^npc/", "portrait/")) then
104 134 return Entity.new{name=actor.name, image=actor.image:gsub("^npc/", "portrait/")}
105   - elseif actor.image:find("^npc/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^npc/", "portrait/")) then
106   - return Entity.new{name=actor.name, image=actor.image:gsub("^npc/", "portrait/")}
  135 + elseif actor.image:find("^player/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^player/", "portrait/")) then
  136 + return Entity.new{name=actor.name, image=actor.image:gsub("^player/", "portrait/")}
107 137 elseif actor.image:find("^object/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^object/", "portrait/")) then
108 138 return Entity.new{name=actor.name, image=actor.image:gsub("^object/", "portrait/")}
109 139 elseif actor.image:find("^object/artifact/") and fs.exists("/data/gfx/shockbolt/"..actor.image:gsub("^object/artifact/", "portrait/")) then
... ...
... ... @@ -45,7 +45,7 @@ function _M:init(t)
45 45 self.iw, self.ih = iw, ih
46 46 if self.image.getEmptyMargins and not t.actor.ignore_margins then
47 47 local x1, x2, y1, y2 = self.image:getEmptyMargins()
48   - self.iy = 0
  48 + self.iy = y1
49 49 else
50 50 self.iy = 0
51 51 end
... ...