-
[Help] "x" number of mobs spawner, then another "x" number of mobs spawned
How would i go about summoning a group of Mobs and after a period of time, let stay 1 minutes, its spawns another group of mobs and so on..
For example
- On entry map, it begins the quest.
- Each round takes 45 seconds.
- Each round spawns up to 10 mobs and will increase every round it advances.
- When that 45 seconds runs out , the New group of mobs will be spawned as well as the mobs that haven 't been killed from the first round. AND the timer resets and starts back at 45Seconds.
HOw do i go about implementing that? Spoon feed please (:
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
use a timer or something to trigger the spawn
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
For example
- On entry map, it begins the quest.
- Each round takes 45 seconds.
- Each round spawns up to 10 mobs and will increase every round it advances.
- When that 45 seconds runs out , the New group of mobs will be spawned as well as the mobs that haven 't been killed from the first round. AND the timer resets and starts back at 45Seconds.
HOw do i go about implementing that? Spoon feed please (:
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
(I'm reffering to MoopleDEV here, some stuff may change if you're using a different source.
Go to MapleMap.java. At the top, at the variables, add this:
Code:
private int eventSpawnTime = 45000;
private boolean eventSpawn = false;
Find this:
Code:
if (mapid == 923010000 && getMonsterById(9300102) == null) { // Kenta's Mount Quest
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300102), new Point(77, 426));
After this, add this:
Code:
} else if (mapid == ID_HERE) { // Spawn monster event.
if (!eventSpawn) {
chr.dropMessage(6, "[Event] The event has started! A group of monsters will spawn every 45 seconds and will increase overtime!");
startEventSpawn();
eventSpawn = true;
}
To remove the event, we will just remove it when the player exists the map through a portal, so, find this:
Code:
characters.remove(chr);
Add this, after:
Code:
if (chr.getMap() == ID_HERE)
TimerManager.getInstance().stop();
eventSpawn = false;
After that, add this function to that same file. This function will spawn any monster you want every (time you set, 45 seconds) and will increase that time after every execution.
Code:
public void startSpawnEvent() {
TimerManager.getInstance().register(new Runnable() {
public void run() {
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300102), new Point(CHANGE_X, CHANGE_Y)); // The monster that it will spawn on x, y that you choose. You can also use array and for loop for some monsters.
if (spawnTime != 45000)
spawnTime += 5000; // Change here for the increment each spawn. It will increase it by 5 every spawn.
}
}, spawnTime);
}
Have fun..
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
I have a few questions.
1. How do i add this part in. I've tried many ways but keep getting errors.
PHP Code:
if (chr.getMap() == ID_HERE)
TimerManager.getInstance().stop();
eventSpawn = false;
into
PHP Code:
public void removePlayer(MapleCharacter chr) {
characterlock.writeLock().lock();
try {
characters.remove(chr);
} finally {
characterlock.writeLock().unlock();
}
removeMapObject(Integer.valueOf(chr.getObjectId()));
broadcastMessage(MaplePacketCreator.removePlayerFromMap(chr.getId()));
for (MapleMonster monster : chr.getControlledMonsters()) {
monster.setController(null);
monster.setControllerHasAggro(false);
monster.setControllerKnowsAboutAggro(false);
updateMonsterController(monster);
}
chr.leaveMap();
chr.cancelMapTimeLimitTask();
for (MapleSummon summon : chr.getSummons().values()) {
if (summon.isStationary()) {
chr.cancelBuffStats(MapleBuffStat.PUPPET);
} else {
removeMapObject(summon);
}
}
}
2. Shouldn't "startEventSpawn();" have a function " public void startEventSpawn() {"
rather than "public void startSpawnEvent() {"
3. Change_X and Change_Y is just the coordinates of the placement of the mob right?
4. How do i change the amount of Mobs that spawn
5. Should there be a "private long spawnTime;" at the top in the variable?
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
Quote:
Originally Posted by
natkemon
I have a few questions.
1. How do i add this part in. I've tried many ways but keep getting errors.
PHP Code:
if (chr.getMap() == ID_HERE)
TimerManager.getInstance().stop();
eventSpawn = false;
into
PHP Code:
public void removePlayer(MapleCharacter chr) {
characterlock.writeLock().lock();
try {
characters.remove(chr);
} finally {
characterlock.writeLock().unlock();
}
removeMapObject(Integer.valueOf(chr.getObjectId()));
broadcastMessage(MaplePacketCreator.removePlayerFromMap(chr.getId()));
for (MapleMonster monster : chr.getControlledMonsters()) {
monster.setController(null);
monster.setControllerHasAggro(false);
monster.setControllerKnowsAboutAggro(false);
updateMonsterController(monster);
}
chr.leaveMap();
chr.cancelMapTimeLimitTask();
for (MapleSummon summon : chr.getSummons().values()) {
if (summon.isStationary()) {
chr.cancelBuffStats(MapleBuffStat.PUPPET);
} else {
removeMapObject(summon);
}
}
}
2. Shouldn't "startEventSpawn();" have a function " public void startEventSpawn() {"
rather than "public void startSpawnEvent() {"
3. Change_X and Change_Y is just the coordinates of the placement of the mob right?
4. How do i change the amount of Mobs that spawn
5. Should there be a "private long spawnTime;" at the top in the variable?
1. Please post the errors you're getting, also, change it to this, I forgot something:
Code:
if (mapid == ID_HERE) {
TimerManager.getInstance().stop();
eventSpawn = false;
2. Yes, that's true, my bad. I wrote it before I even coded the function, haha. So yes, change it to startEventSpawn() {.
3. Yes, those are the coordinates of the placement of the mob. You can also use the player's coordinates!
4. I have a better idea, actually. Change the whole "startEventSpawn() {" command to this:
Code:
public void startEventSpawn() {
int spawnAmount = 5;
int spawnTo = (int) spawnAmount + ((Math.random() * 10) + 1);
TimerManager.getInstance().register(new Runnable() {
public void run() {
for (int i=0; i<spawnTo; i++)
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(MONSTER_ID), new Point(CHANGE_X, CHANGE_Y)); // The monster that it will spawn on x, y that you choose. You can also use array and for loop for some monsters.
if (spawnTime != 45000)
spawnTime += 5000; // Change here for the increment each spawn. It will increase it by 5 every spawn.
spawnAmount += 3;
}
}, spawnTime);
}
Explanation: Now, when the function executes, it will generate a random number between 1 to 10 and add 5 to it. For example, if you get 3, it will be 8 monsters to spawn. Then, in the next round, it will increase the regular spawn amount by 3 and generate another number. So if you get 5 this time, it will 5 + 8 = 13 monsters.
Meaning, each round, it will generate more and more mobs and will increase (or decrease, in some cases) the amount.
5. And again, yes, sorry, my bad, change it to long. Integer can hold values from -32768 to 32767, and long is for more.
EDIT: To spawn it on the player, use this:
[/CODE]
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(MONSTER_ID), new Point(chr.getPosition().x, chr.getPosition().y))
[/CODE]
If you want it a bit far from the player, just add like 20 to the X position or more.
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
You've been a great help thanks. Though, I have 6 errors.
The first one i added "if (chr.getMap() == 222010401) {" this to this function like that below :S
**EDIT Ignore the 1st error. I fixed it. its getMapId() rather than getMap()
PHP Code:
public void removePlayer(MapleCharacter chr) {
characterlock.writeLock().lock();
try {
characters.remove(chr);
if (chr.getMap() == 222010401) {
TimerManager.getInstance().stop();
eventSpawn = false;
}
} finally {
characterlock.writeLock().unlock();
}
removeMapObject(Integer.valueOf(chr.getObjectId()));
broadcastMessage(MaplePacketCreator.removePlayerFromMap(chr.getId()));
for (MapleMonster monster : chr.getControlledMonsters()) {
monster.setController(null);
monster.setControllerHasAggro(false);
monster.setControllerKnowsAboutAggro(false);
updateMonsterController(monster);
}
chr.leaveMap();
chr.cancelMapTimeLimitTask();
for (MapleSummon summon : chr.getSummons().values()) {
if (summon.isStationary()) {
chr.cancelBuffStats(MapleBuffStat.PUPPET);
} else {
removeMapObject(summon);
}
}
}
Code:
init:
deps-jar:
Compiling 2 source files to C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\build\classes
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1457: incomparable types: server.maps.MapleMap and int
if (chr.getMap() == 222010401) {
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1485: possible loss of precision
found : double
required: int
int spawnTo = (int) spawnAmount + ((Math.random() * 10) + 1);
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1488: local variable spawnTo is accessed from within inner class; needs to be declared final
for (int i=0; i<spawnTo; i++)
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1489: cannot find symbol
symbol: variable chr
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(5130108), new Point(chr.getPosition().x, chr.getPosition().y)); // The monster that it will spawn on x, y that you choose. You can also use array and for loop for some monsters.
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1489: cannot find symbol
symbol: variable chr
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(5130108), new Point(chr.getPosition().x, chr.getPosition().y)); // The monster that it will spawn on x, y that you choose. You can also use array and for loop for some monsters.
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1492: local variable spawnAmount is accessed from within inner class; needs to be declared final
spawnAmount += 3;
6 errors
BUILD FAILED (total time: 0 seconds)
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
For the "cannot find symbol: variable chr", try changing chr to player, I don't know the variable it is in MapleMap (I'm reffering to the StartEventSpawn function).
For the others, change it to this:
Code:
public void removePlayer(MapleCharacter chr) {
if (chr.getMap() == 222010401)
stopEventSpawn();
characterlock.writeLock().lock();
try {
characters.remove(chr);
} finally {
characterlock.writeLock().unlock();
}
removeMapObject(Integer.valueOf(chr.getObjectId()));
broadcastMessage(MaplePacketCreator.removePlayerFromMap(chr.getId()));
for (MapleMonster monster : chr.getControlledMonsters()) {
monster.setController(null);
monster.setControllerHasAggro(false);
monster.setControllerKnowsAboutAggro(false);
updateMonsterController(monster);
}
chr.leaveMap();
chr.cancelMapTimeLimitTask();
for (MapleSummon summon : chr.getSummons().values()) {
if (summon.isStationary()) {
chr.cancelBuffStats(MapleBuffStat.PUPPET);
} else {
removeMapObject(summon);
}
}
}
And also, add this function:
(Just to be more organized..).
Code:
public void stopEventSpawn() {
TimerManager.getInstance().stop();
eventSpawn = false;
}
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
This are the variables. I can't seem to find the right one. :S
PHP Code:
private static final List<MapleMapObjectType> rangedMapobjectTypes = Arrays.asList(MapleMapObjectType.SHOP, MapleMapObjectType.ITEM, MapleMapObjectType.NPC, MapleMapObjectType.MONSTER, MapleMapObjectType.DOOR, MapleMapObjectType.SUMMON, MapleMapObjectType.REACTOR);
private Map<Integer, MapleMapObject> mapobjects = new LinkedHashMap<Integer, MapleMapObject>();
private Collection<SpawnPoint> monsterSpawn = new LinkedList<SpawnPoint>();
private AtomicInteger spawnedMonstersOnMap = new AtomicInteger(0);
private Collection<MapleCharacter> characters = new LinkedHashSet<MapleCharacter>();
private Map<Integer, MaplePortal> portals = new HashMap<Integer, MaplePortal>();
private List<Rectangle> areas = new ArrayList<Rectangle>();
private MapleFootholdTree footholds = null;
private int mapid;
private int runningOid = 30000;
private int returnMapId;
private int channel;
private float monsterRate;
private boolean clock;
private boolean boat;
private boolean docked;
private String mapName;
private String streetName;
private MapleMapEffect mapEffect = null;
private boolean everlast = false;
private int forcedReturnMap = 999999999;
private int timeLimit;
private int dropLife = 180000;
private int decHP = 0;
private int protectItem = 0;
private boolean town;
private MapleOxQuiz ox;
private boolean isOxQuiz = false;
private boolean dropsOn = true;
private String onFirstUserEnter;
private String onUserEnter;
private int dropRate;
private int bossDropRate;
private int fieldType;
private int timeMobId;
private String timeMobMessage = "";
private int fieldLimit = 0;
private MapleSquad mapleSquad = null;
public ScheduledFuture respawnTask;
// Threading - allows for better performance (and deadlock prevention) than synchronized methods
private ReentrantReadWriteLock objectlock = new ReentrantReadWriteLock(true);
private ReentrantReadWriteLock characterlock = new ReentrantReadWriteLock(true);
// HPQ
private int riceCakeNum = 0; // bad place to put this
int randhum = MapleCharacter.rand(1,5);
private MapleMapTimer mapTimer = null;
private int eventSpawnTime = 45000;
private boolean eventSpawn = false;
private long spawnTime;
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
Why, are you still getting errors?
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
I have no idea :S
PHP Code:
public void startEventSpawn() {
int spawnAmount = 5;
int spawnTo = (int) spawnAmount + ((Math.random() * 10) + 1);
TimerManager.getInstance().register(new Runnable() {
public void run() {
for (int i=0; i<spawnTo; i++)
spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(222010401), new Point(220, 115)); // The monster that it will spawn on x, y that you choose. You can also use array and for loop for some monsters.
if (spawnTime != 45000)
spawnTime += 5000; // Change here for the increment each spawn. It will increase it by 5 every spawn.
spawnAmount += 3;
}
}, spawnTime);
}
Code:
init:
deps-jar:
Compiling 3 source files to C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\build\classes
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1483: possible loss of precision
found : double
required: int
int spawnTo = (int) spawnAmount + ((Math.random() * 10) + 1);
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1486: local variable spawnTo is accessed from within inner class; needs to be declared final
for (int i=0; i<spawnTo; i++)
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1490: local variable spawnAmount is accessed from within inner class; needs to be declared final
spawnAmount += 3;
3 errors
BUILD FAILED (total time: 0 seconds)
spawnAmount += 3; << whats does that mean?
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
spawnAmount += 3 - Adds 3 to the spawnAmount's value. Instead of using spawnAmount = spawnAmount + 3, you can use +=. Same with all the other operators. Read about it more here: http://docs.oracle.com/javase/tutori...operators.html.
For the issue, change it to this:
Code:
int spawnTo = spawnAmount + (int) ((Math.random() * 10) + 1);
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
What do i do here? It keeps telling me that it needs to declare final. Final means that it dosen't let anything override it or something like that?
Code:
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1486: local variable spawnTo is accessed from within inner class; needs to be declared final
for (int i=0; i<spawnTo; i++)
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1490: local variable spawnAmount is accessed from within inner class; needs to be declared final
spawnAmount += 3;
for (int i=0; i<spawnTo; i++) What does this mean?
Fraysa, Please delete some of your private messages. I cannot send you one since your inbox is full.
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
Quote:
Originally Posted by
natkemon
What do i do here? It keeps telling me that it needs to declare final. Final means that it dosen't let anything override it or something like that?
Code:
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1486: local variable spawnTo is accessed from within inner class; needs to be declared final
for (int i=0; i<spawnTo; i++)
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1490: local variable spawnAmount is accessed from within inner class; needs to be declared final
spawnAmount += 3;
for (int i=0; i<spawnTo; i++) What does this mean?
Final means it's final, you can't change it's value. Just change it to final, because we are changing the spawnAmount and not spawnTo.
for (int i=0; i<spawnTo; i++), this means, it creates a new loop, that starts from 0 until spawnTo varaiable. Let's say at the first exceution of the script the spawnAmount was 5, and the spawnTo was 5 + (Randomized) 3. That's 8. That means, the loop will go from 0 to < 8, means smaller than 8 - until 7, and spawn your desired monster 7 times.
The next "round", it will generate a new randomized number for spawnTo, and increase spawnAmount by 3, so it's 8 now. Let's say you got 3 as the randomized number, again. It's 11. So the loop will go from 0 < 11, means 10. It will spawn 10 monsters.
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
That fixes one problem but this is the only problem left. Btw please delete a message in your inbox so i can PM you.
Code:
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1490: local variable spawnAmount is accessed from within inner class; needs to be declared final
spawnAmount += 3;
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
Quote:
Originally Posted by
natkemon
That fixes one problem but this is the only problem left. Btw please delete a message in your inbox so i can PM you.
Code:
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1490: local variable spawnAmount is accessed from within inner class; needs to be declared final
spawnAmount += 3;
Haha, change that to final as well then. Also, I cleared out my inbox, sir! Thanks for informing me.
-
Re: [Help] "x" number of mobs spawner, then another "x" number of mobs spawned
Code:
C:\Documents and Settings\MyStoryMS\Desktop\Maple Blade 1\src\server\maps\MapleMap.java:1490: cannot assign a value to final variable spawnAmount
spawnAmount += 3;
THis is the error when i put final in.
btw your still full
Quote:
Fraysa has exceeded their stored private messages quota and cannot accept further messages until they clear some space.
PM your skype name and we'll talk business.