本文整理汇总了C++中P_CHAR::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ P_CHAR::getPosition方法的具体用法?C++ P_CHAR::getPosition怎么用?C++ P_CHAR::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_CHAR
的用法示例。
在下文中一共展示了P_CHAR::getPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ItemDroppedOnSelf
static bool ItemDroppedOnSelf(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi)
{
if (ps == NULL) return false;
VALIDATEPIR(pi, false);
// NXWSOCKET s=ps->toInt();
// CHARACTER cc=ps->currCharIdx();
P_CHAR pc = ps->currChar(); // MAKE_CHAR_REF(cc);
VALIDATEPCR(pc, false);
Location charpos = pc->getPosition();
if (pi->getId() >= 0x4000 ) // crashfix , prevents putting multi-objects ni your backback
{
ps->sysmsg(TRANSLATE("Hey, putting houses in your pack crashes your back and client !"));
pi->MoveTo( charpos );
pi->Refresh();//AntiChrist
return true;
}
// if (pi->glow>0) // glowing items
// {
// pc->addHalo(pi);
// pc->glowHalo(pi);
// }
P_ITEM pack = pc->getBackpack();
if (pack==NULL) // if player has no pack, put it at its feet
{
pi->MoveTo( charpos );
pi->Refresh();
}
else
{
pack->AddItem(pi); // player has a pack, put it in there
weights::NewCalc(pc);//AntiChrist bugfixes
statwindow(pc,pc);
pc->playSFX( itemsfx(pi->getId()) );
}
return true;
}
示例2: 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)
{
//.........这里部分代码省略.........
示例3: target_mine
void Skills::target_mine( NXWCLIENT ps, P_TARGET t )
{
P_CHAR pc = ps->currChar();
VALIDATEPC( pc );
NXWSOCKET s = ps->toInt();
P_ITEM weapon = pc->GetItemOnLayer(1);
if( !canMine( pc, weapon ) )
return;
Location target = t->getLocation();
pc->facexy( target.x, target.y );
AMXEXECSVTARGET( pc->getSerial32(),AMXT_SKITARGS,MINING,AMX_BEFORE);
if ( pc->hidden )
pc->unHide();
LOGICAL floor = false;
LOGICAL mountain= false;
map_st map;
land_st land;
pc->stm+=ores.stamina;
if(pc->stm<0)
pc->stm=0;
if(pc->stm>pc->dx)
pc->stm=pc->dx;
pc->updateStats(2);
int cx = abs( (int) (pc->getPosition().x - target.x) );
int cy = abs( (int) (pc->getPosition().y - target.y) );
if( (cx>5) || (cy>5) )
{
pc->sysmsg(TRANSLATE("You are to far away to reach that"));
return;
}
UI32 id = t->getModel();
if( SrvParms->minecheck > 0 && !id )
{
// mountains are "map0's" and no statics !!!
data::seekMap( target.x, target.y, map );
data::seekLand( map.id, land );
if ( !strcmp(land.name,"rock") || !(strcmp(land.name, "mountain")) || !(strcmp(land.name, "cave")))
mountain = true;
}
data::seekMap( target.x, target.y, map );
if( !id )
id= map.id;
switch( id )
{
case 0x0ED3:
case 0x0EDF:
case 0x0EE0:
case 0x0EE1:
case 0x0EE2:
case 0x0EE8:
Skills::GraveDig( s );
return;
default:
break;
}
//
// Caves (Walls & Floors)
//
if( (id >= 0x025C && id <= 0x0276) ||
(id >= 0x027D && id <= 0x0280) ||
(id >= 0x053B && id <= 0x0553) ||
(id == 0x056A))
floor = true;
// sand (Anthalir)
if( (id>=0x0017) && (id<=0x0019) )
floor = true;
// check if cave floor ENDYMION USE THIS BUT SEE VALUES IN OLD CODE
/*if (
( (targetData.getModel( s )>>8)==0x05 && ( ((targetData.getModel( s )%256)>=0x3b && (targetData.getModel( s )%256)<=0x4f ) || ((targetData.getModel( s )%256)>=0x51 && (targetData.getModel( s )%256)<=0x53) || (targetData.getModel( s )%256)==0x6a ))&&
(!( ((targetData.getModel( s )>>8)==0x02)&&
( ( ((targetData.getModel( s )%256)>=0x5c) && ((targetData.getModel( s )%256)<=0x76))||(((targetData.getModel( s )%256)>=0x7d)&&((targetData.getModel( s )%256)<=0x80))))))
floor=1;*/
//.........这里部分代码省略.........
示例4: 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) )
//.........这里部分代码省略.........
示例5: checkFieldEffects
void checkFieldEffects( UI32 currenttime, P_CHAR pc, char timecheck )
{
VALIDATEPC(pc);
if ( (timecheck && !(nextfieldeffecttime<=currenttime)) ) //changed by Luxor
return;
#ifdef SPAR_NEW_WR_SYSTEM
pItemVectorIt itemIt( pc->nearbyItems->begin() ), itemEnd( pc->nearbyItems->end() );
for( ; itemIt != itemEnd; ++itemIt ) {
P_ITEM pi= (*itemIt);
#else
NxwItemWrapper si;
si.fillItemsNearXYZ( pc->getPosition(), 2, false );
for( si.rewind(); !si.isEmpty(); si++ )
{
P_ITEM pi=si.getItem();
#endif
if(ISVALIDPI(pi) ) {
if ( pi->getPosition().x == pc->getPosition().x && pi->getPosition().y == pc->getPosition().y )
//Luxor: added new field damage handling
switch( pi->getId() )
{
case 0x3996:
case 0x398C: //Fire Field
if (!pc->resistsFire())
tempfx::add(pc, pc, tempfx::FIELD_DAMAGE, (UI08)(pi->morex/100.0), DAMAGE_FIRE, 0, 0,1);
return;
case 0x3915:
case 0x3920: //Poison Field
if ((pi->morex<997)) {
tempfx::add(pc, pc, tempfx::FIELD_DAMAGE, 2, DAMAGE_POISON, 0, 0,2);
pc->applyPoison(POISON_WEAK);
} else {
tempfx::add(pc, pc, tempfx::FIELD_DAMAGE, 3, DAMAGE_POISON, 0, 0,2); // gm mages can cast greater poison field, LB
pc->applyPoison(POISON_NORMAL);
}
return;
case 0x3979:
case 0x3967: //Para Field
if (chance(50)) {
tempfx::add(pc, pc, tempfx::SPELL_PARALYZE, 0, 0, 0, 0,3);
pc->playSFX( 0x0204 );
}
return;
}
}
}
}
void checktimers() // Check shutdown timers
{
overflow = (lclock > uiCurrentTime);
if (endtime)
{
if ( endtime <= uiCurrentTime ) keeprun=false;
}
lclock = uiCurrentTime;
}