static void item_bounce4(const NXWSOCKET socket, const P_ITEM pi) { VALIDATEPI( pi ); item_bounce3(pi); if( (pi->getId() >>8) < 0x40) senditem( socket, pi ); }
static void item_bounce5(const UOXSOCKET s, const P_ITEM pi) { item_bounce3(pi); if(pi->isInWorld()) { if (pi->id1>=0x40) senditem(s, pi); } else senditem(s, pi); }
void cDragdrop::get_item(P_CLIENT ps) // Client grabs an item { int npc=-1, amount, update = 0, serial; UOXSOCKET s = ps->GetSocket(); int cc = ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHARREF_LR(cc); serial = calcserial(buffer[s][1], buffer[s][2], buffer[s][3], buffer[s][4]); if (serial == INVALID_SERIAL || buffer[s][1] < 0x40) return; // landscape or a character P_ITEM pi = FindItemBySerial(serial); if (pi == NULL) return; pc_currchar->disturbMed(s); // Meditation // Zippy's stealing changes P_ITEM px = pi; if (!px->isInWorld()) // Find character owning item { unsigned long loopexit = 0; do // Find character owning item { if (isCharSerial(px->contserial)) { npc = calcCharFromSer(px->contserial); } else // its an item { if (px->isInWorld()) { npc=-1; break; } px = FindItemBySerial(px->contserial); // ANTICHRIST -- SECURE TRADE FIX if (px != NULL) // LB overwriting x is essential here, dont change it!!! { if (px->layer == 0 && px->id() == 0x1E5E) { // Trade window??? serial = calcserial(px->moreb1, px->moreb2, px->moreb3, px->moreb4); if (serial == INVALID_SERIAL) return; P_ITEM pi_z = FindItemBySerial(serial); if ( pi_z != NULL ) if ((pi_z->morez || px->morez)) { pi_z->morez = 0; px->morez = 0; sendtradestatus(pi_z, px); } } // Blackwinds Looting is crime implementation // changed slightly by Ripper if (px->corpse != 0 && !pc_currchar->Owns(px)) { P_CHAR co = FindCharBySerial(px->ownserial); if (px->more2 == 1 && Guilds->Compare(DEREF_P_CHAR(pc_currchar), DEREF_P_CHAR(co)) == 0) { pc_currchar->karma -= 5; criminal(DEREF_P_CHAR(pc_currchar)); sysmessage(s, "You lost some karma!"); } npc = 0; } // Criminal stuff if (px->corpse != 0) npc = 0; } // end if x!=-1 if (px == NULL) npc = 0; } } while ((npc==-1) &&(++loopexit < MAXLOOPS)); } if (npc>0) // 0=corpse, hence >0 .. { if (!(pc_currchar->isGM()) && npc != DEREF_P_CHAR(pc_currchar) && ! pc_currchar->Owns(&chars[npc])) {// Own serial stuff by Zippy -^ Pack aniamls and vendors. bounce[1] = 0; Xsend(s, bounce, 2); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce3(pi); pi->magic = 3; } return; } } // End Zippy's change // Boats-> if (px != NULL && npc!=-1) { if (px->multis>0) imultisp.remove(px->multis, px->serial); px->startDecay(); // End Boats Change // AntiChrist -- for poisoned items if (px->layer>0) { chars[npc].removeItemBonus(px); // remove BONUS STATS given by equipped special items } if ((px->trigon==1) && (px->layer != 0) && (px->layer != 15) && (px->layer < 19))// -Frazurbluu- Trigger Type 2 is my new trigger type *- { Trig->triggerwitem(s, pi, 1); // trigger is fired } } 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) { 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; bounce[1] = 0; Xsend(s, bounce, 2); if (ps->IsDragging()) // only restore item if it got dragged before !!! { ps->ResetDragging(); item_bounce4(s, pi); } sysmessage(s, "you can't pick this up, this is too heavy"); return; } } } if (!tooheavy) pc_currchar->weight+=wgt; update = 1; */ // LB remark: drop item if too heavy is a good solution, // but there's still a small bug remaining. // added weight from items picked up, but not put to bp, pd, in other words hold in ones hand, // is NOT subtracted when being dropped again to ground/other chars/other chars' bp's. // but this bug doesnt show up becasue weight is re-calculated automatically all 10 secs. // without adding weight of the item curently carrying in hand. // a correct solutions need the weight of item in hand being stored // , added to auto-re-calculation all x-secs code, and being subtracted if dropped. // because it's now only happening for leight weight items, because heavy weight itms cant be picke up anymore // I haven't corrected this yet. // 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); } } } // end of if i!=-1 if (update) statwindow(s, DEREF_P_CHAR(pc_currchar)); }
static void item_bounce4(const UOXSOCKET s, const P_ITEM pi) { item_bounce3(pi); if (pi->id1>=0x40) senditem(s, pi); }
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); if (pCont->id1>=0x40) senditem(s, pCont); } return; } // - Trash container if (pCont->type==87) { Items->DeleItem(pItem); sysmessage(s, "As you let go of the item it disappears."); return; } // - Spell Book if (pCont->type==9) { if (!IsSpellScroll72(pItem->id())) { sysmessage(s, "You can only place spell scrolls in a spellbook!"); Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce3(pItem); } if (pCont->id1>=0x40) senditem(s, pCont); return; } P_ITEM pBackpack = Packitem(pc_currchar); if (pBackpack != NULL) // lb { if (!pc_currchar->Wears(pCont) && (!(pCont->contserial==pBackpack->serial)) && (!(pc_currchar->canSnoop()))) { sysmessage(s, "You cannot place spells in other peoples spellbooks."); item_bounce6(ps,pItem); return; } if(pItem->name[0]=='#') pItem->getName(temp2); else strcpy((char*)temp2,pItem->name); vector<SERIAL> vecContainer = contsp.getData(pCont->serial); for (unsigned int i = 0; i < vecContainer.size(); i++) // antichrist , bugfix for inscribing scrolls { P_ITEM pi = FindItemBySerial(vecContainer[i]); if (pi != NULL) { if(pi->name[0]=='#') pi->getName(temp); else strcpy((char*)temp, pi->name); if(!(strcmp((char*)temp,(char*)temp2)) || !(strcmp((char*)temp,"All-Spell Scroll"))) { sysmessage(s,"You already have that spell!"); item_bounce6(ps,pItem); return; } } } } } // player run vendors if (!(pCont->pileable && pItem->pileable && pCont->id()==pItem->id() || (pCont->type!=1 && pCont->type!=9))) { j=DEREF_P_CHAR(GetPackOwner(pCont)); if (j>-1) // bugkilling, LB, was j=!-1, arghh, C !!! { if (chars[j].npcaitype==17 && chars[j].isNpc() && pc_currchar->Owns(&chars[j])) { pc_currchar->inputitem = pItem->serial; pc_currchar->inputmode = cChar::enPricing; sysmessage(s, "Set a price for this item."); } } short xx=pp->TxLoc; short yy=pp->TyLoc; pCont->AddItem(pItem,xx,yy); itemsfx(s, pItem->id());// see itemsfx() for details - Dupois Added Oct 09, 1998 statwindow(s,DEREF_P_CHAR(pc_currchar)); } // end of player run vendors else // - Unlocked item spawner or unlockable item spawner if (pCont->type==63 || pCont->type==65 || pCont->type==66) { pItem->SetContSerial(pp->Tserial); // lb bugfix pItem->pos.x=pp->TxLoc; pItem->pos.y=pp->TyLoc; pItem->pos.z=pp->TzLoc; SndRemoveitem(pItem->serial); RefreshItem(pItem);//AntiChrist itemsfx(s, pItem->id()); } else // - Pileable if (pCont->pileable && pItem->pileable && pCont->id()==pItem->id()) { if ((pCont->amount+pItem->amount) > 65535) { pItem->amount -= (65535-pCont->amount); Commands->DupeItem(s, pCont, pItem->amount); pCont->amount = 65535; Items->DeleItem(pItem); } else { pCont->amount=pCont->amount+pItem->amount; itemsfx(s, pItem->id()); Items->DeleItem(pItem); } SndRemoveitem(pItem->serial); RefreshItem(pCont);//AntiChrist } else { pItem->pos.x=pp->TxLoc; pItem->pos.y=pp->TyLoc; pItem->pos.z=pp->TzLoc; // pItem->SetContSerial(-1); pItem->SetContSerial(pp->Tserial); // Tauriel add item to world mapcells mapRegions->Add(pItem); //add this item to a map cell SndRemoveitem(pItem->serial); RefreshItem(pCont);//AntiChrist } // - Spell Book if (pCont->type==9) Magic->SpellBook(s, pCont); // LB, bugfix for showing(!) the wrong spell (clumsy) when a new spell is put into opened spellbook if (pItem->glow>0) // LB's glowing items stuff { int p = DEREF_P_CHAR(GetPackOwner(pCont)); pc_currchar->removeHalo(pItem); // if gm put glowing object in another pack, handle glowsp correctly ! if (p!=-1) { chars[p].addHalo(pItem); chars[p].glowHalo(pItem); } } }
void get_item(P_CLIENT ps) // Client grabs an item { int x, npc=-1, c, amount, update = 0, serial; // tile_st tile; int z;// antichrist for trade fix UOXSOCKET s = ps->GetSocket(); int cc = ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHARREF_LR(cc); serial = calcserial(buffer[s][1], buffer[s][2], buffer[s][3], buffer[s][4]); if (serial == INVALID_SERIAL || buffer[s][1] < 0x40) return; // landscape or a character P_ITEM pi = FindItemBySerial(serial); if (pi == NULL) return; pc_currchar->disturbMed(s); // Meditation // Zippy's stealing changes x = DEREF_P_ITEM(pi); if (!items[x].isInWorld()) // Find character owning item { int loopexit = 0; do // Find character owning item { if (isCharSerial(items[x].contserial)) { npc = calcCharFromSer(items[x].contserial); } else // its an item { if (items[x].isInWorld()) { npc=-1; break; } x = calcItemFromSer(items[x].contserial); // ANTICHRIST -- SECURE TRADE FIX if (x!=-1) // LB overwriting x is essential here, dont change it!!! { if (items[x].layer == 0 && items[x].id() == 0x1E5E) { // Trade window??? serial = calcserial(items[x].moreb1, items[x].moreb2, items[x].moreb3, items[x].moreb4); if (serial == INVALID_SERIAL) return; z = calcItemFromSer(serial); if (z!=-1) if ((items[z].morez || items[x].morez)) { items[z].morez = 0; items[x].morez = 0; sendtradestatus(z, x); } } // Blackwinds Looting is crime implementation // changed slightly by Ripper if (items[x].corpse != 0 && !pc_currchar->Owns(&items[x])) { P_CHAR co = FindCharBySerial(items[x].ownserial); if (items[x].more2 == 1 && Guilds->Compare(cc, DEREF_P_CHAR(co)) == 0) { pc_currchar->karma -= 5; criminal(cc); sysmessage(s, "You lost some karma!"); } npc = 0; } // Criminal stuff if (items[x].corpse != 0) npc = 0; } // end if x!=-1 if (x==-1) npc = 0; } } while ((npc==-1) &&(++loopexit < MAXLOOPS)); } if (npc>0) // 0=corpse, hence >0 .. { if (!(pc_currchar->isGM()) && npc != cc && ! pc_currchar->Owns(&chars[npc])) {// Own serial stuff by Zippy -^ Pack aniamls and vendors. bounce[1] = 0; Xsend(s, bounce, 2); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce3(pi); pi->magic = 3; } return; } } // End Zippy's change // Boats-> if (x!=-1 && npc!=-1) { if (items[x].multis>0) imultisp.remove(items[x].multis, items[x].serial); items[x].startDecay(); // End Boats Change // AntiChrist -- for poisoned items if (items[x].layer>0) { chars[npc].removeItemBonus(&items[x]); // remove BONUS STATS given by equipped special items } if ((items[x].trigon==1) && (items[x].layer != 0) && (items[x].layer != 15) && (items[x].layer < 19))// -Frazurbluu- Trigger Type 2 is my new trigger type *- { 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)); }
/*! \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 ) ) { if ( container->layer == 0 && container->getId() == 0x1E5E) { // Trade window??? SERIAL serial = calcserial( pi->moreb1, pi->moreb2, pi->moreb3, pi->moreb4); if ( serial == INVALID ) return; P_ITEM piz = pointers::findItemBySerial(serial ); if ( ISVALIDPI( piz ) ) if ( piz->morez || container->morez ) { piz->morez = 0; container->morez = 0; sendtradestatus( piz, container ); } //<Luxor> if (pi->amxevents[EVENT_ITAKEFROMCONTAINER]!=NULL) { g_bByPass = false; pi->amxevents[EVENT_ITAKEFROMCONTAINER]->Call( pi->getSerial32(), pi->getContSerial(), pc_currchar->getSerial32() ); if (g_bByPass) { Sndbounce5(s); if (client->isDragging()) { client->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } } //</Luxor> /* //<Luxor> g_bByPass = false; pi->runAmxEvent( EVENT_ITAKEFROMCONTAINER, pi->getSerial32(), pi->getContSerial(), s ); if (g_bByPass) { Sndbounce5(s); if (client->isDragging()) { client->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } //</Luxor> */ if ( container->corpse ) { if ( container->getOwnerSerial32() != pc_currchar->getSerial32()) { //Looter :P pc_currchar->unHide(); bool bCanLoot = false; if( pc_currchar->party!=INVALID ) { P_CHAR dead = pointers::findCharBySerial( container->getOwnerSerial32() ) ; if( ISVALIDPC( dead ) && dead->party==pc_currchar->party ) { P_PARTY party = Partys.getParty( pc_currchar->party ); if( party!=NULL ) { P_PARTY_MEMBER member = party->getMember( pc_currchar->getSerial32() ); if( member!=NULL ) bCanLoot = member->canLoot; } } } if ( !bCanLoot && container->more2==1 ) { pc_currchar->IncreaseKarma(-5); setCrimGrey(pc_currchar, ServerScp::g_nLootingWillCriminal); pc_currchar->sysmsg( TRANSLATE("You are loosing karma!")); } } } // corpse stuff container->SetMultiSerial(INVALID); //at end reset decay of container container->setDecayTime(); } // end cont valid } if ( !pi->corpse ) { UpdateStatusWindow(s, pi); tile_st tile; data::seekTile( pi->getId(), tile); if (!pc_currchar->IsGM() && (( pi->magic == 2 || ((tile.weight == 255) && ( pi->magic != 1))) && !pc_currchar->canAllMove() ) || (( pi->magic == 3|| pi->magic == 4) && !pc_currchar->isOwnerOf( pi ))) { UI08 bounce[2]={ 0x27, 0x00 }; Xsend(s, bounce, 2); //AoS/ Network->FlushBuffer(s); if (client->isDragging()) // only restore item if it got draggged before !!! { client->resetDragging(); item_bounce4(s, pi ); } } // end of can't get else { // AntiChrist bugfix for the bad bouncing bug ( disappearing items when bouncing ) client->setDragging(); pi->setOldPosition( pi->getPosition() ); // first let's save the position pi->oldlayer = pi->layer; // then the layer pi->layer = 0; if (!pi->isInWorld()) pc_currchar->playSFX(0x0057); if (pi->amount>1) { UI16 amount = ShortFromCharPtr(buffer[s] +5); if (amount > pi->amount) amount = pi->amount; else if (amount < pi->amount) { //get not all but a part of item ( piled? ), but anyway make a new one item P_ITEM pin =archive::item::New(); (*pin)=(*pi); pin->amount = (UI16)( pi->amount - amount); pin->setContSerial(pi->getContSerial()); //Luxor pin->setPosition( pi->getPosition() ); /*if( !pin->isInWorld() && isItemSerial( pin->getContSerial() ) ) pin->SetRandPosInCont( (P_ITEM)pin->getContainer() );*/ if ( pin->getOwnerSerial32() != INVALID ) pin->setOwnerSerial32( pi->getOwnerSerial32() ); statwindow(pc_currchar,pc_currchar); pin->Refresh();//AntiChrist } if ( pi->getId() == ITEMID_GOLD) { P_ITEM pack= pc_currchar->getBackpack(); if (ISVALIDPI(pack)) // lb if ( pi->getContSerial() == pack->getSerial32()) statwindow(pc_currchar, pc_currchar); } pi->amount = amount; } // end if corpse #ifdef SPAR_I_LOCATION_MAP pointers::delFromLocationMap( pi ); #else mapRegions->remove( pi ); #endif pi->setPosition( 0, 0, 0 ); pi->setContSerial( INVALID, false ); } } int amt = 0, wgt; if ( container == NULL ) { wgt = (int)weights::LockeddownWeight( pi, &amt); pc_currchar->weight += wgt; statwindow(pc_currchar, pc_currchar); } }
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(); pc->playSFX( itemsfx(pItem->getId()) ); return; } } } // Xanathars's Bank Limit Code if (ServerScp::g_nBankLimit != 0) { if( ISVALIDPI( contOutMost ) && contOutMost->morex==MOREX_BANK ) { int n = contOutMost->CountItems( INVALID, INVALID, false); n -= contOutMost->CountItems( ITEMID_GOLD, INVALID, false); if( pItem->type == ITYPE_CONTAINER ) n += pItem->CountItems( INVALID, INVALID, false); else ++n; if( n > ServerScp::g_nBankLimit ) { ps->sysmsg(TRANSLATE("You exceeded the number of maximimum items in bank of %d"), ServerScp::g_nBankLimit); item_bounce6(ps,pItem); return; } } } //ndEndy this not needed because when is dragging cont serial is INVALID //testing UOP Blocking Tauriel 1-12-99 if (!pItem->isInWorld()) { item_bounce6(ps,pItem); return; } data::seekTile(pItem->getId(), tile); if (( ( (pItem->magic==2) || ( (tile.weight==255) && (pItem->magic != 1 ) ) ) && !pc->canAllMove()) || ( (pItem->magic==3|| pItem->magic==4) && !(pItem->getOwnerSerial32()==pc->getSerial32()))) { Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce3(pItem); if (pCont->getId() >= 0x4000) senditem(s, pCont); } return; } // - Trash container if( pCont->type==ITYPE_TRASH) { pItem->Delete(); ps->sysmsg(TRANSLATE("As you let go of the item it disappears.")); return; } // - Spell Book if (pCont->type==ITYPE_SPELLBOOK) { if (!pItem->IsSpellScroll72()) { ps->sysmsg(TRANSLATE("You can only place spell scrolls in a spellbook!")); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce3(pItem); } if (pCont->getId() >= 0x4000) senditem(s, pCont); return; } pack= pc->getBackpack(); if(ISVALIDPI(pack)) { if ((!(pCont->getContSerial()==pc->getSerial32())) && (!(pCont->getContSerial()==pack->getSerial32())) && (!(pc->CanSnoop()))) { ps->sysmsg(TRANSLATE("You cannot place spells in other peoples spellbooks.")); item_bounce6(ps,pItem); return; } if( strncmp(pItem->getCurrentNameC(), "#", 1) ) pItem->getName(temp2); else strcpy(temp2,pItem->getCurrentNameC()); NxwItemWrapper sii; sii.fillItemsInContainer( pCont, false ); for( sii.rewind(); !sii.isEmpty(); sii++ ) { P_ITEM pi_ci=sii.getItem(); if (ISVALIDPI(pi_ci)) { if( strncmp(pi_ci->getCurrentNameC(), "#", 1) ) pi_ci->getName(temp); else strcpy(temp,pi_ci->getCurrentNameC()); if(!(strcmp(temp,temp2)) || !(strcmp(temp,"All-Spell Scroll"))) { ps->sysmsg(TRANSLATE("You already have that spell!")); item_bounce6(ps,pItem); return; } } // Juliunus, to prevent ppl from wasting scrolls. if (pItem->amount > 1) { ps->sysmsg(TRANSLATE("You can't put more than one scroll at a time in your book.")); item_bounce6(ps,pItem); return; } } } pCont->AddItem( pItem ); ps->sendSpellBook(pCont); return; } if (pCont->type == ITYPE_CONTAINER) { if ( ISVALIDPC(contOwner) ) { if ( (contOwner->npcaitype==NPCAI_PLAYERVENDOR) && (contOwner->npc) && (contOwner->getOwnerSerial32()==pc->getSerial32()) ) { pc->fx1= DEREF_P_ITEM(pItem); pc->fx2=17; pc->sysmsg(TRANSLATE("Set a price for this item.")); } } short xx=pp->TxLoc; short yy=pp->TyLoc; pCont->AddItem(pItem,xx,yy); pc->playSFX( itemsfx(pItem->getId()) ); statwindow(pc,pc); } // end of player run vendors else // - Unlocked item spawner or unlockable item spawner if (pCont->type==ITYPE_UNLOCKED_CONTAINER || pCont->type==ITYPE_NODECAY_ITEM_SPAWNER || pCont->type==ITYPE_DECAYING_ITEM_SPAWNER) { pCont->AddItem(pItem, pp->TxLoc, pp->TyLoc); //Luxor pc->playSFX( itemsfx(pItem->getId()) ); } else // - Pileable if (pCont->pileable && pItem->pileable) { if ( !pCont->PileItem( pItem ) ) { item_bounce6(ps,pItem); return; } } else { if( pItem->getContSerial( true )==INVALID ) //current cont serial is invalid because is dragging { NxwSocketWrapper sw; sw.fillOnline( pItem->getPosition() ); for( sw.rewind(); !sw.isEmpty(); sw++ ) SendDeleteObjectPkt(sw.getSocket(), pItem->getSerial32() ); mapRegions->remove(pItem); } pItem->setPosition( pp->TxLoc, pp->TyLoc, pp->TzLoc); pItem->setContSerial( pCont->getContSerial() ); pItem->Refresh(); } }
static void item_bounce5(const NXWSOCKET socket, const P_ITEM pi) { VALIDATEPI( pi ); item_bounce3(pi); senditem(socket, pi); }