Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.sf.l2j.gameserver.scripting.script.ai.group;
- import java.util.HashMap;
- import java.util.Map;
- import net.sf.l2j.commons.random.Rnd;
- import net.sf.l2j.gameserver.enums.ScriptEventType;
- import net.sf.l2j.gameserver.model.actor.Creature;
- import net.sf.l2j.gameserver.model.actor.Npc;
- import net.sf.l2j.gameserver.scripting.script.ai.AttackableAIScript;
- import net.sf.l2j.gameserver.skills.L2Skill;
- public class AntGuardPolymorphing extends AttackableAIScript
- {
- private static final Map<Integer, Integer[]> MOBSPAWNS = new HashMap<>();
- static
- {
- MOBSPAWNS.put(40000, new Integer[]
- {
- 40001,
- 50,
- 100,
- 0
- });
- MOBSPAWNS.put(40001, new Integer[]
- {
- 40002,
- 50,
- 100,
- 1
- });
- MOBSPAWNS.put(40002, new Integer[]
- {
- 40003,
- 50,
- 100,
- 2
- });
- }
- private static final String[][] MOBTEXTS =
- {
- new String[]
- {
- "Don't think it will be that easy!"
- },
- new String[]
- {
- "Not bad.. but now you don't stand a chance!"
- },
- new String[]
- {
- "You're quite a fighter, but you're done!"
- }
- };
- public AntGuardPolymorphing()
- {
- super("ai/group");
- }
- @Override
- protected void registerNpcs()
- {
- addEventIds(MOBSPAWNS.keySet(), ScriptEventType.ON_ATTACK);
- }
- @Override
- public String onAttack(Npc npc, Creature attacker, int damage, L2Skill skill)
- {
- if (npc.isVisible() && !npc.isDead())
- {
- final Integer[] tmp = MOBSPAWNS.get(npc.getNpcId());
- if (tmp != null)
- {
- if (npc.getStatus().getHpRatio() * 100 <= tmp[1] && Rnd.get(100) < tmp[2])
- {
- if (tmp[3] >= 0)
- npc.broadcastNpcSay(Rnd.get(MOBTEXTS[tmp[3]]));
- final Npc newNpc = addSpawn(tmp[0], npc, false, 0, false);
- newNpc.forceAttack(attacker, 200);
- npc.deleteMe();
- }
- }
- }
- return super.onAttack(npc, attacker, damage, skill);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment