本文整理汇总了C++中P_ITEM::SetContSerial方法的典型用法代码示例。如果您正苦于以下问题:C++ P_ITEM::SetContSerial方法的具体用法?C++ P_ITEM::SetContSerial怎么用?C++ P_ITEM::SetContSerial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_ITEM
的用法示例。
在下文中一共展示了P_ITEM::SetContSerial方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddRandomLoot
P_ITEM cCharStuff::AddRandomLoot(P_ITEM pBackpack, char * lootlist)
{
char sect[512];
int i,j, storeval,loopexit=0;
P_ITEM retitem = NULL;
storeval=-1;
i=0; j=0;
sprintf(sect, "LOOTLIST %s", lootlist);
Script *pScpBase=i_scripts[npc_script];
Script *pScp=pScpBase->Select(sect,custom_npc_script);
if (!pScp) return NULL;
loopexit=0;
do
{
pScp->NextLine();
if (script1[0]!='}')
{
i++; // Count number of entries on list.
}
} while ( (script1[0]!='}') && (++loopexit < MAXLOOPS) );
pScp->Close();
if(i>0)
{
i=rand()%(i);
pScp=pScpBase->Select(sect,custom_npc_script);
loopexit=0;
do
{
pScp->NextLine();
if (script1[0]!='}')
{
if(j==i)
{
storeval=str2num(script1); //script1 = ITEM#
scpMark m=pScp->Suspend();
retitem = Targ->AddMenuTarget(-1, 0, storeval);
pScp->Resume(m);
if(retitem!=NULL)
{
retitem->pos.x=50+(rand()%80);
retitem->pos.y=50+(rand()%80);
retitem->pos.z=9;
retitem->SetContSerial(pBackpack->serial);
}
break;;
}
else j++;
}
} while ( (script1[0]!='}') && (++loopexit < MAXLOOPS) );
pScp->Close();
}
return retitem;
}
示例2: GetBankBox
P_ITEM cChar::GetBankBox( short banktype )
{
P_ITEM pi;
unsigned int ci=0;
vector<SERIAL> vecContainer = contsp.getData(serial);
for ( ci = 0; ci < vecContainer.size(); ci++)
{
pi = FindItemBySerial(vecContainer[ci]);
if (pi->type == 1 && pi->morex == 1)
if ( banktype == 1 && pi->morez == 123 && SrvParams->useSpecialBank())
return pi;
else if ( banktype != 1 || !SrvParams->useSpecialBank())
return pi;
}
// If we reach this point, bankbox wasn't found == wasn't created yet.
sprintf((char*)temp, "%s's bank box.", name.c_str());
UOXSOCKET s = calcSocketFromChar(this);
pi = Items->SpawnItem(this, 1, (char*)temp, 0, 0x09AB, 0, 0);
if(pi == NULL)
return NULL;
pi->layer=0x1d;
pi->SetOwnSerial(this->serial);
pi->SetContSerial(this->serial);
pi->morex=1;
if(SrvParams->useSpecialBank() && banktype == 1)//AntiChrist - Special Bank
pi->morey=123;//gold only bank
pi->type=1;
if (s != -1)
wearIt(s, pi);
return pi;
}
示例3: FindCharBySerial
// Name: item_bounce3
// Purpose: holds some statements that were COPIED some 50 times
// Remarks: temporary functions to revamp the 30 occurences of the 'bouncing bugfix'
// History: init Duke, 10.8.2000
static void item_bounce3(const P_ITEM pi)
{
pi->SetContSerial(pi->oldcontserial);
pi->pos.x=pi->oldx;
pi->pos.y=pi->oldy;
pi->pos.z=pi->oldz;
pi->layer=pi->oldlayer;
pi->flags.isBeeingDragged=false;
P_CHAR pc = FindCharBySerial(pi->oldcontserial);
if (pi->layer > 0 && pc != NULL)
{
pc->st += pi->st2;
pc->chgDex(pi->dx2);
pc->in += pi->in;
}
}
示例4: AddNPC
//.........这里部分代码省略.........
do
{
pScp->NextLineSplitted();
if (script1[0]!='}') {
switch(script1[0])
{
case 'A':
case 'a':
if (!strcmp("ALCHEMY",(char*)script1)) pc_c->baseskill[ALCHEMY] = getstatskillvalue((char*)script2);
else if (!strcmp("ANATOMY",(char*)script1)) pc_c->baseskill[ANATOMY] = getstatskillvalue((char*)script2);
else if (!strcmp("ARCHERY",(char*)script1)) pc_c->baseskill[ARCHERY] = getstatskillvalue((char*)script2);
else if (!strcmp("ARMSLORE",(char*)script1)) pc_c->baseskill[ARMSLORE] = getstatskillvalue((char*)script2);
else if (!strcmp("ANIMALLORE",(char*)script1)) pc_c->baseskill[ANIMALLORE] = getstatskillvalue((char*)script2);
break;
case 'B':
case 'b':
if (!strcmp("BACKPACK", (char*)script1))
{
if (pBackpack == NULL)
{
scpMark m=pScp->Suspend();
pBackpack = Items->SpawnItem(-1, pc_c,1,"Backpack",0,0x0E,0x75,0,0,0);
if(pBackpack == NULL)
{
Npcs->DeleteChar(pc_c);
return NULL;
}
pc_c->packitem = pBackpack->serial;
pBackpack->pos.x=0;
pBackpack->pos.y=0;
pBackpack->pos.z=0;
pBackpack->SetContSerial(pc_c->serial);
pBackpack->layer=0x15;
pBackpack->type=1;
pBackpack->dye=1;
retitem = pBackpack;
pScp->Resume(m);
strcpy((char*)script1, "DUMMY"); // Prevents unexpected matchups...
}
}
else if (!strcmp("BEGGING",(char*)script1)) pc_c->baseskill[BEGGING] = getstatskillvalue((char*)script2);
else if (!strcmp("BLACKSMITHING",(char*)script1)) pc_c->baseskill[BLACKSMITHING] = getstatskillvalue((char*)script2);
else if (!strcmp("BOWCRAFT",(char*)script1)) pc_c->baseskill[BOWCRAFT] = getstatskillvalue((char*)script2);
break;
case 'C':
case 'c':
if (!strcmp("COLOR",(char*)script1)) {
if (retitem != NULL)
{
retitem->color = hex2num(script2);
}
}
else if (!strcmp("CARVE",(char*)script1)) pc_c->carve=str2num(script2);
else if (!strcmp("CAMPING",(char*)script1)) pc_c->baseskill[CAMPING] = getstatskillvalue((char*)script2);
else if (!strcmp("CARPENTRY",(char*)script1)) pc_c->baseskill[CARPENTRY] = getstatskillvalue((char*)script2);
else if (!strcmp("CARTOGRAPHY",(char*)script1)) pc_c->baseskill[CARTOGRAPHY] = getstatskillvalue((char*)script2);
else if (!strcmp("CANTRAIN",(char*)script1)) pc_c->cantrain=true;
else if (!strcmp("COOKING",(char*)script1)) pc_c->baseskill[COOKING] = getstatskillvalue((char*)script2);
else if (!strcmp("COLORMATCHHAIR",(char*)script1))
{
if (retitem != NULL && haircolor!=-1)
示例5: buyaction
//.........这里部分代码省略.........
pc_currchar->name.c_str(), goldtotal, (goldtotal==1) ? "" : "s");
goldsfx(s, goldtotal); // Dupois, SFX for gold movement. Added Oct 08, 1998
}
}
npctalkall(npc, (char*)temp, 0);
npcaction(npc, 0x20); // bow (Duke, 17.3.2001)
clear = 1;
if( !(pc_currchar->isGM() ) )
{
if( useBank )
DeleBankItem( pc_currchar, 0x0EED, 0, goldtotal );
else
delequan( pc_currchar, 0x0EED, goldtotal, NULL );
}
for (i=0;i<itemtotal;i++)
{
P_ITEM pi = buyit[i];
if (pi != NULL)
{
if (pi->amount>amount[i])
{
if (pi->pileable)
{
Commands->DupeItem(s, buyit[i], amount[i]);
}
else
{
for (j=0;j<amount[i];j++)
{
Commands->DupeItem(s, buyit[i], 1);
}
}
pi->amount-=amount[i];
pi->restock+=amount[i];
}
else
{
switch(layer[i])
{
case 0x1A:
if (pi->pileable)
{
Commands->DupeItem(s, buyit[i], amount[i]);
}
else
{
for (j=0;j<amount[i];j++)
{
Commands->DupeItem(s, buyit[i], 1);
}
}
pi->amount=pi->amount-amount[i];
pi->restock=pi->restock+amount[i];
break;
case 0x1B:
if (pi->pileable)
{
pi->SetContSerial(pi_pack->serial);
RefreshItem(buyit[i]);//AntiChrist
}
else
{
for (j=0;j<amount[i]-1;j++)
{
Commands->DupeItem(s, buyit[i], 1);
}
pi->SetContSerial(pi_pack->serial);
pi->amount = 1;
RefreshItem(buyit[i]);//AntiChrist
}
break;
default:
clConsole.send("ERROR: Fallout of switch statement without default. wolfpack.cpp, buyaction()\n"); //Morrolan
}
}
}
}
}
}
else
{
npctalkall(npc, "Alas, thou dost not possess sufficient gold for this purchase!",0);
}
if (clear)
{
clearmsg[0]=0x3B;
clearmsg[1]=0x00;
clearmsg[2]=0x08;
clearmsg[3]=buffer[s][3];
clearmsg[4]=buffer[s][4];
clearmsg[5]=buffer[s][5];
clearmsg[6]=buffer[s][6];
clearmsg[7]=0x00;
Xsend(s, clearmsg, 8);
}
Weight->NewCalc(pc_currchar); // Ison 2-20-99
statwindow(s, pc_currchar);
}
示例6: 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;
}
示例7: get_item
//.........这里部分代码省略.........
{
ps->ResetDragging();
item_bounce4(s, pi);
}
}
else
{
// AntiChrist bugfix for the bad bouncing bug ( disappearing items when bouncing )
DRAGGED[s] = 1;
pi->oldx = pi->pos.x; // first let's save the position
pi->oldy = pi->pos.y;
pi->oldz = pi->pos.z;
pi->oldcontserial = pi->contserial; // then let's save the container
pi->oldlayer = pi->layer; // then the layer
pi->layer = 0;
if (!pi->isInWorld())
soundeffect(s, 0x00, 0x57);
if (pi->amount>1)
{
amount = (buffer[s][5] << 8) + buffer[s][6];
if (amount>pi->amount)
amount = pi->amount;
if (amount < pi->amount)
{
P_ITEM pi_c = Items->MemItemFree();
// pi_c->Init(0);
#pragma note("Replace by a copy constructor before finishing items[]")
memcpy(pi_c, pi, sizeof(cItem)); // Tauriel reduce code faster too
pi_c->SetSerial(cItemsManager::getItemsManager().getUnusedSerial());
pi_c->amount = pi->amount - amount;
pi_c->SetContSerial(pi_c->contserial);
pi_c->SetOwnSerial(pi_c->ownserial);
pi_c->SetSpawnSerial(pi_c->spawnserial);
statwindow(s,DEREF_P_CHAR(pc_currchar));
RefreshItem(pi_c);//AntiChrist
}
if (pi->id() == 0x0EED) // gold coin
{
P_ITEM packnum = packitem(currchar[s]);
if (packnum != NULL) // lb
if (pi->contserial == packnum->serial)
update = 1;
}
pi->amount = amount;
}
/* int amt = 0, wgt; bool tooheavy=false;
wgt = (int)Weight->LockeddownWeight(pi, &amt, 0);
if(pi->contserial>0)
{
if (( (pc_currchar->weight+wgt) > (pc_currchar->st*WEIGHT_PER_STR)+30)) // LB -> added: drop item if too heavy
{
float res=float( (pc_currchar->weight+wgt) - ((pc_currchar->st*WEIGHT_PER_STR)+30))*2;
int diff = pc_currchar->st;
diff -= (int)res;
if (diff<=0 && !pc_currchar->isGM() )
{
tooheavy=true;
示例8: 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);
//.........这里部分代码省略.........
示例9: get_item
//.........这里部分代码省略.........
triggerwitem(s, DEREF_P_ITEM(pi), 1); // trigger is fired
}
// AntiChrist -- for poisoned items
if (items[x].poisoned)
{
chars[npc].poison -= items[x].poisoned;
if (chars[npc].poison < 0)
chars[npc].poison = 0;
}
}
if (pi != NULL)
{
if (pi->corpse != 1)
{
UpdateStatusWindow(s, pi);
if (!pc_currchar->canPickUp(pi))
{
bounce[1] = 0;
Xsend(s, bounce, 2);
if (ps->IsDragging()) // only restore item if it got draggged before !!!
{
ps->ResetDragging();
item_bounce4(s, pi);
}
}
else
{
// AntiChrist bugfix for the bad bouncing bug ( disappearing items when bouncing )
DRAGGED[s] = 1;
pi->oldx = pi->pos.x; // first let's save the position
pi->oldy = pi->pos.y;
pi->oldz = pi->pos.z;
pi->oldcontserial = pi->contserial; // then let's save the container
pi->oldlayer = pi->layer; // then the layer
pi->layer = 0;
if (!pi->isInWorld())
soundeffect(s, 0x00, 0x57);
if (pi->amount>1)
{
amount = (buffer[s][5] << 8) + buffer[s][6];
if (amount>pi->amount)
amount = pi->amount;
if (amount < pi->amount)
{
c=Items->MemItemFree();
items[c].Init(0);
memcpy(&items[c], pi, sizeof(cItem)); // Tauriel reduce code faster too
items[c].SetSerial(itemcount2);
itemcount2++;
items[c].amount = pi->amount - amount;
// Tauriel sorry, there is no way to make this call the item creation stuff
// Why doing it twice?
// setptr(&itemsp[itemcount2%HASHMAX], c);
// itemcount2++; // important bugfix for items disappearing, lb
if (!items[c].isInWorld())
contsp.insert(items[c].contserial, items[c].serial);
if (items[c].ownserial!=-1)
setptr(&ownsp[items[c].ownserial%HASHMAX], c);
if (items[c].spawnserial!=-1)
setptr(&spawnsp[items[c].spawnserial%HASHMAX], c);
statwindow(s,cc);
RefreshItem(c);//AntiChrist
}
if (pi->id() == 0x0EED) // gold coin
{
int packnum = packitem(currchar[s]);
if (packnum!=-1) // lb
if (pi->contserial == items[packnum].serial)
update = 1;
}
pi->amount = amount;
}
// Tauriel remove item from world mapcells
mapRegions->Remove(pi); // remove this item from a map cell
pi->pos.x = 0;
pi->pos.y = 0;
pi->pos.z = 0;
pi->flags.isBeeingDragged=true;
pi->SetContSerial(-1);
if (pi != NULL) // Ripper...adds weight to the players cursor when carrying a item.
{
int amt = 0, wgt;
wgt = (int)Weight->LockeddownWeight(pi, &amt, 0);
pc_currchar->weight += wgt;
update = 1;
}
}
}
} // end of if i!=-1
if (update)
statwindow(s, DEREF_P_CHAR(pc_currchar));
}