本文整理汇总了C++中P_CHAR::distFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ P_CHAR::distFrom方法的具体用法?C++ P_CHAR::distFrom怎么用?C++ P_CHAR::distFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_CHAR
的用法示例。
在下文中一共展示了P_CHAR::distFrom方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AttackStuff
void AttackStuff(NXWSOCKET s, P_CHAR victim)
{
if ( s < 0 || s >= now )
return;
P_CHAR attacker = MAKE_CHAR_REF( currchar[s] );
VALIDATEPC( attacker );
VALIDATEPC( victim );
if( attacker->getSerial32() == victim->getSerial32() )
return;
if ( attacker->amxevents[EVENT_CHR_ONBEGINATTACK]) {
g_bByPass = false;
attacker->amxevents[EVENT_CHR_ONBEGINATTACK]->Call( attacker->getSerial32(), victim->getSerial32() );
if (g_bByPass==true) return;
}
if ( victim->amxevents[EVENT_CHR_ONBEGINDEFENSE]) {
g_bByPass = false;
victim->amxevents[EVENT_CHR_ONBEGINDEFENSE]->Call( victim->getSerial32(), attacker->getSerial32() );
if (g_bByPass==true) return;
}
/*
attacker->runAmxEvent( EVENT_CHR_ONBEGINATTACK, attacker->getSerial32(), victim->getSerial32() );
if (g_bByPass==true)
return;
victim->runAmxEvent( EVENT_CHR_ONBEGINDEFENSE, victim->getSerial32(), attacker->getSerial32() );
if (g_bByPass==true)
return;
*/
attacker->targserial=victim->getSerial32();
attacker->unHide();
attacker->disturbMed();
if( victim->dead || victim->hp <= 0 )//AntiChrist
{
attacker->sysmsg( TRANSLATE("That person is already dead!") );
return;
}
if ( victim->npcaitype==NPCAI_PLAYERVENDOR)
{
attacker->sysmsg( TRANSLATE("%s cannot be harmed."), victim->getCurrentNameC() );
return;
}
SndAttackOK(s, victim->getSerial32()); //keep the target highlighted
if (!( victim->targserial== INVALID))
{
victim->attackerserial=attacker->getSerial32();
victim->ResetAttackFirst();
}
attacker->SetAttackFirst();
attacker->attackerserial=victim->getSerial32();
if( victim->guarded )
{
NxwCharWrapper sc;
sc.fillOwnedNpcs( victim, false, false );
for ( sc.rewind(); !sc.isEmpty(); sc++ )
{
P_CHAR guard = sc.getChar();
if ( ISVALIDPC( guard ) )
if ( guard->npcaitype == NPCAI_PETGUARD && ( attacker->distFrom( guard )<= 10 ) )
npcattacktarget(attacker, guard);
}
}
if ((region[ victim->region].priv & RGNPRIV_GUARDED) && (SrvParms->guardsactive))
{
if (victim->IsGrey())
attacker->SetGrey();
if (victim->npc==0 && victim->IsInnocent() && (!victim->IsGrey()) && Guildz.compareGuilds( attacker->getGuild(), victim->getGuild() )==0) //REPSYS
{
criminal( attacker );
if (ServerScp::g_nInstantGuard==1)
npcs::SpawnGuard(attacker, victim,attacker->getPosition() );
}
else if( victim->npc && victim->IsInnocent() && !victim->HasHumanBody() && victim->npcaitype!=NPCAI_TELEPORTGUARD )
{
criminal( attacker );
if (ServerScp::g_nInstantGuard==1)
npcs::SpawnGuard(attacker, victim, attacker->getPosition() );
}
else if( victim->npc && victim->IsInnocent() && victim->HasHumanBody() && victim->npcaitype!=NPCAI_TELEPORTGUARD )
{
victim->talkAll( TRANSLATE("Help! Guards! I've been attacked!"), 1);
criminal( victim );
callguards(DEREF_P_CHAR(victim)); // Sparhawk must check if npcs can call guards
}
else if( victim->npc && victim->npcaitype==NPCAI_TELEPORTGUARD)
{
criminal( attacker );
npcattacktarget(victim, attacker);
}
else if ((victim->npc || victim->tamed) && !victim->war && victim->npcaitype!=NPCAI_TELEPORTGUARD)
{
//.........这里部分代码省略.........
示例2: deadattack
void deadattack (NXWSOCKET s, CHARACTER i)
{
CHARACTER cc = currchar[s];
P_CHAR pc = MAKE_CHAR_REF( cc );
VALIDATEPC( pc );
P_CHAR pc_other = MAKE_CHAR_REF( i );
VALIDATEPC( pc_other );
if(pc_other->npc)
{
if(pc_other->npcaitype==NPCAI_HEALER)
{
if( pc->IsInnocent() )
{
if ( pc->distFrom( pc_other ) <= 3 )
{//let's resurrect him!
pc_other->playAction(0x10);
pc->resurrect();
staticeffect(cc, 0x37, 0x6A, 0x09, 0x06);
switch(RandomNum(0, 4))
{
case 0: pc_other->talkAll( TRANSLATE("Thou art dead, but 'tis within my power to resurrect thee. Live!"),0); break;
case 1: pc_other->talkAll( TRANSLATE("Allow me to resurrect thee ghost. Thy time of true death has not yet come."),0); break;
case 2: pc_other->talkAll( TRANSLATE("Perhaps thou shouldst be more careful. Here, I shall resurrect thee."),0); break;
case 3: pc_other->talkAll( TRANSLATE("Live again, ghost! Thy time in this world is not yet done."),0); break;
case 4: pc_other->talkAll( TRANSLATE("I shall attempt to resurrect thee."),0); break;
}
}
else
{//if dist>3
pc_other->talkAll( TRANSLATE("Come nearer, ghost, and i'll give you life!"),1);
}
}
else
{//if a bad guy
pc_other->talkAll( TRANSLATE("I will not give life to a scoundrel like thee!"),1);
}
}
else if( pc_other->npcaitype == NPCAI_EVILHEALER )
{
if( pc->IsMurderer())
{
if ( pc->distFrom( pc_other ) <=3 )
{//let's resurrect him!
pc_other->playAction(0x10);
pc->resurrect();
staticeffect(cc, 0x37, 0x09, 0x09, 0x19); //Flamestrike effect
switch(rand()%5)
{
case 0: pc_other->talkAll( TRANSLATE("Fellow minion of Mondain, Live!!"),0); break;
case 1: pc_other->talkAll( TRANSLATE("Thou has evil flowing through your vains, so I will bring you back to life."),0); break;
case 2: pc_other->talkAll( TRANSLATE("If I res thee, promise to raise more hell!."),0); break;
case 3: pc_other->talkAll( TRANSLATE("From hell to Britannia, come alive!."),0); break;
case 4: pc_other->talkAll( TRANSLATE("Since you are Evil, I will bring you back to consciouness."),0); break;
}
}
else
{//if dist >3
pc_other->talkAll( TRANSLATE("Come nearer, evil soul, and i'll give you life!"),1);
}
}
else
{//if player is a good guy
pc_other->talkAll( TRANSLATE("I dispise all things good. I shall not give thee another chance!"),1);
}
}
else
{
sysmessage(s,TRANSLATE("You are dead and cannot do that."));
}//npcaitype check
}
else
{//if this not a npc but a player
if(SrvParms->persecute)
{//start persecute stuff - AntiChrist
pc->targserial = pc_other->getSerial32();
Skills::Persecute(s);
}
else
{
sysmessage(s,TRANSLATE("You are dead and cannot do that."));
}
}//if npc
}
示例3: doubleclick
/*!
\brief Double click
\author Ripper, rewrite by Endymion
\param ps client of player dbclick
\note Completely redone by Morrolan 20-07-99
\warning I use a define CASE for make more readable the code, if you change name of P_ITEM pi chage also the macro
\todo los
*/
void doubleclick(NXWCLIENT ps)
{
if(ps==NULL) return;
P_CHAR pc = ps->currChar();
VALIDATEPC( pc );
NXWSOCKET s = ps->toInt();
// the 0x80 bit in the first byte is used later for "keyboard" and should be ignored
SERIAL serial = LongFromCharPtr(buffer[s] +1) & 0x7FFFFFFF;
if (isCharSerial(serial))
{
P_CHAR pd=pointers::findCharBySerial(serial);
if(ISVALIDPC(pd))
dbl_click_character(ps, pd);
return;
}
P_ITEM pi = pointers::findItemBySerial(serial);
VALIDATEPI(pi);
if (pi->amxevents[EVENT_IONDBLCLICK]!=NULL) {
g_bByPass = false;
pi->amxevents[EVENT_IONDBLCLICK]->Call( pi->getSerial32(), pc->getSerial32() );
if (g_bByPass==true)
return;
}
/*
g_bByPass = false;
pi->runAmxEvent( EVENT_IONDBLCLICK, pi->getSerial32(), s );
if (g_bByPass==true)
return;
*/
if (!checkItemUsability(pc , pi, ITEM_USE_DBLCLICK))
return;
Location charpos= pc->getPosition();
if (pc->IsHiddenBySpell()) return; //Luxor: cannot use items if under invisible spell
if ( !pc->IsGM() && pc->objectdelay >= uiCurrentTime )
{
pc->sysmsg(TRANSLATE("You must wait to perform another action."));
return;
}
else
pc->objectdelay = SrvParms->objectdelay * MY_CLOCKS_PER_SEC + uiCurrentTime;
///MODIFY, CANT CLICK ITEM AT DISTANCE >2//////////////
if ( (pc->distFrom(pi)>2) && !pc->IsGM() && !(pc->nxwflags[0] & cChar::flagSpellTelekinesys) ) //Luxor: let's check also for the telekinesys spell
{
pc->sysmsg( TRANSLATE("Must be closer to use this!"));
pc->objectdelay=0;
return;
}
//<Anthalir> VARIAIBLI
tile_st item;
P_ITEM pack= pc->getBackpack();
VALIDATEPI( pack );
data::seekTile( pi->getId(), item );
//////FINEVARIABILI
if ( ServerScp::g_nEquipOnDclick )
{
// equip the item only if it is in the backpack of the player
if ((pi->getContSerial() == pack->getSerial32()) && (item.quality != 0) && (item.quality != LAYER_BACKPACK) && (item.quality != LAYER_MOUNT))
{
int drop[2]= {-1, -1}; // list of items to drop, there no reason for it to be larger
int curindex= 0;
NxwItemWrapper wea;
wea.fillItemWeared( pc, true, true, true );
for( wea.rewind(); !wea.isEmpty(); wea++ )
{
P_ITEM pj=wea.getItem();
if(!ISVALIDPI(pj))
continue;
if ((item.quality == LAYER_1HANDWEAPON) || (item.quality == LAYER_2HANDWEAPON))// weapons
{
if (pi->itmhand == 2) // two handed weapons or shield
{
if (pj->itmhand == 2)
drop[curindex++]= DEREF_P_ITEM(pj);
if ( (pj->itmhand == 1) || (pj->itmhand == 3) )
//.........这里部分代码省略.........
示例4: target_stealing
/*!
\brief Steal something
\author Unknow, completly rewritten by Endymion
\param ps the client
*/
void Skills::target_stealing( NXWCLIENT ps, P_TARGET t )
{
P_CHAR thief = ps->currChar();
VALIDATEPC(thief);
SERIAL target_serial = t->getClicked();
AMXEXECSVTARGET( thief->getSerial32(),AMXT_SKITARGS,STEALING,AMX_BEFORE);
//steal a char
if ( isCharSerial(target_serial) )
{
Skills::target_randomSteal(ps,t);
return;
}
const P_ITEM pi = pointers::findItemBySerial( target_serial );
VALIDATEPI(pi);
//steal a pickpocket, a steal training dummy
if( pi->getId() == 0x1E2D || pi->getId() == 0x1E2C )
{
Skills::PickPocketTarget(ps);
return;
}
//no stealing for items on layers other than 0 (equipped!) , newbie items, and items not being in containers allowed !
if ( pi->layer!=0 || pi->isNewbie() || pi->isInWorld() )
{
thief->sysmsg(TRANSLATE("You cannot steal that."));
return;
}
P_CHAR victim = pi->getPackOwner();
VALIDATEPC(victim);
if (victim->npcaitype == NPCAI_PLAYERVENDOR)
{
thief->sysmsg(TRANSLATE("You cannot steal from player vendors."));
return;
}
if ( (thief->getSerial32() == victim->getSerial32()) || (thief->getSerial32()==victim->getOwnerSerial32()) )
{
thief->sysmsg(TRANSLATE("You catch yourself red handed."));
return;
}
if (thief->distFrom( victim ) == 1)
{
int result;
R32 we = pi->getWeightActual();
int bonus= (int)( (1800 - we)/5 );
if ( thief->checkSkill( STEALING,0,(1000-bonus)) )
{
// 0 stealing 2 stones, 10 3 stones, 99.9 12 stones, 100 17 stones !!!
int cansteal = thief->skill[STEALING] > 999 ? 1700 : thief->skill[STEALING] + 200;
if ( we > cansteal )
{
thief->sysmsg(TRANSLATE("That is too heavy."));
return;
}
if (pi->amxevents[EVENT_IONSTOLEN]!=NULL)
{
g_bByPass = false;
pi->amxevents[EVENT_IONSTOLEN]->Call(pi->getSerial32(), thief->getSerial32(), victim->getSerial32());
if (g_bByPass==true)
return;
}
if (victim->amxevents[EVENT_CHR_ONSTOLEN])
{
g_bByPass = false;
victim->amxevents[EVENT_CHR_ONSTOLEN]->Call(victim->getSerial32(), thief->getSerial32());
if (g_bByPass==true)
return;
}
/*
pi->runAmxEvent( EVENT_IONSTOLEN, pi->getSerial32(), s, victim->getSerial32() );
if (g_bByPass==true)
return;
victim->runAmxEvent( EVENT_CHR_ONSTOLEN, victim->getSerial32(), s );
if (g_bByPass==true)
return;
*/
P_ITEM pack= thief->getBackpack();
VALIDATEPI(pack);
//.........这里部分代码省略.........
示例5: item_dist
UI32 item_dist(P_CHAR a, P_ITEM b)
{
VALIDATEPCR(a, VERY_VERY_FAR);
return a->distFrom( b );
}
示例6: item_inRange
LOGICAL item_inRange(P_CHAR a, P_ITEM b, UI32 range)
{
VALIDATEPCR(a, false);
return ( a->distFrom( b ) <= range );
}
示例7: char_inRange
LOGICAL char_inRange(P_CHAR a, P_CHAR b, UI32 range)
{
VALIDATEPCR(a, false);
return ( a->distFrom( b ) <= range );
}