添加连续加载子弹功能

This commit is contained in:
aozhiwei 2021-01-06 16:50:12 +08:00
parent dfac21df80
commit 4e7ddfa237
3 changed files with 48 additions and 1 deletions

View File

@ -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();
}
}
}
}
}
}

View File

@ -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;

View File

@ -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; //