添加连续加载子弹功能
This commit is contained in:
parent
dfac21df80
commit
4e7ddfa237
@ -4102,13 +4102,34 @@ void Human::ProcReloadAction()
|
|||||||
if (GetInventory(bullet_meta->i->_inventory_slot()) <=
|
if (GetInventory(bullet_meta->i->_inventory_slot()) <=
|
||||||
p_weapon->GetClipVolume() - ammo) {
|
p_weapon->GetClipVolume() - ammo) {
|
||||||
add_num = GetInventory(bullet_meta->i->_inventory_slot());
|
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);
|
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
||||||
} else {
|
} else {
|
||||||
add_num = p_weapon->GetClipVolume() - ammo;
|
add_num = p_weapon->GetClipVolume() - ammo;
|
||||||
|
if (p_weapon->meta->i->reloadtype() == 1) {
|
||||||
|
add_num = 1;
|
||||||
|
}
|
||||||
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
||||||
}
|
}
|
||||||
p_weapon->ammo += 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -337,6 +337,7 @@ private:
|
|||||||
void OnMetaChange();
|
void OnMetaChange();
|
||||||
void OnChgToTerminator();
|
void OnChgToTerminator();
|
||||||
void ProcReloadAction();
|
void ProcReloadAction();
|
||||||
|
void NextReload(int prev_weapon_id, int prev_weapon_idx);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int level_ = 0;
|
int level_ = 0;
|
||||||
|
@ -95,6 +95,7 @@ message Equip
|
|||||||
optional int32 drop_id = 40;
|
optional int32 drop_id = 40;
|
||||||
optional int32 explosion_effect = 42;
|
optional int32 explosion_effect = 42;
|
||||||
optional string param1 = 43;
|
optional string param1 = 43;
|
||||||
|
optional int32 reloadtype = 46;
|
||||||
|
|
||||||
optional string inventory_slot = 31; //库存槽位
|
optional string inventory_slot = 31; //库存槽位
|
||||||
optional int32 _inventory_slot = 32; //库存槽位
|
optional int32 _inventory_slot = 32; //库存槽位
|
||||||
|
Loading…
x
Reference in New Issue
Block a user