コード例 #1
0
bool cCharStuff::cBankerAI::BankCheck(int c, P_CHAR pBanker, const string& comm)
{
	P_CHAR pc_currchar = currchar[c];
	int beginoffset ;
	int endoffset ;
	int value =0 ;
	string value2;
	if ((beginoffset=comm.find_first_of("0123456789")) != string::npos)
	{
		if ((endoffset=comm.find_first_not_of("0123456789",beginoffset))== string::npos)
			endoffset = comm.length();
		value2= comm.substr(beginoffset,endoffset-beginoffset) ;
		value = str2num(value2) ;
	}

	int d = pc_currchar->CountBankGold();
	{
		int goldcount = value;
		if (goldcount < 5000 || goldcount > 1000000)
		{
			sprintf(temp, "%s you can only get checks worth 5000gp to 1000000gp.", pc_currchar->name.c_str());
			npctalk(c, pBanker, temp, 1);
			return false;
		}
		if (d >= goldcount)
		{
			const P_ITEM pi = Items->SpawnItem(c, pc_currchar, 1, "bank check", 0, 0x14, 0xF0, 0, 0, 0); // bank check
			if (pi != NULL)
			pi->type = 1000;
			pi->setId(0x14F0);
			pi->color = 0x0099;
			pi->priv |= 0x02;
			pi->value = goldcount;
			DeleBankItem(pc_currchar, 0x0EED, 0, goldcount);
			P_ITEM bankbox = pc_currchar->GetBankBox();
			bankbox->AddItem(pi);
			statwindow(c, pc_currchar);
			sprintf(temp, "%s your check has been placed in your bankbox, it is worth %i.", pc_currchar->name.c_str(), goldcount);
			npctalk(c, pBanker, temp, 1);
			return true;
		}
		else
			sprintf(temp, "%s you have insufficent funds!", pc_currchar->name.c_str());
		npctalk(c, pBanker, temp, 1);
		return true;
	}
}
コード例 #2
0
void Human_Stablemaster::handleTargetInput( P_PLAYER player, cUORxTarget* target )
{
	if ( !player )
		return;

	P_ITEM pPack = m_npc->getBankbox();
	if ( !pPack )
		return;

	P_NPC pPet = dynamic_cast<P_NPC>( World::instance()->findChar( target->serial() ) );
	if ( !pPet )
	{
		m_npc->talk( tr( "I cannot stable that!" ) );
		return;
	}

	if ( pPet->owner() != player )
	{
		m_npc->talk( tr( "This does not belong to you!" ) );
		return;
	}

	// we spawn a worldgem in the stablemasters bankbox for the pet
	// it does only hold the serial of it, the serial of the owner and the
	// number of refresh signals since begin of stabling
	// the pet becomes "free", which means, that it isnt in the world
	// but will still be saved.
	P_ITEM pGem = new cItem();
	pGem->Init( true );
	pGem->setTag( "player", cVariant( player->serial() ) );
	pGem->setTag( "pet", cVariant( pPet->serial() ) );
	pGem->setId( 0x1ea7 );
	pGem->setName( tr( "petitem: %1" ).arg( pPet->name() ) );
	pGem->setVisible( 2 ); // gm visible
	pPack->addItem( pGem );
	pGem->update();


	//pPet->free = true;
	MapObjects::instance()->remove( pPet );
	pPet->setStablemasterSerial( this->m_npc->serial() );
	pPet->removeFromView();

	// we need this for db saves
    m_npc->talk( tr( "Say release to get your pet back!" ) );
}
コード例 #3
0
ファイル: player.cpp プロジェクト: Mutilador/Wolfpack
bool cPlayer::mount( P_NPC pMount )
{
	if ( !pMount )
		return false;

	if ( isDead() )
	{
		return false;
	}

	unsigned short mountId = pMount->mountId();

	if ( !mountId )
	{
		return false; // Not mountable
	}

	cUOSocket* socket = this->socket();
	if ( !inRange( pMount, Config::instance()->mountRange() ) && !isGM() )
	{
		if ( socket )
			socket->sysMessage( 500206 ); // That is too far away to ride.
		return true; // Mountable, but not in range
	}

	if ( pMount->owner() == this || isGM() )
	{
		unmount();

		P_ITEM pMountItem = new cItem;
		pMountItem->Init();
		pMountItem->setId( mountId );
		pMountItem->setColor( pMount->skin() );

		if ( direction() != pMount->direction() )
		{
			setDirection( pMount->direction() );
			update();
		}

		this->addItem( cBaseChar::Mount, pMountItem );
		pMountItem->setTag( "pet", cVariant( pMount->serial() ) );
		pMountItem->update();

		// if this is a gm lets tame the animal in the process
		if ( isGM() )
		{
			pMount->setOwner( this );
			pMount->setTamed( true );
		}

		// remove it from screen!
		pMount->bark( Bark_Idle );
		pMount->removeFromView( false );
		pMount->fight( 0 );
		pMount->setStablemasterSerial( serial_ );
	}
	else if ( pMount->owner() == 0 )
	{
		socket->clilocMessage( 501263, 0, 0x3b2, 3, this ); // That mount does not look broken! You would have to tame it to ride it.
	}
	else
		socket->clilocMessage( 501264, 0, 0x3b2, 3, this ); // This isn't your mount; it refuses to let you ride.

	return true;
}
コード例 #4
0
void cTmpEff::Expire()
{
    int k;

    P_CHAR pc_s = FindCharBySerial(getDest());
    if (   num != 9		// grinding
            && num != 10	// create potion
            && num != 13	// door close
            && num != 14	// training dummy
            && num != 17)	// explosion
    {
        //Added by TANiS to fix errors, memory corruption and door auto-close 10-6-98
        // Check to see if it's a dead char and delete the wrong effect, or if it's just
        // a door auto-close effect and process it the right way.
        if ( pc_s == NULL )
        {
            return;		// just remove this effect
        } //End of TANiS' change
    }

    switch(num)
    {
    case 1:
        if (pc_s->priv2&0x02)
        {
            pc_s->priv2 &= 0xFD;
            int sk=calcSocketFromChar((pc_s));
            if (sk!=-1) sysmessage(sk, "You are no longer frozen.");
            Magic->afterParticles(38, pc_s);
        }
        break;
    case 2:
        pc_s->fixedlight='\xFF';
        dolight(calcSocketFromChar((pc_s)), worldbrightlevel);
        break;
    case 3:
        pc_s->chgDex(more1);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 4:
        pc_s->in+=more1;
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 5:
        pc_s->st+=more1;
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 6:
        pc_s->chgDex(-1 * more1);
        pc_s->stm=min(pc_s->stm, (int)pc_s->effDex());
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 7:
        pc_s->in-=more1;
        pc_s->mn=min(pc_s->mn, pc_s->in);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 8:
        pc_s->st-=more1;
        pc_s->hp=min(pc_s->hp, pc_s->st);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 9:
        if (more1 == 0)
        {
            if (more2!=0)
            {
                sprintf((char*)temp, "*%s continues grinding.*", pc_s->name.c_str());
                npcemoteall(pc_s, (char*)temp,1);
            }
            soundeffect2(pc_s, 0x0242);
        }
        break;
    case 10:
    {
        pc_s = FindCharBySerial(getSour());
        P_ITEM pMortar = FindItemBySerial(getDest());
        if(pMortar != NULL) //AntiChrist - to prevent crashes
            Skills->CreatePotion(pc_s, more1, more2, pMortar);
    }
    break;
    case 11:
        pc_s->st-=more1;
        pc_s->hp=min(pc_s->hp, pc_s->st);
        pc_s->chgDex(-1 * more2);
        pc_s->stm=min(pc_s->stm, (int)pc_s->effDex());
        pc_s->in-=more3;
        pc_s->mn=min(pc_s->mn, pc_s->in);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 12:
        pc_s->st+=more1;
        pc_s->chgDex(more2);
        pc_s->in+=more3;
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 13:
    {
        P_ITEM pDoor = FindItemBySerial(getDest());// door
        if (pDoor)
        {
            if (pDoor->dooropen==0)
                break;
            pDoor->dooropen=0;
            dooruse(calcSocketFromChar((pc_s)), pDoor);
        }
        break;
    }
    case 14: //- training dummies Tauriel check to see if item moved or not before searching for it
    {
        P_ITEM pTrainDummy = FindItemBySerial(getDest());
        if (pTrainDummy)
        {
            if (pTrainDummy->id()==0x1071)
            {
                pTrainDummy->setId(0x1070);
                pTrainDummy->gatetime=0;
                RefreshItem(pTrainDummy);//AntiChrist
            }
            else if (pTrainDummy->id()==0x1075)
            {
                pTrainDummy->setId(0x1074);
                pTrainDummy->gatetime=0;
                RefreshItem(pTrainDummy);//AntiChrist
            }
        }
    }
    break;
    case 15: //reactive armor
        pc_s->ra=0;
        break;
    case 16: //Explosion potion messages	Tauriel
        sprintf((char*)temp, "%i", more3);
        sysmessage(calcSocketFromChar((pc_s)), (char*)temp); // crashfix, LB
        break;
    case 17: //Explosion potion explosion	Tauriel
        pc_s = FindCharBySerial(getSour());
        explodeitem(calcSocketFromChar((pc_s)), FindItemBySerial(getDest())); //explode this item
        break;
    case 18: //Polymorph spell by AntiChrist 9/99
        if(pc_s->polymorph)//let's ensure it's under polymorph effect!
        {
            pc_s->setId(pc_s->xid);
            pc_s->polymorph=false;
            teleport(pc_s);
        }
        break;
    case 19: //Incognito spell by AntiChrist 12/99
        reverseIncognito(pc_s);
        break;

    case 20: // LSD potions, LB 5'th nov 1999
    {
        k=calcSocketFromChar((pc_s));
        if (k==-1) return;
        LSD[k]=0;
        sysmessage(k,"LSD has worn off");
        pc_s->stm=3; // stamina near 0
        pc_s->mn=3;
        pc_s->hp=pc_s->hp/7;
        impowncreate(k, pc_s, 0);
        all_items(k); // absolutely necassairy here !!!
        AllCharsIterator it;
        for (it.Begin(); !it.atEnd(); it++) // that hurts, but there's no other good way
        {
            P_CHAR pc = it.GetData();
            if (chardist( pc_s, pc ) < 15 && ( online(pc) || pc->isNpc() ) )
                updatechar(pc);
        }
    }
    break;

    case 21:
        int toDrop;
        toDrop = more1; //Effect->more1;
        if( ( pc_s->baseskill[PARRYING] - toDrop ) < 0 )
            pc_s->baseskill[PARRYING] = 0;
        else
            pc_s->baseskill[PARRYING] -= toDrop;
        break;

    case 33: // delayed hiding for gms after flamestrike effect
        k=calcSocketFromChar((pc_s));
        sysmessage(k,"You have hidden yourself well.");
        pc_s->hidden=1;
        updatechar(pc_s);
        break;

    case 34: // delayed unhide for gms
        // Changed to be uniform with delayed hideing  (Aldur)
        k = calcSocketFromChar((pc_s));
        sysmessage(k, "You are now visible.");
        pc_s->hidden = 0;
        updatechar(pc_s);
        break;

    case 35: //heals some pf - solarin
        int iHp;
        iHp=(int)more1;
        pc_s->hp+=iHp;
        updatestats(pc_s, 0);
        if (!more2)
            tempeffect(pc_s, pc_s, 35, more1+1, 1, more3, 0);
        break;

    default:
        LogErrorVar("Fallout of switch (num = %i).", num);
        break;
    }
    Items->CheckEquipment(pc_s); //AntiChrist - checks equipments for stats requirements
}
コード例 #5
0
void cPlayer::mount( P_NPC pMount )
{
	if ( !pMount )
		return;

	cUOSocket* socket = this->socket();
	if ( !inRange( pMount, 2 ) && !isGM() )
	{
		if ( socket )
			socket->sysMessage( tr( "You are too far away to mount!" ) );
		return;
	}

	if ( pMount->owner() == this || isGM() )
	{
		unmount();

		P_ITEM pMountItem = new cItem;
		pMountItem->Init();
		pMountItem->setId( 0x915 );
		pMountItem->setColor( pMount->skin() );

		switch ( static_cast<unsigned short>( pMount->body() & 0x00FF ) )
		{
		case 0xC8:
			pMountItem->setId( 0x3E9F ); break; // Horse
		case 0xE2:
			pMountItem->setId( 0x3EA0 ); break; // Horse
		case 0xE4:
			pMountItem->setId( 0x3EA1 ); break; // Horse
		case 0xCC:
			pMountItem->setId( 0x3EA2 ); break; // Horse
		case 0xD2:
			pMountItem->setId( 0x3EA3 ); break; // Desert Ostard
		case 0xDA:
			pMountItem->setId( 0x3EA4 ); break; // Frenzied Ostard
		case 0xDB:
			pMountItem->setId( 0x3EA5 ); break; // Forest Ostard
		case 0xDC:
			pMountItem->setId( 0x3EA6 ); break; // LLama
		case 0x34:
			pMountItem->setId( 0x3E9F ); break; // Brown Horse
		case 0x4E:
			pMountItem->setId( 0x3EA0 ); break; // Grey Horse
		case 0x50:
			pMountItem->setId( 0x3EA1 ); break; // Tan Horse
		case 0x74:
			pMountItem->setId( 0x3EB5 ); break; // Nightmare
		case 0x75:
			pMountItem->setId( 0x3EA8 ); break; // Silver Steed
		case 0x72:
			pMountItem->setId( 0x3EA9 ); break; // Dark Steed
		case 0x7A:
			pMountItem->setId( 0x3EB4 ); break; // Unicorn
		case 0x84:
			pMountItem->setId( 0x3EAD ); break; // Kirin
		case 0x73:
			pMountItem->setId( 0x3EAA ); break; // Etheral
		case 0x76:
			pMountItem->setId( 0x3EB2 ); break; // War Horse-Brit
		case 0x77:
			pMountItem->setId( 0x3EB1 ); break; // War Horse-Mage Council
		case 0x78:
			pMountItem->setId( 0x3EAF ); break; // War Horse-Minax
		case 0x79:
			pMountItem->setId( 0x3EB0 ); break; // War Horse-Shadowlord
		case 0xAA:
			pMountItem->setId( 0x3EAB ); break; // Etheral LLama
		case 0x3A:
			pMountItem->setId( 0x3EA4 ); break; // Forest Ostard
		case 0x39:
			pMountItem->setId( 0x3EA3 ); break; // Desert Ostard
		case 0x3B:
			pMountItem->setId( 0x3EA5 ); break; // Frenzied Ostard
		case 0x90:
			pMountItem->setId( 0x3EB3 ); break; // Seahorse
		case 0xAB:
			pMountItem->setId( 0x3EAC ); break; // Etheral Ostard
		case 0xBB:
			pMountItem->setId( 0x3EB8 ); break; // Ridgeback
		case 0x17:
			pMountItem->setId( 0x3EBC ); break; // giant beetle
		case 0x19:
			pMountItem->setId( 0x3EBB ); break; // skeletal mount
		case 0x1a:
			pMountItem->setId( 0x3EBD ); break; // swamp dragon
		case 0x1f:
			pMountItem->setId( 0x3EBE ); break; // armor dragon
		}

		this->addItem( cBaseChar::Mount, pMountItem );
		pMountItem->setTag( "pet", cVariant( pMount->serial() ) );
		pMountItem->update();

		// if this is a gm lets tame the animal in the process
		if ( isGM() )
		{
			pMount->setOwner( this );
		}

		// remove it from screen!
		pMount->bark( Bark_Idle );
		pMount->removeFromView( false );
		pMount->fight( 0 );
		pMount->setStablemasterSerial( serial_ );
	}
	else
		socket->sysMessage( tr( "You dont own that creature." ) );
}