Fixed AreaSkillNpc AI.

This commit is contained in:
MobiusDev
2017-10-11 01:08:25 +00:00
parent a13882d5cc
commit 76b3077374
3 changed files with 120 additions and 117 deletions

View File

@@ -18,7 +18,6 @@ package ai.others;
import com.l2jmobius.commons.util.CommonUtil; import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.SkillHolder; import com.l2jmobius.gameserver.model.holders.SkillHolder;
@@ -34,6 +33,10 @@ public final class AreaSkillNpc extends AbstractNpcAI
// NPCs // NPCs
private static final int[] BASIC = // area_skill_npc private static final int[] BASIC = // area_skill_npc
{ {
143, // Totem of Body
144, // Totem of Spirit
145, // Totem of Bravery
146, // Totem of Fortitude
13018, // Maximum Defense 13018, // Maximum Defense
13019, // Anti-Music 13019, // Anti-Music
13020, // Maximum Resist Status 13020, // Maximum Resist Status
@@ -53,13 +56,6 @@ public final class AreaSkillNpc extends AbstractNpcAI
13380, // Solo Dance 13380, // Solo Dance
13381, // Solo Dance 13381, // Solo Dance
}; };
private static final int[] TOTEMS = // ai_totem_of_body
{
143, // Totem of Body
144, // Totem of Spirit
145, // Totem of Bravery
146, // Totem of Fortitude
};
private static final int[] DECOY = // ai_decoy private static final int[] DECOY = // ai_decoy
{ {
13071, // Virtual Image 13071, // Virtual Image
@@ -85,32 +81,25 @@ public final class AreaSkillNpc extends AbstractNpcAI
private AreaSkillNpc() private AreaSkillNpc()
{ {
addSpawnId(BASIC); addSpawnId(BASIC);
addSpawnId(TOTEMS);
addSpawnId(DECOY); addSpawnId(DECOY);
} }
@Override @Override
public String onSpawn(L2Npc npc) public String onSpawn(L2Npc npc)
{ {
final L2Character summoner = npc.getSummoner(); if (CommonUtil.contains(DECOY, npc.getId()))
if ((summoner != null) && summoner.isPlayer())
{ {
final L2PcInstance player = summoner.getActingPlayer(); final int castTime = npc.getTemplate().getParameters().getInt("i_use_term_time", 5000);
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
if (CommonUtil.contains(BASIC, npc.getId()) || CommonUtil.contains(TOTEMS, npc.getId())) onTimerEvent("SKILL_CAST_BASIC", null, npc, null); // Trigger cast instantly
{ getTimers().addTimer("SKILL_CAST_TIMED", castTime, npc, null);
final int despawnTime = npc.getTemplate().getParameters().getInt("despawn_time", 7); getTimers().addTimer("DELETE_ME", despawnTime, npc, null);
getTimers().addTimer("SKILL_CAST_BASIC", 100, npc, player); }
getTimers().addTimer("DELETE_ME", (despawnTime * 1000), npc, player); else
} {
else if (CommonUtil.contains(DECOY, npc.getId())) final int despawnTime = npc.getTemplate().getParameters().getInt("despawn_time", 7);
{ getTimers().addTimer("SKILL_CAST_TIMED", 100, npc, null);
final int castTime = npc.getTemplate().getParameters().getInt("i_use_term_time", 5000); getTimers().addTimer("DELETE_ME", (despawnTime * 1000), npc, null);
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
onTimerEvent("SKILL_CAST_BASIC", null, npc, player); // Trigger cast instantly
getTimers().addTimer("SKILL_CAST_BASIC", castTime, npc, player);
getTimers().addTimer("DELETE_ME", despawnTime, npc, player);
}
} }
return super.onSpawn(npc); return super.onSpawn(npc);
} }
@@ -118,21 +107,33 @@ public final class AreaSkillNpc extends AbstractNpcAI
@Override @Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player) public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{ {
if (event.equals("SKILL_CAST_BASIC")) switch (event)
{ {
final SkillHolder skill = npc.getParameters().getSkillHolder(CommonUtil.contains(DECOY, npc.getId()) ? "decoy_skill" : "union_skill"); case "SKILL_CAST_BASIC":
final int skillDelay = npc.getParameters().getInt("skill_delay", 2);
if (skill != null)
{ {
npc.doCast(skill.getSkill()); final SkillHolder skill = npc.getParameters().getSkillHolder(CommonUtil.contains(DECOY, npc.getId()) ? "decoy_skill" : "union_skill");
getTimers().addTimer("SKILL_CAST_BASIC", skillDelay * 1000, npc, player); if (skill != null)
{
npc.doCast(skill.getSkill());
}
break;
}
case "SKILL_CAST_TIMED":
{
final SkillHolder skill = npc.getParameters().getSkillHolder(CommonUtil.contains(DECOY, npc.getId()) ? "decoy_skill" : "union_skill");
if (skill != null)
{
npc.doCast(skill.getSkill());
getTimers().addRepeatingTimer("SKILL_CAST_BASIC", npc.getParameters().getInt("skill_delay", 2) * 1000, npc, null);
}
break;
}
case "DELETE_ME":
{
getTimers().cancelTimer("SKILL_CAST_BASIC", npc, null);
npc.deleteMe();
break;
} }
}
else if (event.equals("DELETE_ME"))
{
getTimers().cancelTimer("SKILL_CAST_BASIC", npc, player);
npc.deleteMe();
} }
} }

View File

@@ -18,7 +18,6 @@ package ai.others;
import com.l2jmobius.commons.util.CommonUtil; import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.SkillHolder; import com.l2jmobius.gameserver.model.holders.SkillHolder;
@@ -34,6 +33,10 @@ public final class AreaSkillNpc extends AbstractNpcAI
// NPCs // NPCs
private static final int[] BASIC = // area_skill_npc private static final int[] BASIC = // area_skill_npc
{ {
143, // Totem of Body
144, // Totem of Spirit
145, // Totem of Bravery
146, // Totem of Fortitude
13018, // Maximum Defense 13018, // Maximum Defense
13019, // Anti-Music 13019, // Anti-Music
13020, // Maximum Resist Status 13020, // Maximum Resist Status
@@ -59,13 +62,6 @@ public final class AreaSkillNpc extends AbstractNpcAI
13453, // Solo Dance 13453, // Solo Dance
13454, // Solo Dance 13454, // Solo Dance
}; };
private static final int[] TOTEMS = // ai_totem_of_body
{
143, // Totem of Body
144, // Totem of Spirit
145, // Totem of Bravery
146, // Totem of Fortitude
};
private static final int[] DECOY = // ai_decoy private static final int[] DECOY = // ai_decoy
{ {
13071, // Virtual Image 13071, // Virtual Image
@@ -91,32 +87,25 @@ public final class AreaSkillNpc extends AbstractNpcAI
private AreaSkillNpc() private AreaSkillNpc()
{ {
addSpawnId(BASIC); addSpawnId(BASIC);
addSpawnId(TOTEMS);
addSpawnId(DECOY); addSpawnId(DECOY);
} }
@Override @Override
public String onSpawn(L2Npc npc) public String onSpawn(L2Npc npc)
{ {
final L2Character summoner = npc.getSummoner(); if (CommonUtil.contains(DECOY, npc.getId()))
if ((summoner != null) && summoner.isPlayer())
{ {
final L2PcInstance player = summoner.getActingPlayer(); final int castTime = npc.getTemplate().getParameters().getInt("i_use_term_time", 5000);
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
if (CommonUtil.contains(BASIC, npc.getId()) || CommonUtil.contains(TOTEMS, npc.getId())) onTimerEvent("SKILL_CAST_BASIC", null, npc, null); // Trigger cast instantly
{ getTimers().addTimer("SKILL_CAST_TIMED", castTime, npc, null);
final int despawnTime = npc.getTemplate().getParameters().getInt("despawn_time", 7); getTimers().addTimer("DELETE_ME", despawnTime, npc, null);
getTimers().addTimer("SKILL_CAST_BASIC", 100, npc, player); }
getTimers().addTimer("DELETE_ME", (despawnTime * 1000), npc, player); else
} {
else if (CommonUtil.contains(DECOY, npc.getId())) final int despawnTime = npc.getTemplate().getParameters().getInt("despawn_time", 7);
{ getTimers().addTimer("SKILL_CAST_TIMED", 100, npc, null);
final int castTime = npc.getTemplate().getParameters().getInt("i_use_term_time", 5000); getTimers().addTimer("DELETE_ME", (despawnTime * 1000), npc, null);
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
onTimerEvent("SKILL_CAST_BASIC", null, npc, player); // Trigger cast instantly
getTimers().addTimer("SKILL_CAST_BASIC", castTime, npc, player);
getTimers().addTimer("DELETE_ME", despawnTime, npc, player);
}
} }
return super.onSpawn(npc); return super.onSpawn(npc);
} }
@@ -124,21 +113,33 @@ public final class AreaSkillNpc extends AbstractNpcAI
@Override @Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player) public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{ {
if (event.equals("SKILL_CAST_BASIC")) switch (event)
{ {
final SkillHolder skill = npc.getParameters().getSkillHolder(CommonUtil.contains(DECOY, npc.getId()) ? "decoy_skill" : "union_skill"); case "SKILL_CAST_BASIC":
final int skillDelay = npc.getParameters().getInt("skill_delay", 2);
if (skill != null)
{ {
npc.doCast(skill.getSkill()); final SkillHolder skill = npc.getParameters().getSkillHolder(CommonUtil.contains(DECOY, npc.getId()) ? "decoy_skill" : "union_skill");
getTimers().addTimer("SKILL_CAST_BASIC", skillDelay * 1000, npc, player); if (skill != null)
{
npc.doCast(skill.getSkill());
}
break;
}
case "SKILL_CAST_TIMED":
{
final SkillHolder skill = npc.getParameters().getSkillHolder(CommonUtil.contains(DECOY, npc.getId()) ? "decoy_skill" : "union_skill");
if (skill != null)
{
npc.doCast(skill.getSkill());
getTimers().addRepeatingTimer("SKILL_CAST_BASIC", npc.getParameters().getInt("skill_delay", 2) * 1000, npc, null);
}
break;
}
case "DELETE_ME":
{
getTimers().cancelTimer("SKILL_CAST_BASIC", npc, null);
npc.deleteMe();
break;
} }
}
else if (event.equals("DELETE_ME"))
{
getTimers().cancelTimer("SKILL_CAST_BASIC", npc, player);
npc.deleteMe();
} }
} }

View File

@@ -18,7 +18,6 @@ package ai.others;
import com.l2jmobius.commons.util.CommonUtil; import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc; import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.SkillHolder; import com.l2jmobius.gameserver.model.holders.SkillHolder;
@@ -34,6 +33,10 @@ public final class AreaSkillNpc extends AbstractNpcAI
// NPCs // NPCs
private static final int[] BASIC = // area_skill_npc private static final int[] BASIC = // area_skill_npc
{ {
143, // Totem of Body
144, // Totem of Spirit
145, // Totem of Bravery
146, // Totem of Fortitude
13018, // Maximum Defense 13018, // Maximum Defense
13019, // Anti-Music 13019, // Anti-Music
13020, // Maximum Resist Status 13020, // Maximum Resist Status
@@ -59,13 +62,6 @@ public final class AreaSkillNpc extends AbstractNpcAI
13453, // Solo Dance 13453, // Solo Dance
13454, // Solo Dance 13454, // Solo Dance
}; };
private static final int[] TOTEMS = // ai_totem_of_body
{
143, // Totem of Body
144, // Totem of Spirit
145, // Totem of Bravery
146, // Totem of Fortitude
};
private static final int[] DECOY = // ai_decoy private static final int[] DECOY = // ai_decoy
{ {
13071, // Virtual Image 13071, // Virtual Image
@@ -91,32 +87,25 @@ public final class AreaSkillNpc extends AbstractNpcAI
private AreaSkillNpc() private AreaSkillNpc()
{ {
addSpawnId(BASIC); addSpawnId(BASIC);
addSpawnId(TOTEMS);
addSpawnId(DECOY); addSpawnId(DECOY);
} }
@Override @Override
public String onSpawn(L2Npc npc) public String onSpawn(L2Npc npc)
{ {
final L2Character summoner = npc.getSummoner(); if (CommonUtil.contains(DECOY, npc.getId()))
if ((summoner != null) && summoner.isPlayer())
{ {
final L2PcInstance player = summoner.getActingPlayer(); final int castTime = npc.getTemplate().getParameters().getInt("i_use_term_time", 5000);
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
if (CommonUtil.contains(BASIC, npc.getId()) || CommonUtil.contains(TOTEMS, npc.getId())) onTimerEvent("SKILL_CAST_BASIC", null, npc, null); // Trigger cast instantly
{ getTimers().addTimer("SKILL_CAST_TIMED", castTime, npc, null);
final int despawnTime = npc.getTemplate().getParameters().getInt("despawn_time", 7); getTimers().addTimer("DELETE_ME", despawnTime, npc, null);
getTimers().addTimer("SKILL_CAST_BASIC", 100, npc, player); }
getTimers().addTimer("DELETE_ME", (despawnTime * 1000), npc, player); else
} {
else if (CommonUtil.contains(DECOY, npc.getId())) final int despawnTime = npc.getTemplate().getParameters().getInt("despawn_time", 7);
{ getTimers().addTimer("SKILL_CAST_TIMED", 100, npc, null);
final int castTime = npc.getTemplate().getParameters().getInt("i_use_term_time", 5000); getTimers().addTimer("DELETE_ME", (despawnTime * 1000), npc, null);
final int despawnTime = npc.getTemplate().getParameters().getInt("i_despawn_time", 30000);
onTimerEvent("SKILL_CAST_BASIC", null, npc, player); // Trigger cast instantly
getTimers().addTimer("SKILL_CAST_BASIC", castTime, npc, player);
getTimers().addTimer("DELETE_ME", despawnTime, npc, player);
}
} }
return super.onSpawn(npc); return super.onSpawn(npc);
} }
@@ -124,21 +113,33 @@ public final class AreaSkillNpc extends AbstractNpcAI
@Override @Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player) public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{ {
if (event.equals("SKILL_CAST_BASIC")) switch (event)
{ {
final SkillHolder skill = npc.getParameters().getSkillHolder(CommonUtil.contains(DECOY, npc.getId()) ? "decoy_skill" : "union_skill"); case "SKILL_CAST_BASIC":
final int skillDelay = npc.getParameters().getInt("skill_delay", 2);
if (skill != null)
{ {
npc.doCast(skill.getSkill()); final SkillHolder skill = npc.getParameters().getSkillHolder(CommonUtil.contains(DECOY, npc.getId()) ? "decoy_skill" : "union_skill");
getTimers().addTimer("SKILL_CAST_BASIC", skillDelay * 1000, npc, player); if (skill != null)
{
npc.doCast(skill.getSkill());
}
break;
}
case "SKILL_CAST_TIMED":
{
final SkillHolder skill = npc.getParameters().getSkillHolder(CommonUtil.contains(DECOY, npc.getId()) ? "decoy_skill" : "union_skill");
if (skill != null)
{
npc.doCast(skill.getSkill());
getTimers().addRepeatingTimer("SKILL_CAST_BASIC", npc.getParameters().getInt("skill_delay", 2) * 1000, npc, null);
}
break;
}
case "DELETE_ME":
{
getTimers().cancelTimer("SKILL_CAST_BASIC", npc, null);
npc.deleteMe();
break;
} }
}
else if (event.equals("DELETE_ME"))
{
getTimers().cancelTimer("SKILL_CAST_BASIC", npc, player);
npc.deleteMe();
} }
} }