diff --git a/server/gameserver/android.ai.cc b/server/gameserver/android.ai.cc index 9d00ed8..44eeb17 100644 --- a/server/gameserver/android.ai.cc +++ b/server/gameserver/android.ai.cc @@ -186,11 +186,9 @@ void AndroidAI::DoMoveOldAI() if (hum->room->IsWaitingStart()) { return; } - #if 0 if (hum->HasBuffEffect(kBET_Jump)) { return; } - #endif if (owner->UpdatedTimes() % 2 == 0) { Human* hum = (Human*)owner; int speed = std::max(1, (int)hum->GetSpeed()); diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 4209ea4..3a00e33 100644 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -228,6 +228,8 @@ enum EquipType_e { EQUIP_TYPE_WEAPON = 1, EQUIP_TYPE_BULLET = 2, + EQUIP_TYPE_PROTECTION = 4, + EQUIP_TYPE_BAG = 7, EQUIP_TYPE_OLDSKIN = 8, EQUIP_TYPE_CAR = 9, EQUIP_TYPE_SKIN = 10, diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 32f3c79..356f11e 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -38,7 +38,6 @@ const int kReviveTimeAdd = 12; const int kSkinNum = 4; -const int kREVIVE_BUFF_ID = 0; Human::Human():Creature() { @@ -2147,7 +2146,7 @@ void Human::SendBattleReport() delete params; } -void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta) +void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta, bool& handled) { switch (item_meta->i->equip_subtype()) { case 11: @@ -2187,19 +2186,22 @@ void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta) } break; } + handled = true; } -void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta) +void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta, bool& handled) { DoGetOn(entity->GetUniId()); + handled = true; } -void Human::ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta) +void Human::ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta, bool& handled) { AddItem(item_meta->i->id(), 1); + handled = true; } -void Human::ProcSpoils(Loot* entity, MetaData::Equip* item_meta) +void Human::ProcSpoils(Loot* entity, MetaData::Equip* item_meta, bool& handled) { if (spoils_items.find(item_meta->i->id()) != spoils_items.end()) { @@ -2207,6 +2209,7 @@ void Human::ProcSpoils(Loot* entity, MetaData::Equip* item_meta) } else { spoils_items[item_meta->i->id()] = entity->count; } + handled = true; } void Human::OnDie() @@ -3572,3 +3575,194 @@ void Human::StartRefreshViewTimer() hum->refresh_view_timer_ = nullptr; }); } + +void Human::ProcLootBag(Loot* entity, MetaData::Equip* item_meta, bool& handled) +{ + MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(backpack); + if (old_item_meta) { + if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) { + return; + } + room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1); + } + backpack = item_meta->i->id(); + RecalcVolume(); + handled = true; +} + +void Human::ProcLootProtection(Loot* entity, MetaData::Equip* item_meta, bool& handled) +{ + if (item_meta->i->equip_subtype() == 1) { + //盔甲 + MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(chest); + if (old_item_meta) { + if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) { + return; + } + room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1); + } + chest = item_meta->i->id(); + RecalcBaseAttr(); + } else if (item_meta->i->equip_subtype() == 2) { + //头盔 + MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(helmet); + if (old_item_meta) { + if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) { + return; + } + room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1); + } + helmet = item_meta->i->id(); + RecalcBaseAttr(); + } + handled = true; +} + +void Human::ProcLootSpecItem(Loot* entity, MetaData::Equip* item_meta, bool& handled) +{ + if (item_meta->i->_inventory_slot() >= 0 && + item_meta->i->_inventory_slot() < IS_END) { + if (GetInventory(item_meta->i->_inventory_slot()) >= + GetVolume(item_meta->i->_inventory_slot()) + ) { + return; + } + int add_num = GetVolume(item_meta->i->_inventory_slot()) - + GetInventory(item_meta->i->_inventory_slot()); + add_num = std::min(entity->count, add_num); + + AddInventory(item_meta->i->_inventory_slot(), add_num); + switch (item_meta->i->_inventory_slot()) { + case IS_FRAG: + case IS_SMOKE: + { + Weapon* weapon = &weapons[SPEC1_SLOT_BEGIN + + (item_meta->i->_inventory_slot() - SPEC1_IS_BEGIN) + ]; + weapon->weapon_id = entity->item_id; + weapon->weapon_lv = 1; + weapon->ammo += entity->count; + weapon->meta = item_meta; + weapon->Recalc(); +#if 0 + DecInventory(item_meta->i->_inventory_slot(), add_num); +#endif + } + break; + case IS_1XSCOPE: + case IS_2XSCOPE: + case IS_4XSCOPE: + case IS_8XSCOPE: + case IS_15XSCOPE: + { + if (item_meta->i->_inventory_slot() - IS_1XSCOPE > curr_scope_idx) { + curr_scope_idx = item_meta->i->_inventory_slot() - IS_1XSCOPE; + } + } + break; + case IS_POSION_GAS_BOMB: + case IS_MOLOTOR_COCKTAIL: + case IS_TRAP: + case IS_MINE: + { + Weapon* weapon = &weapons[SPEC2_SLOT_BEGIN + + (item_meta->i->_inventory_slot() - SPEC2_IS_BEGIN) + ]; + weapon->weapon_id = entity->item_id; + weapon->weapon_lv = 1; + weapon->ammo += entity->count; + weapon->meta = item_meta; + weapon->Recalc(); +#if 0 + DecInventory(item_meta->i->_inventory_slot(), add_num); +#endif + } + break; + case IS_C4: + case IS_SHIELD_WALL: + case IS_SINGAL_GUN: + case IS_OIL_BUCKET: + { + Weapon* weapon = &weapons[SPEC3_SLOT_BEGIN + + (item_meta->i->_inventory_slot() - SPEC3_IS_BEGIN) + ]; + weapon->weapon_id = entity->item_id; + weapon->weapon_lv = 1; + weapon->ammo += entity->count; + weapon->meta = item_meta; + weapon->Recalc(); +#if 0 + DecInventory(item_meta->i->_inventory_slot(), add_num); +#endif + } + break; + default: + { + int i = 0; +#if 0 + abort(); +#endif + } + break; + } + if (add_num < entity->count) { + //刷新数量 + entity->count -= add_num; + entity->BroadcastFullState(room); + return; + } + } + if (action_type == AT_None) { + AutoLoadingBullet(); + } + need_sync_active_player = true; + SyncAroundPlayers(__FILE__, __LINE__, __func__); + handled = true; +} + +void Human::ProcLootWeapon(Loot* entity, MetaData::Equip* item_meta, bool& handled) +{ + //装备 + if (item_meta->i->equip_subtype() == 1) { + //近战 + if (default_weapon.weapon_id != weapons[0].weapon_id) { + return; + } else { + weapons[0].weapon_idx = 0; + weapons[0].weapon_id = entity->item_id; + weapons[0].weapon_lv = std::max(1, entity->item_level); + weapons[0].ammo = 0; + weapons[0].meta = item_meta; + weapons[0].Recalc(); + } + need_sync_active_player = true; + SyncAroundPlayers(__FILE__, __LINE__, __func__); + } else { + if (FreezeOperate()) { + return; + } + bool switch_gun = false; + Weapon* weapon = TakeonWeapon(item_meta); + if (weapon && GetCurrWeapon() != weapon) { + switch_gun = true; + } + if (!weapon) { + return; + } + weapon->weapon_id = entity->item_id; + weapon->weapon_lv = std::max(1, entity->item_level); + weapon->ammo = 0; + weapon->meta = item_meta; + weapon->Recalc(); + if (HasBuffEffect(kBET_Car)) { + } else { + AutoLoadingBullet(); + } + if (switch_gun) { + SetCurrWeapon(weapon); + } + need_sync_active_player = true; + SyncAroundPlayers(__FILE__, __LINE__, __func__); + } + handled = true; +} diff --git a/server/gameserver/human.h b/server/gameserver/human.h index d446e5d..6866929 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -272,10 +272,14 @@ class Human : public Creature protected: void _InternalUpdateMove(float speed); - void ProcLootSkin(Loot* entity, MetaData::Equip* item_meta); - void ProcLootCar(Loot* entity, MetaData::Equip* item_meta); - void ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta); - void ProcSpoils(Loot* entity, MetaData::Equip* item_meta); + void ProcLootWeapon(Loot* entity, MetaData::Equip* item_meta, bool& handled); + void ProcLootSkin(Loot* entity, MetaData::Equip* item_meta, bool& handled); + void ProcLootCar(Loot* entity, MetaData::Equip* item_meta, bool& handled); + void ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta, bool& handled); + void ProcSpoils(Loot* entity, MetaData::Equip* item_meta, bool& handled); + void ProcLootBag(Loot* entity, MetaData::Equip* item_meta, bool& handled); + void ProcLootProtection(Loot* entity, MetaData::Equip* item_meta, bool& handled); + void ProcLootSpecItem(Loot* entity, MetaData::Equip* item_meta, bool& handled); void CancelRevive(); Weapon* TakeonWeapon(MetaData::Equip* equip_meta); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index c48091d..c02b36c 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -63,11 +63,6 @@ void Player::InternalUpdate(int delta_time) if (HasBuffEffect(kBET_Fly)) { SetPos(room->plane.curr_pos); room->grid_service->MoveCreature(this); - #ifdef DEBUG - if (GetCar() && GetCar()->IsDriver(this)) { - GetCar()->SyncPos(); - } - #endif } if (HasSpecMove()) { _UpdateSpecMove(); @@ -265,11 +260,7 @@ void Player::UpdateShot() ) { Shot(); } -#if 1 if (room->GetFrameNo() - last_cmmove_frameno >= 4) { -#else - if (series_shot_frames > 8) { -#endif shot_hold = false; series_shot_frames = 0; } @@ -518,61 +509,21 @@ void Player::LootInteraction(Loot* entity) if (!item_meta) { return; } + bool handled = false; switch (item_meta->i->equip_type()) { case EQUIP_TYPE_WEAPON: { - //装备 - if (item_meta->i->equip_subtype() == 1) { - //近战 - if (default_weapon.weapon_id != weapons[0].weapon_id) { - /* - cs::SMPickup notifymsg; - notifymsg.set_error_code(2); - SendNotifyMsg(notifymsg); - */ - return; - } else { - weapons[0].weapon_idx = 0; - weapons[0].weapon_id = entity->item_id; - weapons[0].weapon_lv = std::max(1, entity->item_level); - weapons[0].ammo = 0; - weapons[0].meta = item_meta; - weapons[0].Recalc(); - } - need_sync_active_player = true; - SyncAroundPlayers(__FILE__, __LINE__, __func__); - } else { - if (FreezeOperate()) { - return; - } - bool switch_gun = false; - Weapon* weapon = TakeonWeapon(item_meta); - if (weapon && GetCurrWeapon() != weapon) { - switch_gun = true; - } - if (!weapon) { - /* - cs::SMPickup notifymsg; - notifymsg.set_error_code(2); - SendNotifyMsg(notifymsg); - */ - return; - } - weapon->weapon_id = entity->item_id; - weapon->weapon_lv = std::max(1, entity->item_level); - weapon->ammo = 0; - weapon->meta = item_meta; - weapon->Recalc(); - if (HasBuffEffect(kBET_Car)) { - } else { - AutoLoadingBullet(); - } - if (switch_gun) { - SetCurrWeapon(weapon); - } - need_sync_active_player = true; - SyncAroundPlayers(__FILE__, __LINE__, __func__); - } + ProcLootWeapon(entity, item_meta, handled); + } + break; + case EQUIP_TYPE_PROTECTION: + { + ProcLootProtection(entity, item_meta, handled); + } + break; + case EQUIP_TYPE_BAG: + { + ProcLootBag(entity, item_meta, handled); } break; case EQUIP_TYPE_OLDSKIN: @@ -582,189 +533,46 @@ void Player::LootInteraction(Loot* entity) break; case EQUIP_TYPE_SKIN: { - ProcLootSkin(entity, item_meta); + ProcLootSkin(entity, item_meta, handled); } break; case EQUIP_TYPE_CAR: { - ProcLootCar(entity, item_meta); + ProcLootCar(entity, item_meta, handled); } break; case EQUIP_TYPE_CAMOUFLAGE: { - ProcCamoutflage(entity, item_meta); + ProcCamoutflage(entity, item_meta, handled); } break; case EQUIP_TYPE_SPOILS: { - ProcSpoils(entity, item_meta); + ProcSpoils(entity, item_meta, handled); } break; default: { - if (item_meta->i->_inventory_slot() >= 0 && - item_meta->i->_inventory_slot() < IS_END) { - if (GetInventory(item_meta->i->_inventory_slot()) >= - GetVolume(item_meta->i->_inventory_slot()) - ) { - /* - cs::SMPickup notifymsg; - notifymsg.set_error_code(1); - SendNotifyMsg(notifymsg); - */ - return; - } - int add_num = GetVolume(item_meta->i->_inventory_slot()) - - GetInventory(item_meta->i->_inventory_slot()); - add_num = std::min(entity->count, add_num); - - AddInventory(item_meta->i->_inventory_slot(), add_num); - switch (item_meta->i->_inventory_slot()) { - case IS_FRAG: - case IS_SMOKE: - { - Weapon* weapon = &weapons[SPEC1_SLOT_BEGIN + - (item_meta->i->_inventory_slot() - SPEC1_IS_BEGIN) - ]; - weapon->weapon_id = entity->item_id; - weapon->weapon_lv = 1; - weapon->ammo += entity->count; - weapon->meta = item_meta; - weapon->Recalc(); - #if 0 - DecInventory(item_meta->i->_inventory_slot(), add_num); - #endif - } - break; - case IS_1XSCOPE: - case IS_2XSCOPE: - case IS_4XSCOPE: - case IS_8XSCOPE: - case IS_15XSCOPE: - { - if (item_meta->i->_inventory_slot() - IS_1XSCOPE > curr_scope_idx) { - curr_scope_idx = item_meta->i->_inventory_slot() - IS_1XSCOPE; - } - } - break; - case IS_POSION_GAS_BOMB: - case IS_MOLOTOR_COCKTAIL: - case IS_TRAP: - case IS_MINE: - { - Weapon* weapon = &weapons[SPEC2_SLOT_BEGIN + - (item_meta->i->_inventory_slot() - SPEC2_IS_BEGIN) - ]; - weapon->weapon_id = entity->item_id; - weapon->weapon_lv = 1; - weapon->ammo += entity->count; - weapon->meta = item_meta; - weapon->Recalc(); - #if 0 - DecInventory(item_meta->i->_inventory_slot(), add_num); - #endif - } - break; - case IS_C4: - case IS_SHIELD_WALL: - case IS_SINGAL_GUN: - case IS_OIL_BUCKET: - { - Weapon* weapon = &weapons[SPEC3_SLOT_BEGIN + - (item_meta->i->_inventory_slot() - SPEC3_IS_BEGIN) - ]; - weapon->weapon_id = entity->item_id; - weapon->weapon_lv = 1; - weapon->ammo += entity->count; - weapon->meta = item_meta; - weapon->Recalc(); - #if 0 - DecInventory(item_meta->i->_inventory_slot(), add_num); - #endif - } - break; - default: - { - int i = 0; - #if 0 - abort(); - #endif - } - break; - } - if (add_num < entity->count) { - //刷新数量 - entity->count -= add_num; - entity->BroadcastFullState(room); - return; - } - } else { - switch (item_meta->i->equip_type()) { - case 7: - { - //背包 - MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(backpack); - if (old_item_meta) { - if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) { - return; - } - room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1); - } - backpack = item_meta->i->id(); - RecalcVolume(); - } - break; - case 4: - { - //防具 - if (item_meta->i->equip_subtype() == 1) { - //盔甲 - MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(chest); - if (old_item_meta) { - if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) { - return; - } - room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1); - } - chest = item_meta->i->id(); - RecalcBaseAttr(); - } else if (item_meta->i->equip_subtype() == 2) { - //头盔 - MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(helmet); - if (old_item_meta) { - if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) { - return; - } - room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1); - } - helmet = item_meta->i->id(); - RecalcBaseAttr(); - } - } - break; - } - } - if (action_type == AT_None) { - AutoLoadingBullet(); - } - need_sync_active_player = true; - SyncAroundPlayers(__FILE__, __LINE__, __func__); + ProcLootSpecItem(entity, item_meta, handled); } break; } - entity->pickuped = true; - room->RemoveObjectLater(entity); - if (entity->dummy_thing_uniid != 0) { - Entity* dummy_obj = room->GetEntityByUniId(entity->dummy_thing_uniid); - if (dummy_obj && dummy_obj->GetEntityType() == ET_Obstacle) { - Obstacle* obstacle = (Obstacle*)dummy_obj; - if (!obstacle->IsPermanent()) { - if (!obstacle->IsDead(room)) { - obstacle->Die(room); - obstacle->BroadcastFullState(room); + + if (handled) { + entity->pickuped = true; + room->RemoveObjectLater(entity); + if (entity->dummy_thing_uniid != 0) { + Entity* dummy_obj = room->GetEntityByUniId(entity->dummy_thing_uniid); + if (dummy_obj && dummy_obj->GetEntityType() == ET_Obstacle) { + Obstacle* obstacle = (Obstacle*)dummy_obj; + if (!obstacle->IsPermanent()) { + if (!obstacle->IsDead(room)) { + obstacle->Die(room); + obstacle->BroadcastFullState(room); + } + room->RemoveObjectLater((RoomObstacle*)obstacle); } - room->RemoveObjectLater((RoomObstacle*)obstacle); } } }