Beispiel #1
0
/*!
\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;

}
Beispiel #2
0
/*!
\author Luxor
\brief Adds a temp effect to the object
*/
bool cObject::addTempfx( cObject& src, SI32 num, SI08 more1, SI08 more2, SI08 more3, SI08 more4, SI32 dur, SI32 amxcback )
{
	if ( num < 0 || num >= tempfx::MAX_TEMPFX_INDEX )
		return false;

	//
	//	Repeatable check
	//
	if ( !tempfx::isDestRepeatable(num) && getTempfx( num ) )
			return false;

	if ( !tempfx::isSrcRepeatable(num) && src.getTempfx( num ) )
			return false;

	//
	//	Create the tempfx
	//
	tempfx::cTempfx tmpeff( src.getSerial32(), getSerial32(), num, dur, more1, more2, more3,more4, amxcback );

	if ( !tmpeff.isValid() )
		return false;

    //
    //	Put the object in the global check vector if necessary
    //
    tempfx::addTempfxCheck( getSerial32() );

	//
	//	Start the tempfx
	//
	tmpeff.start();

	//
	//	Put it in the class vector
	//
	if ( tempfx == NULL )
		tempfx = new TempfxVector;

	tempfx->push_front( tmpeff );

	return true;
}
Beispiel #3
0
void cObject::setOwnerSerial32(SI32 ownser, bool force)
{

  //Endymion
  //i think need to have only in cObejct the setOwnerOnly and have SetOwnerSerial in cItem and cChar

	if( !force )
		if ( ownser == getOwnerSerial32() ) return;

	if ( getOwnerSerial32() != INVALID ) // if it was set, remove the old one
		if ( isCharSerial( getSerial32() ) )
			pointers::delFromOwnerMap( (P_CHAR)( this ) );
		else
			pointers::delFromOwnerMap( (P_ITEM)( this ) );


	setOwnerSerial32Only(ownser);

	if ( getOwnerSerial32() == INVALID ) {
		if( isCharSerial( getSerial32() ) )
			((P_CHAR)(this))->tamed = false;
		return;
	}

	if ( isCharSerial( getSerial32() ) ) {
		if ( getOwnerSerial32() != getSerial32() )
			((P_CHAR)(this))->tamed = true;
		else
			((P_CHAR)(this))->tamed = false;
	}

	if ( isCharSerial( getSerial32() ) ) // if there is an owner, add it
		pointers::addToOwnerMap( (P_CHAR)( this ) );
	else
		pointers::addToOwnerMap( (P_ITEM)( this ) );
	//End Endymion..
}
Beispiel #4
0
/*!
\author Wintermute
\brief Adds an existing temp effect to the object
*/
LOGICAL	cObject::addTempfx(tempfx::cTempfx *fx)
{
	if ( !fx->isValid() )
		return false;

    //
    //	Put the object in the global check vector if necessary
    //
    tempfx::addTempfxCheck( getSerial32() );
	//
	//	Put it in the class vector
	//
	if ( tempfx == NULL )
		tempfx = new TempfxVector;

	tempfx->push_front( *fx);

	return true;
}
Beispiel #5
0
/*!
\author Luxor
\brief operator = for the cItem class, let's dupe :)
\todo dupe books fix
*/
cItem& cItem::operator=(cItem& b)
{
        // NAMES
        setCurrentName(b.getCurrentName());
        setRealName(b.getRealName());

        setScriptID(b.getScriptID());
        creator = b.creator;
        incognito = b.incognito;
        madewith = b.madewith;
        rank = b.rank;
        good = b.good;
        rndvaluerate = b.rndvaluerate;
        //setMultiSerial32(b.getMultiSerial32());
        setId( b.getId() );
        //setPosition(b.getPosition());
        //setOldPosition(b.getOldPosition());
        setColor( b.getColor() );
        setContSerial(INVALID);
        //setContSerial(b.getContSerial(true), true);
        layer = b.layer;
        oldlayer = b.oldlayer;
        scriptlayer = b.scriptlayer;
        itmhand = b.itmhand;
        type = b.type;
        type2 = b.type2;
        offspell = b.offspell;
        weight = b.weight;
        more1 = b.more1;
        more2 = b.more2;
        more3 = b.more3;
        more4 = b.more4;
        moreb1 = b.moreb1;
        moreb2 = b.moreb2;
        moreb3 = b.moreb3;
        moreb4 = b.moreb4;
        morex = b.morex;
        morey = b.morey;
        morez = b.morez;
        amount = b.amount;
        amount2 = b.amount2;
        doordir = b.doordir;
        dooropen = b.dooropen;
        pileable = b.pileable;
        dye = b.dye;
        corpse = b.corpse;
        carve = b.carve;
        att = b.att;
        def = b.def;
        fightskill = b.fightskill;
        reqskill[0] = b.reqskill[0];
        reqskill[1] = b.reqskill[1];
        damagetype = b.damagetype;
        auxdamagetype = b.auxdamagetype;
        auxdamage = b.auxdamage;
        lodamage = b.lodamage;
	hidamage = b.hidamage;
        smelt = b.smelt;
        secureIt = b.secureIt;
        wpsk = b.wpsk;
        hp = b.hp;
        maxhp = b.maxhp;
        st = b.st;
        st2 = b.st2;
        dx = b.dx;
        dx2 = b.dx2;
        in = b.in;
        in2 = b.in2;
        spd = b.spd;
        wipe = b.wipe;
        magic = b.magic;
        gatetime = b.gatetime;
        gatenumber = b.gatenumber;
        decaytime = b.decaytime;
        //setOwnerSerial32(b.getOwnerSerial32());
        visible = b.visible;
        spawnserial = INVALID;
        spawnregion = INVALID;
        dir = b.dir;
        priv = b.priv;
        value = b.value;
        restock = b.restock;
        trigger = b.trigger;
        trigtype = b.trigtype;
        tuses = b.tuses;
        poisoned = b.poisoned;
        murderer = b.murderer;
        murdertime = b.murdertime;
        time_unused = b.time_unused;
        timeused_last = b.timeused_last;
        animid1 = b.animid1;
        animid2 = b.animid2;
	ammo = b.ammo;
	ammoFx = b.ammoFx;

        UI32 i;
        for ( i = 0; i < MAX_RESISTANCE_INDEX; i++ )
                resists[i] = b.resists[i];

	for ( i=0; i < ALLITEMEVENTS; i++ ) {
		amxevents[i] = b.amxevents[i];
		/*
		AmxEvent* event = b.getAmxEvent( i );
		if ( event == NULL )
			continue;

		setAmxEvent( i, event->getFuncName(), !(event->shouldBeSaved()) );*/
	}
	vendorDescription = b.vendorDescription;
	amxVS.copyVariable(getSerial32(), b.getSerial32());

        return *this;
}
Beispiel #6
0
/*!
\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;
}