添加机甲装弹逻辑
This commit is contained in:
parent
759d7c3724
commit
eac8e243ec
@ -470,6 +470,22 @@ void Human::CarShot(a8::Vec2& target_dir)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (car_weapon.weapon_idx != 0 &&
|
||||||
|
car_weapon.ammo <= 0) {
|
||||||
|
AutoLoadingBullet();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action_type == AT_Reload) {
|
||||||
|
CancelAction();
|
||||||
|
}
|
||||||
|
if (action_type == AT_Reload ||
|
||||||
|
action_type == AT_Rescue ||
|
||||||
|
action_type == AT_UseItem ||
|
||||||
|
action_type == AT_Relive) {
|
||||||
|
CancelAction();
|
||||||
|
}
|
||||||
|
|
||||||
InternalShot(this,
|
InternalShot(this,
|
||||||
car_weapon.meta,
|
car_weapon.meta,
|
||||||
car_weapon.GetUpgradeMeta(),
|
car_weapon.GetUpgradeMeta(),
|
||||||
@ -479,6 +495,7 @@ void Human::CarShot(a8::Vec2& target_dir)
|
|||||||
5,
|
5,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
--car_weapon.ammo;
|
||||||
last_shot_frameno_ = room->GetFrameNo();
|
last_shot_frameno_ = room->GetFrameNo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,11 +814,15 @@ void Human::SyncAroundPlayers(const char* file, int line, const char* func)
|
|||||||
|
|
||||||
void Human::AutoLoadingBullet(bool manual)
|
void Human::AutoLoadingBullet(bool manual)
|
||||||
{
|
{
|
||||||
if (curr_weapon->weapon_idx != 0 &&
|
Weapon* p_weapon = curr_weapon;
|
||||||
(curr_weapon->ammo <= 0 ||
|
if (car_weapon.meta) {
|
||||||
(manual && curr_weapon->ammo < curr_weapon->GetClipVolume()))
|
p_weapon = &car_weapon;
|
||||||
|
}
|
||||||
|
if (p_weapon->weapon_idx != 0 &&
|
||||||
|
(p_weapon->ammo <= 0 ||
|
||||||
|
(manual && p_weapon->ammo < p_weapon->GetClipVolume()))
|
||||||
) {
|
) {
|
||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(p_weapon->meta->i->use_bullet());
|
||||||
if (bullet_meta &&
|
if (bullet_meta &&
|
||||||
bullet_meta->i->_inventory_slot() >= 0 &&
|
bullet_meta->i->_inventory_slot() >= 0 &&
|
||||||
bullet_meta->i->_inventory_slot() < (int)inventory_.size()
|
bullet_meta->i->_inventory_slot() < (int)inventory_.size()
|
||||||
@ -811,9 +832,9 @@ void Human::AutoLoadingBullet(bool manual)
|
|||||||
on_loading_bullet();
|
on_loading_bullet();
|
||||||
}
|
}
|
||||||
StartAction(AT_Reload,
|
StartAction(AT_Reload,
|
||||||
curr_weapon->meta->i->reload_time(),
|
p_weapon->meta->i->reload_time(),
|
||||||
curr_weapon->weapon_id,
|
p_weapon->weapon_id,
|
||||||
curr_weapon->weapon_idx);
|
p_weapon->weapon_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1695,32 +1716,7 @@ void Human::UpdateAction()
|
|||||||
switch (action_type) {
|
switch (action_type) {
|
||||||
case AT_Reload:
|
case AT_Reload:
|
||||||
{
|
{
|
||||||
if (curr_weapon->weapon_idx == action_target_id &&
|
ProcReloadAction();
|
||||||
curr_weapon->weapon_id == action_item_id &&
|
|
||||||
curr_weapon->weapon_idx != 0) {
|
|
||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
|
|
||||||
if (bullet_meta) {
|
|
||||||
int ammo = curr_weapon->ammo;
|
|
||||||
if (ammo < curr_weapon->GetClipVolume()) {
|
|
||||||
if (bullet_meta->i->_inventory_slot() >= 0 &&
|
|
||||||
bullet_meta->i->_inventory_slot() < IS_END) {
|
|
||||||
if (GetInventory(bullet_meta->i->_inventory_slot()) > 0) {
|
|
||||||
int add_num = 0;
|
|
||||||
if (GetInventory(bullet_meta->i->_inventory_slot()) <=
|
|
||||||
curr_weapon->GetClipVolume() - ammo) {
|
|
||||||
add_num = GetInventory(bullet_meta->i->_inventory_slot());
|
|
||||||
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
|
||||||
} else {
|
|
||||||
add_num = curr_weapon->GetClipVolume() - ammo;
|
|
||||||
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
|
||||||
}
|
|
||||||
curr_weapon->ammo += add_num;
|
|
||||||
need_sync_active_player = true;;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AT_UseItem:
|
case AT_UseItem:
|
||||||
@ -3952,3 +3948,39 @@ void Human::OnChgToTerminator()
|
|||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Human::ProcReloadAction()
|
||||||
|
{
|
||||||
|
Weapon* p_weapon = curr_weapon;
|
||||||
|
if (car_weapon.meta) {
|
||||||
|
p_weapon = &car_weapon;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_weapon->weapon_idx == action_target_id &&
|
||||||
|
p_weapon->weapon_id == action_item_id &&
|
||||||
|
p_weapon->weapon_idx != 0) {
|
||||||
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(p_weapon->meta->i->use_bullet());
|
||||||
|
if (bullet_meta) {
|
||||||
|
int ammo = p_weapon->ammo;
|
||||||
|
if (ammo < p_weapon->GetClipVolume()) {
|
||||||
|
if (bullet_meta->i->_inventory_slot() >= 0 &&
|
||||||
|
bullet_meta->i->_inventory_slot() < IS_END) {
|
||||||
|
if (GetInventory(bullet_meta->i->_inventory_slot()) > 0) {
|
||||||
|
int add_num = 0;
|
||||||
|
if (GetInventory(bullet_meta->i->_inventory_slot()) <=
|
||||||
|
p_weapon->GetClipVolume() - ammo) {
|
||||||
|
add_num = GetInventory(bullet_meta->i->_inventory_slot());
|
||||||
|
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
||||||
|
} else {
|
||||||
|
add_num = p_weapon->GetClipVolume() - ammo;
|
||||||
|
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
||||||
|
}
|
||||||
|
p_weapon->ammo += add_num;
|
||||||
|
need_sync_active_player = true;;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -331,6 +331,7 @@ private:
|
|||||||
void AddPassiveSkillBuff(MetaData::Skill* skill_meta);
|
void AddPassiveSkillBuff(MetaData::Skill* skill_meta);
|
||||||
void OnMetaChange();
|
void OnMetaChange();
|
||||||
void OnChgToTerminator();
|
void OnChgToTerminator();
|
||||||
|
void ProcReloadAction();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int level_ = 0;
|
int level_ = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user