本文整理汇总了C++中P_PLAYER::lineOfSight方法的典型用法代码示例。如果您正苦于以下问题:C++ P_PLAYER::lineOfSight方法的具体用法?C++ P_PLAYER::lineOfSight怎么用?C++ P_PLAYER::lineOfSight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_PLAYER
的用法示例。
在下文中一共展示了P_PLAYER::lineOfSight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dropOnGround
void DragAndDrop::dropOnGround( cUOSocket* socket, P_ITEM pItem, const Coord_cl& pos )
{
P_PLAYER pChar = socket->player();
// Check if the destination is in line of sight
if ( !pChar->lineOfSight( pos.losItemPoint(pItem->id()) ) )
{
socket->bounceItem( pItem, BR_OUT_OF_SIGHT );
return;
}
if ( !pChar->canPickUp( pItem ) )
{
socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP );
return;
}
if ( pItem->onDropOnGround( pos ) )
{
// We're still dragging something
if ( socket->dragging() )
socket->bounceItem( socket->dragging(), BR_NO_REASON );
return;
}
pItem->removeFromCont();
pItem->moveTo( pos );
pItem->update();
// Play Sounds for non gold items
if (pItem->id() != 0xEED) {
pItem->soundEffect(0x42);
}
}
示例2: grabItem
// New Class implementation
void DragAndDrop::grabItem( cUOSocket* socket, cUORxDragItem* packet )
{
// Get our character
P_PLAYER pChar = socket->player();
if ( !pChar )
return;
float weight = pChar->weight();
// Fetch the grab information
UI16 amount = packet->amount();
if ( !amount )
amount = 1;
P_ITEM pItem = FindItemBySerial( packet->serial() );
// If it's an invalid pointer we can't even bounce
if ( !pItem )
return;
// Are we already dragging an item ?
// Bounce it and reject the move
// (Logged out while dragging an item)
if ( socket->dragging() )
{
socket->bounceItem( socket->dragging(), BR_ALREADY_DRAGGING );
return;
}
// Check if the item can be reached
if (pItem->getOutmostChar() != pChar && !pChar->lineOfSight(pItem)) {
socket->bounceItem( pItem, BR_OUT_OF_REACH );
return;
}
if ( pItem->onPickup( pChar ) )
return;
if ( pChar->onPickup( pItem ) )
return;
// Do we really want to let him break his meditation
// When he picks up an item ?
// Maybe a meditation check here ?!?
pChar->disturbMed(); // Meditation
P_CHAR itemOwner = pItem->getOutmostChar();
// Try to pick something out of another characters posessions
if ( !pChar->isGM() && itemOwner && ( itemOwner != pChar ) && ( itemOwner->objectType() == enNPC && dynamic_cast<P_NPC>( itemOwner )->owner() != pChar ) )
{
socket->bounceItem( pItem, BR_BELONGS_TO_SOMEONE_ELSE );
return;
}
// Check if the user can grab the item
if ( !pChar->canPickUp( pItem ) )
{
socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP );
return;
}
// The user can't see the item
// Basically thats impossible as the socket should deny moving the item
// if it's not in line of sight but to prevent exploits
/*if( !line_of_sight( socket->socket(), pChar->pos, pItem->pos, TREES_BUSHES|WALLS_CHIMNEYS|DOORS|ROOFING_SLANTED|FLOORS_FLAT_ROOFING|LAVA_WATER ) )
{
socket->sysMessage( "You can't see the item." );
bounceItem( socket, pItem, true );
return;
}*/
P_ITEM outmostCont = pItem->getOutmostItem();
// If the top-most container ( thats important ) is a corpse
// and looting is a crime, flag the character criminal.
if ( !pChar->isGM() && outmostCont && outmostCont->corpse() )
{
// For each item we take out we loose carma
// if the corpse is innocent and not in our guild
bool sameGuild = true;//( GuildCompare( pChar, outmostCont->owner() ) != 0 );
if ( outmostCont->hasTag( "notoriety" ) && outmostCont->getTag( "notoriety" ).toInt() == 1 && !pChar->owns( outmostCont ) && !sameGuild )
{
// pChar->karma -= 5;
pChar->setKarma( pChar->karma() - 5 );
pChar->setCriminalTime( Server::instance()->time() + Config::instance()->crimtime() * MY_CLOCKS_PER_SEC );
socket->sysMessage( tr( "You lost some karma." ) );
}
}
// Check if the item is too heavy
//if( !pc_currchar->isGMorCounselor() )
//{
//} << Deactivated (DarkStorm)
// ==== Grabbing the Item is allowed here ====
// Send the user a pickup sound if we're picking it up
//.........这里部分代码省略.........