From 21d43977b86e5ac3e22aa56c08201ad51a800b3a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 13 Mar 2020 17:40:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9D=90=E9=AA=91=E7=9B=B8?= =?UTF-8?q?=E5=85=B3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/constant.h | 1 + server/gameserver/human.cc | 17 ++++++++++++++--- server/gameserver/room.cc | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 21f36d8..cb20929 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -110,6 +110,7 @@ enum BuffEffectType_e kBET_Begin = 0, kBET_ChgAttr = 1, //改变属性 kBET_Jump = 2, //翻滚 + kBET_Car = 3, //骑乘 kBET_OnceChgAttr = 11, //一次性buff kBET_End }; diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 936e580..9399016 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -856,6 +856,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) real_dead = true; OnDie(); } + DoGetDown(); } } @@ -902,6 +903,7 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, i if (HasNoDownedTeammate()) { ability.hp = MetaMgr::Instance()->GetSysParamAsInt("downed_recover_hp"); downed = true; + DoGetDown(); downed_timer = room->xtimer.AddRepeatTimerAndAttach( SERVER_FRAME_RATE, a8::XParams() @@ -1088,6 +1090,7 @@ void Human::DoGetDown() SyncAroundPlayers(__FILE__, __LINE__, __func__); room->NotifyUiUpdate(); car_ = HumanCar(); + CancelAction(); } } @@ -2253,6 +2256,9 @@ void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta) void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta) { + if (downed) { + return; + } if (car_.car_id != 0) { int entity_uniid = room->CreateLoot(car_.car_id, GetPos(), 1, 1); Entity* loot_entity = room->GetEntityByUniId(entity_uniid); @@ -2262,7 +2268,10 @@ void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta) ((Loot*)loot_entity)->param2 = 0; room->UpdateCarObject(car_.car_uniid, loot_entity->entity_uniid, loot_entity->GetPos()); } - RemoveBuffById(item_meta->i->buffid()); + room->TakeOffCarObject(entity_uniid, GetPos()); + if (car_.meta->i->buffid()) { + RemoveBuffById(car_.meta->i->buffid()); + } } car_.car_uniid = entity->entity_uniid; car_.car_id = item_meta->i->id(); @@ -2272,6 +2281,7 @@ void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta) if (buff_meta) { AddBuff(buff_meta, 1); } + CancelAction(); SyncAroundPlayers(__FILE__, __LINE__, __func__); room->TakeOnCarObject(car_.car_uniid); room->NotifyUiUpdate(); @@ -2343,7 +2353,6 @@ void Human::FindLocationWithTarget(Entity* target) void Human::OnDie() { room->OnHumanDie(this); - DoGetDown(); SyncAroundPlayers(__FILE__, __LINE__, __func__); if (team_members) { for (auto& hum : *team_members) { @@ -2625,6 +2634,7 @@ void Human::ProcBuffEffect(Buff* buff) { switch (buff->meta->i->buff_effect()) { case kBET_ChgAttr: + case kBET_Car: { RecalcBuffAttr(); } @@ -2649,7 +2659,8 @@ void Human::RecalcBuffAttr() buff_attr_abs_ = {}; buff_attr_rate_ = {}; for (auto& buff : buff_list_) { - if (buff.meta->i->buff_effect() == kBET_ChgAttr) { + if (buff.meta->i->buff_effect() == kBET_ChgAttr || + buff.meta->i->buff_effect() == kBET_Car) { int attr_type = (int)buff.meta->param1; int calc_type = (int)buff.meta->param2; if (IsValidHumanAttr(attr_type)) { diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 417e6ff..c1f8417 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1473,6 +1473,8 @@ void Room::UpdateCarObject(int old_uniid, int new_uniid, a8::Vec2 pos) new_obj.pos = pos; car_hash_[new_uniid] = new_obj; car_hash_.erase(old_uniid); + } else { + assert(false); } }