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; }
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; }
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]; pTiller->MoveTo(pBoat->pos.x,pBoat->pos.y, pTiller->pos.z); pTiller->id2=cShipItems[dir][TILLERID]; pi_hold->MoveTo(pBoat->pos.x,pBoat->pos.y, pi_hold->pos.z); pi_hold->id2=cShipItems[dir][HOLDID]; switch(pBoat->more1)//Now set what size boat it is and move the specail items { case 0x00: case 0x04: pi_p1->moveTo(pi_p1->pos + Coord_cl(iSmallShipOffsets[dir][PORT_PLANK][X], iSmallShipOffsets[dir][PORT_PLANK][Y], 0)); pi_p2->moveTo(pi_p2->pos + Coord_cl(iSmallShipOffsets[dir][STARB_PLANK][X], iSmallShipOffsets[dir][STARB_PLANK][Y], 0)); pTiller->moveTo(pTiller->pos + Coord_cl(iSmallShipOffsets[dir][TILLER][X], iSmallShipOffsets[dir][TILLER][Y], 0)); pi_hold->moveTo(pi_hold->pos + Coord_cl(iSmallShipOffsets[dir][HOLD][X], iSmallShipOffsets[dir][HOLD][Y], 0)); break; case 0x08: case 0x0C: pi_p1->moveTo(pi_p1->pos + Coord_cl(iMediumShipOffsets[dir][PORT_PLANK][X], iMediumShipOffsets[dir][PORT_PLANK][Y], 0) ); pi_p2->moveTo(pi_p2->pos + Coord_cl(iMediumShipOffsets[dir][STARB_PLANK][X], iMediumShipOffsets[dir][STARB_PLANK][Y], 0) ); pTiller->moveTo(pTiller->pos + Coord_cl(iMediumShipOffsets[dir][TILLER][X], iMediumShipOffsets[dir][TILLER][Y], 0) ); pi_hold->moveTo(pi_hold->pos + Coord_cl(iMediumShipOffsets[dir][HOLD][X], iMediumShipOffsets[dir][HOLD][Y], 0) ); break; case 0x10: case 0x14: pi_p1->moveTo(pi_p1->pos + Coord_cl(iLargeShipOffsets[dir][PORT_PLANK][X], iLargeShipOffsets[dir][PORT_PLANK][Y], 0) ); pi_p2->moveTo(pi_p2->pos + Coord_cl(iLargeShipOffsets[dir][STARB_PLANK][X], iLargeShipOffsets[dir][STARB_PLANK][Y], 0 ) ); pTiller->moveTo(pTiller->pos + Coord_cl(iLargeShipOffsets[dir][TILLER][X], iLargeShipOffsets[dir][TILLER][Y], 0 ) ); pi_hold->moveTo(pi_hold->pos + Coord_cl(iLargeShipOffsets[dir][HOLD][X], iLargeShipOffsets[dir][HOLD][Y], 0 ) ); break; default: { sprintf((char*)temp,"Turnboatstuff() more1 error! more1 = %c not found!\n",pBoat->more1); LogWarning((char*)temp); } } sendinrange(pi_p1); sendinrange(pi_p2); sendinrange(pi_hold); sendinrange(pTiller); for (a = 0; a < d; ++a) { Xsend(Send[a],restart,2); } }
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); } } vecEntries.clear(); vecEntries = cmultisp.getData(pBoat->serial); for (a = 0; a < vecEntries.size(); a++) { P_CHAR pc_c = FindCharBySerial(vecEntries[a]); if (pc_c != NULL) { pc_c->moveTo(pc_c->pos + desloc); teleport((pc_c)); } } Xsend(s,restart,2); }
static bool ItemDroppedOnChar(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); P_CHAR pTC=FindCharBySerial(pp->Tserial); // the targeted character if (!pTC) return true; if (DEREF_P_CHAR(pTC)!=DEREF_P_CHAR(pc_currchar)) { if (pTC->isNpc()) { if(!pTC->isHuman()) { ItemDroppedOnPet( ps, pp, pi); } else // Item dropped on a Human character { // Item dropped on a Guard (possible bounty quest) if( ( pTC->isNpc() ) && ( pTC->npcaitype == 4 ) ) { if (!ItemDroppedOnGuard( ps, pp, pi) ) { Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); 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; }
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); } } }
/*! \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; }
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 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; } } }//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; }