This commit is contained in:
aozhiwei 2022-11-16 16:09:38 +08:00
parent f4a36094e5
commit 1c28033fee
6 changed files with 26 additions and 5 deletions

View File

@ -4155,12 +4155,13 @@ void Human::ProcAddItemDto(AddItemDTO& dto)
}
}
void Human::DropWeapon(int weapon_idx)
void Human::DropWeapon(int weapon_idx, int num)
{
if (weapon_idx < 0 ||
weapon_idx >= weapons.size()) {
return;
}
num = std::max(1, num);
bool drop_ok = false;
Weapon* weapon = &weapons[weapon_idx];
int weapon_id = weapon->weapon_id;
@ -4238,6 +4239,24 @@ void Human::DropWeapon(int weapon_idx)
break;
default:
{
weapon_ammo = std::min(weapon->ammo, num);
if (weapon_ammo > 0) {
drop_ok = true;
weapon->ammo = std::max(0, weapon->ammo - weapon_ammo);
if (weapon->ammo <= 0) {
*weapon = Weapon();
weapon->weapon_idx = weapon_idx;
if (GetCurrWeapon() == weapon) {
Weapon* next_weapon = ChooseNextSpecWeapon(weapon_idx);
if (!next_weapon) {
next_weapon = AutoChgWeapon();
}
if (next_weapon) {
SetCurrWeapon(next_weapon);
}
}
}
}
}
break;
}

View File

@ -367,7 +367,7 @@ protected:
Weapon* TakeonWeapon(MetaData::Equip* equip_meta);
void LootInteraction(Loot* entity);
void ProcAddItemDto(AddItemDTO& dto);
void DropWeapon(int weapon_idx);
void DropWeapon(int weapon_idx, int num);
private:
void GenBattleReportData(a8::MutableXObject* params);

View File

@ -855,6 +855,7 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
if (msg.has_drop_weapon()) {
drop_weapon = true;
drop_weapon_idx = msg.drop_weapon();
drop_num = msg.drop_num();
}
if (msg.has_use_scope()) {
use_scope = true;
@ -1067,9 +1068,8 @@ void Player::UpdateDropWeapon()
{
if (drop_weapon_idx >= 0 &&
drop_weapon_idx < weapons.size() &&
!HasBuffEffect(kBET_Terminator) &&
!FreezeOperate()) {
DropWeapon(drop_weapon_idx);
DropWeapon(drop_weapon_idx, drop_num);
}
ResetAction();
AutoLoadingBullet();

View File

@ -39,6 +39,7 @@ class Player : public Human
bool drop_weapon = false;
size_t drop_weapon_idx = 0;
size_t drop_num = 0;
bool cancel_action = false;

View File

@ -951,6 +951,7 @@ message CMMove
optional int32 select_weapon = 8; //()
optional int32 drop_weapon = 9; //
optional int32 drop_num = 43; //()
optional bool cancel_action = 10; //(使)
optional int32 use_item_idx = 11; //使0-16