コード例 #1
0
ファイル: NpcsAI.cpp プロジェクト: Elekaene/dakara-server
void PersigueCiudadano(int NpcIndex) {
	/* '*************************************************** */
	/* 'Autor: Unknown (orginal version) */
	/* 'Last Modification: 12/01/2010 (ZaMa) */
	/* '14/09/2009: ZaMa - Now npcs don't follow protected users. */
	/* '12/01/2010: ZaMa - Los npcs no atacan druidas mimetizados con npcs. */
	/* '*************************************************** */
	int UserIndex;
	int tHeading;
	int i;
	bool UserProtected;

	for (i = (1); i <= (ConnGroups[Npclist[NpcIndex].Pos.Map].CountEntrys);
			i++) {
		UserIndex = ConnGroups[Npclist[NpcIndex].Pos.Map].UserEntrys[i];

		/* 'Is it in it's range of vision?? */
		if (vb6::Abs(UserList[UserIndex].Pos.X - Npclist[NpcIndex].Pos.X)
				<= RANGO_VISION_X) {
			if (vb6::Abs(UserList[UserIndex].Pos.Y - Npclist[NpcIndex].Pos.Y)
					<= RANGO_VISION_Y) {

				if (!criminal(UserIndex)) {

					UserProtected = !IntervaloPermiteSerAtacado(UserIndex)
							&& UserList[UserIndex].flags.NoPuedeSerAtacado;
					UserProtected = UserProtected
							|| UserList[UserIndex].flags.Ignorado
							|| UserList[UserIndex].flags.EnConsulta;

					if (UserList[UserIndex].flags.Muerto == 0
							&& UserList[UserIndex].flags.invisible == 0
							&& UserList[UserIndex].flags.Oculto == 0
							&& UserList[UserIndex].flags.AdminPerseguible
							&& !UserProtected) {

						if (Npclist[NpcIndex].flags.LanzaSpells > 0) {
							NpcLanzaUnSpell(NpcIndex, UserIndex);
						}
						tHeading = FindDirection(Npclist[NpcIndex].Pos,
								UserList[UserIndex].Pos);
						MoveNPCChar(NpcIndex, tHeading);
						return;
					}
				}

			}
		}

	}

	RestoreOldMovement(NpcIndex);
}
コード例 #2
0
ファイル: rcvpkg.cpp プロジェクト: nox-wizard/noxwizard
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)
		{
			victim->fight( attacker );
		}
		else
		{
			victim->setNpcMoveTime();
		}
		//attacker->emoteall( "You see %s attacking %s!", 1, attacker->getCurrentNameC(), victim->getCurrentNameC() );
	}
	else	// not a guarded area
	{
		if ( victim->IsInnocent())
		{
			if ( victim->IsGrey())
				attacker->SetGrey();
			if (!victim->npc && (!victim->IsGrey()) && Guildz.compareGuilds(attacker->getGuild(), victim->getGuild() )==0)
			{
				criminal( attacker );
			}
			else if (victim->npc && victim->tamed)
			{
				criminal( attacker );
				npcattacktarget(victim, attacker);
			}
			else if (victim->npc)
			{
				criminal( attacker );
				npcattacktarget(victim, attacker);
				if (victim->HasHumanBody() )
				{
					victim->talkAll(TRANSLATE("Help! Guards! Tis a murder being commited!"), 1);
				}
			}
		}
	}

}
コード例 #3
0
void RcvAttack(P_CLIENT ps)
{
	UOXSOCKET s = ps->GetSocket();
	P_CHAR pc_currchar = ps->getPlayer();
	int j;

	SERIAL serial=calcserial(buffer[s][1],buffer[s][2],buffer[s][3],buffer[s][4]);
	if(serial == INVALID_SERIAL) return;
	P_CHAR pc_i = FindCharBySerPtr(&buffer[s][1]);
	if(pc_i == NULL) return;	//to avoid problems
	
	if(pc_currchar->dead)//AntiChrist stuff
	{
		if(SrvParams->persecute())
		{//start persecute stuff - AntiChrist
			pc_currchar->targ = pc_i->serial;
			if(pc_currchar->targ==INVALID_SERIAL) return;
			else Skills->Persecute(s);
			return;
		} else
		{
			sysmessage(s,"You are dead and cannot do that.");
			return;
		}
	}
	if(pc_currchar->cell>0)
	{
		sysmessage(s,"There is no fighting in the jail cells!");
		return;
	}

	if(!pc_currchar->dead)
	{
		pc_currchar->targ = serial;
		pc_currchar->unhide();
		pc_currchar->disturbMed(s);

		
		if(pc_i->dead || pc_i->hp<=0)//AntiChrist
		{
			sysmessage(s,"That person is already dead!");
			return;
		}
		
		if (pc_i->npcaitype==17)//PlayerVendors
		{
			sprintf((char*)temp, "%s cannot be harmed.",pc_i->name.c_str());
			sysmessage(s, (char*)temp);
			return;
		}
		
		SndAttackOK(s, pc_i->serial);	//keep the target highlighted       
		if (!(pc_i->targ == INVALID_SERIAL))
		{
			pc_i->attacker = pc_currchar->serial;
			pc_i->resetAttackFirst();
		}
		pc_currchar->setAttackFirst();
		pc_currchar->attacker = pc_i->serial;
 
		pc_currchar->dir = chardir(pc_currchar, pc_i);	// turn to attacker, LB (& Duke)

		updatechar(pc_currchar);

		if( pc_i->guarded )
		{
			AllCharsIterator iter_char;
			for (iter_char.Begin(); !iter_char.atEnd(); iter_char++)
			{
				P_CHAR toCheck = iter_char.GetData();
				if (pc_i->Owns(toCheck) && toCheck->npcaitype == 32 && chardist( pc_currchar, toCheck )<= 10 )
				{
					npcattacktarget( pc_currchar, toCheck );
				}
			}
		}

		if (pc_i->inGuardedArea() && SrvParams->guardsActive())
		{
			if (pc_i->isPlayer() && pc_i->isInnocent() && GuildCompare( pc_currchar, pc_i )==0) //REPSYS
			{
				criminal( pc_currchar );
				Combat->SpawnGuard(pc_currchar, pc_i ,pc_currchar->pos.x,pc_currchar->pos.y,pc_currchar->pos.z);
			}
			else if( pc_i->isNpc() && pc_i->isInnocent() && !pc_i->isHuman() && pc_i->npcaitype!=4 )
			{
				criminal( pc_currchar );
				Combat->SpawnGuard(pc_currchar, pc_i, pc_currchar->pos.x,pc_currchar->pos.y,pc_currchar->pos.z);
			}
			else if( pc_i->isNpc() && pc_i->isInnocent() && pc_i->isHuman() && pc_i->npcaitype!=4 )
			{
				npctalkall(pc_i, "Help! Guards! I've been attacked!", 1);
				criminal( pc_currchar );
				callguards(pc_i);
			}
			else if( pc_i->isNpc() && pc_i->npcaitype==4)
			{
				criminal( pc_currchar );
				npcattacktarget(pc_i, pc_currchar);
			}
			else if ((pc_i->isNpc() || pc_i->tamed) && !pc_i->war && pc_i->npcaitype!=4) // changed from 0x40 to 4, cauz 0x40 was removed LB
			{
				npcToggleCombat(pc_i);
				pc_i->setNextMoveTime();
			}
			else
			{
				pc_i->setNextMoveTime();
			}
			
			sprintf((char*)temp, "You see %s attacking %s!", pc_currchar->name.c_str(), pc_i->name.c_str());
			
			for (j=0;j<now;j++)
			{
				if((inrange1(s, j) && perm[j]) && (s!=j))
				{
					pc_i->emotecolor = 0x0026;
					npcemote(j, pc_currchar, (char*)temp,1);
				}
			}
		}
		else	// not a guarded area
		{
			if (pc_i->isInnocent())
			{
				if (pc_i->isPlayer() && GuildCompare( pc_currchar, pc_i )==0)
				{
					criminal( pc_currchar );
				}
				else if (pc_i->isNpc() && pc_i->tamed)
				{
					criminal( pc_currchar );
					npcattacktarget(pc_i, pc_currchar);
				}
				else if (pc_i->isNpc())
				{
					criminal( pc_currchar );
					npcattacktarget(pc_i, pc_currchar);
					if (pc_i->isHuman() )
					{
						npctalkall(pc_i, "Help! Guards! Tis a murder being commited!", 1);
					}
				}
			}
		}
	}
}
コード例 #4
0
ファイル: Npcs.cpp プロジェクト: irongete/dakara-server
void MuereNpc(int NpcIndex, int UserIndex) {
	/* '******************************************************** */
	/* 'Author: Unknown */
	/* 'Llamado cuando la vida de un NPC llega a cero. */
	/* 'Last Modify Date: 13/07/2010 */
	/* '22/06/06: (Nacho) Chequeamos si es pretoriano */
	/* '24/01/2007: Pablo (ToxicWaste): Agrego para actualización de tag si cambia de status. */
	/* '22/05/2010: ZaMa - Los caos ya no suben nobleza ni plebe al atacar npcs. */
	/* '23/05/2010: ZaMa - El usuario pierde la pertenencia del npc. */
	/* '13/07/2010: ZaMa - Optimizaciones de logica en la seleccion de pretoriano, y el posible cambio de alencion del usuario. */
	/* '******************************************************** */

	struct npc MiNPC;
	MiNPC = Npclist[NpcIndex];
	bool EraCriminal;

	/* ' Es pretoriano? */
	if (MiNPC.NPCtype == eNPCType_Pretoriano) {
		// ClanPretoriano[MiNPC.ClanIndex].MuerePretoriano(NpcIndex);
	}

	/* 'Quitamos el npc */
	QuitarNPC(NpcIndex);

	/* ' Lo mato un usuario? */
	if (UserIndex > 0) {

		if (MiNPC.flags.Snd3 > 0) {
			SendData(SendTarget_ToPCArea, UserIndex,
					dakara::protocol::server::BuildPlayWave(MiNPC.flags.Snd3, MiNPC.Pos.X, MiNPC.Pos.Y));
		}
		UserList[UserIndex].flags.TargetNPC = 0;
		UserList[UserIndex].flags.TargetNpcTipo = eNPCType_Comun;

		/* 'El user que lo mato tiene mascotas? */
		if (UserList[UserIndex].NroMascotas > 0) {
			int T;
			for (T = (1); T <= (MAXMASCOTAS); T++) {
				if (UserList[UserIndex].MascotasIndex[T] > 0) {
					if (Npclist[UserList[UserIndex].MascotasIndex[T]].TargetNPC == NpcIndex) {
						FollowAmo(UserList[UserIndex].MascotasIndex[T]);
					}
				}
			}
		}

		/* '[KEVIN] */
		if (MiNPC.flags.ExpCount > 0) {
			if (UserList[UserIndex].PartyIndex > 0) {
				ObtenerExito(UserIndex, MiNPC.flags.ExpCount, MiNPC.Pos.Map, MiNPC.Pos.X, MiNPC.Pos.Y);
			} else {
				UserList[UserIndex].Stats.Exp = UserList[UserIndex].Stats.Exp + MiNPC.flags.ExpCount;
				if (UserList[UserIndex].Stats.Exp > MAXEXP) {
					UserList[UserIndex].Stats.Exp = MAXEXP;
				}
				WriteConsoleMsg(UserIndex, "Has ganado " + vb6::CStr(MiNPC.flags.ExpCount) + " puntos de experiencia.",
						FontTypeNames_FONTTYPE_FIGHT);
			}
			MiNPC.flags.ExpCount = 0;
		}

		/* '[/KEVIN] */
		WriteConsoleMsg(UserIndex, "¡Has matado a la criatura!", FontTypeNames_FONTTYPE_FIGHT);
		if (UserList[UserIndex].Stats.NPCsMuertos < 32000) {
			UserList[UserIndex].Stats.NPCsMuertos = UserList[UserIndex].Stats.NPCsMuertos + 1;
		}

		EraCriminal = criminal(UserIndex);

		if (MiNPC.Stats.Alineacion == 0) {

			if (MiNPC.Numero == Guardias) {
				UserList[UserIndex].Reputacion.NobleRep = 0;
				UserList[UserIndex].Reputacion.PlebeRep = 0;
				UserList[UserIndex].Reputacion.AsesinoRep = UserList[UserIndex].Reputacion.AsesinoRep + 500;
				if (UserList[UserIndex].Reputacion.AsesinoRep > MAXREP) {
					UserList[UserIndex].Reputacion.AsesinoRep = MAXREP;
				}
			}

			if (MiNPC.MaestroUser == 0) {
				UserList[UserIndex].Reputacion.AsesinoRep = UserList[UserIndex].Reputacion.AsesinoRep
						+ vlASESINO;
				if (UserList[UserIndex].Reputacion.AsesinoRep > MAXREP) {
					UserList[UserIndex].Reputacion.AsesinoRep = MAXREP;
				}
			}

		} else if (!esCaos(UserIndex)) {
			if (MiNPC.Stats.Alineacion == 1) {
				UserList[UserIndex].Reputacion.PlebeRep = UserList[UserIndex].Reputacion.PlebeRep + vlCAZADOR;
				if (UserList[UserIndex].Reputacion.PlebeRep > MAXREP) {
					UserList[UserIndex].Reputacion.PlebeRep = MAXREP;
				}

			} else if (MiNPC.Stats.Alineacion == 2) {
				UserList[UserIndex].Reputacion.NobleRep = UserList[UserIndex].Reputacion.NobleRep
						+ vlASESINO / 2;
				if (UserList[UserIndex].Reputacion.NobleRep > MAXREP) {
					UserList[UserIndex].Reputacion.NobleRep = MAXREP;
				}

			} else if (MiNPC.Stats.Alineacion == 4) {
				UserList[UserIndex].Reputacion.PlebeRep = UserList[UserIndex].Reputacion.PlebeRep + vlCAZADOR;
				if (UserList[UserIndex].Reputacion.PlebeRep > MAXREP) {
					UserList[UserIndex].Reputacion.PlebeRep = MAXREP;
				}

			}
		}

		bool EsCriminal;
		EsCriminal = criminal(UserIndex);

		/* ' Cambio de alienacion? */
		if (EraCriminal != EsCriminal) {

			/* ' Se volvio pk? */
			if (EsCriminal) {
				if (esArmada(UserIndex)) {
					ExpulsarFaccionReal(UserIndex);
				}

				/* ' Se volvio ciuda */
			} else {
				if (esCaos(UserIndex)) {
					ExpulsarFaccionCaos(UserIndex);
				}
			}

			RefreshCharStatus(UserIndex);
		}

		CheckUserLevel(UserIndex);

		if (NpcIndex == UserList[UserIndex].flags.ParalizedByNpcIndex) {
			RemoveParalisis(UserIndex);
		}

		/* ' Userindex > 0 */
	}

	if (MiNPC.MaestroUser == 0) {
		/* 'Tiramos el inventario */
		NPC_TIRAR_ITEMS(MiNPC, MiNPC.NPCtype == eNPCType_Pretoriano);
		/* 'ReSpawn o no */
		ReSpawnNpc(MiNPC);
	}
}
コード例 #5
0
void cDragdrop::get_item(P_CLIENT ps) // Client grabs an item
{
	int npc=-1, amount, update = 0, serial;
	UOXSOCKET s = ps->GetSocket();
	int cc = ps->GetCurrChar();
	P_CHAR pc_currchar = MAKE_CHARREF_LR(cc);
	
	
	serial = calcserial(buffer[s][1], buffer[s][2], buffer[s][3], buffer[s][4]);
	if (serial == INVALID_SERIAL || buffer[s][1] < 0x40)
		return;	// landscape or a character
	P_ITEM pi = FindItemBySerial(serial);
	if (pi == NULL)
		return;
	
	pc_currchar->disturbMed(s); // Meditation
	
	// Zippy's stealing changes  
	P_ITEM px = pi;
	if (!px->isInWorld())  // Find character owning item
	{
		unsigned long loopexit = 0;
		do  // Find character owning item
		{
			if (isCharSerial(px->contserial))
			{
				npc = calcCharFromSer(px->contserial);
			}
			else  // its an item
			{
				if (px->isInWorld())
				{
					npc=-1;
					break;
				}
				px = FindItemBySerial(px->contserial);
				// ANTICHRIST -- SECURE TRADE FIX
				if (px != NULL) // LB overwriting x is essential here, dont change it!!!
				{
					if (px->layer == 0 && px->id() == 0x1E5E)
					{
						// Trade window???
						serial = calcserial(px->moreb1, px->moreb2, px->moreb3, px->moreb4);
						if (serial == INVALID_SERIAL)
							return;
						P_ITEM pi_z = FindItemBySerial(serial);
						if ( pi_z != NULL )
							if ((pi_z->morez || px->morez))
							{
								pi_z->morez = 0;
								px->morez = 0;
								sendtradestatus(pi_z, px);
							}
					}
					// Blackwinds Looting is crime implementation
					// changed slightly by Ripper
					if (px->corpse != 0 && !pc_currchar->Owns(px)) 
					{ 
						P_CHAR co = FindCharBySerial(px->ownserial);
						if (px->more2 == 1 && Guilds->Compare(DEREF_P_CHAR(pc_currchar), DEREF_P_CHAR(co)) == 0) 
						{ 
							pc_currchar->karma -= 5; 
							criminal(DEREF_P_CHAR(pc_currchar));
							sysmessage(s, "You lost some karma!"); 
						} 
						npc = 0;
					} // Criminal stuff
					if (px->corpse != 0)
						npc = 0;
				} // end if x!=-1
				
				if (px == NULL)
					npc = 0; 
			}
		} while ((npc==-1) &&(++loopexit < MAXLOOPS));
	}
	
	if (npc>0) // 0=corpse, hence >0 ..
	{
		if (!(pc_currchar->isGM()) && npc != DEREF_P_CHAR(pc_currchar) && ! pc_currchar->Owns(&chars[npc]))
		{// Own serial stuff by Zippy -^ Pack aniamls and vendors.
			bounce[1] = 0;
			Xsend(s, bounce, 2);
			if (ps->IsDragging())
			{
				ps->ResetDragging();
				item_bounce3(pi);
				pi->magic = 3;
			} 
			return;
		}
	}
	// End Zippy's change
	
	// Boats->
	if (px != NULL && npc!=-1)
	{
		if (px->multis>0)
			imultisp.remove(px->multis, px->serial);
		px->startDecay();
		// End Boats Change
		
		// AntiChrist -- for poisoned items
		if (px->layer>0)
		{
			chars[npc].removeItemBonus(px);	// remove BONUS STATS given by equipped special items
		}
		if ((px->trigon==1) && (px->layer != 0) && (px->layer != 15) && (px->layer < 19))// -Frazurbluu- Trigger Type 2 is my new trigger type *-
		{
			Trig->triggerwitem(s, pi, 1); // trigger is fired
		}	
	}
	if (pi != NULL)
	{
		if (pi->corpse != 1)
		{
			UpdateStatusWindow(s, pi);
			if (!pc_currchar->canPickUp(pi))
			{
				bounce[1] = 0;
				Xsend(s, bounce, 2);
				if (ps->IsDragging()) // only restore item if it got draggged before !!!
				{
					ps->ResetDragging();
					item_bounce4(s, pi);
				}
			}
			else
			{
				// AntiChrist bugfix for the bad bouncing bug ( disappearing items when bouncing )
				DRAGGED[s] = 1;
				
				pi->oldx = pi->pos.x;	// first let's save the position
				pi->oldy = pi->pos.y;
				pi->oldz = pi->pos.z;
				pi->oldcontserial = pi->contserial;	// then let's save the container
				pi->oldlayer = pi->layer;	// then the layer
				
				pi->layer = 0;
				if (!pi->isInWorld())
					soundeffect(s, 0x00, 0x57);
				if (pi->amount>1)
				{
					amount = (buffer[s][5] << 8) + buffer[s][6];
					if (amount>pi->amount)
						amount = pi->amount;
					if (amount < pi->amount)
					{
						P_ITEM pi_c = Items->MemItemFree();
						//	pi_c->Init(0);
#pragma note("Replace by a copy constructor before finishing items[]")
						memcpy(pi_c, pi, sizeof(cItem));  // Tauriel reduce code faster too
						pi_c->SetSerial(cItemsManager::getItemsManager().getUnusedSerial());

						pi_c->amount = pi->amount - amount;
						pi_c->SetContSerial(pi_c->contserial);
						pi_c->SetOwnSerial(pi_c->ownserial);
						pi_c->SetSpawnSerial(pi_c->spawnserial);
						
						statwindow(s,DEREF_P_CHAR(pc_currchar));
						RefreshItem(pi_c);//AntiChrist
					}
					
					if (pi->id() == 0x0EED) // gold coin
					{
						P_ITEM packnum = packitem(currchar[s]);
						if (packnum != NULL) // lb
							if (pi->contserial == packnum->serial)
								update = 1;
					}
					
					pi->amount = amount;
					
				}
				
			/*	int amt = 0, wgt; bool tooheavy=false;				
				wgt = (int)Weight->LockeddownWeight(pi, &amt, 0);
				if(pi->contserial>0)
				{
					if (( (pc_currchar->weight+wgt) > (pc_currchar->st*WEIGHT_PER_STR)+30)) // LB -> added: drop item if too heavy
					{
					  float res=float( (pc_currchar->weight+wgt) - ((pc_currchar->st*WEIGHT_PER_STR)+30))*2;
					  int diff = pc_currchar->st;
					  diff -= (int)res;
					  if (diff<=0 && !pc_currchar->isGM() )					   
					  {
						 tooheavy=true;						 						 

						 bounce[1] = 0;
						 Xsend(s, bounce, 2);
						 if (ps->IsDragging()) // only restore item if it got dragged before !!!
						 {
						   ps->ResetDragging();
						   item_bounce4(s, pi);
						 }
						 sysmessage(s, "you can't pick this up, this is too heavy");					 
						 return;
					 }
					}
				} 

                if (!tooheavy) pc_currchar->weight+=wgt;				   
				update = 1;	*/				

				// LB remark: drop item if too heavy is a good solution,
				// but there's still a small bug remaining.
				// added weight from items picked up, but not put to bp, pd,  in other words hold in ones hand, 
				// is NOT subtracted when being dropped again to ground/other chars/other chars' bp's.
				// but this bug doesnt show up becasue weight is re-calculated automatically all 10 secs.
				// without adding weight of the item curently carrying in hand.
				// a correct solutions need the weight of item in hand being stored
				// , added to auto-re-calculation all x-secs code, and being subtracted if dropped.
				// because it's now only happening for leight weight items, because heavy weight itms cant be picke up anymore
				// I haven't corrected this yet. 			
				
				// Tauriel remove item from world mapcells
				mapRegions->Remove(pi); // remove this item from a map cell				
				pi->pos.x = 0;
				pi->pos.y = 0;
				pi->pos.z = 0;
				
				pi->flags.isBeeingDragged=true;
				pi->SetContSerial(-1);
			
			
			}
		}
	} // end of if i!=-1
	if (update) statwindow(s, DEREF_P_CHAR(pc_currchar));
}
コード例 #6
0
void EnlistarCaos(int UserIndex) {
	/* '*************************************************** */
	/* 'Autor: Pablo (ToxicWaste) & Unknown (orginal version) */
	/* 'Last Modification: 27/11/2009 */
	/* '15/03/2009: ZaMa - No se puede enlistar el fundador de un clan con alineación neutral. */
	/* '27/11/2009: ZaMa - Ahora no se puede enlistar un miembro de un clan neutro, por ende saque la antifaccion. */
	/* 'Handles the entrance of users to the "Legión Oscura" */
	/* '*************************************************** */

	if (!criminal(UserIndex)) {
		WriteChatOverHead(UserIndex, "¡¡¡Lárgate de aquí, bufón!!!",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Faccion.FuerzasCaos == 1) {
		WriteChatOverHead(UserIndex, "¡¡¡Ya perteneces a la legión oscura!!!",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Faccion.ArmadaReal == 1) {
		WriteChatOverHead(UserIndex, "Las sombras reinarán en Argentum. ¡¡¡Fuera de aquí insecto real!!!",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	/* '[Barrin 17-12-03] Si era miembro de la Armada Real no se puede enlistar */
	/* 'Tomamos el valor de ahí: ¿Recibio la experiencia para entrar? */
	if (UserList[UserIndex].Faccion.RecibioExpInicialReal == 1) {
		WriteChatOverHead(UserIndex, "No permitiré que ningún insecto real ingrese a mis tropas.",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}
	/* '[/Barrin] */

	if (!criminal(UserIndex)) {
		WriteChatOverHead(UserIndex, "¡¡Ja ja ja!! Tú no eres bienvenido aquí asqueroso ciudadano.",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Faccion.CiudadanosMatados < 70) {
		WriteChatOverHead(UserIndex,
				"Para unirte a nuestras fuerzas debes matar al menos 70 ciudadanos, sólo has matado "
						+ vb6::CStr(UserList[UserIndex].Faccion.CiudadanosMatados) + ".",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Stats.ELV < 25) {
		WriteChatOverHead(UserIndex, "¡¡¡Para unirte a nuestras fuerzas debes ser al menos nivel 25!!!",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].GuildIndex > 0) {
		if (GuildAlignment(UserList[UserIndex].GuildIndex) == "Neutral") {
			WriteChatOverHead(UserIndex,
					"¡¡¡Perteneces a un clan neutro, sal de él si quieres unirte a nuestras fuerzas!!!",
					(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
			return;
		}
	}

	if (UserList[UserIndex].Faccion.Reenlistadas > 4) {
		if (UserList[UserIndex].Faccion.Reenlistadas == 200) {
			WriteChatOverHead(UserIndex,
					"Has sido expulsado de las fuerzas oscuras y durante tu rebeldía has atacado a mi ejército. ¡Vete de aquí!",
					(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		} else {
			WriteChatOverHead(UserIndex, "¡Has sido expulsado de las fuerzas oscuras demasiadas veces!",
					(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		}
		return;
	}

	UserList[UserIndex].Faccion.Reenlistadas = UserList[UserIndex].Faccion.Reenlistadas + 1;
	UserList[UserIndex].Faccion.FuerzasCaos = 1;

	WriteChatOverHead(UserIndex,
			"¡¡¡Bienvenido al lado oscuro!!! Aquí tienes tus armaduras. Derrama sangre ciudadana y real, y serás recompensado, lo prometo.",
			(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);

	if (UserList[UserIndex].Faccion.RecibioArmaduraCaos == 0) {

		GiveFactionArmours(UserIndex, true);
		GiveExpReward(UserIndex, 0);

		UserList[UserIndex].Faccion.RecibioArmaduraCaos = 1;
		UserList[UserIndex].Faccion.NivelIngreso = UserList[UserIndex].Stats.ELV;
		UserList[UserIndex].Faccion.FechaIngreso = vb6::dateToString(vb6::Now());

		UserList[UserIndex].Faccion.RecibioExpInicialCaos = 1;
		UserList[UserIndex].Faccion.RecompensasCaos = 0;
		UserList[UserIndex].Faccion.NextRecompensa = 160;
	}

	/* 'Actualizamos la barca si esta navegando (NicoNZ) */
	if (UserList[UserIndex].flags.Navegando) {
		RefreshCharStatus(UserIndex);
	}

	LogEjercitoCaos(
			UserList[UserIndex].Name + " ingresó el " + UserList[UserIndex].Faccion.FechaIngreso
					+ " cuando era nivel " + vb6::CStr(UserList[UserIndex].Stats.ELV));
}
コード例 #7
0
void EnlistarArmadaReal(int UserIndex) {
	/* '*************************************************** */
	/* 'Autor: Pablo (ToxicWaste) & Unknown (orginal version) */
	/* 'Last Modification: 15/04/2010 */
	/* 'Handles the entrance of users to the "Armada Real" */
	/* '15/03/2009: ZaMa - No se puede enlistar el fundador de un clan con alineación neutral. */
	/* '27/11/2009: ZaMa - Ahora no se puede enlistar un miembro de un clan neutro, por ende saque la antifaccion. */
	/* '15/04/2010: ZaMa - Cambio en recompensas iniciales. */
	/* '*************************************************** */

	if (UserList[UserIndex].Faccion.ArmadaReal == 1) {
		WriteChatOverHead(UserIndex, "¡¡¡Ya perteneces a las tropas reales!!! Ve a combatir criminales.",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Faccion.FuerzasCaos == 1) {
		WriteChatOverHead(UserIndex, "¡¡¡Maldito insolente!!! Vete de aquí seguidor de las sombras.",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (criminal(UserIndex)) {
		WriteChatOverHead(UserIndex, "¡¡¡No se permiten criminales en el ejército real!!!",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Faccion.CriminalesMatados < 30) {
		WriteChatOverHead(UserIndex,
				"Para unirte a nuestras fuerzas debes matar al menos 30 criminales, sólo has matado "
						+ vb6::CStr(UserList[UserIndex].Faccion.CriminalesMatados) + ".",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Stats.ELV < 25) {
		WriteChatOverHead(UserIndex, "¡¡¡Para unirte a nuestras fuerzas debes ser al menos de nivel 25!!!",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Faccion.CiudadanosMatados > 0) {
		WriteChatOverHead(UserIndex,
				"¡Has asesinado gente inocente, no aceptamos asesinos en las tropas reales!",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Faccion.Reenlistadas > 4) {
		WriteChatOverHead(UserIndex, "¡Has sido expulsado de las fuerzas reales demasiadas veces!",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].Reputacion.NobleRep < 1000000) {
		WriteChatOverHead(UserIndex,
				"Necesitas ser aún más noble para integrar el ejército real, sólo tienes "
						+ vb6::CStr(UserList[UserIndex].Reputacion.NobleRep) + "/1.000.000 puntos de nobleza",
				(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
		return;
	}

	if (UserList[UserIndex].GuildIndex > 0) {
		if (GuildAlignment(UserList[UserIndex].GuildIndex) == "Neutral") {
			WriteChatOverHead(UserIndex,
					"¡¡¡Perteneces a un clan neutro, sal de él si quieres unirte a nuestras fuerzas!!!",
					(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);
			return;
		}
	}

	UserList[UserIndex].Faccion.ArmadaReal = 1;
	UserList[UserIndex].Faccion.Reenlistadas = UserList[UserIndex].Faccion.Reenlistadas + 1;

	WriteChatOverHead(UserIndex,
			"¡¡¡Bienvenido al ejército real!!! Aquí tienes tus vestimentas. Cumple bien tu labor exterminando criminales y me encargaré de recompensarte.",
			(Npclist[UserList[UserIndex].flags.TargetNPC].Char.CharIndex), 0x00ffffff);

	/* ' TODO: Dejo esta variable por ahora, pero con chequear las reenlistadas deberia ser suficiente :S */
	if (UserList[UserIndex].Faccion.RecibioArmaduraReal == 0) {

		GiveFactionArmours(UserIndex, false);
		GiveExpReward(UserIndex, 0);

		UserList[UserIndex].Faccion.RecibioArmaduraReal = 1;
		UserList[UserIndex].Faccion.NivelIngreso = UserList[UserIndex].Stats.ELV;
		UserList[UserIndex].Faccion.FechaIngreso = vb6::dateToString(vb6::Now());
		/* 'Esto por ahora es inútil, siempre va a ser cero, pero bueno, despues va a servir. */
		UserList[UserIndex].Faccion.MatadosIngreso = UserList[UserIndex].Faccion.CiudadanosMatados;

		UserList[UserIndex].Faccion.RecibioExpInicialReal = 1;
		UserList[UserIndex].Faccion.RecompensasReal = 0;
		UserList[UserIndex].Faccion.NextRecompensa = 70;

	}

	/* 'Actualizamos la barca si esta navegando (NicoNZ) */
	if (UserList[UserIndex].flags.Navegando) {
		RefreshCharStatus(UserIndex);
	}

	LogEjercitoReal(
			UserList[UserIndex].Name + " ingresó el " + UserList[UserIndex].Faccion.FechaIngreso + " cuando era nivel "
					+ vb6::CStr(UserList[UserIndex].Stats.ELV));
}
コード例 #8
0
ファイル: SendData.cpp プロジェクト: Elekaene/dakara-server
void SendData(SendTarget sndRoute, int sndIndex, std::string sndData, bool IsDenounce) {
	/* '************************************************************** */
	/* 'Author: Juan Martín Sotuyo Dodero (Maraxus) - Rewrite of original */
	/* 'Last Modify Date: 14/11/2010 */
	/* 'Last modified by: ZaMa */
	/* '14/11/2010: ZaMa - Now denounces can be desactivated. */
	/* '************************************************************** */

	int LoopC;

	switch (sndRoute) {
	case SendTarget_ToPCArea:
		SendToUserArea(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToAdmins:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if (UserList[LoopC].ConnID != -1) {
				if (UserTieneAlgunPrivilegios(LoopC, PlayerType_Admin, PlayerType_Dios, PlayerType_SemiDios, PlayerType_Consejero)) {
					/* ' Denounces can be desactivated */
					if (IsDenounce) {
						if (UserList[LoopC].flags.SendDenounces) {
							EnviarDatosASlot(LoopC, sndData);
						}
					} else {
						EnviarDatosASlot(LoopC, sndData);
					}
				}
			}
		}
		return;

		break;

	case SendTarget_ToAll:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if (UserList[LoopC].ConnID != -1) {
				/* 'Esta logeado como usuario? */
				if (UserList[LoopC].flags.UserLogged) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToAllButIndex:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1) && (LoopC != sndIndex)) {
				/* 'Esta logeado como usuario? */
				if (UserList[LoopC].flags.UserLogged) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_toMap:
		SendToMap(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToMapButIndex:
		SendToMapButIndex(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToGuildMembers:
//  LoopC = m_Iterador_ProximoUserIndex(sndIndex);
//   while (LoopC>0) {
//    if ((UserList[LoopC].ConnID != -1)) {
//    EnviarDatosASlot(LoopC, sndData);
//   }
//   LoopC = m_Iterador_ProximoUserIndex(sndIndex);
		for (auto LoopC : guild_Iterador_ProximoUserIndex(sndIndex)) {
			if ((UserList[LoopC].ConnID != -1)) {
				EnviarDatosASlot(LoopC, sndData);
			}
		}
		break;
		return;

		break;

	case SendTarget_ToDeadArea:
		SendToDeadUserArea(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToPCAreaButIndex:
		SendToUserAreaButindex(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToClanArea:
		SendToUserGuildArea(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToPartyArea:
		SendToUserPartyArea(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToAdminsAreaButConsejeros:
		SendToAdminsButConsejerosArea(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToNPCArea:
		SendToNpcArea(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToDiosesYclan:
		//	LoopC = m_Iterador_ProximoUserIndex(sndIndex);
		//	while (LoopC > 0) {
		//		if ((UserList[LoopC].ConnID != -1)) {
		//			EnviarDatosASlot(LoopC, sndData);
		//		}
		//		LoopC = m_Iterador_ProximoUserIndex(sndIndex);
		//	}
		for (auto LoopC : guild_Iterador_ProximoUserIndex(sndIndex)) {
			if ((UserList[LoopC].ConnID != -1)) {
				EnviarDatosASlot(LoopC, sndData);
			}
		}

//		LoopC = Iterador_ProximoGM(sndIndex);
//		while (LoopC > 0) {
//			if ((UserList[LoopC].ConnID != -1)) {
//				EnviarDatosASlot(LoopC, sndData);
//			}
//			LoopC = Iterador_ProximoGM(sndIndex);
//		}

		for (auto LoopC : guild_Iterador_ProximoGM(sndIndex)) {
			if ((UserList[LoopC].ConnID != -1)) {
				EnviarDatosASlot(LoopC, sndData);
			}
		}

		return;

		break;

	case SendTarget_ToConsejo:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (UserTienePrivilegio(LoopC, PlayerType_RoyalCouncil)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToConsejoCaos:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (UserTienePrivilegio(LoopC, PlayerType_ChaosCouncil)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToRolesMasters:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (UserTienePrivilegio(LoopC, PlayerType_RoleMaster)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToCiudadanos:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (!criminal(LoopC)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToCriminales:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (criminal(LoopC)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToReal:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (UserList[LoopC].Faccion.ArmadaReal == 1) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToCaos:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (UserList[LoopC].Faccion.FuerzasCaos == 1) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToCiudadanosYRMs:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (!criminal(LoopC) || UserTienePrivilegio(LoopC, PlayerType_RoleMaster)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToCriminalesYRMs:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (criminal(LoopC) || UserTienePrivilegio(LoopC, PlayerType_RoleMaster)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToRealYRMs:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (UserList[LoopC].Faccion.ArmadaReal == 1
						|| UserTienePrivilegio(LoopC, PlayerType_RoleMaster)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToCaosYRMs:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (UserList[LoopC].Faccion.FuerzasCaos == 1
						|| UserTienePrivilegio(LoopC, PlayerType_RoleMaster)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToHigherAdmins:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if (UserList[LoopC].ConnID != -1) {
				if (UserTieneAlgunPrivilegios(LoopC, PlayerType_Admin, PlayerType_Dios)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToGMsAreaButRmsOrCounselors:
		SendToGMsAreaButRmsOrCounselors(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToUsersAreaButGMs:
		SendToUsersAreaButGMs(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToUsersAndRmsAndCounselorsAreaButGMs:
		SendToUsersAndRmsAndCounselorsAreaButGMs(sndIndex, sndData);
		return;

		break;

	case SendTarget_ToAdminsButCounselors:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if (UserList[LoopC].ConnID != -1) {
				if (UserTieneAlgunPrivilegios(LoopC, PlayerType_Admin, PlayerType_Dios, PlayerType_SemiDios, PlayerType_RoleMaster)
						&& !UserTieneAlgunPrivilegios(LoopC, PlayerType_Consejero)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToAdminsButCounselorsAndRms:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if (UserList[LoopC].ConnID != -1) {
				if (UserTieneAlgunPrivilegios(LoopC, PlayerType_Admin, PlayerType_Dios, PlayerType_SemiDios)
						&& !UserTieneAlgunPrivilegios(LoopC, PlayerType_Consejero, PlayerType_RoleMaster)) {
						EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToHigherAdminsButRMs:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if (UserList[LoopC].ConnID != -1) {
				if (UserTieneAlgunPrivilegios(LoopC, PlayerType_Admin, PlayerType_Dios)
						&& !UserTieneAlgunPrivilegios(LoopC, PlayerType_RoleMaster)) {
						EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;

		break;

	case SendTarget_ToRMsAndHigherAdmins:
		for (LoopC = (1); LoopC <= (LastUser); LoopC++) {
			if ((UserList[LoopC].ConnID != -1)) {
				if (UserTieneAlgunPrivilegios(LoopC, PlayerType_RoleMaster, PlayerType_Admin, PlayerType_Dios)) {
					EnviarDatosASlot(LoopC, sndData);
				}
			}
		}
		return;
		break;

	case SendTarget_ToGM:
		throw std::runtime_error("SendData unhandled target: SendTarget_ToGM");
		break;
	}
}
コード例 #9
0
// New Class implementation
void cDragItems::grabItem( P_CLIENT client )
{
	// Get our character
	P_CHAR pChar = client->player();
	if( pChar == NULL )
		return;

	// Fetch the grab information
	SERIAL iSerial = LongFromCharPtr( &buffer[ client->socket() ][ 1 ] );
	UI16 amount = ShortFromCharPtr( &buffer[ client->socket() ][ 5 ] );

	P_ITEM pItem = FindItemBySerial( iSerial );

	if( !pItem )
		return;

	// Are we already dragging an item ?
	// Bounce it and reject the move
	// (Logged out while dragging an item)
	if( client->dragging() )
	{
		bounceItem( client, client->dragging() );
		bounceItem( client, pItem, true );
		return;
	}

	// Do we really want to let him break his meditation
	// When he picks up an item ?
	// Maybe a meditation check here ?!?
	pChar->disturbMed( client->socket() ); // Meditation

	P_CHAR itemOwner = GetPackOwner( pItem, 64 );

	// Try to pick something out of another characters posessions
	if( itemOwner && ( itemOwner != pChar ) && ( !pChar->Owns( itemOwner ) ) )
	{
		client->sysMessage( QString( "You have to steal the %1 out of %2's posessions." ).arg( pItem->getName() ).arg( itemOwner->name.c_str() ) );
		bounceItem( client, pItem, true );
		return;
	}

	// Check if the user can grab the item
	if( !pChar->canPickUp( pItem ) )
	{
		client->sysMessage( "You cannot pick that up." );
		bounceItem( client, pItem, true );
		return;
	}

	// The user can't see the item
	// Basically thats impossible as the client should deny moving the item
	// if it's not in line of sight but to prevent exploits
	if( !line_of_sight( client->socket(), pChar->pos, pItem->pos, TREES_BUSHES|WALLS_CHIMNEYS|DOORS|ROOFING_SLANTED|FLOORS_FLAT_ROOFING|LAVA_WATER ) )
	{
		client->sysMessage( "You can't see the item." );
		bounceItem( client, pItem, true );
		return;
	}

	P_ITEM outmostCont = GetOutmostCont( pItem, 64 );  

	// If it's a trade-window, reset the ack-status
	if( outmostCont && ( outmostCont->contserial == pChar->serial ) && ( outmostCont->layer() == 0 ) && ( outmostCont->id() == 0x1E5E ) )
	{
		// Get the other sides tradewindow
		P_ITEM tradeWindow = FindItemBySerial( calcserial( outmostCont->moreb1(), outmostCont->moreb2(), outmostCont->moreb3(), outmostCont->moreb4() ) );

		// If one of the trade-windows has the ack-status reset it
		if( tradeWindow && ( tradeWindow->morez || outmostCont->morez ) )
		{
			tradeWindow->morez = 0;
			outmostCont->morez = 0;
			sendtradestatus( tradeWindow, outmostCont );
		}
	}

	// If the top-most container ( thats important ) is a corpse 
	// and looting is a crime, flag the character criminal.
	if( outmostCont && outmostCont->corpse() )
	{
		// For each item we take out we loose carma
		// if the corpse is innocent and not in our guild
		bool sameGuild = ( GuildCompare( pChar, FindCharBySerial( outmostCont->ownserial ) ) != 0 );

		if( ( outmostCont->more2 == 1 ) && !pChar->Owns( outmostCont ) && !sameGuild )
		{
			pChar->karma -= 5;
			criminal( pChar );
			client->sysMessage( "You lost some karma." );
		}
	}

	// Check if the item is too heavy
	//if( !pc_currchar->isGMorCounselor() )
	//{
	//} << Deactivated (DarkStorm)

	// ==== Grabbing the Item is allowed here ====
	
	// Remove eventual item-bonusses if we're unequipping something
	if( pItem->layer() > 0 ) 
	{
		P_CHAR wearer = FindCharBySerial( pItem->contserial );

		if( wearer )
			wearer->removeItemBonus( pItem );
	}

	// Send the user a pickup sound if we're picking it up
	// From a container/paperdoll
	if( !pItem->isInWorld() )
		soundeffect( client->socket(), 0x00, 0x57 );
	
	// If we're picking up a specific amount of what we got
	// Take that into account
	if( pItem->amount() > 1 )
	{
		UI32 pickedAmount = min( amount, pItem->amount() );

		// We only have to split if we're not taking it all
		if( pickedAmount != pItem->amount() )
		{
			P_ITEM splitItem = new cItem( *pItem ); // Create a new item to pick that up
			splitItem->SetSerial( cItemsManager::getInstance()->getUnusedSerial() );
			splitItem->setAmount( pItem->amount() - pickedAmount );
			splitItem->setContSerial( pItem->contserial );
			splitItem->SetOwnSerial( pItem->ownserial );
			splitItem->SetSpawnSerial( pItem->spawnserial );

			// He needs to see the new item
			RefreshItem( splitItem ); 

			// If we're taking something out of a spawn-region it's spawning "flag" is removed isn't it?
			pItem->SetSpawnSerial( INVALID_SERIAL );
			pItem->setAmount( pickedAmount );
		}
	}
	
	pItem->setContSerial( pChar->serial );
	pItem->SetMultiSerial( INVALID_SERIAL ); 
	pItem->setLayer( 0x1E );
	
	// It's in the equipment of another character
	if( itemOwner && ( itemOwner != pChar ) )
	{
		itemOwner->weight -= pItem->getWeight();
		statwindow( calcSocketFromChar( itemOwner ), itemOwner );
	}

	// If the item is in the bank or any sell-container it's NOT counted as char-weight
	bool inBank = ( outmostCont && 	( outmostCont->contserial == pChar->serial ) && ( outmostCont->layer() >= 0x1A ) );

	// Add the weight if:
	//  - Picked from ground
	//  - Picked out of another character
	//  - Picked out of our bank or any other non-visible container
	if( ( itemOwner != pChar ) || !inBank )
	{
		pChar->weight += pItem->getWeight();	
		statwindow( client->socket(), pChar );
	}
}
コード例 #10
0
void get_item(P_CLIENT ps) // Client grabs an item
{
	int x,  npc=-1, c, amount, update = 0, serial;
//	tile_st tile;
	int z;// antichrist for trade fix
	UOXSOCKET s = ps->GetSocket();
	int cc = ps->GetCurrChar();
	P_CHAR pc_currchar = MAKE_CHARREF_LR(cc);
	
	
	serial = calcserial(buffer[s][1], buffer[s][2], buffer[s][3], buffer[s][4]);
	if (serial == INVALID_SERIAL || buffer[s][1] < 0x40)
		return;	// landscape or a character
	P_ITEM pi = FindItemBySerial(serial);
	if (pi == NULL)
		return;
	
	pc_currchar->disturbMed(s); // Meditation
	
	// Zippy's stealing changes  
	x = DEREF_P_ITEM(pi);
	if (!items[x].isInWorld())  // Find character owning item
	{
		int loopexit = 0;
		do  // Find character owning item
		{
			if (isCharSerial(items[x].contserial))
			{
				npc = calcCharFromSer(items[x].contserial);
			}
			else  // its an item
			{
				if (items[x].isInWorld())
				{
					npc=-1;
					break;
				}
				x = calcItemFromSer(items[x].contserial);
				// ANTICHRIST -- SECURE TRADE FIX
				if (x!=-1) // LB overwriting x is essential here, dont change it!!!
				{
					if (items[x].layer == 0 && items[x].id() == 0x1E5E)
					{
						// Trade window???
						serial = calcserial(items[x].moreb1, items[x].moreb2, items[x].moreb3, items[x].moreb4);
						if (serial == INVALID_SERIAL)
							return;
						z = calcItemFromSer(serial);
						if (z!=-1)
							if ((items[z].morez || items[x].morez))
							{
								items[z].morez = 0;
								items[x].morez = 0;
								sendtradestatus(z, x);
							}
					}
					// Blackwinds Looting is crime implementation
					// changed slightly by Ripper
					if (items[x].corpse != 0 && !pc_currchar->Owns(&items[x])) 
					{ 
						P_CHAR co = FindCharBySerial(items[x].ownserial);
						if (items[x].more2 == 1 && Guilds->Compare(cc, DEREF_P_CHAR(co)) == 0) 
						{ 
							pc_currchar->karma -= 5; 
							criminal(cc);
							sysmessage(s, "You lost some karma!"); 
						} 
						npc = 0;
					} // Criminal stuff
					if (items[x].corpse != 0)
						npc = 0;
				} // end if x!=-1
				
				if (x==-1)
					npc = 0; 
			}
		} while ((npc==-1) &&(++loopexit < MAXLOOPS));
	}
	
	if (npc>0) // 0=corpse, hence >0 ..
	{
		if (!(pc_currchar->isGM()) && npc != cc && ! pc_currchar->Owns(&chars[npc]))
		{// Own serial stuff by Zippy -^ Pack aniamls and vendors.
			bounce[1] = 0;
			Xsend(s, bounce, 2);
			if (ps->IsDragging())
			{
				ps->ResetDragging();
				item_bounce3(pi);
				pi->magic = 3;
			} 
			return;
		}
	}
	// End Zippy's change
	
	// Boats->
	if (x!=-1 && npc!=-1)
	{
		if (items[x].multis>0)
			imultisp.remove(items[x].multis, items[x].serial);
		items[x].startDecay();
		// End Boats Change
		
		// AntiChrist -- for poisoned items
		if (items[x].layer>0)
		{
			chars[npc].removeItemBonus(&items[x]);	// remove BONUS STATS given by equipped special items
		}
		if ((items[x].trigon==1) && (items[x].layer != 0) && (items[x].layer != 15) && (items[x].layer < 19))// -Frazurbluu- Trigger Type 2 is my new trigger type *-
		{
			triggerwitem(s, DEREF_P_ITEM(pi), 1); // trigger is fired
		}	
			// AntiChrist -- for poisoned items
		if (items[x].poisoned)
		{
			chars[npc].poison -= items[x].poisoned;
			if (chars[npc].poison < 0)
				chars[npc].poison = 0;
		}
	}
	if (pi != NULL)
	{
		if (pi->corpse != 1)
		{
			UpdateStatusWindow(s, pi);
			if (!pc_currchar->canPickUp(pi))
			{
				bounce[1] = 0;
				Xsend(s, bounce, 2);
				if (ps->IsDragging()) // only restore item if it got draggged before !!!
				{
					ps->ResetDragging();
					item_bounce4(s, pi);
				}
			}
			else
			{
				// AntiChrist bugfix for the bad bouncing bug ( disappearing items when bouncing )
				DRAGGED[s] = 1;
				
				pi->oldx = pi->pos.x;	// first let's save the position
				pi->oldy = pi->pos.y;
				pi->oldz = pi->pos.z;
				pi->oldcontserial = pi->contserial;	// then let's save the container
				pi->oldlayer = pi->layer;	// then the layer
				
				pi->layer = 0;
				if (!pi->isInWorld())
					soundeffect(s, 0x00, 0x57);
				if (pi->amount>1)
				{
					amount = (buffer[s][5] << 8) + buffer[s][6];
					if (amount>pi->amount)
						amount = pi->amount;
					if (amount < pi->amount)
					{
						c=Items->MemItemFree();
						items[c].Init(0);
						memcpy(&items[c], pi, sizeof(cItem));  // Tauriel reduce code faster too
						items[c].SetSerial(itemcount2);
						itemcount2++;

						items[c].amount = pi->amount - amount;
						// Tauriel sorry, there is no way to make this call the item creation stuff
// Why doing it twice?
//						setptr(&itemsp[itemcount2%HASHMAX], c);
//						itemcount2++; // important bugfix for items disappearing, lb
						if (!items[c].isInWorld())
							contsp.insert(items[c].contserial, items[c].serial);
						if (items[c].ownserial!=-1)
							setptr(&ownsp[items[c].ownserial%HASHMAX], c);
						if (items[c].spawnserial!=-1)
							setptr(&spawnsp[items[c].spawnserial%HASHMAX], c);
						
						statwindow(s,cc);
						RefreshItem(c);//AntiChrist
					}
					
					if (pi->id() == 0x0EED) // gold coin
					{
						int packnum = packitem(currchar[s]);
						if (packnum!=-1) // lb
							if (pi->contserial == items[packnum].serial)
								update = 1;
					}
					
					pi->amount = amount;
				}
				
				// Tauriel remove item from world mapcells
				mapRegions->Remove(pi); // remove this item from a map cell
				pi->pos.x = 0;
				pi->pos.y = 0;
				pi->pos.z = 0;
				
				pi->flags.isBeeingDragged=true;
				pi->SetContSerial(-1);
				if (pi != NULL) // Ripper...adds weight to the players cursor when carrying a item.
				{
					int amt = 0, wgt;
					wgt = (int)Weight->LockeddownWeight(pi, &amt, 0);
					pc_currchar->weight += wgt;
					update = 1;
				}
			}
		}
	} // end of if i!=-1
	if (update)
		statwindow(s, DEREF_P_CHAR(pc_currchar));
}
コード例 #11
0
ファイル: Party.cpp プロジェクト: irongete/dakara-server
bool clsParty::PuedeEntrar(int UserIndex, std::string razon) {
	bool retval;
	/* '*************************************************** */
	/* 'Author: Unknown */
	/* 'Last Modification: 09/29/07 */
	/* 'Last Modification By: Lucas Tavolaro Ortiz (Tavo) */
	/* ' - 09/29/07 There is no level prohibition */
	/* '*************************************************** */
	/* 'DEFINE LAS REGLAS DEL JUEGO PARA DEJAR ENTRAR A MIEMBROS */
	bool esArmada;
	bool esCaos;
//	int MyLevel;
	int i;
	bool rv;
	int UI;

	rv = true;
	esArmada = (UserList[UserIndex].Faccion.ArmadaReal == 1);
	esCaos = (UserList[UserIndex].Faccion.FuerzasCaos == 1);
//	MyLevel = UserList[UserIndex].Stats.ELV;

	rv = Distancia(UserList[p_members[1].UserIndex].Pos, UserList[UserIndex].Pos) <= MAXDISTANCIAINGRESOPARTY;
	if (rv) {
		rv = (p_members[PARTY_MAXMEMBERS].UserIndex == 0);
		if (rv) {
			for (i = (1); i <= (PARTY_MAXMEMBERS); i++) {
				UI = p_members[i].UserIndex;
				/* 'pongo los casos que evitarian que pueda entrar */
				/* 'aspirante armada en party crimi */
				if (UI > 0) {
					if (esArmada && criminal(UI)) {
						razon = "Los miembros del ejército real no entran a una party con criminales.";
						rv = false;
					}
					/* 'aspirante caos en party ciuda */
					if (esCaos && !criminal(UI)) {
						razon = "Los miembros de la legión oscura no entran a una party con ciudadanos.";
						rv = false;
					}
					/* 'aspirante crimi en party armada */
					if (UserList[UI].Faccion.ArmadaReal == 1 && criminal(UserIndex)) {
						razon = "Los criminales no entran a parties con miembros del ejército real.";
						rv = false;
					}
					/* 'aspirante ciuda en party caos */
					if (UserList[UI].Faccion.FuerzasCaos == 1 && !criminal(UserIndex)) {
						razon = "Los ciudadanos no entran a parties con miembros de la legión oscura.";
						rv = false;
					}

					/* 'violate una programacion estructurada */
					if (!rv) {
						break; /* FIXME: EXIT FOR */
					}
				}
			}
		} else {
			razon = "La mayor cantidad de miembros es " + vb6::CStr(PARTY_MAXMEMBERS);
		}
	} else {
		/* '¿Con o sin nombre? */
		razon = "El usuario " + UserList[UserIndex].Name + " se encuentra muy lejos.";
	}

	retval = rv;

	return retval;
}
コード例 #12
0
ファイル: NpcsAI.cpp プロジェクト: Elekaene/dakara-server
void PersigueCriminal(int NpcIndex) {
	/* '*************************************************** */
	/* 'Autor: Unknown (orginal version) */
	/* 'Last Modification: 12/01/2010 (ZaMa) */
	/* '14/09/2009: ZaMa - Now npcs don't follow protected users. */
	/* '12/01/2010: ZaMa - Los npcs no atacan druidas mimetizados con npcs. */
	/* '*************************************************** */
	int UserIndex;
	int tHeading;
	int i;
	int SignoNS;
	int SignoEO;
	bool UserProtected;

	if (Npclist[NpcIndex].flags.Inmovilizado == 1) {
		switch (Npclist[NpcIndex].Char.heading) {
		case eHeading_NORTH:
			SignoNS = -1;
			SignoEO = 0;

			break;

		case eHeading_EAST:
			SignoNS = 0;
			SignoEO = 1;

			break;

		case eHeading_SOUTH:
			SignoNS = 1;
			SignoEO = 0;

			break;

		case eHeading_WEST:
			SignoEO = -1;
			SignoNS = 0;
			break;

		default:
			SignoEO = SignoNS = 0;
			break;
		}

		for (i = (1); i <= (ConnGroups[Npclist[NpcIndex].Pos.Map].CountEntrys);
				i++) {
			UserIndex = ConnGroups[Npclist[NpcIndex].Pos.Map].UserEntrys[i];

			/* 'Is it in it's range of vision?? */
			if (vb6::Abs(UserList[UserIndex].Pos.X - Npclist[NpcIndex].Pos.X)
					<= RANGO_VISION_X
					&& vb6::Sgn(UserList[UserIndex].Pos.X - Npclist[NpcIndex].Pos.X)
							== SignoEO) {
				if (vb6::Abs(
						UserList[UserIndex].Pos.Y - Npclist[NpcIndex].Pos.Y)
						<= RANGO_VISION_Y
						&& vb6::Sgn(UserList[UserIndex].Pos.Y
								- Npclist[NpcIndex].Pos.Y) == SignoNS) {

					if (criminal(UserIndex)) {

						UserProtected = !IntervaloPermiteSerAtacado(UserIndex)
								&& UserList[UserIndex].flags.NoPuedeSerAtacado;
						UserProtected = UserProtected
								|| UserList[UserIndex].flags.Ignorado
								|| UserList[UserIndex].flags.EnConsulta;

						if (UserList[UserIndex].flags.Muerto == 0
								&& UserList[UserIndex].flags.invisible == 0
								&& UserList[UserIndex].flags.Oculto == 0
								&& UserList[UserIndex].flags.AdminPerseguible
								&& !UserProtected) {

							if (Npclist[NpcIndex].flags.LanzaSpells > 0) {
								NpcLanzaUnSpell(NpcIndex, UserIndex);
							}
							return;
						}
					}

				}
			}
		}
	} else {
		for (i = (1); i <= (ConnGroups[Npclist[NpcIndex].Pos.Map].CountEntrys);
				i++) {
			UserIndex = ConnGroups[Npclist[NpcIndex].Pos.Map].UserEntrys[i];

			/* 'Is it in it's range of vision?? */
			if (vb6::Abs(UserList[UserIndex].Pos.X - Npclist[NpcIndex].Pos.X)
					<= RANGO_VISION_X) {
				if (vb6::Abs(
						UserList[UserIndex].Pos.Y - Npclist[NpcIndex].Pos.Y)
						<= RANGO_VISION_Y) {

					if (criminal(UserIndex)) {

						UserProtected = !IntervaloPermiteSerAtacado(UserIndex)
								&& UserList[UserIndex].flags.NoPuedeSerAtacado;
						UserProtected = UserProtected
								|| UserList[UserIndex].flags.Ignorado;

						if (UserList[UserIndex].flags.Muerto == 0
								&& UserList[UserIndex].flags.invisible == 0
								&& UserList[UserIndex].flags.Oculto == 0
								&& UserList[UserIndex].flags.AdminPerseguible
								&& !UserProtected) {
							if (Npclist[NpcIndex].flags.LanzaSpells > 0) {
								NpcLanzaUnSpell(NpcIndex, UserIndex);
							}
							if (Npclist[NpcIndex].flags.Inmovilizado == 1) {
								return;
							}
							tHeading = FindDirection(Npclist[NpcIndex].Pos,
									UserList[UserIndex].Pos);
							MoveNPCChar(NpcIndex, tHeading);
							return;
						}
					}

				}
			}

		}
	}

	RestoreOldMovement(NpcIndex);
}
コード例 #13
0
ファイル: NpcsAI.cpp プロジェクト: Elekaene/dakara-server
/* ' @param NpcIndex Specifies reference to the npc */
void SeguirAgresor(int NpcIndex) {
	/* '************************************************************** */
	/* 'Author: Unknown */
	/* 'Last Modify by: Marco Vanotti (MarKoxX) */
	/* 'Last Modify Date: 08/16/2008 */
	/* '08/16/2008: MarKoxX - Now pets that do mel� attacks have to be near the enemy to attack. */
	/* '************************************************************** */
	int tHeading;
	int UI;

	int i;

	int SignoNS;
	int SignoEO;

	if (Npclist[NpcIndex].flags.Paralizado == 1
			|| Npclist[NpcIndex].flags.Inmovilizado == 1) {
		switch (Npclist[NpcIndex].Char.heading) {
		case eHeading_NORTH:
			SignoNS = -1;
			SignoEO = 0;

			break;

		case eHeading_EAST:
			SignoNS = 0;
			SignoEO = 1;

			break;

		case eHeading_SOUTH:
			SignoNS = 1;
			SignoEO = 0;

			break;

		case eHeading_WEST:
			SignoEO = -1;
			SignoNS = 0;
			break;

		default:
			SignoEO = SignoNS = 0;
			break;
		}

		for (i = (1); i <= (ConnGroups[Npclist[NpcIndex].Pos.Map].CountEntrys);
				i++) {
			UI = ConnGroups[Npclist[NpcIndex].Pos.Map].UserEntrys[i];

			/* 'Is it in it's range of vision?? */
			if (vb6::Abs(UserList[UI].Pos.X - Npclist[NpcIndex].Pos.X)
					<= RANGO_VISION_X
					&& vb6::Sgn(UserList[UI].Pos.X - Npclist[NpcIndex].Pos.X)
							== SignoEO) {
				if (vb6::Abs(UserList[UI].Pos.Y - Npclist[NpcIndex].Pos.Y)
						<= RANGO_VISION_Y
						&& vb6::Sgn(UserList[UI].Pos.Y - Npclist[NpcIndex].Pos.Y)
								== SignoNS) {

					if (UserList[UI].Name
							== Npclist[NpcIndex].flags.AttackedBy) {
						if (Npclist[NpcIndex].MaestroUser > 0) {
							if (!criminal(Npclist[NpcIndex].MaestroUser)
									&& !criminal(UI)
									&& (UserList[Npclist[NpcIndex].MaestroUser].flags.Seguro
											|| UserList[Npclist[NpcIndex].MaestroUser].Faccion.ArmadaReal
													== 1)) {
								WriteConsoleMsg(Npclist[NpcIndex].MaestroUser,
										"La mascota no atacará a ciudadanos si eres miembro del ejército real o tienes el seguro activado.",
										FontTypeNames_FONTTYPE_INFO);
								FlushBuffer(Npclist[NpcIndex].MaestroUser);
								Npclist[NpcIndex].flags.AttackedBy = "";
								return;
							}
						}

						if (UserList[UI].flags.Muerto == 0
								&& UserList[UI].flags.invisible == 0
								&& UserList[UI].flags.Oculto == 0) {
							if (Npclist[NpcIndex].flags.LanzaSpells > 0) {
								NpcLanzaUnSpell(NpcIndex, UI);
							} else {
								if (Distancia(UserList[UI].Pos,
										Npclist[NpcIndex].Pos) <= 1) {
									/* ' TODO : Set this a separate AI for Elementals and Druid's pets */
									if (Npclist[NpcIndex].Numero != 92) {
										NpcAtacaUser(NpcIndex, UI);
									}
								}
							}
							return;
						}
					}

				}
			}

		}
	} else {
		for (i = (1); i <= (ConnGroups[Npclist[NpcIndex].Pos.Map].CountEntrys);
				i++) {
			UI = ConnGroups[Npclist[NpcIndex].Pos.Map].UserEntrys[i];

			/* 'Is it in it's range of vision?? */
			if (vb6::Abs(UserList[UI].Pos.X - Npclist[NpcIndex].Pos.X)
					<= RANGO_VISION_X) {
				if (vb6::Abs(UserList[UI].Pos.Y - Npclist[NpcIndex].Pos.Y)
						<= RANGO_VISION_Y) {

					if (UserList[UI].Name
							== Npclist[NpcIndex].flags.AttackedBy) {
						if (Npclist[NpcIndex].MaestroUser > 0) {
							if (!criminal(Npclist[NpcIndex].MaestroUser)
									&& !criminal(UI)
									&& (UserList[Npclist[NpcIndex].MaestroUser].flags.Seguro
											|| UserList[Npclist[NpcIndex].MaestroUser].Faccion.ArmadaReal
													== 1)) {
								WriteConsoleMsg(Npclist[NpcIndex].MaestroUser,
										"La mascota no atacará a ciudadanos si eres miembro del ejército real o tienes el seguro activado.",
										FontTypeNames_FONTTYPE_INFO);
								FlushBuffer(Npclist[NpcIndex].MaestroUser);
								Npclist[NpcIndex].flags.AttackedBy = "";
								FollowAmo(NpcIndex);
								return;
							}
						}

						if (UserList[UI].flags.Muerto == 0
								&& UserList[UI].flags.invisible == 0
								&& UserList[UI].flags.Oculto == 0) {
							if (Npclist[NpcIndex].flags.LanzaSpells > 0) {
								NpcLanzaUnSpell(NpcIndex, UI);
							} else {
								if (Distancia(UserList[UI].Pos,
										Npclist[NpcIndex].Pos) <= 1) {
									/* ' TODO : Set this a separate AI for Elementals and Druid's pets */
									if (Npclist[NpcIndex].Numero != 92) {
										NpcAtacaUser(NpcIndex, UI);
									}
								}
							}

							tHeading = FindDirection(Npclist[NpcIndex].Pos,
									UserList[UI].Pos);
							MoveNPCChar(NpcIndex, tHeading);

							return;
						}
					}

				}
			}

		}
	}

	RestoreOldMovement(NpcIndex);
}
コード例 #14
0
ファイル: NpcsAI.cpp プロジェクト: Elekaene/dakara-server
void GuardiasAI(int NpcIndex, bool DelCaos) {
	/* '*************************************************** */
	/* 'Autor: Unknown (orginal version) */
	/* 'Last Modification: 12/01/2010 (ZaMa) */
	/* '14/09/2009: ZaMa - Now npcs don't atack protected users. */
	/* '12/01/2010: ZaMa - Los npcs no atacan druidas mimetizados con npcs */
	/* '*************************************************** */
	struct WorldPos nPos;
	int headingloop;
	int UI;
	bool UserProtected;

	for (headingloop = (eHeading_NORTH); headingloop <= (eHeading_WEST);
			headingloop++) {
		nPos = Npclist[NpcIndex].Pos;
		if (Npclist[NpcIndex].flags.Inmovilizado == 0
				|| headingloop == Npclist[NpcIndex].Char.heading) {
			HeadtoPos(static_cast<eHeading>(headingloop), nPos);
			if (InMapBounds(nPos.Map, nPos.X, nPos.Y)) {
				UI = MapData[nPos.Map][nPos.X][nPos.Y].UserIndex;
				if (UI > 0) {
					UserProtected = !IntervaloPermiteSerAtacado(UI)
							&& UserList[UI].flags.NoPuedeSerAtacado;
					UserProtected = UserProtected || UserList[UI].flags.Ignorado
							|| UserList[UI].flags.EnConsulta;

					if (UserList[UI].flags.Muerto == 0
							&& UserList[UI].flags.AdminPerseguible
							&& !UserProtected) {
						/* '�ES CRIMINAL? */
						if (!DelCaos) {
							if (criminal(UI)) {
								if (NpcAtacaUser(NpcIndex, UI)) {
									ChangeNPCChar(NpcIndex,
											Npclist[NpcIndex].Char.body,
											Npclist[NpcIndex].Char.Head,
											static_cast<eHeading>(headingloop));
								}
								return;
							} else if (Npclist[NpcIndex].flags.AttackedBy
									== UserList[UI].Name
									&& !Npclist[NpcIndex].flags.Follow) {

								if (NpcAtacaUser(NpcIndex, UI)) {
									ChangeNPCChar(NpcIndex,
											Npclist[NpcIndex].Char.body,
											Npclist[NpcIndex].Char.Head,
											static_cast<eHeading>(headingloop));
								}
								return;
							}
						} else {
							if (!criminal(UI)) {
								if (NpcAtacaUser(NpcIndex, UI)) {
									ChangeNPCChar(NpcIndex,
											Npclist[NpcIndex].Char.body,
											Npclist[NpcIndex].Char.Head,
											static_cast<eHeading>(headingloop));
								}
								return;
							} else if (Npclist[NpcIndex].flags.AttackedBy
									== UserList[UI].Name
									&& !Npclist[NpcIndex].flags.Follow) {

								if (NpcAtacaUser(NpcIndex, UI)) {
									ChangeNPCChar(NpcIndex,
											Npclist[NpcIndex].Char.body,
											Npclist[NpcIndex].Char.Head,
											static_cast<eHeading>(headingloop));
								}
								return;
							}
						}
					}
				}
			}
			/* 'not inmovil */
		}
	}

	RestoreOldMovement(NpcIndex);
}