Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package ai.group_template;
- import java.util.List;
- import javolution.util.FastList;
- import com.l2jserver.gameserver.Announcements;
- import com.l2jserver.gameserver.ThreadPoolManager;
- import com.l2jserver.gameserver.datatables.SkillTable;
- import com.l2jserver.gameserver.model.L2Object;
- import com.l2jserver.gameserver.model.L2Object.InstanceType;
- import com.l2jserver.gameserver.model.L2Skill;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.L2Npc;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.util.Rnd;
- public class customRaidbossFire extends L2AttackableAIScript
- {
- private enum ClassType
- {
- Mage, Tank, Archer, Summoner, Healer, Enchanter, Fighter, Dagger, Kamael
- }
- private static L2PcInstance _healer = null;
- private static L2PcInstance _mage = null;
- private static int _healersCount = 0;
- private static List<L2Character> _playersInRadius;
- private static final int[] _RBs = { 1000000, 1000001, 1000002, 1000003, 1000004 };
- private static final int[][] _spawns = { { -59516, 178947, -4814 }, { -61428, 181346, -4814 }, { -60755, 179650, -4814 }, { -59503, 183817, -4814 }, { -62385, 184108, -4820 }, { -62396, 183535, -4820 }, { -58521, 183911, -4814 }, { -59511, 186596, -4814 }, { -55855, 181347, -4814 }, { -57013, 186110, -4968 }, { -57372, 186112, -4968 }, { -57390, 186413, -4968 }, { -57013, 186452, -4968 } };
- private static L2Npc _currentSpawn;
- private static int _currentSpawnLoc = 0;
- private static long _lastAttackTime = 0;
- public customRaidbossFire(int questId, String name, String descr)
- {
- super(questId, name, descr);
- for (int id : _RBs)
- {
- addAttackId(id);
- addSpawnId(id);
- addKillId(id);
- addAggroRangeEnterId(id);
- addSkillSeeId(id);
- }
- _playersInRadius = new FastList<L2Character>();
- _currentSpawnLoc = Rnd.get(0, _spawns.length - 1);
- _currentSpawn = addSpawn(_RBs[Rnd.get(_RBs.length)], _spawns[_currentSpawnLoc][0], _spawns[_currentSpawnLoc][1], _spawns[_currentSpawnLoc][2], 0, false, 0);
- System.out.println(_spawns[_currentSpawnLoc][0] + "," + _spawns[_currentSpawnLoc][1] + "," + _spawns[_currentSpawnLoc][2]);
- ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
- {
- public void run()
- {
- if ((System.currentTimeMillis() - _lastAttackTime) > 600000)
- {
- respawn();
- }
- }
- }, 10, 1000);
- }
- @Override
- public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isPet)
- {
- _lastAttackTime = System.currentTimeMillis();
- for (L2Character smth : npc.getKnownList().getKnownCharacters())
- if (smth.getInstanceType() == InstanceType.L2PcInstance)
- {
- _playersInRadius.add(smth);
- }
- //Healers check
- if (_playersInRadius.contains(_healer))
- {
- npc.setTarget(_healer);
- if (Rnd.get(1, 100) <= 50)
- npc.doCast(SkillTable.getInstance().getInfo(1064, 130)); //Silence +30 chance
- if (_healer.isDead())
- _healer = null;
- }
- else
- {
- _healer = null;
- }
- //Mages check
- if (_playersInRadius.contains(_healer) && _healersCount <= 0)
- {
- npc.setTarget(_mage);
- if (Rnd.get(1, 100) <= 50)
- npc.doCast(SkillTable.getInstance().getInfo(1064, 130)); //Silence +30 chance
- if (_mage.isDead())
- _mage = null;
- }
- else
- {
- _mage = null;
- }
- return super.onAttack(npc, player, damage, isPet);
- }
- @Override
- public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
- {
- Announcements.getInstance().announceToAll("Raidboss " + npc.getName() + " was killed by " + killer.getName());
- _lastAttackTime = (System.currentTimeMillis() + 3600000);
- return super.onKill(npc, killer, isPet);
- }
- @Override
- public String onSpawn(L2Npc npc)
- {
- _lastAttackTime = System.currentTimeMillis();
- Announcements.getInstance().announceToAll("Raidboss in Fire Temple was spawned.");
- return super.onSpawn(npc);
- }
- @Override
- public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
- {
- //if (!((L2RaidBossInstance) npc).getAggroList().containsKey(caster))
- // return "";
- _playersInRadius.addAll(npc.getKnownList().getKnownCharactersInRadius(1100));
- switch (skill.getId())
- {
- case 1553: //Chain heal
- case 1219: //Greater Group Heal
- case 1218: //Greater Battle Heal
- case 1217: //Greater Heal
- if (_healer == null)
- _healer = caster;
- break;
- case 1239: //Hurricane
- case 1230: //Prominence
- case 1148: //Death spike
- if (_mage == null)
- _mage = caster;
- break;
- }
- return super.onSkillSee(npc, caster, skill, targets, isPet);
- }
- @Override
- public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isPet)
- {
- if (npc.getNpcId() >= 1000000 && npc.getNpcId() <= 1000004)
- {
- if (getClassType(player) == ClassType.Healer)
- _healersCount++;
- }
- return super.onAggroRangeEnter(npc, player, isPet);
- }
- private void respawn()
- {
- _currentSpawn.deleteMe();
- _currentSpawnLoc = Rnd.get(0, _spawns.length - 1);
- _currentSpawn = addSpawn(_RBs[Rnd.get(_RBs.length)], _spawns[_currentSpawnLoc][0], _spawns[_currentSpawnLoc][1], _spawns[_currentSpawnLoc][2], 0, false, 0);
- System.out.println(_spawns[_currentSpawnLoc][0] + "," + _spawns[_currentSpawnLoc][1] + "," + _spawns[_currentSpawnLoc][2]);
- }
- private ClassType getClassType(L2PcInstance player)
- {
- switch (player.getClassId())
- {
- case duelist:
- return ClassType.Fighter;
- case dreadnought:
- return ClassType.Fighter;
- case phoenixKnight:
- return ClassType.Tank;
- case hellKnight:
- return ClassType.Tank;
- case adventurer:
- return ClassType.Dagger;
- case sagittarius:
- return ClassType.Archer;
- case archmage:
- return ClassType.Mage;
- case soultaker:
- return ClassType.Mage;
- case arcanaLord:
- return ClassType.Summoner;
- case cardinal:
- return ClassType.Healer;
- case hierophant:
- return ClassType.Healer;
- case evaTemplar:
- return ClassType.Tank;
- case swordMuse:
- return ClassType.Enchanter;
- case windRider:
- return ClassType.Dagger;
- case moonlightSentinel:
- return ClassType.Archer;
- case mysticMuse:
- return ClassType.Mage;
- case elementalMaster:
- return ClassType.Summoner;
- case evaSaint:
- return ClassType.Healer;
- case shillienTemplar:
- return ClassType.Tank;
- case spectralDancer:
- return ClassType.Enchanter;
- case ghostHunter:
- return ClassType.Dagger;
- case ghostSentinel:
- return ClassType.Archer;
- case stormScreamer:
- return ClassType.Mage;
- case spectralMaster:
- return ClassType.Summoner;
- case shillienSaint:
- return ClassType.Healer;
- case titan:
- return ClassType.Fighter;
- case grandKhauatari:
- return ClassType.Fighter;
- case overlord:
- return ClassType.Healer;
- case doomcryer:
- return ClassType.Enchanter;
- case fortuneSeeker:
- return ClassType.Fighter;
- case maestro:
- return ClassType.Fighter;
- case doombringer:
- return ClassType.Fighter;
- case maleSoulhound:
- return ClassType.Kamael;
- case femaleSoulhound:
- return ClassType.Kamael;
- case arbalester:
- return ClassType.Kamael;
- case trickster:
- return ClassType.Kamael;
- case judicator:
- return ClassType.Mage;
- }
- return null;
- }
- public static void main(String[] args)
- {
- new customRaidbossFire(-1, "customRaidbossFire", "ai");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement