# Simple Fight Cave Wave Generation

## Recommended Posts

I just wrote this in about 20 mins nothing big.

Work it out yourself, I've done the hard part for you :L

[code]

public class FightCaves {

private final static int[] NPCS = new int[]{2734, 2735, 2736, 2737, 2739, 2740, 2741, 2742, 2743, 2744, 2745};

private int wave = 0;
private int[] waveNpcs = new int[] {};

public void generateWave() {
wave++;
int len = waveNpcs.length;
switch(len) {
case 0:
waveNpcs = new int[]{NPCS[0]};
break;
case 1:
if(waveNpcs[0] == 2734)
waveNpcs = new int[]{waveNpcs[0], NPCS[1]};
else if(waveNpcs[0] != NPCS[NPCS.length-1])
waveNpcs = new int[] {waveNpcs[0], NPCS[0]};
else {
return;
}
break;
case 2:
if(waveNpcs[0]+1 == waveNpcs[1])
waveNpcs = new int[]{NPCS[getIndex(waveNpcs[1])+1]};
else if(waveNpcs[1] == 2734)
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], NPCS[getIndex(waveNpcs[1]+1)]};
else
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], NPCS[0]};
break;
case 3:
if(waveNpcs[1]+1 == waveNpcs[2]) {
if(waveNpcs[0] != 2736 && waveNpcs[2] == 2735 && waveNpcs[1] == 2734)
waveNpcs = new int[]{waveNpcs[0], NPCS[getIndex(waveNpcs[2])+1]};
else if(waveNpcs[1]+1 == waveNpcs[2] && waveNpcs[0]+1 == NPCS[getIndex(waveNpcs[2])+2])
waveNpcs = new int[]{waveNpcs[0], NPCS[getIndex(waveNpcs[2])+2]};
else
waveNpcs = new int[]{waveNpcs[0], NPCS[getIndex(waveNpcs[2])+1]};
} else {
if(waveNpcs[2] != 2734)
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], waveNpcs[2], NPCS[0]};
else
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], waveNpcs[2], NPCS[1]};
}
break;
case 4:
if(waveNpcs[2]+1 == waveNpcs[3]) {
if(waveNpcs[1] != 2736 && waveNpcs[3] == 2735 && waveNpcs[2] == 2734)
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], NPCS[getIndex(waveNpcs[3])+1]};
else if(waveNpcs[2]+1 == waveNpcs[3] && waveNpcs[1]+1 == NPCS[getIndex(waveNpcs[3])+2])
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], NPCS[getIndex(waveNpcs[3])+2]};
else
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], NPCS[getIndex(waveNpcs[3])+1]};
} else {
if(waveNpcs[3] != 2734)
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], waveNpcs[2], waveNpcs[3], NPCS[0]};
else
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], waveNpcs[2], waveNpcs[3], NPCS[1]};
}
break;
case 5:
if(waveNpcs[3]+1 == waveNpcs[4]) {
if(waveNpcs[2] != 2736 && waveNpcs[4] == 2735 && waveNpcs[3] == 2734)
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], waveNpcs[2], NPCS[getIndex(waveNpcs[4])+1]};
else if(waveNpcs[3]+1 == waveNpcs[4])
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], waveNpcs[2], NPCS[getIndex(waveNpcs[4])+2]};
} else
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], waveNpcs[2], waveNpcs[3], waveNpcs[4], NPCS[1]};
break;
case 6:
if(waveNpcs[4]+1 == waveNpcs[5])
if(waveNpcs[4]+1 == waveNpcs[5])
waveNpcs = new int[]{waveNpcs[0], waveNpcs[1], waveNpcs[2], waveNpcs[3], NPCS[getIndex(waveNpcs[5])+2]};
break;
}
}

public static int getIndex(int npcId) {
for(int i = 0; i < NPCS.length; i++)
if(NPCS[i] == npcId)
return i;
return -1;
}

public int getWave() {
return wave;
}

}
[/code]

##### Share on other sites
First, Thanks!
Will be using or messing around with it to make something good!

##### Share on other sites
Have you ever tried like a full fight caves? Was wondering how you handled multiple people doing fight caves at the same time?

##### Share on other sites
It's supposed to be done with an instanced map, but most people just cheat and do playerindex*4 for height level. if you do use this make sure the byte for height in the send Map Data packet is between 0-3.

##### Share on other sites
thanks needed this

##### Share on other sites
Jon I got a problem with mine, Like all the spawns work and the waves are generating, but the npcs wont attack back! I've tried spawning them just by a command and they attack back so it's nothing with the packedcombatdefs :s

##### Share on other sites
Ok, for some reason the waves aren't generating for me. I made a command to see if it would start.
[CODE]if(cmd[0].equals("fight")) {
player.getFightCaves().generateWave();
};[/CODE]
I've added few things into player for it. But still wave generation doesn't start.

##### Share on other sites
[quote name='crypted']Ok, for some reason the waves aren't generating for me. I made a command to see if it would start.
[CODE]if(cmd[0].equals("fight")) {
player.getFightCaves().generateWave();
};[/CODE]
I've added few things into player for it. But still wave generation doesn't start.[/QUOTE]

:fp: it generates the npcs to spawn, it doesn't spawn them for you.

×
• Home

• RSPS List

• Clubs