This commit is contained in:
aozhiwei 2021-09-30 10:43:31 +00:00
commit 528f211ef0
4 changed files with 34 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include "collider.h"
#include "bullet.h"
#include "explosion.h"
#include "roomobstacle.h"
Hero::Hero():Creature()
{
@ -381,3 +382,16 @@ std::string Hero::GetName()
{
return meta->i->name();
}
void Hero::DropItems(Obstacle* obstacle)
{
bool is_treasure_box = false;
if (obstacle->IsEntitySubType(EST_RoomObstacle)) {
is_treasure_box = ((RoomObstacle*)obstacle)->is_treasure_box;
}
int drop_id = obstacle->meta->i->drop();
if (drop_id == 0) {
return;
}
room->ScatterDrop(obstacle->GetPos(), drop_id);
}

View File

@ -31,6 +31,7 @@ public:
virtual void Update(int delta_time) override;
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override;
virtual std::string GetName() override;
virtual void DropItems(Obstacle* obstacle) override;
virtual float GetSpeed() override;
virtual float GetRadius() override;

View File

@ -3480,8 +3480,14 @@ void Human::ProcLootWeapon(AddItemDTO& dto)
void Human::LootInteraction(Loot* entity)
{
#ifdef DEBUG
a8::XPrintf("LootInteraction start %d:%d\n", {entity->GetUniId(), entity->item_id});
#endif
if (entity->pickuped ||
entity->count <= 0) {
#ifdef DEBUG
a8::XPrintf("LootInteraction error1 %d:%d\n", {entity->GetUniId(), entity->item_id});
#endif
return;
}
AddItemDTO dto;
@ -3515,6 +3521,9 @@ void Human::LootInteraction(Loot* entity)
void Human::ProcAddItemDto(AddItemDTO& dto)
{
if (!dto.item_meta) {
#ifdef DEBUG
a8::XPrintf("LootInteraction error20 %d:%d\n", {dto.uniid, dto.item_id});
#endif
return;
}
switch (dto.item_meta->i->equip_type()) {

View File

@ -479,8 +479,14 @@ void Player::ProcInteraction()
}
for (auto obj_id : interaction_objids) {
Entity* entity = room->GetEntityByUniId(obj_id);
#ifdef DEBUG
a8::XPrintf("LootInteraction %d\n", {obj_id});
#endif
if (entity) {
if (entity->GetPos().Distance(GetPos()) > 600) {
#ifdef DEBUG
a8::XPrintf("LootInteraction error3 %d\n", {entity->GetUniId()});
#endif
continue;
}
switch (entity->GetEntityType()) {
@ -507,6 +513,10 @@ void Player::ProcInteraction()
}
break;
}
} else {
#ifdef DEBUG
a8::XPrintf("LootInteraction error4 %d\n", {obj_id});
#endif
}
}
interaction_objids.Clear();