From 4e7ddfa23773b6a4925cf5f4d6b13a97eb44db27 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 6 Jan 2021 16:50:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=9E=E7=BB=AD=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=AD=90=E5=BC=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/human.cc | 47 ++++++++++++++++++++++++- server/gameserver/human.h | 1 + server/tools/protobuild/metatable.proto | 1 + 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 96d1e5a..ab39bb2 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -4102,13 +4102,34 @@ void Human::ProcReloadAction() if (GetInventory(bullet_meta->i->_inventory_slot()) <= p_weapon->GetClipVolume() - ammo) { add_num = GetInventory(bullet_meta->i->_inventory_slot()); + if (p_weapon->meta->i->reloadtype() == 1) { + add_num = 1; + } DecInventory(bullet_meta->i->_inventory_slot(), add_num); } else { add_num = p_weapon->GetClipVolume() - ammo; + if (p_weapon->meta->i->reloadtype() == 1) { + add_num = 1; + } DecInventory(bullet_meta->i->_inventory_slot(), add_num); } p_weapon->ammo += add_num; - need_sync_active_player = true;; + need_sync_active_player = true; + if (p_weapon->meta->i->reloadtype() == 1) { + room->xtimer.AddDeadLineTimerAndAttach + (1, + a8::XParams() + .SetSender(this) + .SetParam1(p_weapon->weapon_idx) + .SetParam2(p_weapon->weapon_id), + [] (const a8::XParams& param) + { + Human* hum = (Human*)param.sender.GetUserData(); + hum->NextReload(param.param2, param.param1); + }, + &xtimer_attacher.timer_list_ + ); + } } } } @@ -4116,3 +4137,27 @@ void Human::ProcReloadAction() } } + +void Human::NextReload(int prev_weapon_id, int prev_weapon_idx) +{ + Weapon* p_weapon = curr_weapon; + if (car_weapon.meta) { + p_weapon = &car_weapon; + } + if (p_weapon && + p_weapon->weapon_id == prev_weapon_id && + p_weapon->weapon_idx == prev_weapon_idx) { + if (p_weapon->weapon_idx != 0 && + p_weapon->ammo < p_weapon->GetClipVolume()) { + MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(p_weapon->meta->i->use_bullet()); + if (bullet_meta) { + if (bullet_meta->i->_inventory_slot() >= 0 && + bullet_meta->i->_inventory_slot() < IS_END) { + if (GetInventory(bullet_meta->i->_inventory_slot()) > 0) { + AutoLoadingBullet(); + } + } + } + } + } +} diff --git a/server/gameserver/human.h b/server/gameserver/human.h index b6b32d5..b2f3fe7 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -337,6 +337,7 @@ private: void OnMetaChange(); void OnChgToTerminator(); void ProcReloadAction(); + void NextReload(int prev_weapon_id, int prev_weapon_idx); protected: int level_ = 0; diff --git a/server/tools/protobuild/metatable.proto b/server/tools/protobuild/metatable.proto index 112126c..b62c7bb 100755 --- a/server/tools/protobuild/metatable.proto +++ b/server/tools/protobuild/metatable.proto @@ -95,6 +95,7 @@ message Equip optional int32 drop_id = 40; optional int32 explosion_effect = 42; optional string param1 = 43; + optional int32 reloadtype = 46; optional string inventory_slot = 31; //库存槽位 optional int32 _inventory_slot = 32; //库存槽位