feat: add quiver ammunition rules and negotiated state sync
This commit is contained in:
@@ -99,6 +99,9 @@ enum EWeaponSubTypes
|
||||
WEAPON_FAN,
|
||||
WEAPON_ARROW,
|
||||
WEAPON_MOUNT_SPEAR,
|
||||
// PORT: preserve AVA2 numeric positions; reserving claw does not enable Wolfman.
|
||||
WEAPON_CLAW = 8,
|
||||
WEAPON_QUIVER = 9,
|
||||
WEAPON_NUM_TYPES,
|
||||
};
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ int get_Item_Type_Value(string inputString)
|
||||
int get_Item_SubType_Value(int type_value, string inputString)
|
||||
{
|
||||
static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
|
||||
"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR"};
|
||||
"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR", "WEAPON_CLAW", "WEAPON_QUIVER"};
|
||||
static string arSub2[] = { "ARMOR_BODY", "ARMOR_HEAD", "ARMOR_SHIELD", "ARMOR_WRIST", "ARMOR_FOOTS",
|
||||
"ARMOR_NECK", "ARMOR_EAR", "ARMOR_PENDANT", "ARMOR_NUM_TYPES"};
|
||||
static string arSub3[] = { "USE_POTION", "USE_TALISMAN", "USE_TUNING", "USE_MOVE", "USE_TREASURE_BOX", "USE_MONEYBAG", "USE_BAIT",
|
||||
|
||||
@@ -146,3 +146,5 @@ $(OBJDIR)/char.o $(OBJDIR)/cmd_general.o $(OBJDIR)/input_p2p.o $(OBJDIR)/p2p.o $
|
||||
|
||||
$(OBJDIR)/cmd_general.o: port_features.h port_rank_runtime.h
|
||||
$(OBJDIR)/char_battle.o $(OBJDIR)/char_skill.o: port_magic_reduction.h
|
||||
$(OBJDIR)/char_battle.o: port_quiver.h
|
||||
$(OBJDIR)/char.o: port_quiver.h port_quiver_sync.inc
|
||||
|
||||
@@ -70,6 +70,9 @@
|
||||
#include "PetSystem.h"
|
||||
#endif
|
||||
#include "DragonSoul.h"
|
||||
#include "item.h"
|
||||
#include "port_quiver.h"
|
||||
#include "port_quiver_sync.inc"
|
||||
|
||||
extern const BYTE g_aBuffOnAttrPoints;
|
||||
extern bool RaceToJob(unsigned race, unsigned *ret_job);
|
||||
@@ -137,6 +140,7 @@ CHARACTER::~CHARACTER()
|
||||
|
||||
void CHARACTER::Initialize()
|
||||
{
|
||||
m_portQuiverSync=false;
|
||||
CEntity::Initialize(ENTITY_CHARACTER);
|
||||
|
||||
m_bNoOpenedShop = true;
|
||||
@@ -984,6 +988,7 @@ void CHARACTER::EncodeInsertPacket(LPENTITY entity)
|
||||
}
|
||||
|
||||
d->Packet(&addPacket, sizeof(TPacketGCCharacterAdditionalInfo));
|
||||
PortSendQuiverState(ch);
|
||||
}
|
||||
|
||||
if (iDur)
|
||||
@@ -1132,6 +1137,7 @@ void CHARACTER::UpdatePacket()
|
||||
{
|
||||
PacketAround(&pack, sizeof(pack));
|
||||
}
|
||||
PortBroadcastQuiverState();
|
||||
}
|
||||
|
||||
LPCHARACTER CHARACTER::FindCharacterInView(const char * c_pszName, bool bFindPCOnly)
|
||||
|
||||
@@ -571,6 +571,10 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
|
||||
public:
|
||||
DWORD m_portFeatureLastQuery = 0; // PORT: read-only query throttle, not persisted.
|
||||
bool m_portQuiverSync = false; // PORT: only this character's negotiated client.
|
||||
void PortEnableQuiverSync();
|
||||
void PortSendQuiverState(LPCHARACTER viewer);
|
||||
void PortBroadcastQuiverState();
|
||||
bool m_portQuietInfo = false; // PORT: batch actions hold back per-item INFO lines...
|
||||
std::string m_portLastInfo; // ...keeping the last one to report a rejected item.
|
||||
DWORD m_portPickupLastCommand = 0; // PORT: batch pickup throttle.
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "port_battlepass_hooks.h"
|
||||
#include "ava2_itemshop.h"
|
||||
#include <algorithm>
|
||||
#include "port_quiver.h"
|
||||
DWORD AdjustExpByLevel(const LPCHARACTER ch, const DWORD exp)
|
||||
{
|
||||
if (PLAYER_EXP_TABLE_MAX < ch->GetLevel())
|
||||
@@ -2876,12 +2877,19 @@ int CHARACTER::GetArrowAndBow(LPITEM * ppkBow, LPITEM * ppkArrow, int iArrowCoun
|
||||
LPITEM pkArrow;
|
||||
|
||||
if (!(pkArrow = GetWear(WEAR_ARROW)) || pkArrow->GetType() != ITEM_WEAPON ||
|
||||
pkArrow->GetProto()->bSubType != WEAPON_ARROW)
|
||||
(pkArrow->GetProto()->bSubType != WEAPON_ARROW && pkArrow->GetProto()->bSubType != WEAPON_QUIVER))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
iArrowCount = MIN(iArrowCount, pkArrow->GetCount());
|
||||
if (pkArrow->GetSubType() == WEAPON_QUIVER)
|
||||
{
|
||||
if (!PortQuiverUsable(pkArrow))
|
||||
return 0;
|
||||
iArrowCount = MIN(iArrowCount, 200);
|
||||
}
|
||||
else
|
||||
iArrowCount = MIN(iArrowCount, pkArrow->GetCount());
|
||||
|
||||
*ppkBow = pkBow;
|
||||
*ppkArrow = pkArrow;
|
||||
@@ -2891,6 +2899,9 @@ int CHARACTER::GetArrowAndBow(LPITEM * ppkBow, LPITEM * ppkArrow, int iArrowCoun
|
||||
|
||||
void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)
|
||||
{
|
||||
if (pkArrow->GetSubType() == WEAPON_QUIVER)
|
||||
return;
|
||||
|
||||
int iCount = pkArrow->GetCount();
|
||||
DWORD dwVnum = pkArrow->GetVnum();
|
||||
iCount = iCount - MIN(iCount, dwArrowCount);
|
||||
|
||||
@@ -791,6 +791,8 @@ const int aiWeaponSocketQty[WEAPON_NUM_TYPES] =
|
||||
3, // WEAPON_FAN,
|
||||
0, // WEAPON_ARROW,
|
||||
0, // WEAPON_MOUNT_SPEAR
|
||||
3, // WEAPON_CLAW (numeric reservation)
|
||||
0, // WEAPON_QUIVER
|
||||
};
|
||||
|
||||
const int aiArmorSocketQty[ARMOR_NUM_TYPES] =
|
||||
|
||||
@@ -14,7 +14,7 @@ int CItem::GetAttributeSetIndex()
|
||||
{
|
||||
if (GetType() == ITEM_WEAPON)
|
||||
{
|
||||
if (GetSubType() == WEAPON_ARROW)
|
||||
if (GetSubType() == WEAPON_ARROW || GetSubType() == WEAPON_QUIVER)
|
||||
return -1;
|
||||
|
||||
return ATTRIBUTE_SET_WEAPON;
|
||||
|
||||
@@ -326,6 +326,7 @@ enum
|
||||
HEADER_GC_CHESTDROP = 66, // PORT: AVA2, DWORD dynamic length
|
||||
HEADER_GC_SWITCHBOT = 171, // AVA2 switchbot (port_switchbot.cpp)
|
||||
HEADER_GC_EXTENDED_POINTS = 218, // PORT: AVA2 64-bit gold
|
||||
HEADER_GC_PORT_QUIVER = 219, // PORT: negotiated, transient actor arrow subtype.
|
||||
#if defined(__BL_67_ATTR__)
|
||||
HEADER_GC_OPEN_67_ATTR = 242,
|
||||
#endif
|
||||
@@ -1002,6 +1003,14 @@ enum ECharacterEquipmentPart
|
||||
CHR_EQUIPPART_NUM,
|
||||
};
|
||||
|
||||
struct TPacketGCQuiverState
|
||||
{
|
||||
BYTE header;
|
||||
DWORD vid;
|
||||
BYTE type; // 0 none, 6 arrow, 9 quiver. No persistent character layout change.
|
||||
};
|
||||
static_assert(sizeof(TPacketGCQuiverState)==6,"quiver state wire size");
|
||||
|
||||
typedef struct packet_add_char
|
||||
{
|
||||
BYTE header;
|
||||
|
||||
@@ -47,7 +47,12 @@ ACMD(do_port_features) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 error %u rate",request);return;
|
||||
}
|
||||
ch->m_portFeatureLastQuery=get_dword_time();
|
||||
if(kind=="cap" && args.size()==3) {ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 cap %u 1 1983 %lld",request,(long long)get_global_time());return;}
|
||||
if(kind=="cap" && args.size()==3) {ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 cap %u 1 4031 %lld",request,(long long)get_global_time());return;}
|
||||
if(kind=="quiver" && args.size()==3) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 begin %u quiver 0 0 0 0 %lld",request,(long long)get_global_time());
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 end %u 0",request);
|
||||
ch->PortEnableQuiverSync();return;
|
||||
}
|
||||
if(kind=="dungeons" && args.size()==3) {PortDungeonQuery(ch,request);return;}
|
||||
if(kind=="bosses" && args.size()==3) {PortBossQuery(ch,request);return;}
|
||||
if(kind=="stats" && args.size()==3) {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef METIN2_PORT_QUIVER_H
|
||||
#define METIN2_PORT_QUIVER_H
|
||||
|
||||
// PORT: do not grant a shot during the gap before the generic expiry event.
|
||||
// Timer duration and first-use initialization still belong to the item system.
|
||||
static bool PortQuiverUsable(LPITEM item)
|
||||
{
|
||||
if (!item || item->GetCount() <= 0)
|
||||
return false;
|
||||
for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
|
||||
{
|
||||
const int type = item->GetLimitType(i);
|
||||
if ((type == LIMIT_REAL_TIME ||
|
||||
(type == LIMIT_REAL_TIME_START_FIRST_USE && item->GetSocket(1) != 0)) &&
|
||||
get_global_time() > item->GetSocket(0))
|
||||
return false;
|
||||
if (type == LIMIT_TIMER_BASED_ON_WEAR && item->GetSocket(0) <= 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
// Included after CHARACTER and item dependencies, never as persistent state.
|
||||
void CHARACTER::PortSendQuiverState(LPCHARACTER viewer)
|
||||
{
|
||||
if (!IsPC() || !viewer || !viewer->m_portQuiverSync || !viewer->GetDesc())
|
||||
return;
|
||||
if (IsObserverMode() && viewer != this)
|
||||
return;
|
||||
BYTE type=0;
|
||||
LPITEM ammo=GetWear(WEAR_ARROW);
|
||||
if (ammo && ammo->GetType()==ITEM_WEAPON && ammo->GetCount()>0)
|
||||
{
|
||||
if (ammo->GetSubType()==WEAPON_ARROW)
|
||||
type=WEAPON_ARROW;
|
||||
else if (ammo->GetSubType()==WEAPON_QUIVER && PortQuiverUsable(ammo))
|
||||
type=WEAPON_QUIVER;
|
||||
}
|
||||
TPacketGCQuiverState packet={HEADER_GC_PORT_QUIVER,GetVID(),type};
|
||||
viewer->GetDesc()->Packet(&packet,sizeof(packet));
|
||||
}
|
||||
|
||||
void CHARACTER::PortBroadcastQuiverState()
|
||||
{
|
||||
PortSendQuiverState(this);
|
||||
if (IsObserverMode())return;
|
||||
for (const auto& entry:m_map_view)
|
||||
if (entry.first && entry.first->IsType(ENTITY_CHARACTER))
|
||||
PortSendQuiverState(static_cast<LPCHARACTER>(entry.first));
|
||||
}
|
||||
|
||||
void CHARACTER::PortEnableQuiverSync()
|
||||
{
|
||||
m_portQuiverSync=true;
|
||||
PortSendQuiverState(this);
|
||||
for (const auto& entry:m_map_view)
|
||||
if (entry.first && entry.first!=this && entry.first->IsType(ENTITY_CHARACTER))
|
||||
static_cast<LPCHARACTER>(entry.first)->PortSendQuiverState(this);
|
||||
}
|
||||
Reference in New Issue
Block a user