diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 1a9e52e..cba2b4e 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -112,6 +112,7 @@ enum VirtualWeapon_e VW_Spectate = 9000001, VW_SelfDetonate = 9000002, VW_Mine = 9000003, + VW_Tank = 9000004, }; enum VirtualPlayer_e diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 082ff91..0672f83 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -762,15 +762,25 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) ((Human*)hum)->stats.kills++; ((Human*)hum)->kill_humans.insert(this); ((Human*)hum)->SyncAroundPlayers(); - MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(weapon_id); - if (equip_meta) { + if (weapon_id == VW_Tank) { std::string msg = a8::Format("%s 使用 %s 干掉了 %s", { killer_name, - equip_meta->i->name(), + "载具", name }); SendRollMsg(msg); + } else { + MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(weapon_id); + if (equip_meta) { + std::string msg = a8::Format("%s 使用 %s 干掉了 %s", + { + killer_name, + equip_meta->i->name(), + name + }); + SendRollMsg(msg); + } } } } else { @@ -1986,6 +1996,26 @@ int Human::SkinLv() return skin.skin_lv; } +void Human::CheckSkinTank() +{ + if (tank_weapon.meta) { + std::set objects; + for (auto& grid : grid_list) { + for (Human* hum: grid->human_list) { + if (hum != this && !hum->dead && + (hum->team_id == 0 || team_id != hum->team_id)) { + if (TestCollision(hum)) { + objects.insert(hum); + } + } + } + }//end for + for (Human* hum : objects) { + hum->BeKill(entity_uniid, name, VW_Tank); + } + } +} + void Human::_UpdateMove(int speed) { for (int i = 0; i < speed; ++i) { diff --git a/server/gameserver/human.h b/server/gameserver/human.h index bb73026..5072576 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -208,6 +208,7 @@ class Human : public Entity const Skin& GetSkin(); int SkinId(); int SkinLv(); + void CheckSkinTank(); protected: void _UpdateMove(int speed); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index c15c78c..bc725d1 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -123,6 +123,9 @@ void Player::UpdateMove() if (last_collision_door && !TestCollision(last_collision_door)) { last_collision_door = nullptr; } + if (tank_weapon.meta) { + CheckSkinTank(); + } } void Player::UpdateShot()