Support for auto use summon skills.

This commit is contained in:
MobiusDevelopment
2022-03-24 23:13:01 +00:00
parent 5d4d64bf34
commit 4c9bb1e4cf
43 changed files with 750 additions and 143 deletions

View File

@@ -5553,7 +5553,6 @@ public class Player extends Playable
{
final List<Summon> summons = new ArrayList<>();
summons.addAll(getServitors().values());
if (_pet != null)
{
summons.add(_pet);

View File

@@ -26,6 +26,7 @@ import org.l2jmobius.gameserver.model.ActionDataHolder;
import org.l2jmobius.gameserver.model.ShortCuts;
import org.l2jmobius.gameserver.model.Shortcut;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.network.GameClient;
@@ -80,6 +81,24 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
if (shortcut.getType() == ShortcutType.SKILL)
{
skill = player.getKnownSkill(shortcut.getId());
if (skill == null)
{
if (player.hasServitors())
{
for (Summon summon : player.getServitors().values())
{
skill = summon.getKnownSkill(shortcut.getId());
if (skill != null)
{
break;
}
}
}
if ((skill == null) && player.hasPet())
{
skill = player.getPet().getKnownSkill(shortcut.getId());
}
}
}
else
{

View File

@@ -184,27 +184,50 @@ public class AutoUseTaskManager implements Runnable
break BUFFS;
}
final Skill skill = player.getKnownSkill(skillId.intValue());
Playable pet = null;
Skill skill = player.getKnownSkill(skillId.intValue());
if (skill == null)
{
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
continue BUFFS;
if (player.hasServitors())
{
SUMMON_SEARCH: for (Summon summon : player.getServitors().values())
{
pet = summon;
skill = summon.getKnownSkill(skillId.intValue());
if (skill != null)
{
break SUMMON_SEARCH;
}
}
}
if ((skill == null) && player.hasPet())
{
pet = player.getPet();
skill = pet.getKnownSkill(skillId.intValue());
}
if (skill == null)
{
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
continue BUFFS;
}
}
final WorldObject target = player.getTarget();
if (canCastBuff(player, target, skill))
{
final Playable caster = pet != null ? pet : player;
// Playable target cast.
if ((target != null) && target.isPlayable() && !((Playable) target).isAlikeDead() && (target.getActingPlayer().getPvpFlag() == 0) && (target.getActingPlayer().getReputation() >= 0))
{
player.doCast(skill);
caster.doCast(skill);
}
else // Target self, cast and re-target.
{
final WorldObject savedTarget = target;
player.setTarget(player);
player.doCast(skill);
player.setTarget(savedTarget);
caster.setTarget(caster);
caster.doCast(skill);
caster.setTarget(savedTarget);
}
}
}
@@ -230,13 +253,34 @@ public class AutoUseTaskManager implements Runnable
}
// Acquire next skill.
Playable pet = null;
final Integer skillId = player.getAutoUseSettings().getNextSkillId();
final Skill skill = player.getKnownSkill(skillId.intValue());
Skill skill = player.getKnownSkill(skillId.intValue());
if (skill == null)
{
player.getAutoUseSettings().getAutoSkills().remove(skillId);
player.getAutoUseSettings().resetSkillOrder();
break SKILLS;
if (player.hasServitors())
{
SUMMON_SEARCH: for (Summon summon : player.getServitors().values())
{
pet = summon;
skill = summon.getKnownSkill(skillId.intValue());
if (skill != null)
{
break SUMMON_SEARCH;
}
}
}
if ((skill == null) && player.hasPet())
{
pet = player.getPet();
skill = pet.getKnownSkill(skillId.intValue());
}
if (skill == null)
{
player.getAutoUseSettings().getAutoSkills().remove(skillId);
player.getAutoUseSettings().resetSkillOrder();
break SKILLS;
}
}
// Casting on self stops movement.
@@ -258,7 +302,7 @@ public class AutoUseTaskManager implements Runnable
break SKILLS;
}
if (!canUseMagic(player, target, skill) || player.useMagic(skill, null, true, false))
if (!canUseMagic(player, target, skill) || (pet != null ? pet : player).useMagic(skill, null, true, false))
{
player.getAutoUseSettings().incrementSkillOrder();
}