bool CInventory::Eat(PIItem pIItem) { //устанаовить съедобна ли вещь CEatableItem* pItemToEat = smart_cast<CEatableItem*>(pIItem); if ( !pItemToEat ) return false; CEntityAlive *entity_alive = smart_cast<CEntityAlive*>(m_pOwner); if ( !entity_alive ) return false; CInventoryOwner* IO = smart_cast<CInventoryOwner*>(entity_alive); if ( !IO ) return false; CInventory* pInventory = pItemToEat->m_pInventory; if ( !pInventory || pInventory != this ) return false; if ( pInventory != IO->m_inventory ) return false; if ( pItemToEat->object().H_Parent()->ID() != entity_alive->ID() ) return false; if (!pItemToEat->UseBy(entity_alive)) return false; #ifdef MP_LOGGING Msg( "--- Actor [%d] use or eat [%d][%s]", entity_alive->ID(), pItemToEat->object().ID(), pItemToEat->object().cNameSect().c_str() ); #endif // MP_LOGGING if(IsGameTypeSingle() && Actor()->m_inventory == this) Actor()->callback(GameObject::eUseObject)((smart_cast<CGameObject*>(pIItem))->lua_game_object()); if(pItemToEat->Empty()) { pIItem->SetDropManual(TRUE); return false; } return true; }
bool CInventory::Eat(PIItem pIItem) { R_ASSERT(pIItem->m_pCurrentInventory==this); //устанаовить съедобна ли вещь CEatableItem* pItemToEat = smart_cast<CEatableItem*>(pIItem); R_ASSERT (pItemToEat); CEntityAlive *entity_alive = smart_cast<CEntityAlive*>(m_pOwner); R_ASSERT (entity_alive); pItemToEat->UseBy (entity_alive); if(IsGameTypeSingle() && Actor()->m_inventory == this) Actor()->callback(GameObject::eUseObject)((smart_cast<CGameObject*>(pIItem))->lua_game_object()); if(pItemToEat->Empty() && entity_alive->Local()) { NET_Packet P; CGameObject::u_EventGen (P,GE_OWNERSHIP_REJECT,entity_alive->ID()); P.w_u16 (pIItem->object().ID()); CGameObject::u_EventSend (P); CGameObject::u_EventGen (P,GE_DESTROY,pIItem->object().ID()); CGameObject::u_EventSend (P); return false; } return true; }
bool CInventory::Eat(PIItem pIItem) { //устанаовить съедобна ли вещь CEatableItem* pItemToEat = smart_cast<CEatableItem*>(pIItem); if(!pItemToEat) return false; CEntityAlive *entity_alive = smart_cast<CEntityAlive*>(m_pOwner); if(!entity_alive) return false; pItemToEat->UseBy (entity_alive); if(IsGameTypeSingle() && Actor()->m_inventory == this) Actor()->callback(GameObject::eUseObject)((smart_cast<CGameObject*>(pIItem))->lua_game_object()); if(pItemToEat->Empty() ) { pIItem->Drop(); return false; } return true; }
bool CInventory::ClientEat(PIItem pIItem) { CEatableItem* pItemToEat = smart_cast<CEatableItem*>(pIItem); if ( !pItemToEat ) return false; CEntityAlive *entity_alive = smart_cast<CEntityAlive*>(m_pOwner); if ( !entity_alive ) return false; CInventoryOwner* IO = smart_cast<CInventoryOwner*>(entity_alive); if ( !IO ) return false; CInventory* pInventory = pItemToEat->m_pInventory; if ( !pInventory || pInventory != this ) return false; if ( pInventory != IO->m_inventory ) return false; if ( pItemToEat->object().H_Parent()->ID() != entity_alive->ID() ) return false; NET_Packet P; CGameObject::u_EventGen (P, GEG_PLAYER_ITEM_EAT, pIItem->parent_id()); P.w_u16 (pIItem->object().ID()); CGameObject::u_EventSend (P); return true; }