introduce coloured loot message

This commit is contained in:
ErikasKontenis 2022-08-09 19:59:44 +03:00
parent 1c35d04337
commit eed5309ed0
11 changed files with 89 additions and 14 deletions

View File

@ -646,7 +646,12 @@ function addTabText(text, speaktype, tab, creatureName)
label:setColoredText(highlightData) label:setColoredText(highlightData)
end end
end end
if tab == serverTab then
local highlightText = toHighlightedText(text, speaktype.color)
label:setColoredText(highlightText)
end
label.name = creatureName label.name = creatureName
consoleBuffer.onMouseRelease = function(self, mousePos, mouseButton) consoleBuffer.onMouseRelease = function(self, mousePos, mouseButton)
processMessageMenu(mousePos, mouseButton, nil, nil, nil, tab) processMessageMenu(mousePos, mouseButton, nil, nil, nil, tab)

View File

@ -92,12 +92,20 @@ function displayMessage(mode, text)
end end
if msgtype.screenTarget then if msgtype.screenTarget then
local label = messagesPanel:recursiveGetChildById(msgtype.screenTarget) local label = messagesPanel:recursiveGetChildById(msgtype.screenTarget)
label:setText(text) if mode == 20 then
label:setColor(msgtype.color) local highlightData = toHighlightedText(text, msgtype.color)
label:setVisible(true) label:setColoredText(highlightData)
removeEvent(label.hideEvent) label:setVisible(true)
label.hideEvent = scheduleEvent(function() label:setVisible(false) end, calculateVisibleTime(text)) removeEvent(label.hideEvent)
label.hideEvent = scheduleEvent(function() label:setVisible(false) end, calculateVisibleTime(text))
else
label:setText(text)
label:setColor(msgtype.color)
label:setVisible(true)
removeEvent(label.hideEvent)
label.hideEvent = scheduleEvent(function() label:setVisible(false) end, calculateVisibleTime(text))
end
end end
end end

View File

@ -8,4 +8,33 @@ function dirtostring(dir)
return k return k
end end
end end
end
function toHighlightedText(text, color)
local tmpData = {}
for i, part in ipairs(text:split("[")) do
if i == 1 then
table.insert(tmpData, part)
table.insert(tmpData, color)
else
for j, part2 in ipairs(part:split("]")) do
if j == 1 then
local text = part2:split(":")
if #text == 2 then
table.insert(tmpData, part2:split(":")[2])
table.insert(tmpData, part2:split(":")[1])
else
table.insert(tmpData, '[' .. part2 .. ']')
table.insert(tmpData, color)
end
else
table.insert(tmpData, part2)
table.insert(tmpData, color)
end
end
end
end
return tmpData
end end

View File

@ -3259,3 +3259,15 @@ ProtocolGame parse message exception (21 bytes, 0 unread, last opcode is 0x0b (1
6a 02 7e a4 79 06 01 3a 6a 02 7e a4 79 06 01 3a
0b 01 0b 01
ProtocolGame parse message exception (25 bytes, 1 unread, last opcode is 0xd2 (210), prev opcode is 0xffffffff (-1), proto: 792): InputMessage eof reached
18 00 15 00
d2 01 00 00 00 0d 00 4b 69 6e 67 20 54 69 62 69 61 6e 75 73 00
ProtocolGame parse message exception (16 bytes, 1 unread, last opcode is 0xd2 (210), prev opcode is 0xffffffff (-1), proto: 792): InputMessage eof reached
10 00 0c 00
d2 08 00 00 00 04 00 56 65 72 64 00
ProtocolGame parse message exception (19 bytes, 1 unread, last opcode is 0xd2 (210), prev opcode is 0xffffffff (-1), proto: 792): InputMessage eof reached
18 00 0f 00
d2 2a 05 00 00 07 00 44 72 75 69 64 6b 65 00

View File

@ -52,7 +52,7 @@ serverName = "Tibianus"
statusTimeout = 5000 statusTimeout = 5000
replaceKickOnLogin = true replaceKickOnLogin = true
maxPacketsPerSecond = 50 maxPacketsPerSecond = 50
packetCompression = true packetCompression = false
autoStackCumulatives = true autoStackCumulatives = true
moneyRate = 1 moneyRate = 1

View File

@ -14826,7 +14826,7 @@ TypeID = 3280
Name = "a fire sword" Name = "a fire sword"
Description = "The blade is a magic flame" Description = "The blade is a magic flame"
Flags = {MultiUse,Take,Weapon} Flags = {MultiUse,Take,Weapon}
Attributes = {Weight=2300,Brightness=3,LightColor=199,WeaponType=SWORD,Attack=35,Defense=20} Attributes = {Weight=2300,Brightness=3,LightColor=199,WeaponType=SWORD,Attack=35,Defense=20,Cost=4000}
TypeID = 3281 TypeID = 3281
Name = "a giant sword" Name = "a giant sword"
@ -15373,7 +15373,7 @@ Attributes = {Weight=2950,SlotType=HEAD,ArmorValue=7}
TypeID = 3386 TypeID = 3386
Name = "a dragon scale mail" Name = "a dragon scale mail"
Flags = {Take,Armor} Flags = {Take,Armor}
Attributes = {Weight=11400,SlotType=BODY,ArmorValue=15} Attributes = {Weight=11400,SlotType=BODY,ArmorValue=15,Cost=30000}
TypeID = 3387 TypeID = 3387
Name = "a demon helmet" Name = "a demon helmet"
@ -15591,7 +15591,7 @@ Attributes = {Weight=5200,Defense=27}
TypeID = 3428 TypeID = 3428
Name = "a tower shield" Name = "a tower shield"
Flags = {Take,Shield} Flags = {Take,Shield}
Attributes = {Weight=8200,Defense=32} Attributes = {Weight=8200,Defense=32,Cost=8000}
TypeID = 3429 TypeID = 3429
Name = "a black shield" Name = "a black shield"

View File

@ -155,8 +155,19 @@ std::ostringstream& Container::getContentDescription(std::ostringstream& os) con
} else { } else {
os << ", "; os << ", ";
} }
os << item->getNameDescription(); if (item->getCost() >= 50000) {
os << "[#BA90C7:" << item->getNameDescription() << "]";
}
else if (item->getCost() >= 15000) {
os << "[#F3E84A:" << item->getNameDescription() << "]";
}
else if (item->getCost() >= 1000) {
os << "[#629AC4:" << item->getNameDescription() << "]";
}
else {
os << item->getNameDescription();
}
} }
if (firstitem) { if (firstitem) {

View File

@ -1182,6 +1182,12 @@ std::string Item::getWeightDescription() const
return getWeightDescription(weight); return getWeightDescription(weight);
} }
uint32_t Item::getCost() const
{
const ItemType& it = items[id];
return it.cost;
}
bool Item::canDecay() const bool Item::canDecay() const
{ {
if (isRemoved()) { if (isRemoved()) {

View File

@ -565,6 +565,7 @@ class Item : virtual public Thing
std::string getDescription(int32_t lookDistance) const final; std::string getDescription(int32_t lookDistance) const final;
std::string getNameDescription() const; std::string getNameDescription() const;
std::string getWeightDescription() const; std::string getWeightDescription() const;
uint32_t getCost() const;
//serialization //serialization
virtual Attr_ReadValue readAttr(AttrTypes_t attr, PropStream& propStream); virtual Attr_ReadValue readAttr(AttrTypes_t attr, PropStream& propStream);

View File

@ -423,6 +423,8 @@ bool Items::loadItems()
items[id].lightColor = script.readNumber(); items[id].lightColor = script.readNumber();
} else if (identifier == "extrahitchance") { } else if (identifier == "extrahitchance") {
items[id].extraHitChance = script.readNumber(); items[id].extraHitChance = script.readNumber();
} else if (identifier == "cost") {
items[id].cost = script.readNumber();
} else if (identifier == "extraattack") { } else if (identifier == "extraattack") {
items[id].extraAttack = script.readNumber(); items[id].extraAttack = script.readNumber();
} else if (identifier == "totalexpiretime") { } else if (identifier == "totalexpiretime") {

View File

@ -208,6 +208,7 @@ class ItemType
uint32_t minReqLevel = 0; uint32_t minReqLevel = 0;
uint32_t minReqMagicLevel = 0; uint32_t minReqMagicLevel = 0;
uint32_t charges = 0; uint32_t charges = 0;
uint32_t cost = 0;
int32_t attackStrength = 0; int32_t attackStrength = 0;
int32_t attackVariation = 0; int32_t attackVariation = 0;
int32_t manaConsumption = 0; int32_t manaConsumption = 0;
@ -222,7 +223,7 @@ class ItemType
int32_t runeLevel = 0; int32_t runeLevel = 0;
int32_t nutrition = 0; int32_t nutrition = 0;
int32_t destroyTarget = 0; int32_t destroyTarget = 0;
CombatType_t combatType = COMBAT_NONE; CombatType_t combatType = COMBAT_NONE;
CombatType_t damageType = COMBAT_NONE; CombatType_t damageType = COMBAT_NONE;