@Override public String onKill(NpcInstance npc, QuestState st) { if (st.getState() != STARTED) { return null; } int npcId = npc.getNpcId(); long album = st.getQuestItemsCount(COIN_ALBUM); long coin = st.getQuestItemsCount(KAILS_COIN); long clover = st.getQuestItemsCount(CLOVER_COIN); if ((npcId == ANCIENT_GARGOYLE) && (coin == 0)) { if (Rnd.chance(GARGOYLE_CHANCE)) { st.giveItems(KAILS_COIN, 1); if ((album > 0) || (clover > 0)) { st.playSound(SOUND_MIDDLE); } else { st.playSound(SOUND_ITEMGET); } } } else if ((npcId == VEGUS) && ((clover + album) == 0) && (st.getInt("id") != 0)) { if (Rnd.chance(VEGUS_CHANCE)) { st.giveItems(CLOVER_COIN, 1); if (coin > 0) { st.playSound(SOUND_MIDDLE); } else { st.playSound(SOUND_ITEMGET); } } } return null; }
private void sayScreenMessage(Player player) { if (player.isInParty()) { for (Player players : player.getParty().getPartyMembers()) { if (players.isInRange(player, 1000)) { players.sendPacket( new ExShowScreenMessage( Rnd.get(FUCKED_HARNAK), 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true, ExShowScreenMessage.STRING_TYPE, 0, true, 0)); } } } else { player.sendPacket( new ExShowScreenMessage( Rnd.get(FUCKED_HARNAK), 5000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true, ExShowScreenMessage.STRING_TYPE, 0, true, 0)); } }
/** * Method dropAttackable. * * @param attackable NpcInstance * @param killer Player */ public void dropAttackable(NpcInstance attackable, Player killer) { if (killer.isInOlympiadMode() || killer.isCursedWeaponEquipped() || (_cursedWeapons.length == 0) || (killer.getReflection() != ReflectionManager.DEFAULT)) { return; } synchronized (_cursedWeapons) { CursedWeapon[] cursedWeapons = new CursedWeapon[0]; for (CursedWeapon cw : _cursedWeapons) { if (cw.isActive()) { continue; } cursedWeapons = ArrayUtils.add(cursedWeapons, cw); } if (cursedWeapons.length > 0) { CursedWeapon cw = cursedWeapons[Rnd.get(cursedWeapons.length)]; if (Rnd.get(100000000) <= cw.getDropRate()) { cw.create(attackable, killer); } } } }
/** * Method run. * * @see java.lang.Runnable#run() */ @Override public void run() { Functions.npcShout(BlacksmithNpc, mammonText[Rnd.get(mammonText.length)]); final int nextTown = Rnd.get(MAMMON_PRIEST_POINTS.length); PriestNpc.teleToLocation(MAMMON_PRIEST_POINTS[nextTown]); MerchantNpc.teleToLocation(MAMMON_MERCHANT_POINTS[nextTown]); BlacksmithNpc.teleToLocation(MAMMON_BLACKSMITH_POINTS[nextTown]); }
/** * Method onEvtAttacked. * * @param attacker Creature * @param damage int */ @Override public void onEvtAttacked(Creature attacker, int damage) { final NpcInstance actor = getActor(); super.onEvtAttacked(attacker, damage); if ((PositionUtils.calculateDistance(attacker, actor, false) > 300.) && Rnd.chance(0.13)) { addTaskCast(attacker, DRAIN_SKILL); } final Creature target = actor.getAggroList().getMostHated(); if ((target.equals(attacker)) && Rnd.chance(0.3)) { addTaskCast(attacker, DAMAGE_SKILL); } }
/** * Method notifyDead. * * @param killer Creature */ void notifyDead(Creature killer) { if (!Config.ALLOW_DEATH_PENALTY_C5) { return; } if (_hasCharmOfLuck) { _hasCharmOfLuck = false; return; } if ((killer == null) || killer.isPlayable()) { return; } Player player = getPlayer(); if ((player == null) || (player.getLevel() <= 9)) { return; } int karmaBonus = player.getKarma() / Config.ALT_DEATH_PENALTY_C5_KARMA_PENALTY; if (karmaBonus < 0) { karmaBonus = 0; } if (Rnd.chance(Config.ALT_DEATH_PENALTY_C5_CHANCE + karmaBonus)) { addLevel(); } }
/** * Method onEvtClanAttacked. * * @param attacked_member Creature * @param attacker Creature * @param damage int */ @Override protected void onEvtClanAttacked(Creature attacked_member, Creature attacker, int damage) { super.onEvtClanAttacked(attacked_member, attacker, damage); final NpcInstance actor = getActor(); if (_healSkills.length == 0) { return; } if (attacked_member.isDead() || actor.isDead() || (attacked_member.getCurrentHpPercents() > 50)) { return; } int heal_chance = 0; if (attacked_member.getId() == actor.getId()) { heal_chance = (attacked_member.getObjectId() == actor.getObjectId()) ? 100 : 0; } else { heal_chance = (attacked_member.getId() == Orfen_id) ? 90 : 10; } if (Rnd.chance(heal_chance) && canUseSkill(_healSkills[0], attacked_member, -1)) { addTaskAttack(attacked_member, _healSkills[0], 1000000); } }
/** * Method sendOrderToMinions. * * @param actor NpcInstance */ private void sendOrderToMinions(NpcInstance actor) { if (!actor.isInCombat()) { _lastMinionsTargetRef = HardReferences.emptyRef(); return; } final MinionList ml = actor.getMinionList(); if ((ml == null) || !ml.hasMinions()) { _lastMinionsTargetRef = HardReferences.emptyRef(); return; } final long now = System.currentTimeMillis(); if ((_nextOrderTime > now) && (_lastMinionsTargetRef.get() != null)) { final Player old_target = _lastMinionsTargetRef.get(); if ((old_target != null) && !old_target.isAlikeDead()) { for (MinionInstance m : ml.getAliveMinions()) { if (!m.getAI().getAttackTarget().equals(old_target)) { m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, old_target, 10000000); } } return; } } _nextOrderTime = now + 30000; final List<Player> pl = World.getAroundPlayers(actor); if (pl.isEmpty()) { _lastMinionsTargetRef = HardReferences.emptyRef(); return; } final List<Player> alive = new LazyArrayList<>(); for (Player p : pl) { if (!p.isAlikeDead()) { alive.add(p); } } if (alive.isEmpty()) { _lastMinionsTargetRef = HardReferences.emptyRef(); return; } final Player target = alive.get(Rnd.get(alive.size())); _lastMinionsTargetRef = target.getRef(); Functions.npcSay(actor, "You " + target.getName() + "! Attack them!"); for (MinionInstance m : ml.getAliveMinions()) { m.getAggroList().clear(); m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 10000000); } }
/** * Method onEvtDead. * * @param killer Creature */ @Override protected void onEvtDead(Creature killer) { final NpcInstance actor = getActor(); if (Rnd.chance(30)) { Functions.npcSay(actor, "Враги! В�?�?ду враги! В�?е �?�?да, враги зде�?�?!"); } actor.deleteMe(); }
/** * Method onEvtAttacked. * * @param attacker Creature * @param dam int */ @Override public void onEvtAttacked(Creature attacker, int dam) { super.onEvtAttacked(attacker, dam); if (Rnd.chance(10)) { addTaskCast(attacker, ATTACK_SKILL); } }
@Override protected boolean thinkActive() { NpcInstance actor = getActor(); if (Rnd.chance(8)) { Functions.npcSay(actor, NpcString.I_HIT_THINGS_THEY_FALL_DEAD); } return false; }
/** Method onEvtArrived. */ @Override protected void onEvtArrived() { startMoveTask(); if (Rnd.chance(52)) { sayRndMsg(); } super.onEvtArrived(); }
@Override public String onKill(NpcInstance npc, QuestState qs) { if ((qs.getState() != STARTED) || (qs.getQuestItemsCount(ROYAL_MEMBERSHIP) == 0)) { return null; } final int[] droplist = MOBS.get(npc.getId()); qs.rollAndGive(droplist[Rnd.get(droplist.length)], 1, 10); return null; }
/** * Method shuffle. * * @param array Entry<Integer,String>[] */ private static void shuffle(Entry<Integer, String>[] array) { int j; Entry<Integer, String> tmp; for (int i = array.length; i > 1; i--) { j = Rnd.get(i); tmp = array[j]; array[j] = array[i - 1]; array[i - 1] = tmp; } }
/** * Method onEvtScriptEvent. * * @param event String * @param arg1 Object * @param arg2 Object */ @Override protected void onEvtScriptEvent(String event, Object arg1, Object arg2) { super.onEvtScriptEvent(event, arg1, arg2); switch (event) { case "SHOUT_ALL_1": Functions.npcSayInRange( getActor(), 1500, NpcString.valueOf(MESSAGES_1[Rnd.get(MESSAGES_1.length)])); startBattle = true; break; case "SHOUT_ALL_2": Functions.npcSayInRange( getActor(), 1500, NpcString.valueOf(MESSAGES_2[Rnd.get(MESSAGES_2.length)])); break; case "TENTACLE_DIE": diedTentacle++; break; } }
/** * Method roll. * * @param rate double * @return List<RewardItem> */ public List<RewardItem> roll(double rate) { double mult = Math.ceil(rate); List<RewardItem> ret = new ArrayList<>(1); RewardItem t = null; long count; for (int n = 0; n < mult; n++) { if (Rnd.get(RewardList.MAX_CHANCE) <= (_chance * Math.min(rate - n, 1.0))) { if (getMinDrop() >= getMaxDrop()) { count = getMinDrop(); } else { count = Rnd.get(getMinDrop(), getMaxDrop()); } if (t == null) { ret.add(t = new RewardItem(_item.getItemId())); t.count = count; } else { t.count = SafeMath.addAndLimit(t.count, count); } } } return ret; }
/** * Method onEvtSeeSpell. * * @param skill Skill * @param caster Creature */ @Override protected void onEvtSeeSpell(Skill skill, Creature caster) { final NpcInstance actor = getActor(); if (skill.isMagic()) { return; } if (_mobsNotSpawned) { _mobsNotSpawned = false; for (int i = 0; i < MOBS_COUNT; i++) { try { SimpleSpawner sp = new SimpleSpawner(NpcHolder.getInstance().getTemplate(MOBS)); sp.setLoc(Location.findPointToStay(actor, 100, 120)); NpcInstance npc = sp.doSpawn(true); if (caster.isPet() || caster.isServitor()) { npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, caster, Rnd.get(2, 100)); } npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, caster.getPlayer(), Rnd.get(1, 100)); } catch (Exception e) { e.printStackTrace(); } } } }
@Override public String onKill(NpcInstance npc, QuestState st) { int cond = st.getCond(); if ((cond != 1) || (npc == null)) { return null; } if ((ArrayUtils.contains(Mobs, npc.getNpcId())) && (Rnd.chance(50))) { st.giveItems(19496, 1L); } if (st.getQuestItemsCount(19496) >= 45L) { st.setCond(2); } return null; }
/** * Method reduceCurrentHp. * * @param damage double * @param reflectableDamage double * @param attacker Creature * @param skill Skill * @param awake boolean * @param standUp boolean * @param directHp boolean * @param canReflect boolean * @param transferDamage boolean * @param isDot boolean * @param sendMessage boolean */ @Override public void reduceCurrentHp( double damage, double reflectableDamage, Creature attacker, Skill skill, boolean awake, boolean standUp, boolean directHp, boolean canReflect, boolean transferDamage, boolean isDot, boolean sendMessage) { if (_massiveDamage > System.currentTimeMillis()) { damage = 10000; } else if (getCurrentHpPercents() > 50) { if (attacker.isPlayer()) { damage = ((damage / getMaxHp()) / 0.05) * 100; } else { damage = ((damage / getMaxHp()) / 0.05) * 10; } } else if (getCurrentHpPercents() > 30) { if (Rnd.chance(90)) { if (attacker.isPlayer()) { damage = ((damage / getMaxHp()) / 0.05) * 100; } else { damage = ((damage / getMaxHp()) / 0.05) * 10; } } else { _massiveDamage = System.currentTimeMillis() + 5000L; } } else { _massiveDamage = System.currentTimeMillis() + 5000L; } super.reduceCurrentHp( damage, reflectableDamage, attacker, skill, awake, standUp, directHp, canReflect, transferDamage, isDot, sendMessage); }
@Override protected boolean thinkActive() { NpcInstance actor = getActor(); if (Rnd.chance(3)) { switch (actor.getNpcId()) { case 33172: Functions.npcSay(actor, NpcString.THE_ONLY_GOOD_SHILEN_CREATURE_IS_A_DEAD_ONE); break; case 33170: Functions.npcSay(actor, NpcString.GET_BEHIND_ME_GET_BEHIND_ME); break; default: break; } } return startAttack(); }
/** Method runImpl. */ @Override public void runImpl() { final NpcInstance actor = (NpcInstance) getActor(); final Player attacker = _playerRef.get(); if ((attacker == null) || (actor == null)) { return; } for (NpcInstance npc : actor.getAroundNpc(1500, 200)) { if (npc.isSiegeGuard() && Rnd.chance(20)) { npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, attacker, 5000); } } if ((attacker.getCastingSkill() != null) && (attacker.getCastingSkill().getTargetType() == Skill.SkillTargetType.TARGET_HOLY)) { ThreadPoolManager.getInstance().schedule(this, 10000); } }
@Override public String onKill(NpcInstance npc, QuestState st) { int npcId = npc.getNpcId(); int cond = st.getCond(); if (Mobs.contains(npcId)) { if ((cond == 4) && Rnd.chance(99)) { st.giveItems(LostSkullOfElf, 1); st.playSound(SOUND_MIDDLE); st.setCond(5); } } if (npcId == SoulOfWell) { if (cond == 10) { st.setCond(9); st.takeItems(JewelOfAdventurerGreen, -1); st.takeItems(JewelOfAdventurerRed, -1); st.cancelQuestTimer("attack_timer"); } } return null; }
/** Method SpawnMammons. */ public void SpawnMammons() { final int firstTown = Rnd.get(MAMMON_PRIEST_POINTS.length); NpcTemplate template = NpcHolder.getInstance().getTemplate(MAMMON_PRIEST_ID); SimpleSpawner sp = new SimpleSpawner(template); sp.setLoc(MAMMON_PRIEST_POINTS[firstTown]); sp.setAmount(1); sp.setRespawnDelay(0); PriestNpc = sp.doSpawn(true); template = NpcHolder.getInstance().getTemplate(MAMMON_MERCHANT_ID); sp = new SimpleSpawner(template); sp.setLoc(MAMMON_MERCHANT_POINTS[firstTown]); sp.setAmount(1); sp.setRespawnDelay(0); MerchantNpc = sp.doSpawn(true); template = NpcHolder.getInstance().getTemplate(MAMMON_BLACKSMITH_ID); sp = new SimpleSpawner(template); sp.setLoc(MAMMON_BLACKSMITH_POINTS[firstTown]); sp.setAmount(1); sp.setRespawnDelay(0); BlacksmithNpc = sp.doSpawn(true); }
/** * Method thinkActive. * * @return boolean */ @Override protected boolean thinkActive() { final NpcInstance actor = getActor(); if (actor.isDead()) { return true; } if (_def_think) { doTask(); return true; } if ((System.currentTimeMillis() > wait_timeout) && ((current_point > -1) || Rnd.chance(5))) { if (!wait) { switch (current_point) { case 5: wait_timeout = System.currentTimeMillis() + 15000; Functions.npcSay(actor, "The Mother Tree is always so gorgeous!"); wait = true; return true; case 9: wait_timeout = System.currentTimeMillis() + 60000; Functions.npcSay(actor, "Lady Mirabel, may the peace of the lake be with you!"); wait = true; return true; } } wait_timeout = 0; wait = false; current_point++; if (current_point >= points.length) { current_point = 0; } addTaskMove(points[current_point], true); doTask(); return true; } if (randomAnimation()) { return true; } return false; }
/** * Method closeMe. * * @param closer Player * @param autoOpen boolean * @return boolean */ public boolean closeMe(Player closer, boolean autoOpen) { if (isDead()) { return false; } _openLock.lock(); try { if (!setOpen(false)) { return false; } setGeoOpen(false); } finally { _openLock.unlock(); } broadcastStatusUpdate(); if (autoOpen && (getTemplate().getOpenTime() > 0)) { long openDelay = getTemplate().getOpenTime() * 1000L; if (getTemplate().getRandomTime() > 0) { openDelay += Rnd.get(0, getTemplate().getRandomTime()) * 1000L; } scheduleAutoAction(true, openDelay); } getAI().onEvtClose(closer); for (Listener<Creature> l : getListeners().getListeners()) { if (l instanceof OnOpenCloseListener) { ((OnOpenCloseListener) l).onClose(this); } } return true; }
/** Method thinkAttack. */ @Override protected void thinkAttack() { final NpcInstance actor = getActor(); final NpcInstance brother = getBrother(); if (!brother.isDead() && !actor.isInRange(brother, 300)) { actor.altOnMagicUseTimer(getActor(), SkillTable.getInstance().getInfo(6371, 1)); } else { removeInvul(actor); } if ((_spawnTimer + 40000) < System.currentTimeMillis()) { _spawnTimer = System.currentTimeMillis(); final NpcInstance mob = actor .getReflection() .addSpawnWithoutRespawn( _minions[Rnd.get(_minions.length)], Location.findAroundPosition(actor, 300), 0); mob.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, actor.getAggressionTarget(), 1000); } super.thinkAttack(); }
/** Method sayRndMsg. */ private void sayRndMsg() { final NpcInstance actor = getActor(); if (actor == null) { return; } NpcString ns; switch (Rnd.get(6)) { case 1: ns = NpcString.WHEN_YOU_GO_TO_THE_MUSEUM_SPEAK_TO_PANTHEON; break; case 2: ns = NpcString.WHEN_YOU_GO_TO_THE_MUSEUM_SPEAK_TO_PANTHEON; break; case 3: ns = NpcString.WHEN_YOU_GO_TO_THE_MUSEUM_SPEAK_TO_PANTHEON; break; case 4: ns = NpcString.WHEN_YOU_GO_TO_THE_MUSEUM_SPEAK_TO_PANTHEON; break; case 5: ns = NpcString.WHEN_YOU_GO_TO_THE_MUSEUM_SPEAK_TO_PANTHEON; break; default: ns = NpcString.WHEN_YOU_GO_TO_THE_MUSEUM_SPEAK_TO_PANTHEON; break; } Functions.npcSay(actor, ns); }
/** * Method thinkActive. * * @return boolean */ @Override protected boolean thinkActive() { final NpcInstance actor = getActor(); if ((actor == null) || actor.isDead()) { return true; } if (_def_think) { doTask(); return true; } if ((diedTentacle < 3) || (currentPoint > (MOVE_LOC.length - 1))) { final List<Creature> list = World.getAroundCharacters( getActor(), getActor().getAggroRange(), getActor().getAggroRange()); for (Creature target : list) { if ((target != null) && !target.isDead() && Util.contains(ATTACK_IDS, target.getId())) { clearTasks(); actor.setRunning(); addTaskAttack(target); return true; } } if ((currentPoint > (MOVE_LOC.length - 1)) && (currentPoint2 <= (way.length - 1))) { if (loc == null) { loc = new Location( (way[currentPoint2].getX() + Rnd.get(50)) - Rnd.get(50), (way[currentPoint2].getY() + Rnd.get(50)) - Rnd.get(50), (way[currentPoint2].getZ() + Rnd.get(50)) - Rnd.get(50)); } actor.setRunning(); clearTasks(); addTaskMove(loc, true); doTask(); return true; } return false; } else if ((diedTentacle >= 3) && (currentPoint <= (MOVE_LOC.length - 1))) { if (loc == null) { loc = new Location( (MOVE_LOC[currentPoint].getX() + Rnd.get(50)) - Rnd.get(50), (MOVE_LOC[currentPoint].getY() + Rnd.get(50)) - Rnd.get(50), (MOVE_LOC[currentPoint].getZ() + Rnd.get(50)) - Rnd.get(50)); } actor.setRunning(); clearTasks(); addTaskMove(loc, true); doTask(); return true; } return false; }
@Override public String onEvent(String event, QuestState qs, NpcInstance npc) { String htmltext = event; final long amount = qs.getQuestItemsCount(ARTICLES_DEAD_HEROES); final int cond = qs.getCond(); final int level = qs.getPlayer().getLevel(); switch (event) { case "30754-04.htm": if ((level >= 48) && (cond == 0)) { qs.setState(STARTED); qs.setCond(1); qs.playSound(SOUND_ACCEPT); } else { htmltext = "noquest"; qs.exitCurrentQuest(true); } break; case "30754-08.htm": qs.exitCurrentQuest(true); qs.playSound(SOUND_FINISH); break; case "30754-06.htm": if (cond == 1) { if (amount == 0) { htmltext = "30754-06a.htm"; } else { if (Rnd.get((int) (SPECIAL / qs.getRateQuestsReward())) >= amount) { qs.giveItems(ADENA_ID, amount * 60); } else { htmltext = "30754-10.htm"; qs.set("ok", "1"); qs.set("amount", str(amount)); } qs.takeItems(ARTICLES_DEAD_HEROES, -1); } } break; case "30754-11.htm": if (cond == 1) { if (qs.getInt("ok") != 1) { htmltext = "noquest"; } else { int random = Rnd.get(100); qs.setCond(2); qs.unset("ok"); if (random < 25) { htmltext = "30754-12.htm"; qs.giveItems(OLD_KEY, 1); } else if (random < 50) { htmltext = "30754-13.htm"; qs.giveItems(OLD_HILT, 1); } else if (random < 75) { htmltext = "30754-14.htm"; qs.giveItems(OLD_TOTEM, 1); } else { qs.giveItems(CRUCIFIX, 1); } } } break; } return htmltext; }
private boolean rewards(QuestState qs, int npcId) { boolean state = false; final int chance = Rnd.get(100); switch (npcId) { case ORVEN: if (qs.getQuestItemsCount(CRUCIFIX) > 0) { qs.set("mission", "1"); qs.takeItems(CRUCIFIX, -1); state = true; if (chance < 50) { qs.giveItems(1875, 19); } else if (chance < 70) { qs.giveItems(952, 5); } else { qs.giveItems(2437, 1); } } break; case GARVARENTZ: if (qs.getQuestItemsCount(OLD_TOTEM) > 0) { qs.set("mission", "2"); qs.takeItems(OLD_TOTEM, -1); state = true; if (chance < 45) { qs.giveItems(1882, 70); } else if (chance < 95) { qs.giveItems(1881, 50); } else { qs.giveItems(191, 1); } } break; case KAIEN: if (qs.getQuestItemsCount(OLD_HILT) > 0) { qs.set("mission", "3"); qs.takeItems(OLD_HILT, -1); state = true; if (chance < 50) { qs.giveItems(1874, 25); } else if (chance < 75) { qs.giveItems(1887, 10); } else if (chance < 99) { qs.giveItems(951, 1); } else { qs.giveItems(133, 1); } } break; case RODEMAI: if (qs.getQuestItemsCount(OLD_KEY) > 0) { qs.set("mission", "4"); qs.takeItems(OLD_KEY, -1); state = true; if (chance < 40) { qs.giveItems(1879, 55); } else if (chance < 90) { qs.giveItems(951, 1); } else { qs.giveItems(885, 1); } } break; } return state; }