Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: general fixes, npc "poff" on hit and walk on fields, window projectile blocking and npc speech bubble #853

Merged
merged 4 commits into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions data-canary/scripts/lib/register_npc_type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ registerNpcType.description = function(npcType, mask)
end
end

registerNpcType.speechBubble = function(npcType, mask)
local speechBubble = npcType:speechBubble()
if mask.speechBubble then
npcType:speechBubble(mask.speechBubble)
elseif speechBubble == 3 then
npcType:speechBubble(4)
elseif speechBubble < 1 then
npcType:speechBubble(1)
else
npcType:speechBubble(2)
end
end

registerNpcType.outfit = function(npcType, mask)
if mask.outfit then
npcType:outfit(mask.outfit)
Expand Down Expand Up @@ -206,3 +193,9 @@ registerNpcType.currency = function(npcType, mask)
npcType:currency(mask.currency)
end
end

registerNpcType.speechBubble = function(npcType, mask)
if mask.speechBubble then
npcType:speechBubble(mask.speechBubble)
end
end
19 changes: 6 additions & 13 deletions data-otservbr-global/scripts/lib/register_npc_type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ registerNpcType.description = function(npcType, mask)
end
end

registerNpcType.speechBubble = function(npcType, mask)
local speechBubble = npcType:speechBubble()
if mask.speechBubble then
npcType:speechBubble(mask.speechBubble)
elseif speechBubble == 3 then
npcType:speechBubble(4)
elseif speechBubble < 1 then
npcType:speechBubble(1)
else
npcType:speechBubble(2)
end
end

registerNpcType.outfit = function(npcType, mask)
if mask.outfit then
npcType:outfit(mask.outfit)
Expand Down Expand Up @@ -206,3 +193,9 @@ registerNpcType.currency = function(npcType, mask)
npcType:currency(mask.currency)
end
end

registerNpcType.speechBubble = function(npcType, mask)
if mask.speechBubble then
npcType:speechBubble(mask.speechBubble)
end
end
94 changes: 78 additions & 16 deletions data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10650,7 +10650,10 @@
<attribute key="weight" value="500"/>
</item>
<item id="5301" name="wooden planks"/>
<item fromid="5302" toid="5303" article="a" name="white stone wall window"/>
<item fromid="5302" toid="5303" article="a" name="white stone wall window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="5304" toid="5306" article="a" name="white stone railing"/>
<item id="5307" article="a" name="white stone pillar"/>
<item fromid="5308" toid="5313" article="a" name="white stone railing"/>
Expand Down Expand Up @@ -13126,43 +13129,70 @@
<item id="6434" article="a" name="demon trophy">
<attribute key="weight" value="500"/>
</item>
<item fromid="6435" toid="6438" article="a" name="framework window">
<item fromid="6435" toid="6436" article="a" name="framework window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6439" toid="6442" article="a" name="brick window">
<item fromid="6437" toid="6438" article="a" name="framework window">
<attribute key="type" value="door"/>
</item>
<item fromid="6439" toid="6440" article="a" name="brick window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6443" toid="6446" article="a" name="stone window">
<item fromid="6441" toid="6442" article="a" name="brick window">
<attribute key="type" value="door"/>
</item>
<item fromid="6443" toid="6444" article="a" name="stone window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6445" toid="6446" article="a" name="stone window">
<attribute key="type" value="door"/>
</item>
<item fromid="6447" toid="6448" article="a" name="marble window"/>
<item fromid="6449" toid="6452" article="a" name="tree window">
<item fromid="6449" toid="6450" article="a" name="tree window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6453" toid="6456" article="a" name="sandstone window">
<item fromid="6451" toid="6452" article="a" name="tree window">
<attribute key="type" value="door"/>
</item>
<item fromid="6453" toid="6454" article="a" name="sandstone window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6457" toid="6460" article="a" name="bamboo window">
<item fromid="6455" toid="6456" article="a" name="sandstone window">
<attribute key="type" value="door"/>
</item>
<item fromid="6457" toid="6458" article="a" name="bamboo window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6461" toid="6464" article="a" name="sandstone window">
<item fromid="6459" toid="6460" article="a" name="bamboo window">
<attribute key="type" value="door"/>
</item>
<item fromid="6461" toid="6462" article="a" name="sandstone window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6465" toid="6468" article="a" name="stone window">
<item fromid="6463" toid="6464" article="a" name="sandstone window">
<attribute key="type" value="door"/>
</item>
<item fromid="6465" toid="6466" article="a" name="stone window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6469" toid="6472" article="a" name="wooden window">
<item fromid="6467" toid="6468" article="a" name="stone window">
<attribute key="type" value="door"/>
</item>
<item fromid="6469" toid="6470" article="a" name="wooden window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6471" toid="6472" article="a" name="wooden window">
<attribute key="type" value="door"/>
</item>
<item fromid="6473" toid="6474" name="wooden planks"/>
<item fromid="6475" toid="6487" name="debris"/>
<item fromid="6488" toid="6489" article="a" name="christmas branch">
Expand Down Expand Up @@ -13561,7 +13591,11 @@
<item fromid="6773" toid="6774" article="a" name="fur wall"/>
<item id="6775" article="a" name="fur pillar"/>
<item fromid="6776" toid="6787" article="a" name="fur wall"/>
<item fromid="6788" toid="6791" article="a" name="fur wall window">
<item fromid="6788" toid="6789" article="a" name="fur wall window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="6790" toid="6791" article="a" name="fur wall window">
<attribute key="type" value="door"/>
</item>
<item id="6792" article="an" name="entrance"/>
Expand Down Expand Up @@ -13720,8 +13754,12 @@
<item fromid="7020" toid="7022" article="a" name="snowy dead tree"/>
<item id="7023" article="a" name="snowy pine tree"/>
<item id="7024" article="a" name="pine"/>
<item fromid="7025" toid="7028" article="a" name="nordic wall window">
<item fromid="7025" toid="7026" article="a" name="nordic wall window">
<attribute key="type" value="door"/>
</item>
<item fromid="7027" toid="7028" article="a" name="nordic wall window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="7029" toid="7030" article="an" name="ice wall window">
<attribute key="type" value="door"/>
Expand Down Expand Up @@ -18442,6 +18480,7 @@
<attribute key="weight" value="700"/>
</item>
<item id="9303" article="a" name="leviathan's amulet">
<attribute key="showattributes" value="1" />
<attribute key="description" value="It holds the last breath of Leviathan"/>
<attribute key="showCharges" value="1"/>
<attribute key="absorbpercentphysical" value="60"/>
Expand All @@ -18450,6 +18489,7 @@
<attribute key="weight" value="700"/>
</item>
<item id="9304" article="a" name="shockwave amulet">
<attribute key="showattributes" value="1" />
<attribute key="description" value="It tickles your neck in a rather pleasant way and absorbs loads of damage"/>
<attribute key="showCharges" value="1"/>
<attribute key="absorbpercentphysical" value="60"/>
Expand All @@ -18468,10 +18508,13 @@
</item>
<item fromid="9309" toid="9331" article="a" name="framework wall"/>
<item fromid="9332" toid="9344" article="a" name="stone wall"/>
<item fromid="9347" toid="9350" article="a" name="framework window">
<item fromid="9347" toid="9348" article="a" name="framework window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="9349" toid="9350" article="a" name="framework window">
<attribute key="type" value="door"/>
</item>
<item id="9351" article="a" name="closed door" editorsuffix="(it is locked)">
<attribute key="type" value="door"/>
<attribute key="description" value="It is locked."/>
Expand Down Expand Up @@ -18926,10 +18969,13 @@
<attribute key="type" value="door"/>
</item>
<item fromid="9569" toid="9570" article="a" name="limestone window"/>
<item fromid="9571" toid="9574" article="a" name="limestone window">
<item fromid="9571" toid="9572" article="a" name="limestone window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="9573" toid="9574" article="a" name="limestone window">
<attribute key="type" value="door"/>
</item>
<item fromid="9575" toid="9581" name="pavement"/>
<item id="9582" name="remains of a water elemental">
<attribute key="description" value="Something is wobbling inside. Maybe with a fishing rod you could reach it."/>
Expand Down Expand Up @@ -47740,8 +47786,12 @@
<item fromid="33590" toid="33607" article="a" name="wall"/>
<item fromid="33611" toid="33622" article="a" name="wall"/>
<item fromid="33623" toid="33627" article="a" name="buttress"/>
<item fromid="33628" toid="33631" article="a" name="wall window">
<item fromid="33628" toid="33629" article="a" name="wall window">
<attribute key="type" value="door"/>
</item>
<item fromid="33630" toid="33631" article="a" name="wall window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item id="33632" article="a" name="closed door">
<attribute key="type" value="door"/>
Expand All @@ -47764,8 +47814,19 @@
<item fromid="33636" toid="33637" article="an" name="open door">
<attribute key="type" value="door"/>
</item>
<item fromid="33638" toid="33645" article="a" name="wall window">
<item fromid="33638" toid="33639" article="a" name="wall window">
<attribute key="type" value="door"/>
</item>
<item fromid="33640" toid="33641" article="a" name="wall window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="33642" toid="33643" article="a" name="wall window">
<attribute key="type" value="door"/>
</item>
<item fromid="33644" toid="33645" article="a" name="wall window">
<attribute key="type" value="door"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item fromid="33646" toid="33651" article="a" name="wall"/>
<item fromid="33652" toid="33653" article="an" name="open door">
Expand Down Expand Up @@ -50208,6 +50269,7 @@
</attribute>
</item>
<item id="35523" article="an" name="exotic amulet">
<attribute key="showattributes" value="1" />
<attribute key="absorbpercentphysical" value="4"/>
<attribute key="absorbpercentpoison" value="5"/>
<attribute key="weight" value="730"/>
Expand Down
2 changes: 2 additions & 0 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ ReturnValue Combat::canDoCombat(Creature* attacker, Creature* target) {
}
}
}
} else if (target && target->getNpc()) {
return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE;
}

if (g_game().getWorldType() == WORLD_TYPE_NO_PVP) {
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/combat/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ bool ConditionDamage::doDamage(Creature* creature, int32_t healthChange) {
}

if (!creature->isAttackable() || Combat::canDoCombat(attacker, creature) != RETURNVALUE_NOERROR) {
if (!creature->isInGhostMode()) {
if (!creature->isInGhostMode() && !creature->getNpc()) {
g_game().addMagicEffect(creature->getPosition(), CONST_ME_POFF);
}
return false;
Expand Down
1 change: 1 addition & 0 deletions src/creatures/creatures_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ enum SpeechBubble_t {
SPEECHBUBBLE_TRADE = 2,
SPEECHBUBBLE_QUEST = 3,
SPEECHBUBBLE_QUESTTRADER = 4,
SPEECHBUBBLE_HIRELING = 7,
};

enum MarketAction_t {
Expand Down
2 changes: 2 additions & 0 deletions src/creatures/npcs/npcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ void NpcType::loadShop(NpcType* npcType, ShopBlock shopBlock) {
} else {
npcType->info.shopItemVector.push_back(shopBlock);
}

info.speechBubble = SPEECHBUBBLE_TRADE;
}

bool Npcs::load(bool loadLibs /* = true*/, bool loadNpcs /* = true*/, bool reloading /* = false*/) const {
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/npcs/npcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NpcType {

LightInfo light = {};

uint8_t speechBubble;
uint8_t speechBubble = SPEECHBUBBLE_NORMAL;

uint16_t currencyId = ITEM_GOLD_COIN;

Expand Down
15 changes: 4 additions & 11 deletions src/items/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,25 +169,18 @@ bool Items::loadFromXml() {
}

for (auto itemNode : doc.child("items").children()) {
pugi::xml_attribute idAttribute = itemNode.attribute("id");
if (idAttribute) {
if (auto idAttribute = itemNode.attribute("id"); idAttribute) {
parseItemNode(itemNode, pugi::cast<uint16_t>(idAttribute.value()));
continue;
}

pugi::xml_attribute fromIdAttribute = itemNode.attribute("fromid");
auto fromIdAttribute = itemNode.attribute("fromid");
if (!fromIdAttribute) {
if (idAttribute) {
SPDLOG_WARN("[Items::loadFromXml] - "
"No item id: {} found",
idAttribute.value());
} else {
SPDLOG_WARN("[Items::loadFromXml] - No item id found");
}
SPDLOG_WARN("[Items::loadFromXml] - No item id found, use id or fromid");
continue;
}

pugi::xml_attribute toIdAttribute = itemNode.attribute("toid");
auto toIdAttribute = itemNode.attribute("toid");
if (!toIdAttribute) {
SPDLOG_WARN("[Items::loadFromXml] - "
"tag fromid: {} without toid",
Expand Down
Loading