本文整理汇总了C++中P_ITEM::Refresh方法的典型用法代码示例。如果您正苦于以下问题:C++ P_ITEM::Refresh方法的具体用法?C++ P_ITEM::Refresh怎么用?C++ P_ITEM::Refresh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_ITEM
的用法示例。
在下文中一共展示了P_ITEM::Refresh方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddItem
/*!
\brief Add item to container
\author Endymion
\param pItem the item to add
\param xx the x location or INVALID if use rand pos
\param yy the y location or INVALID if use rand pos
*/
LOGICAL cItem::AddItem(P_ITEM pItem, short xx, short yy)
{
VALIDATEPIR(pItem,false);
NxwSocketWrapper sw;
sw.fillOnline( pItem );
for( sw.rewind(); !sw.isEmpty(); sw++ )
SendDeleteObjectPkt(sw.getSocket(), pItem->getSerial32() );
if (xx!=-1) // use the given position
{
pItem->setContSerial( getSerial32() );
pItem->setPosition(xx, yy, 9);
}
else // no pos given
{
if( !ContainerPileItem(pItem) ) { // try to pile
pItem->SetRandPosInCont(this); // not piled, random pos
pItem->setContSerial( getSerial32() );
}
else
return true; //Luxor: we cannot do a refresh because item was piled
}
pItem->Refresh();
return true;
}
示例2: 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;
}
示例3: target_randomSteal
//.........这里部分代码省略.........
VALIDATEPI(pi);
if( pi->isNewbie() )
{//newbie
thief->sysmsg(TRANSLATE("... and fail because it is of no value to you."));
return;
}
if(pi->isSecureContainer())
{
thief->sysmsg(TRANSLATE("... and fail because it's a locked container."));
return;
}
if ( thief->checkSkill( STEALING,0,999) )
{
// 0 stealing 2 stones, 10 3 stones, 99.9 12 stones, 100 17 stones !!!
int cansteal = thief->skill[STEALING] > 999 ? 1700 : thief->skill[STEALING] + 200;
if ( ((pi->getWeightActual())>cansteal) && !pi->isContainer())//Containers
thief->sysmsg(TRANSLATE("... and fail because it is too heavy."));
else
if(pi->isContainer() && (weights::RecursePacks(pi)>cansteal))
thief->sysmsg(TRANSLATE("... and fail because it is too heavy."));
else
{
if (victim->amxevents[EVENT_CHR_ONSTOLEN])
{
g_bByPass = false;
victim->amxevents[EVENT_CHR_ONSTOLEN]->Call(victim->getSerial32(), thief->getSerial32());
if (g_bByPass==true)
return;
}
/*
victim->runAmxEvent( EVENT_CHR_ONSTOLEN, victim->getSerial32(), s);
if (g_bByPass==true)
return;
*/
P_ITEM thiefpack = thief->getBackpack();
VALIDATEPI(thiefpack);
pi->setContSerial( thiefpack->getSerial32() );
thief->sysmsg(TRANSLATE("... and you succeed."));
pi->Refresh();
//all_items(s);
}
}
else
thief->sysmsg(TRANSLATE(".. and fail because you're not good enough."));
if ( thief->skill[STEALING] < rand()%1001 )
{
thief->unHide();
thief->sysmsg(TRANSLATE("You have been caught!"));
thief->IncreaseKarma( ServerScp::g_nStealKarmaLoss);
thief->modifyFame( ServerScp::g_nStealFameLoss);
if (victim->IsInnocent() && thief->attackerserial!=victim->getSerial32() && Guilds->Compare(thief,victim)==0)//AntiChrist
setCrimGrey(thief, ServerScp::g_nStealWillCriminal);//Blue and not attacker and not guild
std::string itmname = "";
if ( pi->getCurrentName() != "#" )
itmname = pi->getCurrentName();
else
{
pi->getName( temp );
itmname = temp;
}
sprintf(temp,TRANSLATE("You notice %s trying to steal %s from you!"), thief->getCurrentNameC(), itmname.c_str());
sprintf(temp2,TRANSLATE("You notice %s trying to steal %s from %s!"), thief->getCurrentNameC(), itmname.c_str(), victim->getCurrentNameC());
if ( victim->npc)
victim->talkAll(TRANSLATE( "Guards!! A thief is amoung us!"),0);
else
victim->sysmsg(temp);
//send to all player temp2 = thief are stealing victim if are more intelligent and a bonus of luck :D
//
//
NxwSocketWrapper sw;
sw.fillOnline( thief, true );
for( sw.rewind(); !sw.isEmpty(); sw++ ) {
NXWCLIENT ps_i=sw.getClient();
if( ps_i==NULL ) continue;
P_CHAR pc_i=ps_i->currChar();
if ( ISVALIDPC(pc_i) )
if( (rand()%10+10==17) || ( (rand()%2==1) && (pc_i->in>=thief->in)))
sysmessage(ps_i->toInt(),temp2);
}
}
}
else
{
thief->sysmsg( TRANSLATE("... and realise you're too far away."));
}
}
示例4: target_stealing
//.........这里部分代码省略.........
return;
}
if (pi->amxevents[EVENT_IONSTOLEN]!=NULL)
{
g_bByPass = false;
pi->amxevents[EVENT_IONSTOLEN]->Call(pi->getSerial32(), thief->getSerial32(), victim->getSerial32());
if (g_bByPass==true)
return;
}
if (victim->amxevents[EVENT_CHR_ONSTOLEN])
{
g_bByPass = false;
victim->amxevents[EVENT_CHR_ONSTOLEN]->Call(victim->getSerial32(), thief->getSerial32());
if (g_bByPass==true)
return;
}
/*
pi->runAmxEvent( EVENT_IONSTOLEN, pi->getSerial32(), s, victim->getSerial32() );
if (g_bByPass==true)
return;
victim->runAmxEvent( EVENT_CHR_ONSTOLEN, victim->getSerial32(), s );
if (g_bByPass==true)
return;
*/
P_ITEM pack= thief->getBackpack();
VALIDATEPI(pack);
pi->setContSerial( pack->getSerial32() );
thief->sysmsg(TRANSLATE("You successfully steal the item."));
pi->Refresh();
result=+200;
//all_items(s); why all item?
}
else
{
thief->sysmsg( TRANSLATE("You failed to steal the item."));
result=-200;
//Only onhide when player is caught!
}
if ( rand()%1000 > ( thief->skill[STEALING] + result ) )
{
thief->unHide();
thief->sysmsg(TRANSLATE("You have been caught!"));
thief->IncreaseKarma(ServerScp::g_nStealKarmaLoss);
thief->modifyFame(ServerScp::g_nStealFameLoss);
if ( victim->IsInnocent() && thief->attackerserial != victim->getSerial32() && Guilds->Compare(thief,victim)==0)
setCrimGrey(thief, ServerScp::g_nStealWillCriminal); //Blue and not attacker and not same guild
std::string itmname ( "" );
char temp[TEMP_STR_SIZE]; //xan -> this overrides the global temp var
char temp2[TEMP_STR_SIZE]; //xan -> this overrides the global temp var
if ( pi->getCurrentName() != "#" )
itmname = pi->getCurrentName();
else
{
pi->getName( temp );
itmname = temp;
}
sprintf(temp,TRANSLATE("You notice %s trying to steal %s from you!"), thief->getCurrentNameC(), itmname.c_str());
sprintf(temp2,TRANSLATE("You notice %s trying to steal %s from %s!"), thief->getCurrentNameC(), itmname.c_str(), victim->getCurrentNameC());
if ( victim->npc )
if( victim->HasHumanBody() )
victim->talkAll(TRANSLATE( "Guards!! A thief is amoung us!"),0);
else
victim->sysmsg(temp);
//send to all player temp2 = thief are stealing victim if are more intelligent and a bonus of luck :D
NxwSocketWrapper sw;
sw.fillOnline( thief, true );
for( sw.rewind(); !sw.isEmpty(); sw++ ) {
NXWCLIENT ps_i=sw.getClient();
if(ps_i==NULL ) continue;
P_CHAR pc_i=ps_i->currChar();
if ( ISVALIDPC(pc_i) )
if( (rand()%10+10==17) || ( (rand()%2==1) && (pc_i->in>=thief->in)))
pc_i->sysmsg(temp2);
}
}
}
else
{
thief->sysmsg(TRANSLATE("You are too far away to steal that item."));
}
AMXEXECSVTARGET( thief->getSerial32(),AMXT_SKITARGS,STEALING,AMX_AFTER);
}
示例5: 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;
}
示例6: get_item
/*!
\brief Get an item
\author Unknow, revamped by Endymion
\param client the client
*/
void get_item( NXWCLIENT client ) // Client grabs an item
{
if ( client == NULL)
return;
P_CHAR pc_currchar = client->currChar();
VALIDATEPC( pc_currchar );
NXWSOCKET s = client->toInt();
P_ITEM pi = pointers::findItemBySerPtr(buffer[s]+1);
VALIDATEPI(pi);
//Luxor: not-movable items
/*if (pi->magic == 2 || (isCharSerial(pi->getContSerial()) && pi->getContSerial() != pc_currchar->getSerial32()) ) {
if (isCharSerial(pi->getContSerial())) {
P_CHAR pc_i = pointers::findCharBySerial(pi->getContSerial());
if (ISVALIDPC(pc_i))
pc_i->sysmsg("Warning, backpack bug located!");
}
if (client->isDragging()) {
client->resetDragging();
UpdateStatusWindow(s,pi);
}
pi->setContSerial( pi->getContSerial(true) );
pi->setPosition( pi->getOldPosition() );
pi->layer = pi->oldlayer;
pi->Refresh();
return;
}*/
pc_currchar->disturbMed(); // Meditation
tile_st item;
data::seekTile( pi->getId(), item );
// Check if item is equiped
if( pi->getContSerial() == pc_currchar->getSerial32() && pi->layer == item.quality )
{
if( pc_currchar->UnEquip( pi, 1 ) == 1 ) // bypass called
{
if( client->isDragging() )
{
UI08 cmd[1]= {0x29};
client->resetDragging();
Xsend(s, cmd, 1);
UpdateStatusWindow(s,pi);
//AoS/ Network->FlushBuffer(s);
}
return;
}
}
P_CHAR owner=NULL;
P_ITEM container=NULL;
if ( !pi->isInWorld() ) { // Find character owning item
if ( isCharSerial( pi->getContSerial()))
{
owner = pointers::findCharBySerial( pi->getContSerial());
}
else // its an item
{
//Endymion Bugfix:
//before check the container.. but if this cont is a subcont?
//so get the outmostcont and check it else:
//can loot without lose karma in subcont
//can steal in trade ecc
//not very good :P
container = pi->getOutMostCont();
if( isCharSerial( container->getContSerial() ) )
owner=pointers::findCharBySerial( container->getContSerial() );
}
if ( ISVALIDPC( owner ) && owner->getSerial32()!=pc_currchar->getSerial32() )
{
if ( !pc_currchar->IsGM() && owner->getOwnerSerial32() != pc_currchar->getSerial32() )
{// Own serial stuff by Zippy -^ Pack aniamls and vendors.
UI08 bounce[2]= { 0x27, 0x00 };
Xsend(s, bounce, 2);
//AoS/ Network->FlushBuffer(s);
if (client->isDragging())
{
client->resetDragging();
pi->setContSerial(pi->getContSerial(),true,false);
item_bounce3(pi);
UpdateStatusWindow(s,pi);
}
return;
}
}
}
if ( ISVALIDPI( container ) )
//.........这里部分代码省略.........
示例7: 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();
//.........这里部分代码省略.........
示例8: ItemDroppedOnChar
static bool ItemDroppedOnChar(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi)
{
if (ps == NULL) return true;
VALIDATEPIR(pi, false);
NXWSOCKET s = ps->toInt();
// CHARACTER cc=ps->currCharIdx();
P_CHAR pTC = pointers::findCharBySerial(pp->Tserial); // the targeted character
VALIDATEPCR(pTC, false);
P_CHAR pc_currchar = ps->currChar(); //MAKE_CHAR_REF(cc);
VALIDATEPCR(pc_currchar, false);
Location charpos = pc_currchar->getPosition();
if (!pTC) return true;
if (pi->amxevents[EVENT_IDROPONCHAR]!=NULL)
{
g_bByPass = false;
pi->amxevents[EVENT_IDROPONCHAR]->Call( pi->getSerial32(), pc_currchar->getSerial32(), pTC->getSerial32() );
if (g_bByPass) {
pi->Refresh();
return true;
}
}
if (pc_currchar->getSerial32() != pTC->getSerial32() /*DEREF_P_CHAR(pTC)!=cc*/)
{
if (pTC->npc)
{
if(!pTC->HasHumanBody())
{
ItemDroppedOnPet( ps, pp, pi);
}
else // Item dropped on a Human character
{
// Item dropped on a Guard (possible bounty quest)
if( ( pTC->npc == 1 ) && ( pTC->npcaitype == NPCAI_TELEPORTGUARD ) )
{
ItemDroppedOnGuard( ps, pp, pi);
}
if ( pTC->npcaitype == NPCAI_BEGGAR )
{
ItemDroppedOnBeggar( ps, pp, pi);
}
//This crazy training stuff done by Anthracks ([email protected])
if(pc_currchar->isBeingTrained() )
{
if ( pc_currchar->trainer != pTC->getSerial32())
{
pTC->talk(s, TRANSLATE("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);
}
}
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;
}
}
//.........这里部分代码省略.........