This commit is contained in:
aozhiwei 2023-03-02 13:53:07 +08:00
parent 71123a3434
commit 077cc66182
3 changed files with 64 additions and 0 deletions

View File

@ -207,6 +207,7 @@ class Human : public Creature
a8::XTimerWp dead_timer;
int match_mode = 0;
std::shared_ptr<cs::MFThrow> throw_bomb;
std::map<int, std::shared_ptr<cs::MFThrow>> pending_throw_bomb;
std::string name;
std::string avatar_url;

View File

@ -1581,5 +1581,67 @@ void Player::InternalRevive(int target_uniid, int revive_coin)
void Player::UpdateThrowBomb()
{
if (downed) {
throw_bomb.reset();
return;
}
if (IsCar()) {
throw_bomb.reset();
return;
}
if (HasBuffEffect(kBET_Jump) ||
HasBuffEffect(kBET_Fly)) {
throw_bomb.reset();
return;
}
if (action_type == AT_Reload ||
action_type == AT_Rescue ||
action_type == AT_UseItem ||
action_type == AT_Relive) {
CancelAction();
throw_bomb.reset();
return;
}
const mt::Equip* equip_meta = mt::Equip::GetById(throw_bomb->weapon_id());
if (equip_meta && equip_meta->_inventory_slot() > 0) {
int slot_id = 0;
switch (equip_meta->_inventory_slot()) {
case IS_FRAG:
case IS_SMOKE:
{
slot_id = SPEC1_SLOT_BEGIN + equip_meta->_inventory_slot() - IS_FRAG;
}
break;
case IS_MOLOTOR_COCKTAIL:
{
slot_id = SPEC2_SLOT_BEGIN + equip_meta->_inventory_slot() - IS_MINE;
}
break;
default:
{
}
break;
}//end switch
if (slot_id > 0 && slot_id < weapons.size()) {
Weapon& weapon = weapons[slot_id];
if (weapon.weapon_idx != 0 &&
weapon.meta &&
weapon.ammo > 0) {
if (HasBuffEffect(kBET_Hide)) {
RemoveBuffByEffectId(kBET_Hide);
}
--weapon.ammo;
room->frame_event.AddPropChg
(
GetWeakPtrRef(),
kPropWeaponAmmo,
weapon.weapon_idx,
weapon.ammo,
true
);
}
}
}
throw_bomb.reset();
}

View File

@ -662,6 +662,7 @@ message MFThrow
optional MFVec3 pos = 3; //
optional MFVec3 dir = 4; //
optional float fly_distance = 5; //
optional int32 estimated_time = 6; //()
}
//