additemdto ok
This commit is contained in:
parent
bca6430e7a
commit
afed210f7e
@ -2146,9 +2146,9 @@ void Human::SendBattleReport()
|
|||||||
delete params;
|
delete params;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta, bool& handled)
|
void Human::ProcLootSkin(AddItemDTO& dto)
|
||||||
{
|
{
|
||||||
switch (item_meta->i->equip_subtype()) {
|
switch (dto.item_meta->i->equip_subtype()) {
|
||||||
case 11:
|
case 11:
|
||||||
{
|
{
|
||||||
//装饰
|
//装饰
|
||||||
@ -2161,7 +2161,7 @@ void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta, bool& handled
|
|||||||
}
|
}
|
||||||
|
|
||||||
*old_skin = Skin();
|
*old_skin = Skin();
|
||||||
old_skin->skin_id = item_meta->i->id();
|
old_skin->skin_id = dto.item_meta->i->id();
|
||||||
old_skin->skin_lv = 1;
|
old_skin->skin_lv = 1;
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
@ -2179,37 +2179,37 @@ void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta, bool& handled
|
|||||||
}
|
}
|
||||||
|
|
||||||
*old_skin = Skin();
|
*old_skin = Skin();
|
||||||
old_skin->skin_id = item_meta->i->id();
|
old_skin->skin_id = dto.item_meta->i->id();
|
||||||
old_skin->skin_lv = 1;
|
old_skin->skin_lv = 1;
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
handled = true;
|
dto.handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta, bool& handled)
|
void Human::ProcLootCar(AddItemDTO& dto)
|
||||||
{
|
{
|
||||||
DoGetOn(entity->GetUniId());
|
DoGetOn(dto.uniid);
|
||||||
handled = true;
|
dto.handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta, bool& handled)
|
void Human::ProcCamoutflage(AddItemDTO& dto)
|
||||||
{
|
{
|
||||||
AddItem(item_meta->i->id(), 1);
|
AddItem(dto.item_meta->i->id(), 1);
|
||||||
handled = true;
|
dto.handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::ProcSpoils(Loot* entity, MetaData::Equip* item_meta, bool& handled)
|
void Human::ProcSpoils(AddItemDTO& dto)
|
||||||
{
|
{
|
||||||
if (spoils_items.find(item_meta->i->id()) !=
|
if (spoils_items.find(dto.item_meta->i->id()) !=
|
||||||
spoils_items.end()) {
|
spoils_items.end()) {
|
||||||
spoils_items[item_meta->i->id()] += entity->count;
|
spoils_items[dto.item_meta->i->id()] += dto.count;
|
||||||
} else {
|
} else {
|
||||||
spoils_items[item_meta->i->id()] = entity->count;
|
spoils_items[dto.item_meta->i->id()] = dto.count;
|
||||||
}
|
}
|
||||||
handled = true;
|
dto.handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::OnDie()
|
void Human::OnDie()
|
||||||
@ -3153,119 +3153,15 @@ void Human::GMAddItem(int item_id, int item_num)
|
|||||||
if (!item_meta) {
|
if (!item_meta) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item_meta->i->equip_type() == EQUIP_TYPE_WEAPON) {
|
AddItemDTO dto;
|
||||||
if (item_meta->i->equip_subtype() == 1) {
|
dto.uniid = 0;
|
||||||
if (default_weapon.weapon_id != weapons[0].weapon_id) {
|
dto.item_id = item_id;
|
||||||
} else {
|
dto.count = item_num;
|
||||||
weapons[0].weapon_idx = 0;
|
dto.item_level = 1;
|
||||||
weapons[0].weapon_id = item_id;
|
dto.handled = false;
|
||||||
weapons[0].weapon_lv = std::max(1, 1);
|
dto.item_meta = item_meta;
|
||||||
weapons[0].ammo = 0;
|
|
||||||
weapons[0].meta = item_meta;
|
|
||||||
weapons[0].Recalc();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Weapon* weapon = weapon = TakeonWeapon(item_meta);
|
|
||||||
if (weapon) {
|
|
||||||
if (GetCurrWeapon() != weapon) {
|
|
||||||
SetCurrWeapon(weapon);
|
|
||||||
}
|
|
||||||
weapon->weapon_id = item_id;
|
|
||||||
weapon->weapon_lv = std::max(1, 1);
|
|
||||||
weapon->ammo = 0;
|
|
||||||
weapon->meta = item_meta;
|
|
||||||
weapon->Recalc();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (item_meta->i->_inventory_slot() >= 0 &&
|
|
||||||
item_meta->i->_inventory_slot() < IS_END) {
|
|
||||||
if (GetInventory(item_meta->i->_inventory_slot()) >=
|
|
||||||
GetVolume(item_meta->i->_inventory_slot())
|
|
||||||
) {
|
|
||||||
/*
|
|
||||||
cs::SMPickup notifymsg;
|
|
||||||
notifymsg.set_error_code(1);
|
|
||||||
SendNotifyMsg(notifymsg);
|
|
||||||
*/
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int add_num = GetVolume(item_meta->i->_inventory_slot()) -
|
|
||||||
GetInventory(item_meta->i->_inventory_slot());
|
|
||||||
add_num = std::min(item_num, add_num);
|
|
||||||
|
|
||||||
AddInventory(item_meta->i->_inventory_slot(), add_num);
|
|
||||||
switch (item_meta->i->_inventory_slot()) {
|
|
||||||
case IS_FRAG:
|
|
||||||
case IS_SMOKE:
|
|
||||||
{
|
|
||||||
Weapon* weapon = &weapons[SPEC1_SLOT_BEGIN +
|
|
||||||
(item_meta->i->_inventory_slot() - SPEC1_IS_BEGIN)
|
|
||||||
];
|
|
||||||
weapon->weapon_id = item_id;
|
|
||||||
weapon->weapon_lv = 1;
|
|
||||||
weapon->ammo += item_num;
|
|
||||||
weapon->meta = item_meta;
|
|
||||||
weapon->Recalc();
|
|
||||||
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IS_1XSCOPE:
|
|
||||||
case IS_2XSCOPE:
|
|
||||||
case IS_4XSCOPE:
|
|
||||||
case IS_8XSCOPE:
|
|
||||||
case IS_15XSCOPE:
|
|
||||||
{
|
|
||||||
if (item_meta->i->_inventory_slot() - IS_1XSCOPE > curr_scope_idx) {
|
|
||||||
curr_scope_idx = item_meta->i->_inventory_slot() - IS_1XSCOPE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IS_POSION_GAS_BOMB:
|
|
||||||
case IS_MOLOTOR_COCKTAIL:
|
|
||||||
case IS_TRAP:
|
|
||||||
case IS_MINE:
|
|
||||||
{
|
|
||||||
Weapon* weapon = &weapons[SPEC2_SLOT_BEGIN +
|
|
||||||
(item_meta->i->_inventory_slot() - SPEC2_IS_BEGIN)
|
|
||||||
];
|
|
||||||
weapon->weapon_id = item_id;
|
|
||||||
weapon->weapon_lv = 1;
|
|
||||||
weapon->ammo += item_num;
|
|
||||||
weapon->meta = item_meta;
|
|
||||||
weapon->Recalc();
|
|
||||||
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IS_C4:
|
|
||||||
case IS_SHIELD_WALL:
|
|
||||||
case IS_SINGAL_GUN:
|
|
||||||
case IS_OIL_BUCKET:
|
|
||||||
{
|
|
||||||
Weapon* weapon = &weapons[SPEC3_SLOT_BEGIN +
|
|
||||||
(item_meta->i->_inventory_slot() - SPEC3_IS_BEGIN)
|
|
||||||
];
|
|
||||||
weapon->weapon_id = item_id;
|
|
||||||
weapon->weapon_lv = 1;
|
|
||||||
weapon->ammo += item_num;
|
|
||||||
weapon->meta = item_meta;
|
|
||||||
weapon->Recalc();
|
|
||||||
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
abort();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
AddItem(item_id, item_num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
|
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3576,76 +3472,76 @@ void Human::StartRefreshViewTimer()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::ProcLootBag(Loot* entity, MetaData::Equip* item_meta, bool& handled)
|
void Human::ProcLootBag(AddItemDTO& dto)
|
||||||
{
|
{
|
||||||
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(backpack);
|
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(backpack);
|
||||||
if (old_item_meta) {
|
if (old_item_meta) {
|
||||||
if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) {
|
if (old_item_meta->i->equip_lv() >= dto.item_meta->i->equip_lv()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1);
|
room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1);
|
||||||
}
|
}
|
||||||
backpack = item_meta->i->id();
|
backpack = dto.item_meta->i->id();
|
||||||
RecalcVolume();
|
RecalcVolume();
|
||||||
handled = true;
|
dto.handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::ProcLootProtection(Loot* entity, MetaData::Equip* item_meta, bool& handled)
|
void Human::ProcLootProtection(AddItemDTO& dto)
|
||||||
{
|
{
|
||||||
if (item_meta->i->equip_subtype() == 1) {
|
if (dto.item_meta->i->equip_subtype() == 1) {
|
||||||
//盔甲
|
//盔甲
|
||||||
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(chest);
|
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(chest);
|
||||||
if (old_item_meta) {
|
if (old_item_meta) {
|
||||||
if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) {
|
if (old_item_meta->i->equip_lv() >= dto.item_meta->i->equip_lv()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1);
|
room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1);
|
||||||
}
|
}
|
||||||
chest = item_meta->i->id();
|
chest = dto.item_meta->i->id();
|
||||||
RecalcBaseAttr();
|
RecalcBaseAttr();
|
||||||
} else if (item_meta->i->equip_subtype() == 2) {
|
} else if (dto.item_meta->i->equip_subtype() == 2) {
|
||||||
//头盔
|
//头盔
|
||||||
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(helmet);
|
MetaData::Equip* old_item_meta = MetaMgr::Instance()->GetEquip(helmet);
|
||||||
if (old_item_meta) {
|
if (old_item_meta) {
|
||||||
if (old_item_meta->i->equip_lv() >= item_meta->i->equip_lv()) {
|
if (old_item_meta->i->equip_lv() >= dto.item_meta->i->equip_lv()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1);
|
room->DropItem(GetPos(), old_item_meta->i->id(), 1, 1);
|
||||||
}
|
}
|
||||||
helmet = item_meta->i->id();
|
helmet = dto.item_meta->i->id();
|
||||||
RecalcBaseAttr();
|
RecalcBaseAttr();
|
||||||
}
|
}
|
||||||
handled = true;
|
dto.handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::ProcLootSpecItem(Loot* entity, MetaData::Equip* item_meta, bool& handled)
|
void Human::ProcLootSpecItem(AddItemDTO& dto)
|
||||||
{
|
{
|
||||||
if (item_meta->i->_inventory_slot() >= 0 &&
|
if (dto.item_meta->i->_inventory_slot() >= 0 &&
|
||||||
item_meta->i->_inventory_slot() < IS_END) {
|
dto.item_meta->i->_inventory_slot() < IS_END) {
|
||||||
if (GetInventory(item_meta->i->_inventory_slot()) >=
|
if (GetInventory(dto.item_meta->i->_inventory_slot()) >=
|
||||||
GetVolume(item_meta->i->_inventory_slot())
|
GetVolume(dto.item_meta->i->_inventory_slot())
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int add_num = GetVolume(item_meta->i->_inventory_slot()) -
|
int add_num = GetVolume(dto.item_meta->i->_inventory_slot()) -
|
||||||
GetInventory(item_meta->i->_inventory_slot());
|
GetInventory(dto.item_meta->i->_inventory_slot());
|
||||||
add_num = std::min(entity->count, add_num);
|
add_num = std::min(dto.count, add_num);
|
||||||
|
|
||||||
AddInventory(item_meta->i->_inventory_slot(), add_num);
|
AddInventory(dto.item_meta->i->_inventory_slot(), add_num);
|
||||||
switch (item_meta->i->_inventory_slot()) {
|
switch (dto.item_meta->i->_inventory_slot()) {
|
||||||
case IS_FRAG:
|
case IS_FRAG:
|
||||||
case IS_SMOKE:
|
case IS_SMOKE:
|
||||||
{
|
{
|
||||||
Weapon* weapon = &weapons[SPEC1_SLOT_BEGIN +
|
Weapon* weapon = &weapons[SPEC1_SLOT_BEGIN +
|
||||||
(item_meta->i->_inventory_slot() - SPEC1_IS_BEGIN)
|
(dto.item_meta->i->_inventory_slot() - SPEC1_IS_BEGIN)
|
||||||
];
|
];
|
||||||
weapon->weapon_id = entity->item_id;
|
weapon->weapon_id = dto.item_id;
|
||||||
weapon->weapon_lv = 1;
|
weapon->weapon_lv = 1;
|
||||||
weapon->ammo += entity->count;
|
weapon->ammo += dto.count;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = dto.item_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
#if 0
|
#if 0
|
||||||
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
DecInventory(dto.item_meta->i->_inventory_slot(), add_num);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3655,8 +3551,8 @@ void Human::ProcLootSpecItem(Loot* entity, MetaData::Equip* item_meta, bool& han
|
|||||||
case IS_8XSCOPE:
|
case IS_8XSCOPE:
|
||||||
case IS_15XSCOPE:
|
case IS_15XSCOPE:
|
||||||
{
|
{
|
||||||
if (item_meta->i->_inventory_slot() - IS_1XSCOPE > curr_scope_idx) {
|
if (dto.item_meta->i->_inventory_slot() - IS_1XSCOPE > curr_scope_idx) {
|
||||||
curr_scope_idx = item_meta->i->_inventory_slot() - IS_1XSCOPE;
|
curr_scope_idx = dto.item_meta->i->_inventory_slot() - IS_1XSCOPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3666,15 +3562,15 @@ void Human::ProcLootSpecItem(Loot* entity, MetaData::Equip* item_meta, bool& han
|
|||||||
case IS_MINE:
|
case IS_MINE:
|
||||||
{
|
{
|
||||||
Weapon* weapon = &weapons[SPEC2_SLOT_BEGIN +
|
Weapon* weapon = &weapons[SPEC2_SLOT_BEGIN +
|
||||||
(item_meta->i->_inventory_slot() - SPEC2_IS_BEGIN)
|
(dto.item_meta->i->_inventory_slot() - SPEC2_IS_BEGIN)
|
||||||
];
|
];
|
||||||
weapon->weapon_id = entity->item_id;
|
weapon->weapon_id = dto.item_id;
|
||||||
weapon->weapon_lv = 1;
|
weapon->weapon_lv = 1;
|
||||||
weapon->ammo += entity->count;
|
weapon->ammo += dto.count;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = dto.item_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
#if 0
|
#if 0
|
||||||
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
DecInventory(dto.item_meta->i->_inventory_slot(), add_num);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3684,15 +3580,15 @@ void Human::ProcLootSpecItem(Loot* entity, MetaData::Equip* item_meta, bool& han
|
|||||||
case IS_OIL_BUCKET:
|
case IS_OIL_BUCKET:
|
||||||
{
|
{
|
||||||
Weapon* weapon = &weapons[SPEC3_SLOT_BEGIN +
|
Weapon* weapon = &weapons[SPEC3_SLOT_BEGIN +
|
||||||
(item_meta->i->_inventory_slot() - SPEC3_IS_BEGIN)
|
(dto.item_meta->i->_inventory_slot() - SPEC3_IS_BEGIN)
|
||||||
];
|
];
|
||||||
weapon->weapon_id = entity->item_id;
|
weapon->weapon_id = dto.item_id;
|
||||||
weapon->weapon_lv = 1;
|
weapon->weapon_lv = 1;
|
||||||
weapon->ammo += entity->count;
|
weapon->ammo += dto.count;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = dto.item_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
#if 0
|
#if 0
|
||||||
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
DecInventory(dto.item_meta->i->_inventory_slot(), add_num);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3705,10 +3601,13 @@ void Human::ProcLootSpecItem(Loot* entity, MetaData::Equip* item_meta, bool& han
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (add_num < entity->count) {
|
if (add_num < dto.count) {
|
||||||
//刷新数量
|
//刷新数量
|
||||||
entity->count -= add_num;
|
Entity* entity = room->GetEntityByUniId(dto.uniid);
|
||||||
entity->BroadcastFullState(room);
|
if (entity && entity->IsEntityType(ET_Loot)) {
|
||||||
|
((Loot*)entity)->count -= add_num;
|
||||||
|
((Loot*)entity)->BroadcastFullState(room);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3717,22 +3616,22 @@ void Human::ProcLootSpecItem(Loot* entity, MetaData::Equip* item_meta, bool& han
|
|||||||
}
|
}
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
handled = true;
|
dto.handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::ProcLootWeapon(Loot* entity, MetaData::Equip* item_meta, bool& handled)
|
void Human::ProcLootWeapon(AddItemDTO& dto)
|
||||||
{
|
{
|
||||||
//装备
|
//装备
|
||||||
if (item_meta->i->equip_subtype() == 1) {
|
if (dto.item_meta->i->equip_subtype() == 1) {
|
||||||
//近战
|
//近战
|
||||||
if (default_weapon.weapon_id != weapons[0].weapon_id) {
|
if (default_weapon.weapon_id != weapons[0].weapon_id) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
weapons[0].weapon_idx = 0;
|
weapons[0].weapon_idx = 0;
|
||||||
weapons[0].weapon_id = entity->item_id;
|
weapons[0].weapon_id = dto.item_id;
|
||||||
weapons[0].weapon_lv = std::max(1, entity->item_level);
|
weapons[0].weapon_lv = std::max(1, dto.item_level);
|
||||||
weapons[0].ammo = 0;
|
weapons[0].ammo = 0;
|
||||||
weapons[0].meta = item_meta;
|
weapons[0].meta = dto.item_meta;
|
||||||
weapons[0].Recalc();
|
weapons[0].Recalc();
|
||||||
}
|
}
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
@ -3742,17 +3641,17 @@ void Human::ProcLootWeapon(Loot* entity, MetaData::Equip* item_meta, bool& handl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool switch_gun = false;
|
bool switch_gun = false;
|
||||||
Weapon* weapon = TakeonWeapon(item_meta);
|
Weapon* weapon = TakeonWeapon(dto.item_meta);
|
||||||
if (weapon && GetCurrWeapon() != weapon) {
|
if (weapon && GetCurrWeapon() != weapon) {
|
||||||
switch_gun = true;
|
switch_gun = true;
|
||||||
}
|
}
|
||||||
if (!weapon) {
|
if (!weapon) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
weapon->weapon_id = entity->item_id;
|
weapon->weapon_id = dto.item_id;
|
||||||
weapon->weapon_lv = std::max(1, entity->item_level);
|
weapon->weapon_lv = std::max(1, dto.item_level);
|
||||||
weapon->ammo = 0;
|
weapon->ammo = 0;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = dto.item_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
if (HasBuffEffect(kBET_Car)) {
|
if (HasBuffEffect(kBET_Car)) {
|
||||||
} else {
|
} else {
|
||||||
@ -3764,5 +3663,92 @@ void Human::ProcLootWeapon(Loot* entity, MetaData::Equip* item_meta, bool& handl
|
|||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
handled = true;
|
dto.handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Human::LootInteraction(Loot* entity)
|
||||||
|
{
|
||||||
|
if (entity->pickuped ||
|
||||||
|
entity->count <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AddItemDTO dto;
|
||||||
|
dto.uniid = entity->GetUniId();
|
||||||
|
dto.item_id = entity->item_id;
|
||||||
|
dto.count = entity->count;
|
||||||
|
dto.item_level = entity->item_level;
|
||||||
|
dto.handled = false;
|
||||||
|
dto.item_meta = MetaMgr::Instance()->GetEquip(entity->item_id);
|
||||||
|
|
||||||
|
if (dto.handled) {
|
||||||
|
entity->pickuped = true;
|
||||||
|
room->RemoveObjectLater(entity);
|
||||||
|
if (entity->dummy_thing_uniid != 0) {
|
||||||
|
Entity* dummy_obj = room->GetEntityByUniId(entity->dummy_thing_uniid);
|
||||||
|
if (dummy_obj && dummy_obj->GetEntityType() == ET_Obstacle) {
|
||||||
|
Obstacle* obstacle = (Obstacle*)dummy_obj;
|
||||||
|
if (!obstacle->IsPermanent()) {
|
||||||
|
if (!obstacle->IsDead(room)) {
|
||||||
|
obstacle->Die(room);
|
||||||
|
obstacle->BroadcastFullState(room);
|
||||||
|
}
|
||||||
|
room->RemoveObjectLater((RoomObstacle*)obstacle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Human::ProcAddItemDto(AddItemDTO& dto)
|
||||||
|
{
|
||||||
|
if (!dto.item_meta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (dto.item_meta->i->equip_type()) {
|
||||||
|
case EQUIP_TYPE_WEAPON:
|
||||||
|
{
|
||||||
|
ProcLootWeapon(dto);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EQUIP_TYPE_PROTECTION:
|
||||||
|
{
|
||||||
|
ProcLootProtection(dto);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EQUIP_TYPE_BAG:
|
||||||
|
{
|
||||||
|
ProcLootBag(dto);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EQUIP_TYPE_OLDSKIN:
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EQUIP_TYPE_SKIN:
|
||||||
|
{
|
||||||
|
ProcLootSkin(dto);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EQUIP_TYPE_CAR:
|
||||||
|
{
|
||||||
|
ProcLootCar(dto);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EQUIP_TYPE_CAMOUFLAGE:
|
||||||
|
{
|
||||||
|
ProcCamoutflage(dto);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EQUIP_TYPE_SPOILS:
|
||||||
|
{
|
||||||
|
ProcSpoils(dto);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ProcLootSpecItem(dto);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,16 +272,18 @@ class Human : public Creature
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _InternalUpdateMove(float speed);
|
void _InternalUpdateMove(float speed);
|
||||||
void ProcLootWeapon(Loot* entity, MetaData::Equip* item_meta, bool& handled);
|
void ProcLootWeapon(AddItemDTO& dto);
|
||||||
void ProcLootSkin(Loot* entity, MetaData::Equip* item_meta, bool& handled);
|
void ProcLootSkin(AddItemDTO& dto);
|
||||||
void ProcLootCar(Loot* entity, MetaData::Equip* item_meta, bool& handled);
|
void ProcLootCar(AddItemDTO& dto);
|
||||||
void ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta, bool& handled);
|
void ProcCamoutflage(AddItemDTO& dto);
|
||||||
void ProcSpoils(Loot* entity, MetaData::Equip* item_meta, bool& handled);
|
void ProcSpoils(AddItemDTO& dto);
|
||||||
void ProcLootBag(Loot* entity, MetaData::Equip* item_meta, bool& handled);
|
void ProcLootBag(AddItemDTO& dto);
|
||||||
void ProcLootProtection(Loot* entity, MetaData::Equip* item_meta, bool& handled);
|
void ProcLootProtection(AddItemDTO& dto);
|
||||||
void ProcLootSpecItem(Loot* entity, MetaData::Equip* item_meta, bool& handled);
|
void ProcLootSpecItem(AddItemDTO& dto);
|
||||||
void CancelRevive();
|
void CancelRevive();
|
||||||
Weapon* TakeonWeapon(MetaData::Equip* equip_meta);
|
Weapon* TakeonWeapon(MetaData::Equip* equip_meta);
|
||||||
|
void LootInteraction(Loot* entity);
|
||||||
|
void ProcAddItemDto(AddItemDTO& dto);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClearFrameData();
|
void ClearFrameData();
|
||||||
|
@ -499,85 +499,6 @@ void Player::ObstacleInteraction(Obstacle* entity)
|
|||||||
entity->DoInteraction(this);
|
entity->DoInteraction(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::LootInteraction(Loot* entity)
|
|
||||||
{
|
|
||||||
if (entity->pickuped ||
|
|
||||||
entity->count <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(entity->item_id);
|
|
||||||
if (!item_meta) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bool handled = false;
|
|
||||||
switch (item_meta->i->equip_type()) {
|
|
||||||
case EQUIP_TYPE_WEAPON:
|
|
||||||
{
|
|
||||||
ProcLootWeapon(entity, item_meta, handled);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EQUIP_TYPE_PROTECTION:
|
|
||||||
{
|
|
||||||
ProcLootProtection(entity, item_meta, handled);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EQUIP_TYPE_BAG:
|
|
||||||
{
|
|
||||||
ProcLootBag(entity, item_meta, handled);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EQUIP_TYPE_OLDSKIN:
|
|
||||||
{
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EQUIP_TYPE_SKIN:
|
|
||||||
{
|
|
||||||
ProcLootSkin(entity, item_meta, handled);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EQUIP_TYPE_CAR:
|
|
||||||
{
|
|
||||||
ProcLootCar(entity, item_meta, handled);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EQUIP_TYPE_CAMOUFLAGE:
|
|
||||||
{
|
|
||||||
ProcCamoutflage(entity, item_meta, handled);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EQUIP_TYPE_SPOILS:
|
|
||||||
{
|
|
||||||
|
|
||||||
ProcSpoils(entity, item_meta, handled);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
ProcLootSpecItem(entity, item_meta, handled);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handled) {
|
|
||||||
entity->pickuped = true;
|
|
||||||
room->RemoveObjectLater(entity);
|
|
||||||
if (entity->dummy_thing_uniid != 0) {
|
|
||||||
Entity* dummy_obj = room->GetEntityByUniId(entity->dummy_thing_uniid);
|
|
||||||
if (dummy_obj && dummy_obj->GetEntityType() == ET_Obstacle) {
|
|
||||||
Obstacle* obstacle = (Obstacle*)dummy_obj;
|
|
||||||
if (!obstacle->IsPermanent()) {
|
|
||||||
if (!obstacle->IsDead(room)) {
|
|
||||||
obstacle->Die(room);
|
|
||||||
obstacle->BroadcastFullState(room);
|
|
||||||
}
|
|
||||||
room->RemoveObjectLater((RoomObstacle*)obstacle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::HumanInteraction(Human* hum)
|
void Player::HumanInteraction(Human* hum)
|
||||||
{
|
{
|
||||||
if (downed) {
|
if (downed) {
|
||||||
|
@ -93,7 +93,6 @@ class Player : public Human
|
|||||||
void Shot();
|
void Shot();
|
||||||
void ProcInteraction();
|
void ProcInteraction();
|
||||||
void ObstacleInteraction(Obstacle* entity);
|
void ObstacleInteraction(Obstacle* entity);
|
||||||
void LootInteraction(Loot* entity);
|
|
||||||
void HumanInteraction(Human* hum);
|
void HumanInteraction(Human* hum);
|
||||||
void ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
|
void ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
|
||||||
prepare_items);
|
prepare_items);
|
||||||
|
@ -1 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
namespace MetaData
|
||||||
|
{
|
||||||
|
struct Equip;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AddItemDTO
|
||||||
|
{
|
||||||
|
int uniid = 0;
|
||||||
|
int item_id = 0;
|
||||||
|
int count = 0;
|
||||||
|
int item_level = 0;
|
||||||
|
MetaData::Equip* item_meta = nullptr;
|
||||||
|
bool handled = false;
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user