本文整理汇总了C++中P_ITEM::name方法的典型用法代码示例。如果您正苦于以下问题:C++ P_ITEM::name方法的具体用法?C++ P_ITEM::name怎么用?C++ P_ITEM::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_ITEM
的用法示例。
在下文中一共展示了P_ITEM::name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChangeName
// TESTED: OKAY
// guildnamechange(character, text) copies the text info the guildstones name field
// (guildnumber gets calculated from the double clicked guildstones), and notifies all online
// guildmambers about the change.
void cGuildStone::ChangeName(UOXSOCKET s, char *text)
{
list<SERIAL>::iterator it;
for (it = guilds.begin(); it != guilds.end(); ++it)
{
P_ITEM pStone = FindItemBySerial(*it);
if (pStone->name() == text)
{
sysmessage(s,"This name is already taken by another guild.");
return;
}
}
this->setName( text );
char txt[200];
sprintf(txt, "Your guild got renamed to %s", this->name().ascii() );
this->Broadcast(txt);
}
示例2: dropOnGuard
void cDragItems::dropOnGuard( P_CLIENT client, P_ITEM pItem, P_CHAR pGuard )
{
// Only heads for bountys are accepted
if( !pItem->name().contains( "the head of" ) || !pItem->owner())
{
pGuard->talk( "Bring that to a merchant if you want to sell it!" );
client->sysMessage( "I do not want that, citizen!" );
bounceItem( client, pItem );
return;
}
P_CHAR pVictim = pItem->owner();
if( pVictim->questBountyReward() <= 0 )
{
pGuard->talk( "You can not claim a prize for innocent citizens!. You are lucky I don't strike you down where you stand!" );
bounceItem( client, pItem );
return;
}
if( pVictim == client->player() )
{
pGuard->talk( "You can not claim that prize scoundrel. You are lucky I don't strike you down where you stand!" );
Items->DeleItem( pItem ); // The guard wont give the head back...
return;
}
addgold( client->socket(), pVictim->questBountyReward() );
goldsfx( client->socket(), pVictim->questBountyReward() );
Bounty->BountyDelete( pVictim->serial );
// Thank them for their work
pGuard->talk( QString( "Excellent work! You have brought us the head of %1. Here is your reward of %2 gold coins." ).arg( pVictim->name.c_str() ).arg( pVictim->questBountyReward() ) );
client->player()->karma += 100;
}
示例3: Menu
// guildstonemenu() : Opens the guild menu for a player
// Recognizes Guildmaster with the owner fields of the stone.
// Ofcourse checks for membership before opening any gump ;)
void cGuildStone::Menu(UOXSOCKET s, int page)
{
//int total,i, counter,guild,recruit,war,member;
int counter = 1;
int lentext;
int gumpnum = 0;
char guildfealty[60],guildt[16],toggle[6];
static char mygump[MAXMEMRECWAR][257];
P_CHAR pc = currchar[s];
if (!isMember( pc ) && !pc->isGM())
{
sysmessage(s, "You are not a member of this guild. Ask an existing guildmember to invite you into this guild.");
return;
}
strcpy(guildfealty, "yourself");
if ((pc->guildfealty() != pc->serial)&&(pc->guildfealty() != INVALID_SERIAL))
{
vector<SERIAL>::iterator it = find(member.begin(), member.end(), pc->guildfealty());
if ( it != member.end())
{
strcpy(guildfealty, FindCharBySerial(*it)->name.c_str());
}
}
else
pc->setGuildfealty( pc->serial );
if (this->ownserial == INVALID_SERIAL)
CalcMaster();
P_CHAR guildmaster = FindCharBySerial(this->ownserial);
switch (this->guildType)
{
case standard: strcpy(guildt, " Standard"); break;
case order: strcpy(guildt, "n Order"); break;
case chaos: strcpy(guildt, " Chaos"); break;
}
if (pc->guildtoggle())
strcpy(toggle, "On");
else
strcpy(toggle, "Off");
// our prefix is 0xFE (darkstorm)
gmprefix[7] = 0xFE;
switch(page)
{
case 1:
gumpnum=9;
gmprefix[8] = 1;
if (guildmaster<0) return;
lentext = sprintf(mygump[0], "%s (%s %s)", this->guildName.c_str(), guildmaster->guildtitle().latin1(), guildmaster->name.c_str());
strcpy(mygump[1],"Recruit someone into the guild.");
strcpy(mygump[2],"View the current roster.");
strcpy(mygump[3],"View the guild's charter.");
sprintf(mygump[4],"Declare your fealty. You are currently loyal to %s.",guildfealty);
sprintf(mygump[5],"Toggle showing the guild's abbreviation in your name to unguilded people. Currently %s.",toggle);
strcpy(mygump[6],"Resign from the guild.");
strcpy(mygump[7],"View list of candidates who have been sponsored to the guild.");
if ((pc->serial == this->ownserial)|| (pc->isGM())) // Guildmaster Access?
{
gumpnum=10;
gmprefix[8] = 0;
sprintf(mygump[8],"Access %s functions.", guildmaster->guildtitle().latin1());
sprintf(mygump[9],"View list of guild that %s has declared war on.", this->guildName.c_str());
sprintf(mygump[10],"View list of guilds that have declared war on %s.",this->guildName.c_str());
} else { // Normal Members access!
sprintf(mygump[8],"View list of guilds that %s have declared war on.",this->guildName.c_str());
sprintf(mygump[9],"View list of guilds that have declared war on %s.",this->guildName.c_str());
}
break;
case 2: // guildmaster menu
gumpnum=14;
lentext = sprintf(mygump[0], "%s, %s functions", this->guildName.c_str(), guildmaster->guildtitle().latin1());
strcpy(mygump[1], "Set the guild name.");
strcpy(mygump[2], "Set the guild's abbreviation.");
sprintf(mygump[3], "Change the type of the guild. (Currently a%s guild.)",guildt);
strcpy(mygump[4], "Set the guild's charter.");
strcpy(mygump[5], "Dismiss a member.");
strcpy(mygump[6], "Declare war from menu.");
strcpy(mygump[7], "Declare war from targeting enemy.");
strcpy(mygump[8], "Declare peace.");
strcpy(mygump[9], "Accept a candidate seeking membership.");
strcpy(mygump[10],"Refuse a candidate seeking membership.");
strcpy(mygump[11],"Set the guildmaster's title.");
strcpy(mygump[12],"Grant a title to another member.");
strcpy(mygump[13],"Move this guildstone.");
strcpy(mygump[14],"Return to the main menu.");
gmprefix[8] = 2;
break;
case 3: // guild type
//.........这里部分代码省略.........
示例4: equipItem
//.........这里部分代码省略.........
// Males can't wear female armor
if( ( pChar->id() == 0x0190 ) && ( pItem->id() >= 0x1C00 ) && ( pItem->id() <= 0x1C0D ) )
{
client->sysMessage( "You cannot wear female armor." );
bounceItem( client, pItem );
return;
}
// Needs a check (!)
// Checks for equipment on the same layer
// If there is any it tries to unequip it
// If that fails it cancels
UI08 layer = pItem->layer();
vector< SERIAL > equipment = contsp.getData( pWearer->serial );
for( UI32 i = 0; i < equipment.size(); i++ )
{
P_ITEM pEquip = FindItemBySerial( equipment[ i ] );
if( pEquip )
continue;
// We found an item which is on the same layer (!)
// Unequip it if we can
bool twoHanded = false;
if( pEquip->twohanded() && ( layer == 1 || layer == 2 ) )
twoHanded = true;
if( pItem->twohanded() && ( pEquip->layer() == 1 || pEquip->layer() == 2 ) )
twoHanded = true;
if( ( pEquip->layer() == layer ) || twoHanded )
{
if( pChar->canPickUp( pEquip ) ) // we're equipping so we do the check
pEquip->toBackpack( pWearer );
// If it's still on the char: cancel equipment
if( pEquip->contserial == pWearer->serial )
{
client->sysMessage( "You already have an item on that layer." );
bounceItem( client, pItem );
return;
}
}
}
// At this point we're certain that we can wear the item
pItem->setContSerial( playerId );
pItem->setLayer( pTile.layer ); // Don't trust the user input on this one
// Handle the weight if the item is leaving our "body"
if( pWearer != pChar )
{
pChar->weight -= pItem->getWeight();
pWearer->weight += pItem->getWeight();
// Update the status-windows
statwindow( client->socket(), pChar );
statwindow( calcSocketFromChar( pWearer ), pWearer );
}
if( pTile.layer == 0x19 )
pWearer->setOnHorse( true );
// Apply the bonuses
pWearer->st += pItem->st2;
pWearer->chgDex( pItem->dx2 );
pWearer->in += pItem->in2;
// Show debug information if requested
if( showlayer )
clConsole.send( QString( "Item (%1) equipped on layer %2" ).arg( pItem->name() ).arg( pItem->layer() ) );
// I don't think we need to remove the item
// as it's only visible to the current char
// And he looses contact anyway
// SndRemoveitem( pi->serial );
// Build our packets
cWornItems wearItem( pWearer->serial, pItem->serial, pItem->layer(), pItem->id(), pItem->color() );
cSoundEffect soundEffect( 0x57, pWearer->pos );
// Send to all sockets in range
// ONLY the new equipped item and the sound-effect
for( UOXSOCKET s = 0; s < now; s++ )
if( perm[s] && inrange1p( pWearer, currchar[s] ) )
{
soundEffect.send( s );
wearItem.send( s );
}
// Lord Binaries Glow stuff
if( pItem->glow != INVALID_SERIAL )
{
pChar->removeHalo( pItem );
pWearer->addHalo( pItem );
pWearer->glowHalo( pItem );
}
}