Jump to content

Recommended Posts

Posted (edited)
mini event to let the happy friends! rsrs ^^
 
info:
set //dropmonsters and wait 60secs to start
 
==========================================================
 
go to com.seuprojeto.gameserver.model.event
new DropMonstersEvent.java
package com.l2jdemonniac.gameserver.model.event;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
 
import javolution.util.FastList;
 
import com.l2jdemonniac.Config;
import com.l2jdemonniac.gameserver.datatables.sql.NpcTable;
import com.l2jdemonniac.gameserver.datatables.sql.SpawnTable;
import com.l2jdemonniac.gameserver.model.L2World;
import com.l2jdemonniac.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jdemonniac.gameserver.model.actor.instance.L2PcInstance;
import com.l2jdemonniac.gameserver.model.entity.Announcements;
import com.l2jdemonniac.gameserver.model.spawn.L2Spawn;
import com.l2jdemonniac.gameserver.templates.L2NpcTemplate;
import com.l2jdemonniac.gameserver.thread.ThreadPoolManager;
import com.l2jdemonniac.util.database.L2DatabaseFactory;
import com.l2jdemonniac.util.random.Rnd;
 
/**
 * @author allanalcantara
 *         
 */
 
public class DropMonstersEvent implements Runnable
{
 
public static L2Spawn _mobsSpawn;
public static boolean TownMonsterAtivo = false;
public static int _bossHeading = 0;
@SuppressWarnings("unused")
public List<L2Spawn> _MonsterSpawn = new FastList<L2Spawn>();
 
static int[] mobs={ 21162, 21253, 21184, 21205, 21163, 21254, 21206, 21185, 21255, 21207, 21165, 21186 };
 
 
public void eventomanager()
{
TownMonsterAtivo = true;
Announcements.getInstance().gameAnnouncetoEvents("The event will start at 60 Seconds.");
waitSecs(60);
spawnMonstersEvent();
Announcements.getInstance().gameAnnouncetoEvents("The event will finish in 30 Minutes.");
wait(30);
ThreadPoolManager.getInstance().scheduleGeneral(new unspawnMonstersrun(), 1);
waitSecs(10);
TownMonsterAtivo = false;
Announcements.getInstance().gameAnnouncetoEvents("The event ended.");
}
 
class unspawnMonstersrun implements Runnable
{
@Override
public void run()
{
unspawnMonsters();
}
}
 
private void SpawnMonster1()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
 
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(149013 + Rnd.get(950) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(16694 + Rnd.get(950) - Rnd.get(250) + Rnd.get(140)); // loc y
_mobsSpawn.setLocz(-1541); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
private void SpawnMonster01()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in Aden Castle.");
 
while (valorr < 30)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(145885 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(16830 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(310) + Rnd.get(130)); // loc y
_mobsSpawn.setLocz(-1560); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
private void SpawnMonster2()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
 
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(87054 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(148844 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3061); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
private void SpawnMonster02()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in entrance of Monastery.");
 
while (valorr < 30)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(124109 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(-74952 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(310) + Rnd.get(130)); // loc y
_mobsSpawn.setLocz(-2915); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
private void SpawnMonster3()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
 
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(124860 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(-75504 + Rnd.get(950) + (Rnd.get(20) * 2) - Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-2912); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
private void SpawnMonster03()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in Giran.");
 
while (valorr < 20)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(82732 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(148723 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(310) + Rnd.get(130)); // loc y
_mobsSpawn.setLocz(-3471); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
private void SpawnMonster4()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
 
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(81948 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(147837 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3471); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
private void SpawnMonster04()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in Near the Town of Dion.");
 
while (valorr < 15)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(19023 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(141199 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3340); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
private void SpawnMonster5()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
 
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(20781 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(140355 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3464); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
private void SpawnMonster05()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
 
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in west of gludin, Near the harbor.");
 
while (valorr < 20)
{
_mobsSpawn = new L2Spawn(tmpl);
 
_mobsSpawn.setLocx(-86372 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(150012 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3061); // loc z
 
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
 
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false); 
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
 
valorr++;
 
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
 
public static void waitSecs(int i)
{
try
{
Thread.sleep(i * 1000);
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}
}
 
public static void wait(int i)
{
try
{
Thread.sleep(i * 60000);
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}
}
 
public final List<L2Spawn> getMonsterIds()
{
return _MonsterSpawn;
}
 
public void unspawnMonsters()
{
for (L2Spawn spawn : getMonsterIds())
{
spawn.stopRespawn();
spawn.getLastSpawn().doDie(spawn.getLastSpawn());
}
 
getMonsterIds().clear();
}
 
public void spawnMonstersEvent()
{
int city = Rnd.get(5) + 1;
if (city == 1)
{
SpawnMonster1();
SpawnMonster01();
}
else if (city == 2)
{
SpawnMonster2();
SpawnMonster02();
}
else if (city == 3)
{
SpawnMonster3();
SpawnMonster03();
}
else if (city == 4)
{
SpawnMonster4();
SpawnMonster04();
}
else if (city == 5)
{
SpawnMonster5();
SpawnMonster05();
}
for (L2Spawn spawn : getMonsterIds())
if (spawn != null)
{
spawn.init();
}
}
 
@Override
public void run()
{
if (TownMonsterAtivo == true)
{
return;
}
 
eventomanager();
 
} 
}
 
go com.seuprojeto.gameserver.handler.admincommandhandlers
new AdminDropMonstersEvent.java
package com.l2jdemonniac.gameserver.handler.admincommandhandlers;
 
import com.l2jdemonniac.Config;
import com.l2jdemonniac.gameserver.handler.IAdminCommandHandler;
import com.l2jdemonniac.gameserver.model.actor.instance.L2PcInstance;
import com.l2jdemonniac.gameserver.model.entity.event.DropMonstersEvent;
import com.l2jdemonniac.gameserver.thread.ThreadPoolManager;
 
public class AdminDropMonstersEvent implements IAdminCommandHandler
{
 
public AdminDropMonstersEvent()
{
}
 
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.startsWith("admin_dropmonsters"))
{
ThreadPoolManager.getInstance().scheduleGeneral(new DropMonstersEvent(), 1);
}
return true;
}
 
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
 
private static final String ADMIN_COMMANDS[] =
{
"admin_dropmonsters"
};
 
}
 
dont forget:
 
AdminCommandHandler:
import com.l2jdemonniac.gameserver.handler.admincommandhandlers.AdminRandomFight;
+import com.l2jdemonniac.gameserver.handler.admincommandhandlers.AdminDropMonstersEvent;
======
registerAdminCommandHandler(new AdminRandomFight());
+registerAdminCommandHandler(new AdminDropMonstersEvent());

 

basically its a event where you choose the id of the monsters " make some specials ones or w.e"  setup a spawner, with random spawn " X coordinate - randomly generated number etc.) From what the code states there are 4 different spawner's, and it gets picked at random, so for example if it rolls aden castle, like the coordinates suggests then it will spawn the monsters there, and so on.

People have X amount of time to kill them and get special rewards, then after that X amount of time mobs disappear and then you can set the timer or set them manually from the admin commands.

events by me

 
thx, enjoy!
Edited by allanalcantara
Posted

From reading the code, 

 

basically its a event where you choose the id of the monsters " make some specials ones or w.e"  setup a spawner, with random spawn " X coordinate - randomly generated number etc.) From what the code states there are 4 different spawner's, and it gets picked at random, so for example if it rolls aden castle, like the coordinates suggests then it will spawn the monsters there, and so on.

 

People have X amount of time to kill them and get special rewards, then after that X amount of time mobs disappear and then you can set the timer or set them manually from the admin commands.

Posted

Maybe you could add a description ?

What the hell is that event .. ?!

¬¬'

 

From reading the code, 

 

basically its a event where you choose the id of the monsters " make some specials ones or w.e"  setup a spawner, with random spawn " X coordinate - randomly generated number etc.) From what the code states there are 4 different spawner's, and it gets picked at random, so for example if it rolls aden castle, like the coordinates suggests then it will spawn the monsters there, and so on.

 

People have X amount of time to kill them and get special rewards, then after that X amount of time mobs disappear and then you can set the timer or set them manually from the admin commands.

thx you for informing! :]

  • 4 months later...
Posted (edited)

can you make it for Hi5 please

 

 Revision 6670 server
Revision 10490:DataPack_BETA

 

how and where i need to put  DropMonstersEvent.java

and were i need to put

registerAdminCommandHandler(new AdminDropMonstersEvent());

 

thanks

Edited by Attila
  • 2 weeks later...
  • Vision locked this topic
Guest
This topic is now closed to further replies.


  • Posts

    • First, don't really follow the "main voice", moreover if you consider it an hobby. Simply do what you want, you got only one life so use it as you want. If you make it an hobby, it's exactly like piano, or velo - only practice makes you better.   Secondly, how do you learn things ? It's actually a really important question, since some can simply be scholar, read books (theory) then practice ; and some simply can't read books. I'm the second type, I hated school, I find it boring - my knowledge in Java comes from try-and-fail. You improve your coding style every year or so, I can myself rewrite my own code (which I already considered top-notched) after a while. You always learn something new - even if Java barely evolves. L2J is a fun way to learn programming, it's a giant sandbox where you can edit anything, and I believe it should be taken as it.   My own way of learning was as follow : Add existing customs, no matter what they are : the point is to know main classes used by L2J / customs. L2J is barely Java knowledge ; the true knowledge is to know WHAT to search in WHICH location (what I call, organization). You have to understand than EVERYTHING you think already exists, in a form on another, in the source code. A custom is only the association of the different mechanisms you found "here and there", glued together in a proper goal. Once you know main classes to edit, and the customs you added are compiling fine, the main point is to know WHAT exactly you DID. Try to understand WHY and WHERE you actually copied the code. Third point would be to MANIPULATE the customs you added in order to fit your wish. First edit little values, then logic conditions ; eventually add a new Config, or a new functionality to the custom. Fourth point would be to begin to craft your own ideas. Once again, EVERYTHING already exists, in a form or another. You want a cycled event ? You got Seven Signs main task as exemple. Npc ? Search any type of Npc and figure out what it does. Fifth point would be to understand Java - mostly containers (WHAT and WHERE to use them), variables types and main Java mechanisms (inheritance, static modifier, etc). You should also begin to cut your code into maintainable classes or methods. Java can actually run without optimization, but bigger your ideas, more optimized and well-thought it should be. It's direct saved time in the future, and you would thank yourself doing so. Main tips : ALWAYS use any type of versioning system - GIT or SVN. It allows to save your work, step by step and eventually revert back anytime you want if you terribly messed up. L2J is 80% organization knowledge, and 20% Java knowledge. Basically, if you know WHAT and WHERE to search, if you aren't dumb, it's easy to replicate and re-use things. Cherry on top is to use a already good coded pack to avoid copy-paste crap and get bad habits. Avoid any type of russian or brazilian packs, for exemple - their best ability is to leak someone's else code. Obviously you need some default sense of logic, but Java and programming in general help you to improve it.   Finally, most of your questions could be solved joining related Discord (at least for aCis, I can't speak for others) - from the moment your question was correctly asked (and you seemed to search for the answer). My community (and myself) welcomes newbies, but got some issues with noobies.   The simpliest is to try, fail and repeat until you succeed - it sounds stupid, but that's basically how life works.   PS : about Java ressources, before ChatGPT, it was mostly about stackoverflow website, and site like Baeldung's one. With ChatGPT and alike, you generally double-cross AI output to avoid fucked up answers. Also, care about AI, they are often hallucinating really hard, even today. They can give you complete wrong answer, you tell them they are wrong, and they say "indeed, I suck, sorry - here's a new fucked up answer". You shouldn't 100% rely over AI answer, even if that can give sometimes legit answers, full code or just skeletons of ideas.   PPS : I don't think there are reliable ressources regarding L2J itself, also most of the proposed code decays pretty fast if the source code is actually maintained (at least for aCis). Still, old coded customs for old aCis sources are actually a good beginner challenge to apply on latest source.
    • Add prices please.
    • WTS: - AQ - Baium - Zaken  - Frintezza - Vesper Fighter Focus Fire Element   pm for detalis
    • We have the best price! L2Reborn.org Signature x1 Franz NEW!! 1KK = $20 HURRY TO BUY AT THE TOP PRICE discord - adver745645
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock