diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index b4c9b90..21f36d8 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -181,6 +181,12 @@ enum EquipAttr_e EA_End }; +enum EquipType_e +{ + EQUIP_TYPE_CAR = 9, + EQUIP_TYPE_End +}; + enum EntityType_e { ET_None = 0, diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 57a41c7..d70a177 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -74,17 +74,9 @@ void Human::Initialize() float Human::GetSpeed() { if (a8::HasBitFlag(status, HS_Jump)) { - #if 1 return meta->i->jump_speed(); - #else - return meta->i->jump_speed() + buff.speed; - #endif } if (downed) { - #if 1 return meta->i->move_speed3(); - #else - return meta->i->move_speed3() + buff.speed; - #endif } else { if (shot_hold) { if (curr_weapon->weapon_idx == GUN_SLOT1 || @@ -96,11 +88,9 @@ float Human::GetSpeed() } else if (aiming) { return meta->i->aiming_speed(); } - #if 1 - return meta->i->move_speed(); - #else - return meta->i->move_speed() + buff.speed; - #endif + float speed = meta->i->move_speed(); + speed = (speed + buff_attr_abs_[kHAT_Speed]) * (1 + buff_attr_rate_[kHAT_Speed]); + return std::max(speed, 1.0f); } } @@ -1081,20 +1071,22 @@ void Human::DoSkill() void Human::DoGetDown() { - if (skin_tank.skin_id != 0) { - int entity_uniid = room->CreateLoot(skin_tank.skin_id, GetPos(), 1, 1); + if (car_.car_id != 0) { + int entity_uniid = room->CreateLoot(car_.car_id, GetPos(), 1, 1); Entity* loot_entity = room->GetEntityByUniId(entity_uniid); if (loot_entity && loot_entity->entity_type == ET_Loot) { - ((Loot*)loot_entity)->bullet_num = tank_weapon.ammo; - ((Loot*)loot_entity)->param1 = tank_oil_value; - ((Loot*)loot_entity)->param2 = tank_oil_max; + ((Loot*)loot_entity)->bullet_num = 0; + ((Loot*)loot_entity)->param1 = 0; + ((Loot*)loot_entity)->param2 = 0; + room->UpdateCarObject(car_.car_uniid, loot_entity->entity_uniid, loot_entity->GetPos()); } - room->UpdateCarObject(skin_tank.tank_uniid, entity_uniid, GetPos()); room->TakeOffCarObject(entity_uniid, GetPos()); - ResetTankSkin(); + if (car_.meta->i->buffid()) { + RemoveBuffById(car_.meta->i->buffid()); + } SyncAroundPlayers(__FILE__, __LINE__, __func__); room->NotifyUiUpdate(); - need_sync_active_player = true; + car_ = HumanCar(); } } @@ -2250,6 +2242,32 @@ void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta) } } +void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta) +{ + if (car_.car_id != 0) { + int entity_uniid = room->CreateLoot(car_.car_id, GetPos(), 1, 1); + Entity* loot_entity = room->GetEntityByUniId(entity_uniid); + if (loot_entity && loot_entity->entity_type == ET_Loot) { + ((Loot*)loot_entity)->bullet_num = 0; + ((Loot*)loot_entity)->param1 = 0; + ((Loot*)loot_entity)->param2 = 0; + room->UpdateCarObject(car_.car_uniid, loot_entity->entity_uniid, loot_entity->GetPos()); + } + RemoveBuffById(item_meta->i->buffid()); + } + car_.car_uniid = entity->entity_uniid; + car_.car_id = item_meta->i->id(); + car_.meta = item_meta; + SetPos(entity->GetPos()); + MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(car_.meta->i->buffid()); + if (buff_meta) { + AddBuff(buff_meta, 1); + } + SyncAroundPlayers(__FILE__, __LINE__, __func__); + room->TakeOnCarObject(car_.car_uniid); + room->NotifyUiUpdate(); +} + void Human::FindLocationWithTarget(Entity* target) { a8::Vec2 old_pos = GetPos(); @@ -2316,6 +2334,7 @@ void Human::FindLocationWithTarget(Entity* target) void Human::OnDie() { room->OnHumanDie(this); + DoGetDown(); SyncAroundPlayers(__FILE__, __LINE__, __func__); if (team_members) { for (auto& hum : *team_members) { diff --git a/server/gameserver/human.h b/server/gameserver/human.h index da9a020..00fa3fc 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -241,6 +241,7 @@ class Human : public Entity protected: void _UpdateMove(int speed); void ProcLootSkin(Loot* entity, MetaData::Equip* item_meta); + void ProcLootCar(Loot* entity, MetaData::Equip* item_meta); void ResetTankSkin(); void SelectSkillTargets(const a8::Vec2& target_pos, std::set& target_list); Buff* GetBuffById(int buff_id); @@ -292,6 +293,7 @@ protected: std::vector chged_skillcds_; Human* follow_target_ = nullptr; bool follow_synced_active_player = false; + HumanCar car_; MetaData::Skill* skill_meta_ = nullptr; diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index cf7e692..756e0a9 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -571,6 +571,11 @@ void Player::LootInteraction(Loot* entity) ProcLootSkin(entity, item_meta); } break; + case EQUIP_TYPE_CAR: + { + ProcLootCar(entity, item_meta); + } + break; default: { if (item_meta->i->_inventory_slot() >= 0 && diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index f76b139..417e6ff 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1570,7 +1570,7 @@ void Room::CreateMapObject(MetaData::MapTplThing& thing_tpl) 1, 1 ); - if (entity_uniid && equip_meta->i->is_luck() == 2) { + if (entity_uniid && equip_meta->i->equip_type() == EQUIP_TYPE_CAR) { Entity* loot_entity = GetEntityByUniId(entity_uniid); if (loot_entity && loot_entity->entity_type == ET_Loot) { ((Loot*)loot_entity)->bullet_num = equip_meta->i->clip_volume(); diff --git a/server/gameserver/types.h b/server/gameserver/types.h index 3f7f4c5..a56a942 100755 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -111,6 +111,14 @@ struct CarObject bool taken = false; }; +struct HumanCar +{ + int car_id = 0; + int car_uniid = 0; + + MetaData::Equip* meta = nullptr; +}; + struct BornPoint { MetaData::MapTplThing* thing_tpl = nullptr; diff --git a/server/tools/protobuild/metatable.proto b/server/tools/protobuild/metatable.proto index 7ef7d6f..c976ae8 100755 --- a/server/tools/protobuild/metatable.proto +++ b/server/tools/protobuild/metatable.proto @@ -88,6 +88,7 @@ message Equip optional string name = 35; //装备名字 optional float rad = 36; //半径 optional float rad2 = 37; + optional int32 buffid = 38; optional string inventory_slot = 31; //库存槽位 optional int32 _inventory_slot = 32; //库存槽位