本文整理汇总了C++中P_ITEM::MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C++ P_ITEM::MoveTo方法的具体用法?C++ P_ITEM::MoveTo怎么用?C++ P_ITEM::MoveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_ITEM
的用法示例。
在下文中一共展示了P_ITEM::MoveTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ItemDroppedOnSelf
static bool ItemDroppedOnSelf(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi)
{
if (ps == NULL) return false;
VALIDATEPIR(pi, false);
// NXWSOCKET s=ps->toInt();
// CHARACTER cc=ps->currCharIdx();
P_CHAR pc = ps->currChar(); // MAKE_CHAR_REF(cc);
VALIDATEPCR(pc, false);
Location charpos = pc->getPosition();
if (pi->getId() >= 0x4000 ) // crashfix , prevents putting multi-objects ni your backback
{
ps->sysmsg(TRANSLATE("Hey, putting houses in your pack crashes your back and client !"));
pi->MoveTo( charpos );
pi->Refresh();//AntiChrist
return true;
}
// if (pi->glow>0) // glowing items
// {
// pc->addHalo(pi);
// pc->glowHalo(pi);
// }
P_ITEM pack = pc->getBackpack();
if (pack==NULL) // if player has no pack, put it at its feet
{
pi->MoveTo( charpos );
pi->Refresh();
}
else
{
pack->AddItem(pi); // player has a pack, put it in there
weights::NewCalc(pc);//AntiChrist bugfixes
statwindow(pc,pc);
pc->playSFX( itemsfx(pi->getId()) );
}
return true;
}
示例2: ItemDroppedOnSelf
static bool ItemDroppedOnSelf(P_CLIENT ps, PKGx08 *pp, P_ITEM pi)
{
UOXSOCKET s=ps->GetSocket();
CHARACTER cc=ps->GetCurrChar();
P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,true);
if (pi->id1>=0x40) // crashfix , prevents putting multi-objects ni your backback
{
sysmessage(s,"Hey, putting houses in your pack crashes your back and client !");
pi->MoveTo(pc_currchar->pos.x,pc_currchar->pos.y,pc_currchar->pos.z);
RefreshItem(pi);//AntiChrist
return true;
}
if (pi->glow>0) // glowing items
{
pc_currchar->addHalo(pi);
pc_currchar->glowHalo(pi);
}
P_ITEM pack = Packitem(pc_currchar); // LB ...
if (pack == NULL) // if player has no pack, put it at its feet
{
pi->MoveTo(pc_currchar->pos.x,pc_currchar->pos.y,pc_currchar->pos.z);
RefreshItem(pi);//AntiChrist
}
else
{
pack->AddItem(pi); // player has a pack, put it in there
Weight->NewCalc(DEREF_P_CHAR(pc_currchar));//AntiChrist bugfixes
statwindow(s,DEREF_P_CHAR(pc_currchar));
itemsfx(s, pi->id());
}
return true;
}
示例3: Turn
void cBoat::Turn(P_ITEM pBoat, int turn)//Turn the boat item, and send all the people/items on the boat to turnboatstuff()
{
if (pBoat == NULL) return;
int id2 = pBoat->id2 ,olddir = pBoat->dir;
unsigned short int Send[MAXCLIENT];
SERIAL serial;
int a,dir, d=0;
for (a = 0; a < now; ++a)
{
if (iteminrange(a, pBoat, BUILDRANGE) && perm[a])
{
Send[d]=a;
Xsend(a,wppause,2);
d++;
}
}
//Of course we need the boat items!
serial = calcserial(pBoat->moreb1,pBoat->moreb2,pBoat->moreb3,pBoat->moreb4);
if(serial == INVALID_SERIAL) return;
P_ITEM pTiller = FindItemBySerial( serial );
if(pTiller == NULL) return;
P_ITEM pi_p1 = FindItemBySerial( pBoat->morex );
if(pi_p1 == NULL) return;
P_ITEM pi_p2 = FindItemBySerial( pBoat->morey );
if(pi_p2 == NULL) return;
P_ITEM pi_hold = FindItemBySerial( pBoat->morez );
if(pi_hold == NULL) return;
if(turn)//Right
{
pBoat->dir+=2;
id2++;
} else {//Left
pBoat->dir-=2;
id2--;
}
if(pBoat->dir>7) pBoat->dir-=4;//Make sure we dont have any DIR errors
//if(pBoat->dir<0) pBoat->dir+=4;
if(id2<pBoat->more1) id2+=4;//make sure we don't have any id errors either
if(id2>pBoat->more2) id2-=4;//Now you know what the min/max id is for :-)
pBoat->id2=id2;//set the id
if(pBoat->id2==pBoat->more1) pBoat->dir=0;//extra DIR error checking
if(pBoat->id2==pBoat->more2) pBoat->dir=6;
if( Block( pBoat, 0, 0, pBoat->dir ) )
{
pBoat->dir = olddir;
for( a = 0; a < d; a++ )
{
Xsend( Send[a], restart, 2 );
itemtalk( Send[a], pTiller, "Arr, something's in the way!" );
}
return;
}
pBoat->id2=id2;//set the id
if(pBoat->id2==pBoat->more1) pBoat->dir=0;//extra DIR error checking
if(pBoat->id2==pBoat->more2) pBoat->dir=6;
serial=pBoat->serial; // lb !!!
unsigned int ci;
vector<SERIAL> vecEntries = imultisp.getData(serial);
for (ci = 0; ci < vecEntries.size(); ci++)
{
P_ITEM pi = FindItemBySerial(vecEntries[ci]);
if (pi != NULL)
TurnStuff(pBoat, pi, turn);
}
vecEntries.clear();
vecEntries = cmultisp.getData(serial);
for (ci = 0; ci < vecEntries.size(); ci++)
{
P_CHAR pc = FindCharBySerial(vecEntries[ci]);
if (pc != NULL)
TurnStuff(pBoat, pc, turn);
}
//Set the DIR for use in the Offsets/IDs array
dir = (pBoat->dir&0x0F)/2;
//set it's Z to 0,0 inside the boat
pi_p1->MoveTo(pBoat->pos.x,pBoat->pos.y,pi_p1->pos.z);
pi_p1->id2 = cShipItems[dir][PORT_P_C];//change the ID
pi_p2->MoveTo(pBoat->pos.x,pBoat->pos.y,pi_p2->pos.z);
pi_p2->id2=cShipItems[dir][STAR_P_C];
//.........这里部分代码省略.........
示例4: Move
void cBoat::Move(UOXSOCKET s, int dir, P_ITEM pBoat)
{//Move the boat and all it's items 1 square
int tx=0,ty=0;
int serial;
if (pBoat == NULL)
return;
serial = calcserial(pBoat->moreb1, pBoat->moreb2, pBoat->moreb3, pBoat->moreb4);
if (serial == INVALID_SERIAL) return;
P_ITEM pTiller = FindItemBySerial( serial );
if(pTiller == NULL)
return;
P_ITEM pi_p1 = FindItemBySerial( pBoat->morex );
if(pi_p1 == NULL)
return;
P_ITEM pi_p2 = FindItemBySerial( pBoat->morey );
if(pi_p2 == NULL)
return;
P_ITEM pHold = FindItemBySerial( pBoat->morez );
if(pHold == NULL)
return;
Xsend(s,wppause,2);
switch(dir&0x0F)//Which DIR is it going in?
{
case '\x00' :
ty--;
break;
case '\x01' :
tx++;
ty--;
break;
case '\x02' :
tx++;
break;
case '\x03' :
tx++;
ty++;
break;
case '\x04' :
ty++;
break;
case '\x05' :
tx--;
ty++;
break;
case '\x06' :
tx--;
break;
case '\x07' :
tx--;
ty--;
break;
default:
{
sprintf((char*)temp,"warning: Boat direction error: %i int boat %i\n",pBoat->dir&0x0F,pBoat->serial);
LogWarning((char*)temp);
break;
}
}
if((pBoat->pos.x+tx<=200 || pBoat->pos.x+tx>=6000) && (pBoat->pos.y+ty<=200 || pBoat->pos.y+ty>=4900)) //bugfix LB
{
pBoat->type2=0;
itemtalk(s, pTiller, "Arr, Sir, we've hit rough waters!");
Xsend(s,restart,2);
return;
}
if(Block(pBoat,tx,ty,dir))
{
pBoat->type2=0;
itemtalk(s, pTiller, "Arr, somethings in the way!");
Xsend(s,restart,2);
return;
}
//Move all the special items
Coord_cl desloc(tx, ty, 0);
pBoat->moveTo(pBoat->pos + desloc);
pTiller->moveTo(pTiller->pos + desloc);
pi_p1->moveTo(pi_p1->pos + desloc);
pi_p2->moveTo(pi_p2->pos + desloc);
pHold->moveTo(pHold->pos + desloc);
serial = pBoat->serial;
unsigned int a;
vector<SERIAL> vecEntries = imultisp.getData(pBoat->serial);
for (a = 0; a < vecEntries.size(); a++)
{
P_ITEM pi = FindItemBySerial(vecEntries[a]);
if(pi != NULL)
{
pi->MoveTo(pi->pos.x+=tx, pi->pos.y+=ty, pi->pos.z);
sendinrange(pi);
//.........这里部分代码省略.........
示例5: ItemDroppedOnChar
//.........这里部分代码省略.........
item_bounce5(s,pi);
}
}
return true;
}
if ( pTC->npcaitype == 5 )
{
if (!ItemDroppedOnBeggar( ps, pp, pi))
{
Sndbounce5(s);
if (ps->IsDragging())
{
ps->ResetDragging();
item_bounce5(s,pi);
}
}
return true;
}
if ( pTC->npcaitype == 8 )
{
if (!ItemDroppedOnBanker( ps, pp, pi))
{
Sndbounce5(s);
if (ps->IsDragging())
{
ps->ResetDragging();
item_bounce5(s,pi);
}
}
return true;
}
//This crazy training stuff done by Anthracks ([email protected])
if(pc_currchar->trainer!=pTC->serial)
{
npctalk(s, DEREF_P_CHAR(pTC), "Thank thee kindly, but I have done nothing to warrant a gift.",0);
Sndbounce5(s);
if (ps->IsDragging())
{
ps->ResetDragging();
item_bounce5(s,pi);
}
return true;
}
else // The player is training from this NPC
{
ItemDroppedOnTrainer( ps, pp, pi);
return true;
}
}//if human or not
}
else // dropped on another player
{
// By Polygon: Avoid starting the trade if GM drops item on logged on char (crash fix)
if ((pc_currchar->isGM()) && !online(DEREF_P_CHAR(pTC)))
{
// Drop the item in the players pack instead
// Get the pack
P_ITEM pack = Packitem(pTC);
if (pack != NULL) // Valid pack?
{
pack->AddItem(pi); // Add it
Weight->NewCalc(DEREF_P_CHAR(pTC));
}
else // No pack, give it back to the GM
{
pack = Packitem(pc_currchar);
if (pack != NULL) // Valid pack?
{
pack->AddItem(pi); // Add it
Weight->NewCalc(DEREF_P_CHAR(pc_currchar));
}
else // Even GM has no pack?
{
// Drop it to it's feet
pi->MoveTo(pc_currchar->pos.x, pc_currchar->pos.y, pc_currchar->pos.z);
RefreshItem(pi);
}
}
}
else
{
P_ITEM pj = Trade->tradestart(s, DEREF_P_CHAR(pTC)); //trade-stuff
pi->SetContSerial(pj->serial);
pi->pos.x=30;
pi->pos.y=30;
pi->pos.z=9;
SndRemoveitem(pi->serial);
RefreshItem(pi);
}
}
}
else // dumping stuff to his own backpack !
{
ItemDroppedOnSelf( ps, pp, pi);
}
return true;
}
示例6: pack_item
void pack_item(P_CLIENT ps, PKGx08 *pp) // Item is put into container
{
int j, serial;
bool abort=false;
UOXSOCKET s=ps->GetSocket();
CHARACTER cc=ps->GetCurrChar();
P_CHAR pc_currchar = MAKE_CHARREF_LR(cc);
serial=pp->Tserial;
if(serial == INVALID_SERIAL) abort=true;
const P_ITEM pCont= FindItemBySerial( serial );
serial=pp->Iserial;
if(serial == INVALID_SERIAL) abort=true;
const P_ITEM pItem = FindItemBySerial( serial );
if (pCont == NULL)
{
RefreshItem(pCont);//AntiChrist
return;
}
if (pItem == NULL || pCont == NULL) return; //LB
pItem->flags.isBeeingDragged=false;
if (pItem->id1>=0x40)
{
abort=true; // LB crashfix that prevents moving multi objcts in BP's
sysmessage(s,"Hey, putting houses in your pack crashes your back and client!");
}
j=DEREF_P_CHAR(GetPackOwner(pCont));
if (j>-1)
if (chars[j].npcaitype==17 && chars[j].isNpc() && !pc_currchar->Owns(&chars[j]))
{
abort=true;
sysmessage(s, "This aint your vendor!");
}
if(abort)
{//AntiChrist to preview item disappearing
item_bounce6(ps,pItem);
return;
}
if (pCont->layer==0 && pCont->id() == 0x1E5E &&
pc_currchar->Wears(pCont))
{
// Trade window???
serial=calcserial(pCont->moreb1, pCont->moreb2, pCont->moreb3, pCont->moreb4);
if(serial == INVALID_SERIAL) return;
P_ITEM pi_z = FindItemBySerial( serial );
if (pi_z != NULL)
if ((pi_z->morez || pCont->morez))
{
pi_z->morez=0;
pCont->morez=0;
sendtradestatus(pi_z, pCont);
}
}
//
//AntiChrist - Special Bank Stuff
//
//if morey==123 - gold only bank
//
if(SrvParms->usespecialbank)//only if special bank is activated
{
if(pCont->morey==123 && pCont->morex==1 && pCont->type==1)
{
if ( pItem->id() == 0x0EED )
{//if they're gold ok
goldsfx(s, 2);
} else
{//if they're not gold..bounce on ground
sysmessage(s,"You can only put golds in this bank box!");
pItem->SetContSerial(-1);
pItem->MoveTo(pc_currchar->pos.x,pc_currchar->pos.y,pc_currchar->pos.z);
RefreshItem(pItem);//AntiChrist
itemsfx(s,pItem->id());
return;
}
}
}
//testing UOP Blocking Tauriel 1-12-99
if (!pItem->isInWorld())
{
item_bounce6(ps,pItem);
return;
}
if (!pc_currchar->canPickUp(pItem))
{
Sndbounce5(s);
if (ps->IsDragging())
{
ps->ResetDragging();
item_bounce3(pItem);
//.........这里部分代码省略.........
示例7: doDecay
/*!
\author Luxor
\brief execute decay on the item
\return true if decayed (so deleted), false else
*/
LOGICAL cItem::doDecay()
{
if ( !canDecay() )
return false;
if ( magic == 4/* || magic == 2*/ )
return false;
if ( !isInWorld() )
return false;
if ( TIMEOUT( decaytime ) )
{
if ( amxevents[EVENT_IONDECAY] !=NULL )
{
g_bByPass = false;
amxevents[EVENT_IONDECAY]->Call(getSerial32(), DELTYPE_DECAY);
if ( g_bByPass == true )
return false;
}
/*
g_bByPass = false;
runAmxEvent( EVENT_IONDECAY, getSerial32(), DELTYPE_DECAY );
if ( g_bByPass == true )
return false;
*/
//Multis
if ( !isFieldSpellItem() && !corpse )
{
if ( getMultiSerial32() == INVALID )
{
P_ITEM pi_multi = findmulti(getPosition());
if ( ISVALIDPI(pi_multi) )
{
if ( pi_multi->more4 == 0 )
{
setDecayTime();
SetMultiSerial(pi_multi->getSerial32());
return false;
}
}
}
else
{
setDecayTime();
return false;
}
}
//End Multis
if( type == ITYPE_CONTAINER || ( !SrvParms->lootdecayswithcorpse && corpse ) )
{
NxwItemWrapper si;
si.fillItemsInContainer( this, false );
for( si.rewind(); !si.isEmpty(); si++ )
{
P_ITEM pj = si.getItem();
if( ISVALIDPI(pj) )
{
pj->setContSerial(INVALID);
pj->MoveTo( getPosition() );
pj->setDecayTime();
pj->Refresh();
}
}
}
Delete();
return true;
}
else
return false;
}
示例8: pack_item
void pack_item(NXWCLIENT ps, PKGx08 *pp) // Item is put into container
{
if (ps == NULL) return;
char temp[TEMP_STR_SIZE]; //xan -> this overrides the global temp var
char temp2[TEMP_STR_SIZE]; //xan -> this overrides the global temp var
int serial/*, serhash*/;
tile_st tile;
// bool abort=false;
NXWSOCKET s=ps->toInt();
P_CHAR pc=ps->currChar();
VALIDATEPC(pc);
Location charpos= pc->getPosition();
P_ITEM pack;
P_ITEM pCont = pointers::findItemBySerial(pp->Tserial);
VALIDATEPI(pCont);
P_ITEM pItem = pointers::findItemBySerial(pp->Iserial);
VALIDATEPI(pItem);
if (pItem->getId() >= 0x4000)
{
// abort=true; // LB crashfix that prevents moving multi objcts in BP's
ps->sysmsg(TRANSLATE("Hey, putting houses in your pack crashes your back and client!"));
}
//ndEndy recurse only a time
P_ITEM contOutMost = pCont->getOutMostCont();
P_CHAR contOwner = ( !contOutMost->isInWorld() )? pointers::findCharBySerial( contOutMost->getContSerial() ) : NULL;
if( ISVALIDPC(contOwner) ) {
//if ((contOwner->npcaitype==NPCAI_PLAYERVENDOR) && (contOwner->npc) && (contOwner->getOwnerSerial32()!=pc->getSerial32()) )
if ( contOwner->getSerial32() != pc->getSerial32() && contOwner->getOwnerSerial32() != pc->getSerial32() && !pc->IsGM() ) { // Luxor
ps->sysmsg(TRANSLATE("This aint your backpack!"));
Sndbounce5(s);
if (ps->isDragging()) {
ps->resetDragging();
item_bounce3(pItem);
if (pCont->getId() >= 0x4000)
senditem(s, pCont);
}
return;
}
}
if (pCont->amxevents[EVENT_IONPUTITEM]!=NULL) {
g_bByPass = false;
pCont->amxevents[EVENT_IONPUTITEM]->Call( pCont->getSerial32(), pItem->getSerial32(), pc->getSerial32() );
if (g_bByPass)
{
item_bounce6(ps,pItem);
return;
}
}
/*
g_bByPass = false;
pCont->runAmxEvent( EVENT_IONPUTITEM, pCont->getSerial32(), pItem->getSerial32(), pc->getSerial32() );
if (g_bByPass)
{ //AntiChrist to preview item disappearing
item_bounce6(ps,pItem);
return;
}
*/
if (pCont->layer==0 && pCont->getId() == 0x1E5E &&
pCont->getContSerial()==pc->getSerial32())
{
// Trade window???
serial=calcserial(pCont->moreb1, pCont->moreb2, pCont->moreb3, pCont->moreb4);
if(serial==-1) return;
P_ITEM pi_z = pointers::findItemBySerial(serial);
if (ISVALIDPI(pi_z))
if ((pi_z->morez || pCont->morez))
{
pi_z->morez=0;
pCont->morez=0;
sendtradestatus( pi_z, pCont );
}
}
if(SrvParms->usespecialbank)//only if special bank is activated
{
if(pCont->morey==MOREY_GOLDONLYBANK && pCont->morex==MOREX_BANK && pCont->type==ITYPE_CONTAINER)
{
if ( pItem->getId() == ITEMID_GOLD )
{//if they're gold ok
pc->playSFX( goldsfx(2) );
} else
{//if they're not gold..bounce on ground
ps->sysmsg(TRANSLATE("You can only put golds in this bank box!"));
pItem->setContSerial(-1);
pItem->MoveTo( charpos );
pItem->Refresh();
//.........这里部分代码省略.........
示例9: ItemDroppedOnChar
//.........这里部分代码省略.........
return true;
}
else // The player is training from this NPC
{
ItemDroppedOnTrainer( ps, pp, pi);
}
}
if ( pTC->isHirable() )
{
// test if gold is enough
if ( pi->amount < pTC->getHireFee() )
{
pTC->talk(s, TRANSLATE("I need much more gold if i shall be working for you !"),0);
Sndbounce5(s);
if (ps->isDragging())
{
ps->resetDragging();
item_bounce5(s,pi);
}
return true;
}
else if ( pi->amount >= pTC->getHireFee() )
{
if ( pi->amount > pTC->getHireFee() )
{
pi->amount=(UI16)(pi->amount - pTC->getHireFee());
pTC->talk(s, TRANSLATE("Thank thee kindly, but this is more than i need for the day."),0);
Sndbounce5(s);
if (ps->isDragging())
{
ps->resetDragging();
item_bounce5(s,pi);
}
}
pTC->setOwner(pc_currchar);
tempfx::add(pTC,
pc_currchar,
tempfx::NPC_HIRECOST,
0,
0,
0,
0,
(UI16)(MY_CLOCKS_PER_SEC*secondsperuominute*60*24 )); // call callback every uo day
return true;
}
}
}//if human or not
}
else // dropped on another player
{
// By Polygon: Avoid starting the trade if GM drops item on logged on char (crash fix)
if ((pc_currchar->IsGM()) && !pTC->IsOnline())
{
// Drop the item in the players pack instead
// Get the pack
P_ITEM pack = pTC->getBackpack();
if (pack != NULL) // Valid pack?
{
pack->AddItem(pi); // Add it
weights::NewCalc(pTC);
}
else // No pack, give it back to the GM
{
pack = pc_currchar->getBackpack();
if (pack != NULL) // Valid pack?
{
pack->AddItem(pi); // Add it
weights::NewCalc(pc_currchar);
}
else // Even GM has no pack?
{
// Drop it to it's feet
pi->MoveTo( charpos );
pi->Refresh();
}
}
}
else
{
//<Luxor>: secure trade
P_ITEM tradeCont = tradestart(pc_currchar, pTC);
if (ISVALIDPI(tradeCont)) {
tradeCont->AddItem( pi, 30, 30 );
} else {
Sndbounce5(s);
if (ps->isDragging()) {
ps->resetDragging();
UpdateStatusWindow(s,pi);
}
}
//</Luxor>
}
}
}
else // dumping stuff to his own backpack !
{
ItemDroppedOnSelf( ps, pp, pi);
}
return true;
}