summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoraK-FDF <horak-fdf@web.de>2024-06-06 19:36:23 +0000
committerLed Mitz <smoothshifter@tuta.io>2024-06-06 19:36:23 +0000
commit04c17a55c5b83e1b8ef1dc336fd8e023ba1e10ad (patch)
tree684a3f499b16bc44940eff429314ec54077f75ff
parent1841311e6302ff88e53446744e571bed703d2087 (diff)
downloadtmwa-04c17a55c5b83e1b8ef1dc336fd8e023ba1e10ad.tar.gz
tmwa-04c17a55c5b83e1b8ef1dc336fd8e023ba1e10ad.tar.bz2
tmwa-04c17a55c5b83e1b8ef1dc336fd8e023ba1e10ad.tar.xz
tmwa-04c17a55c5b83e1b8ef1dc336fd8e023ba1e10ad.zip
KeepAfterUse + DontUseAmmo
**** Approved-by: Free Yorp <thefreeyorp+git@gmail.com> Approved-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl> Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
-rw-r--r--src/map/battle.cpp28
-rw-r--r--src/map/clif.cpp23
-rw-r--r--src/map/npc.cpp14
-rw-r--r--src/map/pc.cpp8
-rw-r--r--src/map/storage.cpp10
-rw-r--r--src/mmo/enums.hpp2
6 files changed, 61 insertions, 24 deletions
diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index b745e05..ac8dcf2 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -2060,18 +2060,28 @@ ATK battle_weapon_attack(dumb_ptr<block_list> src, dumb_ptr<block_list> target,
// 攻撃対象となりうるので攻撃 | Attack because it can be attacked
if (sd && sd->status.weapon == ItemLook::W_BOW)
{
- IOff0 aidx = sd->equip_index_maybe[EQUIP::ARROW];
- if (aidx.ok())
- {
- if (battle_config.arrow_decrement)
- pc_delitem(sd, aidx, 1, 0);
- }
- else
+ IOff0 widx = sd->equip_index_maybe[EQUIP::WEAPON];
+
+ OMATCH_BEGIN_SOME (sdidw, sd->inventory_data[widx])
{
- clif_arrow_fail(sd, 0);
- return ATK::ZERO;
+ if (!bool(sdidw->mode & ItemMode::DONT_USE_AMMO))
+ {
+ IOff0 aidx = sd->equip_index_maybe[EQUIP::ARROW];
+ if (aidx.ok())
+ {
+ if (battle_config.arrow_decrement)
+ pc_delitem(sd, aidx, 1, 0);
+ }
+ else
+ {
+ clif_arrow_fail(sd, 0);
+ return ATK::ZERO;
+ }
+ }
}
+ OMATCH_END ();
}
+
wd = battle_calc_weapon_attack(src, target, SkillID::ZERO, 0, 0);
// significantly increase injuries for hasted characters
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 9edf2af..a5bb2ba 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -4617,11 +4617,17 @@ RecvResult clif_parse_DropItem(Session *s, dumb_ptr<map_session_data> sd)
clif_displaymessage(sd->sess, "Can't drop items here."_s);
return rv;
}
- if (bool(itemdb_search(sd->status.inventory[fixed.ioff2.unshift()].nameid)->mode & ItemMode::NO_DROP))
+
+ OMATCH_BEGIN_SOME (sdidn, sd->inventory_data[fixed.ioff2.unshift()])
{
- clif_displaymessage(sd->sess, "This item can't be dropped."_s);
- return rv;
+ if (bool(sdidn->mode & ItemMode::NO_DROP))
+ {
+ clif_displaymessage(sd->sess, "This item can't be dropped."_s);
+ return rv;
+ }
}
+ OMATCH_END ();
+
if (sd->npc_id
|| sd->opt1 != Opt1::ZERO)
{
@@ -4901,11 +4907,16 @@ RecvResult clif_parse_TradeAddItem(Session *s, dumb_ptr<map_session_data> sd)
if (fixed.zeny_or_ioff2.index != 0 && !fixed.zeny_or_ioff2.ok())
return RecvResult::Error;
if (fixed.zeny_or_ioff2.ok())
- if (bool(itemdb_search(sd->status.inventory[fixed.zeny_or_ioff2.unshift()].nameid)->mode & ItemMode::NO_TRADE))
+ OMATCH_BEGIN_SOME (sdidn, sd->inventory_data[fixed.zeny_or_ioff2.unshift()])
{
- clif_displaymessage(sd->sess, "This item can't be traded."_s);
- return rv;
+ if (bool(sdidn->mode & ItemMode::NO_TRADE))
+ {
+ clif_displaymessage(sd->sess, "This item can't be traded."_s);
+ return rv;
+ }
}
+ OMATCH_END ();
+
trade_tradeadditem(sd, fixed.zeny_or_ioff2, fixed.amount);
return rv;
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index 7d3e62b..a6d3dda 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -1003,12 +1003,18 @@ int npc_selllist(dumb_ptr<map_session_data> sd,
if (!nameid ||
sd->status.inventory[item_list[i].ioff2.unshift()].amount < item_list[i].count)
return 1;
- if (bool(itemdb_search(nameid)->mode & ItemMode::NO_SELL_TO_NPC))
+
+ OMATCH_BEGIN_SOME (sdidn, sd->inventory_data[item_list[i].ioff2.unshift()])
{
- //clif_displaymessage(sd->sess, "This item can't be sold to an NPC."_s);
- // M+ already outputs "Unable to sell unsellable item." on return value 3.
- return 3;
+ if (bool(sdidn->mode & ItemMode::NO_SELL_TO_NPC))
+ {
+ //clif_displaymessage(sd->sess, "This item can't be sold to an NPC."_s);
+ // M+ already outputs "Unable to sell unsellable item." on return value 3.
+ return 3;
+ }
}
+ OMATCH_END ();
+
if (sd->trade_partner)
return 2; // cant sell while trading
z += static_cast<double>(itemdb_value_sell(nameid)) * item_list[i].count;
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 12af48f..cac3666 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -2404,8 +2404,12 @@ int pc_useitem(dumb_ptr<map_session_data> sd, IOff0 n)
}
P<const ScriptBuffer> script = borrow(*sdidn->use_script);
- clif_useitemack(sd, n, amount - 1, 1);
- pc_delitem(sd, n, 1, 1);
+
+ if (!bool(sdidn->mode & ItemMode::KEEP_AFTER_USE))
+ {
+ clif_useitemack(sd, n, amount - 1, 1);
+ pc_delitem(sd, n, 1, 1);
+ }
// activity
if (sd)
diff --git a/src/map/storage.cpp b/src/map/storage.cpp
index 54398f3..cab3f0f 100644
--- a/src/map/storage.cpp
+++ b/src/map/storage.cpp
@@ -186,11 +186,15 @@ int storage_storageadd(dumb_ptr<map_session_data> sd, IOff0 index, int amount)
if (amount < 1 || amount > sd->status.inventory[index].amount)
return 0;
- if (bool(itemdb_search(sd->status.inventory[index].nameid)->mode & ItemMode::NO_STORAGE))
+ OMATCH_BEGIN_SOME (sdidn, sd->inventory_data[index])
{
- clif_displaymessage(sd->sess, "This item can't be stored."_s);
- return 0;
+ if (bool(sdidn->mode & ItemMode::NO_STORAGE))
+ {
+ clif_displaymessage(sd->sess, "This item can't be stored."_s);
+ return 0;
+ }
}
+ OMATCH_END ();
// log_tostorage(sd, index, 0);
if (storage_additem(sd, stor, &sd->status.inventory[index], amount) == 0)
diff --git a/src/mmo/enums.hpp b/src/mmo/enums.hpp
index c4a1b17..377f7d7 100644
--- a/src/mmo/enums.hpp
+++ b/src/mmo/enums.hpp
@@ -135,6 +135,8 @@ enum class ItemMode : uint8_t
NO_TRADE = 2,
NO_SELL_TO_NPC = 4,
NO_STORAGE = 8,
+ KEEP_AFTER_USE = 16,
+ DONT_USE_AMMO = 32,
};
ENUM_BITWISE_OPERATORS(ItemMode)
}