Free version update 14-12-2023.

This commit is contained in:
MobiusDevelopment
2023-12-14 02:11:28 +02:00
parent 6a0a4be1ea
commit 1204ad8e00
6352 changed files with 98838 additions and 68045 deletions

View File

@@ -581,6 +581,7 @@ public class Config
public static boolean ENABLE_AUTO_SKILL;
public static boolean ENABLE_AUTO_ITEM;
public static boolean RESUME_AUTO_PLAY;
public static boolean ENABLE_AUTO_ASSIST;
public static Set<Integer> DISABLED_AUTO_SKILLS = new HashSet<>();
public static Set<Integer> DISABLED_AUTO_ITEMS = new HashSet<>();
public static String AUTO_PLAY_LOGIN_MESSAGE;
@@ -1862,6 +1863,7 @@ public class Config
ENABLE_AUTO_SKILL = autoPlayConfig.getBoolean("EnableAutoSkill", true);
ENABLE_AUTO_ITEM = autoPlayConfig.getBoolean("EnableAutoItem", true);
RESUME_AUTO_PLAY = autoPlayConfig.getBoolean("ResumeAutoPlay", false);
ENABLE_AUTO_ASSIST = autoPlayConfig.getBoolean("AssistLeader", false);
DISABLED_AUTO_SKILLS.clear();
final String disabledSkills = autoPlayConfig.getString("DisabledSkillIds", "");
if (!disabledSkills.isEmpty())

View File

@@ -38,6 +38,7 @@ import org.l2jmobius.gameserver.model.DropProtection;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.WorldRegion;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.knownlist.NullKnownList;
@@ -1107,10 +1108,11 @@ public class Item extends WorldObject
// Set the x,y,z position of the Item dropped and update its _worldregion
setSpawned(true);
getLocation().setXYZ(x, y, z);
setWorldRegion(World.getInstance().getRegion(getLocation()));
final WorldRegion region = World.getInstance().getRegion(getLocation());
setWorldRegion(region);
// Add the Item dropped to _visibleObjects of its WorldRegion
getWorldRegion().addVisibleObject(this);
region.addVisibleObject(this);
}
setDropTime(System.currentTimeMillis());

View File

@@ -16,6 +16,7 @@
*/
package org.l2jmobius.gameserver.taskmanager;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -24,6 +25,7 @@ import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
@@ -40,6 +42,7 @@ import org.l2jmobius.gameserver.util.Util;
public class AutoPlayTaskManager
{
private static final Set<Set<Player>> POOLS = ConcurrentHashMap.newKeySet();
private static final Map<Player, Integer> IDLE_COUNT = new ConcurrentHashMap<>();
private static final int POOL_SIZE = 300;
private static final int TASK_DELAY = 300;
private static final Integer AUTO_ATTACK_ACTION = 2;
@@ -95,6 +98,12 @@ public class AutoPlayTaskManager
// We take granted that mage classes do not auto hit.
if (isMageCaster(player))
{
// Logic adjustment for summons not attacking.
final Summon summon = player.getPet();
if ((summon != null) && summon.hasAI() && !summon.isMoving() && !summon.isDisabled() && (summon.getAI().getIntention() != CtrlIntention.AI_INTENTION_ATTACK) && (summon.getAI().getIntention() != CtrlIntention.AI_INTENTION_CAST) && creature.isAutoAttackable(player) && GeoEngine.getInstance().canSeeTarget(player, creature))
{
summon.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, creature);
}
continue PLAY;
}
@@ -120,23 +129,32 @@ public class AutoPlayTaskManager
final Weapon weapon = player.getActiveWeaponItem();
if (weapon != null)
{
final boolean ranged = weapon.getItemType() == WeaponType.BOW;
final double angle = Util.calculateHeadingFrom(player, creature);
final double radian = Math.toRadians(angle);
final double course = Math.toRadians(180);
final double distance = (ranged ? player.getCollisionRadius() : player.getCollisionRadius() + creature.getTemplate().getCollisionRadius()) * 2;
final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance);
final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance);
final Location location;
if (ranged)
final int idleCount = IDLE_COUNT.getOrDefault(player, 0);
if (idleCount > 10)
{
location = new Location(player.getX() + x1, player.getY() + y1, player.getZ());
final boolean ranged = weapon.getItemType() == WeaponType.BOW;
final double angle = Util.calculateHeadingFrom(player, creature);
final double radian = Math.toRadians(angle);
final double course = Math.toRadians(180);
final double distance = (ranged ? player.getCollisionRadius() : player.getCollisionRadius() + creature.getTemplate().getCollisionRadius()) * 2;
final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance);
final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance);
final Location location;
if (ranged)
{
location = new Location(player.getX() + x1, player.getY() + y1, player.getZ());
}
else
{
location = new Location(creature.getX() + x1, creature.getY() + y1, player.getZ());
}
player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, location);
IDLE_COUNT.remove(player);
}
else
{
location = new Location(creature.getX() + x1, creature.getY() + y1, player.getZ());
IDLE_COUNT.put(player, idleCount + 1);
}
player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, location);
}
}
}
@@ -144,6 +162,9 @@ public class AutoPlayTaskManager
}
}
// Reset idle count.
IDLE_COUNT.remove(player);
// Pickup.
if (player.getAutoPlaySettings().doPickup())
{
@@ -183,41 +204,61 @@ public class AutoPlayTaskManager
// Find target.
Creature creature = null;
double closestDistance = Double.MAX_VALUE;
TARGET: for (Creature nearby : player.getKnownList().getKnownCharactersInRadius(player.getAutoPlaySettings().isShortRange() && (targetMode != 2 /* Characters */) ? 600 : 1400))
final Party party = player.getParty();
final Player leader = party == null ? null : party.getLeader();
if (Config.ENABLE_AUTO_ASSIST && (party != null) && (leader != null) && (leader != player) && !leader.isDead())
{
if (nearby == null)
if (Util.calculateDistance(leader, player, true) < (Config.ALT_PARTY_RANGE * 2 /* 2? */))
{
continue;
final WorldObject leaderTarget = leader.getTarget();
if ((leaderTarget != null) && (leaderTarget.isAttackable() || (leaderTarget.isPlayable() && !party.getPartyMembers().contains(leaderTarget))))
{
creature = (Creature) leaderTarget;
}
else if ((player.getAI().getIntention() != CtrlIntention.AI_INTENTION_FOLLOW) && !player.isDisabled())
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, leader);
}
}
// Skip unavailable creatures.
if (nearby.isAlikeDead())
}
else
{
double closestDistance = Double.MAX_VALUE;
TARGET: for (Creature nearby : player.getKnownList().getKnownCharactersInRadius(player.getAutoPlaySettings().isShortRange() && (targetMode != 2 /* Characters */) ? 600 : 1400))
{
continue TARGET;
}
// Check creature target.
if (player.getAutoPlaySettings().isRespectfulHunting() && !nearby.isPlayable() && (nearby.getTarget() != null) && (nearby.getTarget() != player))
{
final Summon summon = player.getPet();
if ((summon != null) && (summon.getObjectId() == nearby.getTarget().getObjectId()))
if (nearby == null)
{
continue;
}
// Skip unavailable creatures.
if (nearby.isAlikeDead())
{
continue TARGET;
}
}
// Check next target mode.
if (!isTargetModeValid(targetMode, player, nearby))
{
continue TARGET;
}
// Check if creature is reachable.
if ((Math.abs(player.getZ() - nearby.getZ()) < 180) && GeoEngine.getInstance().canSeeTarget(player, nearby) && GeoEngine.getInstance().canMoveToTarget(player.getX(), player.getY(), player.getZ(), nearby.getX(), nearby.getY(), nearby.getZ(), player.getInstanceId()))
{
final double creatureDistance = player.calculateDistance2D(nearby);
if (creatureDistance < closestDistance)
// Check creature target.
if (player.getAutoPlaySettings().isRespectfulHunting() && !nearby.isPlayable() && (nearby.getTarget() != null) && (nearby.getTarget() != player))
{
creature = nearby;
closestDistance = creatureDistance;
final Summon summon = player.getPet();
if ((summon != null) && (summon.getObjectId() == nearby.getTarget().getObjectId()))
{
continue TARGET;
}
}
// Check next target mode.
if (!isTargetModeValid(targetMode, player, nearby))
{
continue TARGET;
}
// Check if creature is reachable.
if ((Math.abs(player.getZ() - nearby.getZ()) < 180) && GeoEngine.getInstance().canSeeTarget(player, nearby) && GeoEngine.getInstance().canMoveToTarget(player.getX(), player.getY(), player.getZ(), nearby.getX(), nearby.getY(), nearby.getZ(), player.getInstanceId()))
{
final double creatureDistance = player.calculateDistance2D(nearby);
if (creatureDistance < closestDistance)
{
creature = nearby;
closestDistance = creatureDistance;
}
}
}
}
@@ -310,6 +351,7 @@ public class AutoPlayTaskManager
{
summon.followOwner();
}
IDLE_COUNT.remove(player);
return;
}
}