添加 榴弹炮功能

This commit is contained in:
aozhiwei 2019-05-05 15:09:54 +08:00
parent 308a64c62d
commit 0b66e7d927
6 changed files with 85 additions and 3 deletions

View File

@ -146,12 +146,54 @@ void Bullet::OnHit(std::set<Entity*>& objects)
void Bullet::ProcBomb()
{
self_collider_->rad = gun_meta->i->explosion_range();
std::set<Entity*> objects;
for (auto& grid : grid_list) {
for (Human* hum: grid->human_list) {
#if 1
if (hum != player) {
#else
if (hum != player &&
(hum->team_id == 0 || player->team_id != hum->team_id)) {
#endif
if (TestCollision(hum)) {
objects.insert(hum);
}
}
}
for (Entity* entity : grid->entity_list) {
switch (entity->entity_type) {
case ET_Obstacle:
case ET_Building:
{
if (TestCollision(entity)) {
objects.insert(entity);
}
}
break;
default:
{
}
break;
}
}
}//end for
switch (meta->i->_inventory_slot()) {
case 4:
{
//榴弹炮
Vector2D bomb_pos = pos;
room->frame_event.AddExplosionEx(player, 0, bomb_pos, 0);
OnHit(objects);
}
break;
case 5:
{
//手雷
Vector2D bomb_pos = pos;
room->frame_event.AddExplosion(this, meta->i->id(), bomb_pos);
OnHit(objects);
}
break;
case 6:
@ -167,6 +209,8 @@ void Bullet::ProcBomb()
bool Bullet::IsBomb()
{
return meta->i->_inventory_slot() == 5 ||
return
meta->i->_inventory_slot() == 4 ||
meta->i->_inventory_slot() == 5 ||
meta->i->_inventory_slot() == 6;
}

View File

@ -48,6 +48,8 @@ void HandlerMgr::RegisterNetMsgHandlers()
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMove);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMEmote);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMVoice);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMGameOver);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMWatchWar);
}
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,

View File

@ -954,3 +954,15 @@ void Player::_CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg)
.SetSender(&notifymsg),
send_func);
}
void Player::_CMGameOver(f8::MsgHdr& hdr, const cs::CMGameOver& msg)
{
cs::SMGameOver respmsg;
FillSMGameOver(respmsg);
SendNotifyMsg(respmsg);
}
void Player::_CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg)
{
}

View File

@ -88,5 +88,7 @@ class Player : public Human
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
void _CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg);
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
void _CMGameOver(f8::MsgHdr& hdr, const cs::CMGameOver& msg);
void _CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg);
};

View File

@ -9,6 +9,8 @@ enum CMMessageId_e
_CMMove = 201;
_CMEmote = 204;
_CMVoice = 206;
_CMGameOver = 207;
_CMWatchWar = 208;
}
enum SMMessageId_e
@ -16,6 +18,8 @@ enum SMMessageId_e
_SMPing = 101;
_SMRpcError = 102;
_SMWatchWar = 208;
_SMJoinedNotify = 103;
_SMMapInfo = 1002;
_SMPlayerInfo = 1003;

View File

@ -646,8 +646,26 @@ message CMVoice
optional string download_url = 2; //
}
//
message CMGameOver
{
}
//
message CMWatchWar
{
}
//endcmmsg
//error_code == 0 ,
message SMWatchWar
{
optional int32 error_code = 1; //
optional string error_msg = 2; //
}
//
message SMJoinedNotify
{