添加连续加载子弹功能

This commit is contained in:
aozhiwei 2021-01-06 16:50:27 +08:00
parent 18aa9f350e
commit 5523ca6169
3 changed files with 48 additions and 1 deletions

View File

@ -4156,13 +4156,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_
);
}
}
}
}
@ -4220,3 +4241,27 @@ void Human::OnLand()
SetPos(old_pos);
}
}
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

@ -343,6 +343,7 @@ private:
void ProcReloadAction();
void OnBuffRemove(const Buff& buff);
void OnLand();
void NextReload(int prev_weapon_id, int prev_weapon_idx);
protected:
int level_ = 0;

View File

@ -100,6 +100,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; //