This commit is contained in:
aozhiwei 2021-08-20 11:59:28 +00:00
parent 7dda3bffb3
commit 1436e0ae7e
6 changed files with 53 additions and 1 deletions

View File

@ -3864,3 +3864,28 @@ void Human::ProcUseItem(int item_id)
DecItem(item_id, 1);
}
}
Weapon* Human::TakeWeapon(MetaData::Equip* equip_meta)
{
Weapon* weapon = nullptr;
if (equip_meta->i->equip_type() == EQUIP_TYPE_WEAPON) {
if (equip_meta->i->equip_subtype() == 1) {
} else {
for (int i = GUN_SLOT1; i <= GUN_SLOT2; ++i) {
if (weapons[i].weapon_id == 0) {
weapon = &weapons[i];
weapon->weapon_idx = i;
} else if (weapons[i].meta->i->equip_subtype() ==
equip_meta->i->equip_subtype()){
if (equip_meta->i->quality() > weapons[i].meta->i->quality()) {
weapon = &weapons[i];
weapon->weapon_idx = i;
} else {
weapon = nullptr;
}
}
}
}
}
return weapon;
}

View File

@ -275,6 +275,7 @@ private:
virtual void OnBuffRemove(Buff& buff) override;
virtual void DoSkillPreProc(int skill_id, int target_id, const a8::Vec2& target_pos) override;
virtual void DoSkillPostProc(bool used, int skill_id, int target_id, const a8::Vec2& target_pos) override;
Weapon* TakeWeapon(MetaData::Equip* equip_meta);
protected:
int level_ = 0;

View File

@ -546,8 +546,13 @@ void Player::LootInteraction(Loot* entity)
need_sync_active_player = true;
SyncAroundPlayers(__FILE__, __LINE__, __func__);
} else {
if (FreezeOperate()) {
return;
}
Weapon* weapon = nullptr;
bool switch_gun = false;
#if 0
#else
if (weapons[GUN_SLOT1].weapon_id == 0) {
weapon = &weapons[GUN_SLOT1];
weapon->weapon_idx = GUN_SLOT1;
@ -561,6 +566,7 @@ void Player::LootInteraction(Loot* entity)
switch_gun = true;
}
}
#endif
if (!weapon) {
/*
cs::SMPickup notifymsg;

View File

@ -1755,6 +1755,7 @@ void Room::AirDrop(int appear_time, int box_id, int airdrop_id)
param.param2.GetDouble(),
param.param3.GetDouble()
);
obstacle->PushCollisionObjects();
obstacle->is_treasure_box = true;
if (room->GetRoomMode() == kZombieMode) {
obstacle->is_terminator_airdrop_box =

View File

@ -488,7 +488,9 @@ void RoomObstacle::SummonAirDropBox(int box_id)
GetPos().x,
GetPos().y
);
if (obstacle) {
obstacle->PushCollisionObjects();
}
}
Entity* RoomObstacle::GetRealObject(Room* room)
@ -606,3 +608,19 @@ void RoomObstacle::Destory()
#endif
DetachFromMaster();
}
void RoomObstacle::PushCollisionObjects()
{
std::set<GridCell*> grid_list;
room->grid_service->GetAllCellsByXy(room, GetPos().x, GetPos().y, grid_list);
room->grid_service->TraverseCreatures
(
room->GetRoomIdx(),
grid_list,
[this] (Creature* c, bool& stop)
{
if (TestCollision(room, c)) {
c->MustBeAddBuff(c, 8003);
}
});
}

View File

@ -34,6 +34,7 @@ class RoomObstacle : public Obstacle
RoomObstacleWeakPtr AllocWeakPtr();
RoomObstacleWeakPtr& GetWeakPtrRef();
void Destory();
void PushCollisionObjects();
private:
void SpecExplosion();