Beispiel #1
0
	PCHAR_VECTOR* getNearbyChars( UI32 x, UI32 y, UI32 range, UI32 flags, P_CHAR pSelf )
	{
		PCHAR_VECTOR* pvCharsInRange = 0;

		if( x > 0 && x < 6145 && y > 0 && y < 4097 )
		{
			pvCharsInRange = new PCHAR_VECTOR();

			calculateBoundary( x, y, range );

			PCHARLOCATIONMAPIT it(  pCharLocationMap.lower_bound( locationToKey( upperLeft.x,  upperLeft.y ) ) ),
					   end( pCharLocationMap.upper_bound( locationToKey( lowerRight.x, lowerRight.y) ) );
			P_CHAR pc = 0;

			for( ; it != end; ++it )
			{
				pc = it->second;
				if( flags )
				{
					if( pSelf )
					{
						if( (flags & EXCLUDESELF) && pSelf->getSerial32() == pc->getSerial32() )
						{
							continue;
						}

						if ( (flags & COMBATTARGET) && pSelf->getSerial32() == pc->targserial )
						{
							pvCharsInRange->push_back( pc );
							continue;
						}
					}

					if ( pc->npc )
					{
						if ( (flags & NPC) )
						{
							pvCharsInRange->push_back( pc );
							continue;
						}
						continue;
					}

					if ( (flags & ONLINE) && pc->IsOnline() )
					{
						pvCharsInRange->push_back( pc );
						continue;
					}

					if ( (flags & OFFLINE) && !pc->IsOnline() )
					{
						pvCharsInRange->push_back( pc );
						continue;
					}

					if ( (flags & DEAD) && pc->dead )
					{
						pvCharsInRange->push_back( pc );
						continue;
					}
				}
				else
				{
					pvCharsInRange->push_back( pc );
				}
			}
		}
		return pvCharsInRange;
	}
Beispiel #2
0
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;
}