Ir para conteúdo
  • Cadastre-se

[AI] [FREYA] Summon Minion (Mob que sumonam outros, Custom)


Seifer Almasy®

Posts recomendados

é mais simples do que parece... a parada é no arquivo SummonMinions.java localizado na pasta gameserver\data\scripts\ai\group_template

 

/*

* 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 <

O conteúdo está oculto, favor efetuar login ou se cadastrar!

*/

package ai.group_template;

 

import gnu.trove.TIntHashSet;

import gnu.trove.TIntObjectHashMap;

import javolution.util.FastList;

import javolution.util.FastMap;

 

import com.l2jserver.gameserver.ai.CtrlIntention;

import com.l2jserver.gameserver.model.actor.L2Attackable;

import com.l2jserver.gameserver.model.actor.L2Npc;

import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

import com.l2jserver.gameserver.network.serverpackets.NpcSay;

import com.l2jserver.util.Rnd;

 

public class SummonMinions extends L2AttackableAIScript

{

private static int HasSpawned;

private static TIntHashSet myTrackingSet = new TIntHashSet(); //Used to track instances of npcs

private FastMap<Integer, FastList<L2PcInstance>> _attackersList = new FastMap<Integer, FastList<L2PcInstance>>().shared();

private static final TIntObjectHashMap<int[]> MINIONS = new TIntObjectHashMap<int[]>();

 

static

{

MINIONS.put(20767,new int[]{20768,20769,20770}); //Timak Orc Troop

//MINIONS.put(22030,new Integer[]{22045,22047,22048}); //Ragna Orc Shaman

//MINIONS.put(22032,new Integer[]{22036}); //Ragna Orc Warrior - summons shaman but not 22030 ><

//MINIONS.put(22038,new Integer[]{22037}); //Ragna Orc Hero

MINIONS.put(21524,new int[]{21525}); //Blade of Splendor

MINIONS.put(21531,new int[]{21658}); //Punishment of Splendor

MINIONS.put(21539,new int[]{21540}); //Wailing of Splendor

MINIONS.put(22257,new int[]{18364,18364}); //Island Guardian

MINIONS.put(22258,new int[]{18364,18364}); //White Sand Mirage

MINIONS.put(22259,new int[]{18364,18364}); //Muddy Coral

MINIONS.put(22260,new int[]{18364,18364}); //Kleopora

MINIONS.put(22261,new int[]{18365,18365}); //Seychelles

MINIONS.put(22262,new int[]{18365,18365}); //Naiad

MINIONS.put(22263,new int[]{18365,18365}); //Sonneratia

MINIONS.put(22264,new int[]{18366,18366}); //Castalia

MINIONS.put(22265,new int[]{18366,18366}); //Chrysocolla

MINIONS.put(22266,new int[]{18366,18366}); //Pythia

MINIONS.put(22774,new int[]{22768,22768}); //Tanta Lizardman Summoner

MINIONS.put(22795,new int[]{22796,22797,22798,22799,22800}); //Meu edit para area farm (custom)

}

 

public SummonMinions(int questId, String name, String descr)

{

super(questId, name, descr);

int[] temp =

{

20767, 21524, 21531, 21539, 22257, 22258, 22259, 22260, 22261, 22262, 22263, 22264, 22265, 22266, 22774, 22795

};

this.registerMobs(temp, QuestEventType.ON_ATTACK, QuestEventType.ON_KILL);

}

 

@Override

public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)

{

int npcId = npc.getNpcId();

int npcObjId = npc.getObjectId();

if (MINIONS.containsKey(npcId))

{

if (!myTrackingSet.contains(npcObjId)) //this allows to handle multiple instances of npc

{

synchronized (myTrackingSet)

{

myTrackingSet.add(npcObjId);

}

 

HasSpawned = npcObjId;

}

if (HasSpawned == npcObjId)

{

switch (npcId)

{

case 22030: //mobs that summon minions only on certain hp

case 22032:

case 22038:

case 22795:

{

if (npc.getCurrentHp() < (npc.getMaxHp() / 2.0))

{

HasSpawned = 0;

if (Rnd.get(50) < 100) //mobs that summon minions only on certain chance

{

int[] minions = MINIONS.get(npcId);

for (int val : minions)

{

L2Attackable newNpc = (L2Attackable) this.addSpawn(val,

 

(npc.getX() + Rnd.get(-150, 150)), (npc.getY() + Rnd.get(-150, 150)), npc.getZ(), 0, false, 0);

newNpc.setRunning();

newNpc.addDamageHate(attacker, 0, 999);

newNpc.getAI().setIntention

 

(CtrlIntention.AI_INTENTION_ATTACK, attacker);

}

minions = null;

}

npc.broadcastPacket(new NpcSay(npcObjId, 0, npcId, "Ta pensando que vai ser facil é? tenho

 

uma surpresinha pra você!!!"));

}

 

break;

}

case 22257:

case 22258:

case 22259:

case 22260:

case 22261:

case 22262:

case 22263:

case 22264:

case 22265:

case 22266:

{

if (isPet)

attacker = (attacker).getPet().getOwner();

if (attacker.getParty() != null)

{

for (L2PcInstance member : attacker.getParty().getPartyMembers())

{

if (_attackersList.get(npcObjId) == null)

{

FastList<L2PcInstance> player = new FastList<L2PcInstance>();

player.add(member);

_attackersList.put(npcObjId,player);

}

else if (!_attackersList.get(npcObjId).contains(member))

_attackersList.get(npcObjId).add(member);

}

}

else

{

if (_attackersList.get(npcObjId) == null)

{

FastList<L2PcInstance> player = new FastList<L2PcInstance>();

player.add(attacker);

_attackersList.put(npcObjId,player);

}

else if (!_attackersList.get(npcObjId).contains(attacker))

_attackersList.get(npcObjId).add(attacker);

}

if ((attacker.getParty() != null && attacker.getParty().getMemberCount() > 2)||_attackersList.get

 

(npcObjId).size() > 2) //Just to make sure..

{

HasSpawned = 0;

for (int val : MINIONS.get(npcId))

{

L2Attackable newNpc = (L2Attackable) this.addSpawn(val, npc.getX() +

 

Rnd.get(-150, 150), npc.getY() + Rnd.get(-150, 150), npc.getZ(), 0, false, 0);

newNpc.setRunning();

newNpc.addDamageHate(attacker, 0, 999);

newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK,

 

attacker);

}

}

break;

}

default: //mobs without special conditions

{

HasSpawned = 0;

if (npcId != 20767)

{

for (int val : MINIONS.get(npcId))

{

L2Attackable newNpc = (L2Attackable) this.addSpawn(val, npc.getX() +

 

Rnd.get(-150, 150), npc.getY() + Rnd.get(-150, 150), npc.getZ(), 0, false, 0);

newNpc.setRunning();

newNpc.addDamageHate(attacker, 0, 999);

newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK,

 

attacker);

}

}

else

{

for (int val : MINIONS.get(npcId))

{

this.addSpawn(val, (npc.getX() + Rnd.get(-100, 100)), (npc.getY() +

 

Rnd.get(-100, 100)), npc.getZ(), 0, false, 0);

}

}

if (npcId == 20767)

{

npc.broadcastPacket(new NpcSay(npcObjId, 0, npcId, "Come out, you children of

 

darkness!"));

}

if (npcId == 22795)

{

npc.broadcastPacket(new NpcSay(npcObjId, 0, npcId, "Ta pensando que vai ser facil

 

é? tenho uma surpresinha pra você!!!"));

}

break;

}

}

}

}

return super.onAttack(npc, attacker, damage, isPet);

}

 

@Override

public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)

{

int npcId = npc.getNpcId();

int npcObjId = npc.getObjectId();

if (MINIONS.containsKey(npcId))

{

synchronized (myTrackingSet)

{

myTrackingSet.remove(npcObjId);

}

}

if (_attackersList.get(npcObjId) != null)

{

_attackersList.get(npcObjId).clear();

}

return super.onKill(npc, killer, isPet);

}

 

public static void main(String[] args)

{

// now call the constructor (starts up the ai)

new SummonMinions(-1, "SummonMinions", "ai");

}

}

 

o texto em preto é o default, normal do arquivo, o texto em vermelho são as modificações feitas, nada complicado, só ver que eu apenas adicionei dados, não criei nenhum tipo de função ou adicionei nenhuma função também, só edição mesmo, outra edição é em if (Rnd.get(100) < 33) que eu mudei pra if (Rnd.get(50) < 100) pra sumonar de qualquer forma, quando o life chega em 50%, chegou em 50% ele fala alguma asneira (aparece no chat) e os mobs aparecem

 

feito de forma correta, o mob que você sumonar, (vide primeira edição em vermelho) após apanhar um pouco, vai sumonar outros (quantos voce quiser, só separar por virgula)

 

PROBLEMA: Todos os mobs afetados por essa AI no caso dessa condição (life 50%) vão ser afetados junto

 

Espero que seja de ajuda pra quem gosta de fazer areas farm ou instances custom

 

^^

Editado por Seifer Almasy®

EM BREVE - GALAGARD.COM.BR

SERVIDOR Grand Crusade - 50x

SERVIDOR Classic - 8x

Link para o comentário
Compartilhar em outros sites


Ja fiz algo semelhante em Python..

Pra summonar de qualquer forma, use isto:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

 

Ao invés do que você disse, pois você está gerando um numero aleatório que não será usado para nada.

"In a way, the supernatural is what's behind the curtain. Normally, you only need to see what's happening on stage. That's how reality works. If you don't know then it's for the best. Actually, learning about the supernatural only increases the number of things you don't know."'

Link para o comentário
Compartilhar em outros sites

po legal rsrs

bem interessante

 

Aquele que aprendeu e reviveu aqui na l2jbrasil

Faço muitos trabalhos para esta comunidade, assim como tambem ajudo aos que precisão.

A VIDA E UMA CAIXINHA DE SUPRESAS, NAO DEIXE PARA DEPOIS O QUE PODES FAZER AGORA!

 

Link para o comentário
Compartilhar em outros sites

Ja fiz algo semelhante em Python..

Pra summonar de qualquer forma, use isto:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

 

Ao invés do que você disse, pois você está gerando um numero aleatório que não será usado para nada.

sim, eu sei mas o problema era acompanhar o life em 50% mesmo, porque o script também trabalha com "chance", desse jeito que postei ficou certinho ^^ metade do life aparece os bicho

Editado por Seifer Almasy®

EM BREVE - GALAGARD.COM.BR

SERVIDOR Grand Crusade - 50x

SERVIDOR Classic - 8x

Link para o comentário
Compartilhar em outros sites

  • 2 years later...

Só postando pra avisar que nas revisões novas do l2jserver esse arquivo não existe mais, foi incorporado parece no core essas funções, talvez estendendo elas de pra usar, mas não fiz e não pretendo mexer nisso tão já

EM BREVE - GALAGARD.COM.BR

SERVIDOR Grand Crusade - 50x

SERVIDOR Classic - 8x

Link para o comentário
Compartilhar em outros sites





×
×
  • Criar Novo...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.