Jump to content
  • 0

[REQUEST] L2Monster return to spawn point like L2Raid


Question

Posted

 

 

As title say i need same code for L2Monsters to return at spawn point like L2Raids when i attacj to 1 monster after X distance return to spawn point with current HP

what i have to fix?

Recommended Posts

  • 0
Posted

i add this code but same problem

 

/**
 * Return home.
 */
public void returnHome()
 {
  ThreadPoolManager.getInstance().scheduleAi(new Runnable() {
   @Override
   public void run()
   {
    L2Spawn mobSpawn = getSpawn();
    if(!isInCombat() && !isAlikeDead() && !isDead() && mobSpawn != null && !isInsideRadius(mobSpawn.getLocx(), mobSpawn.getLocy(), Config.MAX_DRIFT_RANGE, false))
    {
     teleToLocation(mobSpawn.getLocx(), mobSpawn.getLocy(), mobSpawn.getLocz(), false);
    }
    mobSpawn = null;
   }
   
  }, 1000);
 }
protected void startMaintenanceTask()
{
	ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable() {
		@Override
		public void run()
		{
			checkAndReturnToSpawn();
		}
	}, 3000, getMaintenanceInterval()+Rnd.get(5000));
}
protected void checkAndReturnToSpawn()
{
	if (isDead() || isMovementDisabled())
		return;

	final L2Spawn spawn = getSpawn();
	if (spawn == null)
		return;

	final int spawnX = spawn.getLocx();
	final int spawnY = spawn.getLocy();
	final int spawnZ = spawn.getLocz();

	if (!isInCombat() && !isMovementDisabled())
	{
		if (!isInsideRadius(spawnX, spawnY, spawnZ, Math.max(1000, 200), true, false))
			teleToLocation(spawnX, spawnY, spawnZ);
	}
}

 

 

i use L2jfrozen last revision

 

forzen have one config for that but dont work.

 

  • 0
Posted

Copy/paste, find what code makes Raid Bosses return and just simple change it for mobs.. L2RaidBossInstance with L2MonsterInstance.

Or smth like that if you get mt mind...

  • 0
Posted

I can't describe how retarded this code is...First of all you told that what you wanted is when the player runs and the monsters get out of the x,y radius should be teleported back, well with that check !isInCombat() if the monster is following the player and hitting him he won't be teleported back cause he is in combat...

  • 0
Posted

I can't describe how retarded this code is...First of all you told that what you wanted is when the player runs and the monsters get out of the x,y radius should be teleported back, well with that check !isInCombat() if the monster is following the player and hitting him he won't be teleported back cause he is in combat...

 

Thats the code from L2RaidbossInstance idk what u have in your pack but it works as it should...

 

the !isInCombat(); on this code, makes the NPC teleport when u run but u dont attack it, if you want the Npc to teleport back even if its under attack just remove the method

  • 0
Posted

That behavior is located in L2AttackableAI, and it is part of thinkAttack method. If you want "retail" system where mob runs back to his location.

 

 

// Order to the L2MonsterInstance to random walk (1/100)
	else if(!(npc instanceof L2ChestInstance) && npc.getSpawn() != null && Rnd.nextInt(RANDOM_WALK_RATE) == 0)
	{
		int x1, y1, z1;

		// If NPC with random coord in territory
		if(npc.getSpawn().getLocx() == 0 && npc.getSpawn().getLocy() == 0)
		{
			// If NPC with random fixed coord, don't move
			if(TerritoryTable.getInstance().getProcMax(npc.getSpawn().getLocation()) > 0)
				return;

			// Calculate a destination point in the spawn area
			int p[] = TerritoryTable.getInstance().getRandomPoint(npc.getSpawn().getLocation());
			x1 = p[0];
			y1 = p[1];
			z1 = p[2];

			// Calculate the distance between the current position of the L2Character and the target (x,y)
			double distance2 = _actor.getPlanDistanceSq(x1, y1);

			if(distance2 > Config.MAX_DRIFT_RANGE * Config.MAX_DRIFT_RANGE)
			{
				npc.setisReturningToSpawnPoint(true);
				float delay = (float) Math.sqrt(distance2) / Config.MAX_DRIFT_RANGE;
				x1 = _actor.getX() + (int) ((x1 - _actor.getX()) / delay);
				y1 = _actor.getY() + (int) ((y1 - _actor.getY()) / delay);
			}
			else
			{
				npc.setisReturningToSpawnPoint(false);
			}

		}
		else
		{
			if(Config.MONSTER_RETURN_DELAY > 0 && npc instanceof L2MonsterInstance && !npc.isAlikeDead() && !npc.isDead() && npc.getSpawn() != null && !npc.isInsideRadius(npc.getSpawn().getLocx(), npc.getSpawn().getLocy(), Config.MAX_DRIFT_RANGE, false))
			{
				((L2MonsterInstance) _actor).returnHome();
			}

			// If NPC with fixed coord
			x1 = npc.getSpawn().getLocx() + Rnd.nextInt(Config.MAX_DRIFT_RANGE * 2) - Config.MAX_DRIFT_RANGE;
			y1 = npc.getSpawn().getLocy() + Rnd.nextInt(Config.MAX_DRIFT_RANGE * 2) - Config.MAX_DRIFT_RANGE;
			z1 = npc.getZ();
		}

		//_log.config("Curent pos ("+getX()+", "+getY()+"), moving to ("+x1+", "+y1+").");
		// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)
		moveTo(x1, y1, z1);
	}

	npc = null;

	return;

}

 

i find this, i wanna monster when run a X distance teleport back to spawn point..

  • 0
Posted

Thats the code from L2RaidbossInstance idk what u have in your pack but it works as it should...

 

the !isInCombat(); on this code, makes the NPC teleport when u run but u dont attack it, if you want the Npc to teleport back even if its under attack just remove the method

i know it dude i said it is retarded for what he is asking...

  • 0
Posted

Frozen Config have this

 

# The maximum deviation from the point of Spawn mobs
MaxDriftRange = 200

 

 

here is 2 codes for that but no1 works

 

this is in L2attack

 

// Order to the L2MonsterInstance to random walk (1/100)
	else if(!(npc instanceof L2ChestInstance) && npc.getSpawn() != null && Rnd.nextInt(RANDOM_WALK_RATE) == 0)
	{
		int x1, y1, z1;

		// If NPC with random coord in territory
		if(npc.getSpawn().getLocx() == 0 && npc.getSpawn().getLocy() == 0)
		{
			// If NPC with random fixed coord, don't move
			if(TerritoryTable.getInstance().getProcMax(npc.getSpawn().getLocation()) > 0)
				return;

			// Calculate a destination point in the spawn area
			int p[] = TerritoryTable.getInstance().getRandomPoint(npc.getSpawn().getLocation());
			x1 = p[0];
			y1 = p[1];
			z1 = p[2];

			// Calculate the distance between the current position of the L2Character and the target (x,y)
			double distance2 = _actor.getPlanDistanceSq(x1, y1);

			if(distance2 > Config.MAX_DRIFT_RANGE * Config.MAX_DRIFT_RANGE)
			{
				npc.setisReturningToSpawnPoint(true);
				float delay = (float) Math.sqrt(distance2) / Config.MAX_DRIFT_RANGE;
				x1 = _actor.getX() + (int) ((x1 - _actor.getX()) / delay);
				y1 = _actor.getY() + (int) ((y1 - _actor.getY()) / delay);
			}
			else
			{
				npc.setisReturningToSpawnPoint(false);
			}

		}
		else
		{
			if(Config.MONSTER_RETURN_DELAY > 0 && npc instanceof L2MonsterInstance && !npc.isAlikeDead() && !npc.isDead() && npc.getSpawn() != null && !npc.isInsideRadius(npc.getSpawn().getLocx(), npc.getSpawn().getLocy(), Config.MAX_DRIFT_RANGE, false))
			{
				((L2MonsterInstance) _actor).returnHome();
			}

			// If NPC with fixed coord
			x1 = npc.getSpawn().getLocx() + Rnd.nextInt(Config.MAX_DRIFT_RANGE * 2) - Config.MAX_DRIFT_RANGE;
			y1 = npc.getSpawn().getLocy() + Rnd.nextInt(Config.MAX_DRIFT_RANGE * 2) - Config.MAX_DRIFT_RANGE;
			z1 = npc.getZ();
		}

		//_log.config("Curent pos ("+getX()+", "+getY()+"), moving to ("+x1+", "+y1+").");
		// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)
		moveTo(x1, y1, z1);
	}

	npc = null;

	return;

}

 

this in l2monsterinstance

 

	/**
 * Return home.
 */
public void returnHome()
{
	ThreadPoolManager.getInstance().scheduleAi(new Runnable() {
		@Override
		public void run()
		{
			L2Spawn mobSpawn = getSpawn();
			if(!isInCombat() && !isAlikeDead() && !isDead() && mobSpawn != null && !isInsideRadius(mobSpawn.getLocx(), mobSpawn.getLocy(), Config.MAX_DRIFT_RANGE, false))
			{
				teleToLocation(mobSpawn.getLocx(), mobSpawn.getLocy(), mobSpawn.getLocz(), false);
			}
			mobSpawn = null;
		}
	}, Config.MONSTER_RETURN_DELAY * 1000);
}

  • 0
Posted

Already answered you dude remove this !isInCombat() and try again although it could be better handled in l2attackable as tk said

  • 0
Posted

As I said, it's part of thinkAttack() method. At top beginning you got a possibility the AI is setted on active statut, notably if the Ai hasn't anymore target, or timer runs out without being able to attack.

 

Then, on thinkActive(), you got the code to send back monsters to his location. On aCis, he runs from one point to another. Just use latest L2J sources to get overall code, and edit following your wishes (instead of moveTo(), use teleToLocation()).

 

You got notably isReturningToSpawnPoint() / setIsReturningToSpawnPoint() methods.

  • Thanks 1
  • 0
Posted

Guys i spend to many hours for this shit :/ my experience is low on l2j and until do compile and test compiel and test it will take a year to fix this code ..:/

 

 

i remove that borinio same exist as tryskel say i have to check on attack files but i dont know... i m searching on l2j to find solution for this fail.

 

if some1 have any idea help me to finish this shit

  • 0
Posted

As I said, it's part of thinkAttack() method. At top beginning you got a possibility the AI is setted on active statut, notably if the Ai hasn't anymore target, or timer runs out without being able to attack.

 

Then, on thinkActive(), you got the code to send back monsters to his location. On aCis, he runs from one point to another. Just use latest L2J sources to get overall code, and edit following your wishes (instead of moveTo(), use teleToLocation()).

 

You got notably isReturningToSpawnPoint() / setIsReturningToSpawnPoint() methods.

 

i find this

 

 

// Order to the L2MonsterInstance to random walk (1/100)
	else if (npc.getSpawn() != null && Rnd.nextInt(RANDOM_WALK_RATE) == 0 
			&& !_actor.isRndWalk())
	{
		int x1, y1, z1;
		final int range = Config.MAX_DRIFT_RANGE;



		// If NPC with random coord in territory
		if (npc.getSpawn().getLocx() == 0 && npc.getSpawn().getLocy() == 0)
		{
			// Calculate a destination point in the spawn area
			int p[] = TerritoryTable.getInstance().getRandomPoint(npc.getSpawn().getLocation());
			x1 = p[0];
			y1 = p[1];
			z1 = p[2];

			// Calculate the distance between the current position of the L2Character and the target (x,y)
			double distance2 = _actor.getPlanDistanceSq(x1, y1);

			if (distance2 > (range + range) * (range + range))
			{
				npc.setisReturningToSpawnPoint(true);
				float delay = (float) Math.sqrt(distance2) / range;
				x1 = _actor.getX() + (int) ((x1 - _actor.getX()) / delay);
				y1 = _actor.getY() + (int) ((y1 - _actor.getY()) / delay);
			}

			// If NPC with random fixed coord, don't move (unless needs to return to spawnpoint)
			if (TerritoryTable.getInstance().getProcMax(npc.getSpawn().getLocation()) > 0 && !npc.isReturningToSpawnPoint())
				return;
		}
		else
		{
			// If NPC with fixed coord
			x1 = npc.getSpawn().getLocx();
			y1 = npc.getSpawn().getLocy();
			z1 = npc.getSpawn().getLocz();

			if (!_actor.isInsideRadius(x1, y1, z1, range + range, true, false))
				npc.setisReturningToSpawnPoint(true);
			else
			{
				x1 += Rnd.nextInt(range * 2) - range;
				y1 += Rnd.nextInt(range * 2) - range;
				z1 = npc.getZ();
			}
		}

		//_log.config("Curent pos ("+getX()+", "+getY()+"), moving to ("+x1+", "+y1+").");
		// Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation (broadcast)
		moveTo(x1, y1, z1);
	}
}

 

i have only with red line this

 

isRndWalk

 

i remove code all code for walk and monsters walk like crazy xd

but i test the code for return and nothing happend again follow ..

 

can some1 edit this code for frozen? .. :/

  • 0
Posted

Bump no solution : /

 

 

Guys if u know this code help me here i cant to more test already 30 compiles , i dont know i try everything .. :/

 

Guest
This topic is now closed to further replies.


  • Posts

    • Hello, Skill Activation: The activation options from the Alt+K window work perfectly. However, when activating them from the skill bar, there is still a delay of approximately 1 second. I need to remove that delay
    • --- Interlude Faction/GvE PvP grand opening 2025-11-15 19:00 GMT+2 ---   Gameplay: Chronicle: Interlude Type: Faction/GvE (Angels vs Nature vs Demons) GM Shop: B-S grade Buff slots: 20+4 Starting level: 74 + rebirth system   New Features: Client: Modern interface based on Essence Balance: New class skills for better balance Achievement Rewards: Daily, Weekly, One-time TOP rankings: PvP, Event PvP, Map PvP, Clan PvP, Event MvP, Map MvP Zones: 70 different PvP zones,  18 different events (8 map events | 10 main events) 12 Grand/raid bosses. Castle siege Olympiad Clan Hall challenge Custom Enchant System: Dynamic success chance (greater enchant level or item grade less enchanting success chance) Enchant rate: Blessed scrolls dynamic from 100% to 25%. Crystal Scrolls: 100%; Max enchant weapon +12 Max enchant armor +8 Safe point enchant system Extra Features: PvP items with level upgrade Weapon/Armor upgrade (from B grade to S) system Attributes system   Website: https://l2cygnus.com Community: Discord Facebook: https://www.facebook.com/l2cygnus Youtube:   
    • More fluid combat, not 100% yet, but I think it's acceptable. I put the following logic in movetopawn, moveto, maybemovetopawn, validatelocation, movetolocation: If Config.GeoData is active, it applies the coordinates using geodata; if disabled, use setdistanceplansq to measure the distance of things! Fix for reflected damage (if the attacker is null, it will not be calculated). Minor improvements to the Day/Night item generation manager. Fix to not punish players who destroy items with a count = 0... Fix for when a player tried to use a resurrection scroll while seated, it disappeared without effect. Fix for when it was possible to equip armor while paralyzed. Cleanup of System message. Rework of PathNodes. Fixed the ia for mobs attack range when chasing the player (test) Fixed Pathnodes loading Added # ------------------------ #Show Red Name for Aggressive Mobs # ------------------------ ShowRedName = True Which was missing in the configs
    • ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚔️ L2JOmen High Five - SERVIDOR 100% RETAIL ⚔️ 📢 SOLICITAMOS APOYO PARA TESTING 📢 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ¡Saludos, comunidad de Lineage II! Estamos desarrollando un proyecto ambicioso y de calidad: L2JOmen High Five, un servidor  100% RETAIL que busca ofrecer la experiencia más auténtica de High Five.  Nos encontramos en la fase de desarrollo y testing, y necesitamos tu ayuda para hacerlo  grande. Si eres un amante del retail, disfrutas probar nuevas funciones y quieres formar  parte de un proyecto serio desde sus inicios, ¡tu apoyo es invaluable! ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🎮 CARACTERÍSTICAS PRINCIPALES 🎮 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ SERVIDOR 100% RETAIL    • Experiencia auténtica de High Five    • Geodata PTS Official    • Plataforma Premium 2025 ✅ SISTEMA DE RATES DINÁMICO (Progresión Retail x1 con ayuda x5 -> x1)    • XP: 1-20 (5.0x) | 21-40 (3.0x) | 41-60 (2.0x) | 61-75 (1.5x) | 76-85 (1.0x)    • SP: 1-20 (5.0x) | 21-40 (3.0x) | 41-60 (2.0x) | 61-75 (1.5x) | 76-85 (1.0x)    • Adena: x2.0 (Retail con pequeño ajuste)    • Drop y Spoil: x1.0 (Mobs, Raids y Epics) ✅ SISTEMA DE ENCANTAMIENTO PROFESIONAL    • Enchant Safe: +6 (100% seguro hasta +6)    • Enchant Máximo: +30    • Tasas de encantamiento balanceadas:      * 0-3: 100% | 4: 80% | 5: 75% | 6: 70% | 7: 65% | 8: 60%      * 9: 55% | 10: 50% | 11: 45% | 12: 40%      * 13: 10% | 14-25: 5-9% | 26-30: 1-4%    • Sistema Blessed Enchant habilitado ✅ INICIO DE PERSONAJE    • Dynasty Masterwork Set completo +12    • 1 Ticket para Weapon S +12    • Duración: 7 días ✅ CONFIGURACIÓN RETAIL    • Element Limit: Nivel 4    • Buffs: Duración de 1 hora    • Nobless: Obtenible mediante quest    • Subclass Máxima: 10 (Certificación para cada Subclass) ✅ SISTEMA DE FARM Y ECONOMÍA    • Múltiples monedas de farm (Adena, Ancient Adena, Coin of Luck, PC Bang Points, Farm Coins)    • Varias zonas de farm disponibles    • Zona de Party Farm (se habilita cada 3 horas por 1 hora)    • 4 Raids diarias programadas ✅ SISTEMA PC BANG POINTS    • Aproximadamente 10,000 puntos por 24 horas conectado    • Entrega cada 10 minutos    • Jugadores Normales: 60-72 puntos/intervalo    • Jugadores Premium: 96-116 puntos/intervalo    • 5% probabilidad de doble puntos ✅ SHOPS COMPLETOS    • Shop Normal (Adena y Farm Coins)    • Shop Donate (con opciones premium)    • Armaduras y Armas hasta Grado Dynasty, Moirai, S84    • Joyas completas, no incluye Epics    • Scrolls (Normales, Blessed, Divine, Ancient)    • Elementos hasta nivel 4-7    • Accesorios y consumibles ✅ SISTEMA VIP    • 5 niveles de VIP disponibles    • Bonificaciones progresivas de XP/SP/Drop    • Recompensas diarias exclusivas ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🤝 ¿QUÉ NECESITAMOS DE TI? 🤝 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔍 TESTERS ACTIVOS    • Jugadores que prueben todas las funciones del servidor    • Feedback constructivo sobre bugs, balance y mejoras    • Reporte de problemas encontrados 🎮 JUGADORES DEDICADOS    • Amantes del retail que valoren la experiencia auténtica    • Personas dispuestas a ayudar a mejorar el proyecto    • Comunidad comprometida con el crecimiento del servidor 📊 REPORTES DETALLADOS    • Bugs y errores encontrados    • Sugerencias de balance    • Opiniones sobre el gameplay    • Feedback sobre sistemas implementados ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 💎 ¿POR QUÉ UNIRTE A L2JOmen? 💎 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🌟 PROYECTO SERIO Y COMPROMETIDO    • Desarrollo constante y mejoras continuas    • Atención a la comunidad activa    • Transparencia en todas las decisiones 🎯 EXPERIENCIA 100% RETAIL    • Sin modificaciones que rompan el juego original    • Balance auténtico de High Five    • Gameplay puro y tradicional ⚡ TECNOLOGÍA DE VANGUARDIA    • Servidor optimizado y estable    • Geodata oficial de PTS    • Sistema robusto y sin lag    • Sistema Anticheat Premium 🎁 RECOMPENSAS PARA TESTERS    • Participación activa en el desarrollo    • Reconocimiento especial en el lanzamiento    • Beneficios exclusivos para early testers ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📞 CONTACTO E INFORMACIÓN 📞 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Si estás interesado en formar parte de este proyecto y ayudarnos a crear el mejor  servidor retail de High Five, contáctanos. Tu apoyo es fundamental para hacer realidad  este grandioso proyecto. 💬 Únete a nuestro grupo de testing 🌐 WhatsApp: https://chat.whatsapp.com/Km6uRtFsoUq2tNZZalo5HB?mode=wwt ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🏆 ¡Juntos construimos el mejor servidor retail! 🏆 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock