Hello guys! i have been working on my custom instance, its kamaloka like, but using Tower of insolence, i need help to make "random spawns".
Red letter are the moobs ids declaration and their spawn use, i want to make a list where i declare them and use Random get to spawn. i tried but i failed several times, trust me i spend maaany time on it.
Well here is my full code:
package instances.RaidTower;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.logging.Level;
import com.l2jserver.gameserver.datatables.SkillData;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.L2Spawn;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Instance;
import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public final class RaidTower extends Quest
{
/*
* Reset time for all RaidTower Default: 6:30AM on server time
*/
private static final int RESET_HOUR = 6;
private static final int RESET_MIN = 30;
/*
* Time after which instance without players will be destroyed Default: 5 minutes
*/
private static final int EMPTY_DESTROY_TIME = 5;
/*
* Time to destroy instance (and eject players away) after boss defeat Default: 5 minutes
*/
private static final int EXIT_TIME = 5;
/*
* Maximum level difference between players level and RaidTower level Default: 5
*/
private static final int MAX_LEVEL_DIFFERENCE = 5;
/*
* If true shaman in the first room will have same npcId as other mobs, making radar useless Default: true (but not retail like)
*/
private static final boolean STEALTH_SHAMAN = true;
// Template IDs for RaidTower
// @formatter:off
private static final int[] TEMPLATE_IDS =
{
1000, 1001, 1002, 1003, 1004
};
// Level of the RaidTower
private static final int[] LEVEL =
{
26, 46, 66, 76, 86
};
// Duration of the instance, minutes
private static final int[] DURATION =
{
45, 45, 45, 45, 45
};
// Maximum party size for the instance
private static final int[] MAX_PARTY_SIZE =
{
2, 2, 2, 2, 2
};
/**
* List of buffs NOT removed on enter from player and pet<br>
* On retail only newbie guide buffs not removed<br>
* CAUTION: array must be sorted in ascension order!
*/
protected static final int[] BUFFS_WHITELIST =
{
4322, 4323, 4324, 4325, 4326, 4327, 4328, 4329, 4330, 4331, 5632, 5637, 5950
};
// @formatter:on
// Teleport points into instances x, y, z
private static final Location[] TELEPORTS =
{
new Location(114674, 11458, -5125),
new Location(114674, 11458, -5125),
new Location(114674, 11458, -5125), // -76280, -185540, -10936
new Location(114674, 11458, -5125),
new Location(114674, 11458, -5125),
};
// Respawn delay for the mobs in the first room, seconds Default: 25
private static final int FIRST_ROOM_RESPAWN_DELAY = 25;
/**
* First room information, null if room not spawned.<br>
* Skill is casted on the boss when shaman is defeated and mobs respawn stopped<br>
* Default: 5699 (decrease pdef)<br>
* shaman npcId, minions npcId, skillId, skillLvl
*/
private static final int[][] FIRST_ROOM =
{
{
22485,
22486,
5699,
1
},
{
22485,
22486,
5699,
1
},
{
22485,
22486,
5699,
1
},
{
22485,
22486,
5699,
1
},
{
22485,
22486,
5699,
1
},
};
/*
* First room spawns, null if room not spawned x, y, z
*/
private static final int[][][] FIRST_ROOM_SPAWNS =
{
/* instancia 26 */
{
{
114636,
15532,
-5100
},
{
114711,
15536,
-5100
},
{
114567,
15539,
-5100
},
{
114485,
15700,
-5100
},
{
114638,
15719,
-5100
},
{
112965,
17291,
-4378
},
{
112890,
17380,
-4378
},
{
113096,
17179,
-4378
},
{
112759,
16815,
-4378
}
},
/* instancia 46 */
{
{
114636,
15532,
-5100
},
{
114711,
15536,
-5100
},
{
114567,
15539,
-5100
},
{
114485,
15700,
-5100
},
{
114638,
15719,
-5100
},
{
112965,
17291,
-4378
},
{
112890,
17380,
-4378
},
{
113096,
17179,
-4378
},
{
112759,
16815,
-4378
}
},
/* instancia 66 */
{
{
114636,
15532,
-5100
},
{
114711,
15536,
-5100
},
{
114567,
15539,
-5100
},
{
114485,
15700,
-5100
},
{
114638,
15719,
-5100
},
{
112965,
17291,
-4378
},
{
112890,
17380,
-4378
},
{
113096,
17179,
-4378
},
{
112759,
16815,
-4378
}
},
/* instancia 76 */
{
{
114636,
15532,
-5100
},
{
114711,
15536,
-5100
},
{
114567,
15539,
-5100
},
{
114485,
15700,
-5100
},
{
114638,
15719,
-5100
},
{
112965,
17291,
-4378
},
{
112890,
17380,
-4378
},
{
113096,
17179,
-4378
},
{
112759,
16815,
-4378
}
},
/* instancia 86 */
{
{
114636,
15532,
-5100
},
{
114711,
15536,
-5100
},
{
114567,
15539,
-5100
},
{
114485,
15700,
-5100
},
{
114638,
15719,
-5100
},
{
112965,
17291,
-4378
},
{
112890,
17380,
-4378
},
{
113096,
17179,
-4378
},
{
112759,
16815,
-4378
}
}
};
/*
* Second room information, null if room not spawned Skill is casted on the boss when all mobs are defeated Default: 5700 (decrease mdef) npcId, skillId, skillLvl
*/
private static final int[][] SECOND_ROOM =
{
{
22487,
5700,
1
},
{
22490,
5700,
2
},
{
22493,
5700,
3
},
{
22496,
5700,
4
},
{
22499,
5700,
5
}
};
/*
* Spawns for second room, null if room not spawned x, y, z
*/
private static final int[][][] SECOND_ROOM_SPAWNS =
{
/*instancia 26 */
{
{
114637,
16223,
-2127
},
{
114543,
16083,
-2127
},
{
114833,
16099,
-2127
},
{
114618,
15848,
-2127
},
{
114627,
15637,
-2127
},
{
116230,
14822,
-1414
},
{
116460,
14922,
-1417
},
{
116303,
14973,
-1414
},
{
116598,
15466,
-1414
}
},
/*instancia 46 */
{
{
114637,
16223,
-2127
},
{
114543,
16083,
-2127
},
{
114833,
16099,
-2127
},
{
114618,
15848,
-2127
},
{
114627,
15637,
-2127
},
{
116230,
14822,
-1414
},
{
116460,
14922,
-1417
},
{
116303,
14973,
-1414
},
{
116598,
15466,
-1414
}
},
/*instancia 66 */
{
{
114637,
16223,
-2127
},
{
114543,
16083,
-2127
},
{
114833,
16099,
-2127
},
{
114618,
15848,
-2127
},
{
114627,
15637,
-2127
},
{
116230,
14822,
-1414
},
{
116460,
14922,
-1417
},
{
116303,
14973,
-1414
},
{
116598,
15466,
-1414
}
},
/*instancia 76 */
{
{
114637,
16223,
-2127
},
{
114543,
16083,
-2127
},
{
114833,
16099,
-2127
},
{
114618,
15848,
-2127
},
{
114627,
15637,
-2127
},
{
116230,
14822,
-1414
},
{
116460,
14922,
-1417
},
{
116303,
14973,
-1414
},
{
116598,
15466,
-1414
}
},
/*instancia 86 */
{
{
114637,
16223,
-2127
},
{
114543,
16083,
-2127
},
{
114833,
16099,
-2127
},
{
114618,
15848,
-2127
},
{
114627,
15637,
-2127
},
{
116230,
14822,
-1414
},
{
116460,
14922,
-1417
},
{
116303,
14973,
-1414
},
{
116598,
15466,
-1414
}
}
};
// miniboss info
// skill is casted on the boss when miniboss is defeated
// npcId, x, y, z, skill id, skill level
/*
* Miniboss information, null if miniboss not spawned Skill is casted on the boss when miniboss is defeated Default: 5701 (decrease patk) npcId, x, y, z, skillId, skillLvl
*/
private static final int[][] MINIBOSS =
{
/*intancia 26 */
{
25616,
115376,
16225,
-645,
5701,
1
},
/*intancia 46 */
{
25616,
115376,
16225,
-645,
5701,
1
},
/*intancia 66 */
{
25616,
115376,
16225,
-645,
5701,
1
},
/*intancia 76 */
{
25616,
115376,
16225,
-645,
5701,
1
},
/*intancia 86 */
{
25616,
115376,
16225,
-645,
5701,
1
}
};
/*
* Bosses of the RaidTower Instance ends when boss is defeated npcId, x, y, z
*/
private static final int[][] BOSS =
{
/*intancia 26 */
{
18554,
114671,
16976,
928
},
/*intancia 46 */
{
18555,
114671,
16976,
928
},
/*intancia 66 */
{
29129,
114671,
16976,
928
},
/*intancia 76 */
{
18558,
114671,
16976,
928
},
/*intancia 86 */
{
18559,
114671,
16976,
928
}
};
/*
* Escape telepoters spawns, null if not spawned x, y, z
*/
private static final int[][] TELEPORTERS =
{
/*intancia 26 */
{
114649,
17642,
925
},
/*intancia 46 */
{
114649,
17642,
925
},
/*intancia 66 */
{
114649,
17642,
925
},
/*intancia 76 */
{
114649,
17642,
925
},
/*intancia 86 */
{
114649,
17642,
925
}
};
/*
* Escape teleporter npcId
*/
private static final int TELEPORTER = 80026;
/** RaidTower captains (start npc's) npcIds. */
private static final int[] CAPTAINS =
{
80020,
80021,
80022,
80023,
80024,
80026
};
protected class RaidTowerWorld extends InstanceWorld
{
public int index; // 0-18 index of the Raid type in arrays
public int shaman = 0; // objectId of the shaman
public List<L2Spawn> firstRoom; // list of the spawns in the first room (excluding shaman)
public List<Integer> secondRoom;// list of objectIds mobs in the second room
public int miniBoss = 0; // objectId of the miniboss
public L2Npc boss = null; // boss
}
private RaidTower()
{
super(-1, RaidTower.class.getSimpleName(), "instances");
addFirstTalkId(TELEPORTER);
addTalkId(TELEPORTER);
for (int cap : CAPTAINS)
{
addStartNpc(cap);
addTalkId(cap);
}
for (int[] mob : FIRST_ROOM)
{
if (mob != null)
{
if (STEALTH_SHAMAN)
{
addKillId(mob[1]);
}
else
{
addKillId(mob[0]);
}
}
}
for (int[] mob : SECOND_ROOM)
{
if (mob != null)
{
addKillId(mob[0]);
}
}
for (int[] mob : MINIBOSS)
{
if (mob != null)
{
addKillId(mob[0]);
}
}
for (int[] mob : BOSS)
{
addKillId(mob[0]);
}
}
/**
* Check if party with player as leader allowed to enter
* @param player party leader
* @param index (0-18) index of the RaidTower in arrays
* @return true if party allowed to enter
*/
private static final boolean checkConditions(L2PcInstance player, int index)
{
final L2Party party = player.getParty();
// player must be in party
if (party == null)
{
player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
return false;
}
// ...and be party leader
if (party.getLeader() != player)
{
player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
return false;
}
// party must not exceed max size for selected instance
if (party.getMemberCount() > MAX_PARTY_SIZE[index])
{
player.sendPacket(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER);
return false;
}
// get level of the instance
final int level = LEVEL[index];
// and client name
final String instanceName = InstanceManager.getInstance().getInstanceIdName(TEMPLATE_IDS[index]);
Map<Integer, Long> instanceTimes;
// for each party member
for (L2PcInstance partyMember : party.getMembers())
{
// player level must be in range
if (Math.abs(partyMember.getLevel() - level) > MAX_LEVEL_DIFFERENCE)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
sm.addPcName(partyMember);
player.sendPacket(sm);
return false;
}
// player must be near party leader
if (!partyMember.isInsideRadius(player, 1000, true, true))
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
sm.addPcName(partyMember);
player.sendPacket(sm);
return false;
}
// get instances reenter times for player
instanceTimes = InstanceManager.getInstance().getAllInstanceTimes(partyMember.getObjectId());
if (instanceTimes != null)
{
for (int id : instanceTimes.keySet())
{
// find instance with same name (RaidTower or labyrinth)
// TODO: Zoey76: Don't use instance name, use other system.
if (!instanceName.equals(InstanceManager.getInstance().getInstanceIdName(id)))
{
continue;
}
// if found instance still can't be reentered - exit
if (System.currentTimeMillis() < instanceTimes.get(id))
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET);
sm.addPcName(partyMember);
player.sendPacket(sm);
return false;
}
}
}
}
return true;
}
/**
* Removing all buffs from player and pet except BUFFS_WHITELIST
* @param ch player
*/
private static final void removeBuffs(L2Character ch)
{
Function<BuffInfo, Boolean> removeBuffs = info ->
{
if ((info != null) && !info.getSkill().isStayAfterDeath() && (Arrays.binarySearch(BUFFS_WHITELIST, info.getSkill().getId()) < 0))
{
info.getEffected().getEffectList().stopSkillEffects(true, info.getSkill());
}
return true;
};
ch.getEffectList().forEach(removeBuffs, false);
if (ch.hasSummon())
{
ch.getSummon().getEffectList().forEach(removeBuffs, false);
}
}
/**
* Handling enter of the players into RaidTower
* @param player party leader
* @param index (0-18) RaidTower index in arrays
*/
private final synchronized void enterInstance(L2PcInstance player, int index)
{
int templateId;
try
{
templateId = TEMPLATE_IDS[index];
}
catch (ArrayIndexOutOfBoundsException e)
{
throw e;
}
// check for existing instances for this player
InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
// player already in the instance
if (world != null)
{
// but not in RaidTower
if (!(world instanceof RaidTowerWorld) || (world.getTemplateId() != templateId))
{
player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
return;
}
// check for level difference again on reenter
if (Math.abs(player.getLevel() - LEVEL[((RaidTowerWorld) world).index]) > MAX_LEVEL_DIFFERENCE)
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
sm.addPcName(player);
player.sendPacket(sm);
return;
}
// check what instance still exist
Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
if (inst != null)
{
removeBuffs(player);
teleportPlayer(player, TELEPORTS[index], world.getInstanceId());
}
return;
}
// Creating new RaidTower instance
if (!checkConditions(player, index))
{
return;
}
// Creating dynamic instance without template
final int instanceId = InstanceManager.getInstance().createDynamicInstance(null);
final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
// set name for the RaidTower
inst.setName(InstanceManager.getInstance().getInstanceIdName(templateId));
// set return location
inst.setSpawnLoc(new Location(player));
// disable summon friend into instance
inst.setAllowSummon(false);
// set duration and empty destroy time
inst.setDuration(DURATION[index] * 60000);
inst.setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000);
// Creating new instanceWorld, using our instanceId and templateId
world = new RaidTowerWorld();
world.setInstanceId(instanceId);
world.setTemplateId(templateId);
// set index for easy access to the arrays
((RaidTowerWorld) world).index = index;
InstanceManager.getInstance().addWorld(world);
world.setStatus(0);
// spawn npcs
spawnRaidTower((RaidTowerWorld) world);
// and finally teleport party into instance
final L2Party party = player.getParty();
for (L2PcInstance partyMember : party.getMembers())
{
world.addAllowed(partyMember.getObjectId());
removeBuffs(partyMember);
teleportPlayer(partyMember, TELEPORTS[index], instanceId);
}
return;
}
/**
* Called on instance finish and handles reenter time for instance
* @param world instanceWorld
*/
private static final void finishInstance(InstanceWorld world)
{
if (world instanceof RaidTowerWorld)
{
Calendar reenter = Calendar.getInstance();
reenter.set(Calendar.MINUTE, RESET_MIN);
// if time is >= RESET_HOUR - roll to the next day
if (reenter.get(Calendar.HOUR_OF_DAY) >= RESET_HOUR)
{
reenter.add(Calendar.DATE, 1);
}
reenter.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_RESTRICTED);
sm.addInstanceName(world.getTemplateId());
// set instance reenter time for all allowed players
for (int objectId : world.getAllowed())
{
L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
if ((obj != null) && obj.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
obj.sendPacket(sm);
}
}
// destroy instance after EXIT_TIME
Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
inst.setDuration(EXIT_TIME * 60000);
inst.setEmptyDestroyTime(0);
}
}
/**
* Spawn all NPCs in RaidTower
* @param world instanceWorld
*/
@SuppressWarnings("all")
private final void spawnRaidTower(RaidTowerWorld world)
{
int[] npcs;
int[][] spawns;
L2Npc npc;
final int index = world.index;
// first room
npcs = FIRST_ROOM[index];
spawns = FIRST_ROOM_SPAWNS[index];
if (npcs != null)
{
world.firstRoom = new ArrayList<L2Spawn>(spawns.length - 1);
int shaman = getRandom(spawns.length); // random position for shaman
for (int i = 0; i < spawns.length; i++)
{
if (i == shaman)
{
// stealth shaman use same npcId as other mobs
npc = addSpawn(STEALTH_SHAMAN ? npcs[1] : npcs[0], spawns[i][0], spawns[i][1], spawns[i][2], 0, false, 0, false, world.getInstanceId());
world.shaman = npc.getObjectId();
}
else
{
npc = addSpawn(npcs[1], spawns[i][0], spawns[i][1], spawns[i][2], 0, false, 0, false, world.getInstanceId());
L2Spawn spawn = npc.getSpawn();
spawn.setRespawnDelay(FIRST_ROOM_RESPAWN_DELAY);
spawn.setAmount(1);
spawn.startRespawn();
world.firstRoom.add(spawn); // store mobs spawns
}
npc.setIsNoRndWalk(true);
}
}
// second room
npcs = SECOND_ROOM[index];
spawns = SECOND_ROOM_SPAWNS[index];
if (npcs != null)
{
world.secondRoom = new ArrayList<Integer>(spawns.length);
for (int[] spawn : spawns)
{
npc = addSpawn(npcs[0], spawn[0], spawn[1], spawn[2], 0, false, 0, false, world.getInstanceId());
npc.setIsNoRndWalk(true);
world.secondRoom.add(npc.getObjectId());
}
}
// miniboss
if (MINIBOSS[index] != null)
{
npc = addSpawn(MINIBOSS[index][0], MINIBOSS[index][1], MINIBOSS[index][2], MINIBOSS[index][3], 0, false, 0, false, world.getInstanceId());
npc.setIsNoRndWalk(true);
world.miniBoss = npc.getObjectId();
}
// escape teleporter
if (TELEPORTERS[index] != null)
{
addSpawn(TELEPORTER, TELEPORTERS[index][0], TELEPORTERS[index][1], TELEPORTERS[index][2], 0, false, 0, false, world.getInstanceId());
}
// boss
npc = addSpawn(BOSS[index][0], BOSS[index][1], BOSS[index][2], BOSS[index][3], 0, false, 0, false, world.getInstanceId());
((L2MonsterInstance) npc).setOnKillDelay(100);
world.boss = npc;
}
/**
* Handles only player's enter, single parameter - integer RaidTower index
*/
@Override
public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if (npc == null)
{
return "";
}
try
{
enterInstance(player, Integer.parseInt(event));
}
catch (Exception e)
{
_log.log(Level.WARNING, "", e);
}
return "";
}
/**
* Talk with captains and using of the escape teleporter
*/
@Override
public final String onTalk(L2Npc npc, L2PcInstance player)
{
final int npcId = npc.getId();
if (npcId == TELEPORTER)
{
final L2Party party = player.getParty();
// only party leader can talk with escape teleporter
if ((party != null) && party.isLeader(player))
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (world instanceof RaidTowerWorld)
{
// party members must be in the instance
if (world.isAllowed(player.getObjectId()))
{
Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
// teleports entire party away
for (L2PcInstance partyMember : party.getMembers())
{
if ((partyMember != null) && (partyMember.getInstanceId() == world.getInstanceId()))
{
teleportPlayer(partyMember, inst.getSpawnLoc(), 0);
}
}
}
}
}
}
else
{
return npcId + ".htm";
}
return "";
}
/**
* Only escape teleporters first talk handled
*/
@Override
public final String onFirstTalk(L2Npc npc, L2PcInstance player)
{
if (npc.getId() == TELEPORTER)
{
if (player.isInParty() && player.getParty().isLeader(player))
{
return "80026.htm";
}
return "80026-no.htm";
}
return "";
}
@Override
public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpWorld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpWorld instanceof RaidTowerWorld)
{
final RaidTowerWorld world = (RaidTowerWorld) tmpWorld;
final int objectId = npc.getObjectId();
// first room was spawned ?
if (world.firstRoom != null)
{
// is shaman killed ?
if ((world.shaman != 0) && (world.shaman == objectId))
{
world.shaman = 0;
// stop respawn of the minions
for (L2Spawn spawn : world.firstRoom)
{
if (spawn != null)
{
spawn.stopRespawn();
}
}
world.firstRoom.clear();
world.firstRoom = null;
if (world.boss != null)
{
final int skillId = FIRST_ROOM[world.index][2];
final int skillLvl = FIRST_ROOM[world.index][3];
if ((skillId != 0) && (skillLvl != 0))
{
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLvl);
if (skill != null)
{
skill.applyEffects(world.boss, world.boss);
}
}
}
return super.onKill(npc, player, isSummon);
}
}
// second room was spawned ?
if (world.secondRoom != null)
{
boolean all = true;
// check for all mobs in the second room
for (int i = 0; i < world.secondRoom.size(); i++)
{
// found killed now mob
if (world.secondRoom.get(i) == objectId)
{
world.secondRoom.set(i, 0);
}
else if (world.secondRoom.get(i) != 0)
{
all = false;
}
}
// all mobs killed ?
if (all)
{
world.secondRoom.clear();
world.secondRoom = null;
if (world.boss != null)
{
final int skillId = SECOND_ROOM[world.index][1];
final int skillLvl = SECOND_ROOM[world.index][2];
if ((skillId != 0) && (skillLvl != 0))
{
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLvl);
if (skill != null)
{
skill.applyEffects(world.boss, world.boss);
}
}
}
return super.onKill(npc, player, isSummon);
}
}
// miniboss spawned ?
if ((world.miniBoss != 0) && (world.miniBoss == objectId))
{
world.miniBoss = 0;
if (world.boss != null)
{
final int skillId = MINIBOSS[world.index][4];
final int skillLvl = MINIBOSS[world.index][5];
if ((skillId != 0) && (skillLvl != 0))
{
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLvl);
if (skill != null)
{
skill.applyEffects(world.boss, world.boss);
}
}
}
return super.onKill(npc, player, isSummon);
}
// boss was killed, finish instance
if ((world.boss != null) && (world.boss == npc))
{
world.boss = null;
finishInstance(world);
}
}
return super.onKill(npc, player, isSummon);
}
public static void main(String[] args)
{
new RaidTower();
}
}
Warning: This guy is a big scammer, trying to sell everything, advertising for servers etc.
That's his mail address evgesha.nrnr@gmail.com , stay away!
@Atom @Celestine
Warning: This guy is a big scammer, trying to sell everything, advertising for servers etc.
That's his mail address evgesha.nrnr@gmail.com , stay away!
@Celestine
@Atom
Question
HammerV2
Hello guys! i have been working on my custom instance, its kamaloka like, but using Tower of insolence, i need help to make "random spawns".
Red letter are the moobs ids declaration and their spawn use, i want to make a list where i declare them and use Random get to spawn. i tried but i failed several times, trust me i spend maaany time on it.
Well here is my full code:
package instances.RaidTower; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.logging.Level; import com.l2jserver.gameserver.datatables.SkillData; import com.l2jserver.gameserver.instancemanager.InstanceManager; import com.l2jserver.gameserver.model.L2Party; import com.l2jserver.gameserver.model.L2Spawn; import com.l2jserver.gameserver.model.L2World; import com.l2jserver.gameserver.model.Location; import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.L2Npc; import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.entity.Instance; import com.l2jserver.gameserver.model.instancezone.InstanceWorld; import com.l2jserver.gameserver.model.quest.Quest; import com.l2jserver.gameserver.model.skills.BuffInfo; import com.l2jserver.gameserver.model.skills.Skill; import com.l2jserver.gameserver.network.SystemMessageId; import com.l2jserver.gameserver.network.serverpackets.SystemMessage; public final class RaidTower extends Quest { /* * Reset time for all RaidTower Default: 6:30AM on server time */ private static final int RESET_HOUR = 6; private static final int RESET_MIN = 30; /* * Time after which instance without players will be destroyed Default: 5 minutes */ private static final int EMPTY_DESTROY_TIME = 5; /* * Time to destroy instance (and eject players away) after boss defeat Default: 5 minutes */ private static final int EXIT_TIME = 5; /* * Maximum level difference between players level and RaidTower level Default: 5 */ private static final int MAX_LEVEL_DIFFERENCE = 5; /* * If true shaman in the first room will have same npcId as other mobs, making radar useless Default: true (but not retail like) */ private static final boolean STEALTH_SHAMAN = true; // Template IDs for RaidTower // @formatter:off private static final int[] TEMPLATE_IDS = { 1000, 1001, 1002, 1003, 1004 }; // Level of the RaidTower private static final int[] LEVEL = { 26, 46, 66, 76, 86 }; // Duration of the instance, minutes private static final int[] DURATION = { 45, 45, 45, 45, 45 }; // Maximum party size for the instance private static final int[] MAX_PARTY_SIZE = { 2, 2, 2, 2, 2 }; /** * List of buffs NOT removed on enter from player and pet<br> * On retail only newbie guide buffs not removed<br> * CAUTION: array must be sorted in ascension order! */ protected static final int[] BUFFS_WHITELIST = { 4322, 4323, 4324, 4325, 4326, 4327, 4328, 4329, 4330, 4331, 5632, 5637, 5950 }; // @formatter:on // Teleport points into instances x, y, z private static final Location[] TELEPORTS = { new Location(114674, 11458, -5125), new Location(114674, 11458, -5125), new Location(114674, 11458, -5125), // -76280, -185540, -10936 new Location(114674, 11458, -5125), new Location(114674, 11458, -5125), }; // Respawn delay for the mobs in the first room, seconds Default: 25 private static final int FIRST_ROOM_RESPAWN_DELAY = 25; /** * First room information, null if room not spawned.<br> * Skill is casted on the boss when shaman is defeated and mobs respawn stopped<br> * Default: 5699 (decrease pdef)<br> * shaman npcId, minions npcId, skillId, skillLvl */ private static final int[][] FIRST_ROOM = { { 22485, 22486, 5699, 1 }, { 22485, 22486, 5699, 1 }, { 22485, 22486, 5699, 1 }, { 22485, 22486, 5699, 1 }, { 22485, 22486, 5699, 1 }, }; /* * First room spawns, null if room not spawned x, y, z */ private static final int[][][] FIRST_ROOM_SPAWNS = { /* instancia 26 */ { { 114636, 15532, -5100 }, { 114711, 15536, -5100 }, { 114567, 15539, -5100 }, { 114485, 15700, -5100 }, { 114638, 15719, -5100 }, { 112965, 17291, -4378 }, { 112890, 17380, -4378 }, { 113096, 17179, -4378 }, { 112759, 16815, -4378 } }, /* instancia 46 */ { { 114636, 15532, -5100 }, { 114711, 15536, -5100 }, { 114567, 15539, -5100 }, { 114485, 15700, -5100 }, { 114638, 15719, -5100 }, { 112965, 17291, -4378 }, { 112890, 17380, -4378 }, { 113096, 17179, -4378 }, { 112759, 16815, -4378 } }, /* instancia 66 */ { { 114636, 15532, -5100 }, { 114711, 15536, -5100 }, { 114567, 15539, -5100 }, { 114485, 15700, -5100 }, { 114638, 15719, -5100 }, { 112965, 17291, -4378 }, { 112890, 17380, -4378 }, { 113096, 17179, -4378 }, { 112759, 16815, -4378 } }, /* instancia 76 */ { { 114636, 15532, -5100 }, { 114711, 15536, -5100 }, { 114567, 15539, -5100 }, { 114485, 15700, -5100 }, { 114638, 15719, -5100 }, { 112965, 17291, -4378 }, { 112890, 17380, -4378 }, { 113096, 17179, -4378 }, { 112759, 16815, -4378 } }, /* instancia 86 */ { { 114636, 15532, -5100 }, { 114711, 15536, -5100 }, { 114567, 15539, -5100 }, { 114485, 15700, -5100 }, { 114638, 15719, -5100 }, { 112965, 17291, -4378 }, { 112890, 17380, -4378 }, { 113096, 17179, -4378 }, { 112759, 16815, -4378 } } }; /* * Second room information, null if room not spawned Skill is casted on the boss when all mobs are defeated Default: 5700 (decrease mdef) npcId, skillId, skillLvl */ private static final int[][] SECOND_ROOM = { { 22487, 5700, 1 }, { 22490, 5700, 2 }, { 22493, 5700, 3 }, { 22496, 5700, 4 }, { 22499, 5700, 5 } }; /* * Spawns for second room, null if room not spawned x, y, z */ private static final int[][][] SECOND_ROOM_SPAWNS = { /*instancia 26 */ { { 114637, 16223, -2127 }, { 114543, 16083, -2127 }, { 114833, 16099, -2127 }, { 114618, 15848, -2127 }, { 114627, 15637, -2127 }, { 116230, 14822, -1414 }, { 116460, 14922, -1417 }, { 116303, 14973, -1414 }, { 116598, 15466, -1414 } }, /*instancia 46 */ { { 114637, 16223, -2127 }, { 114543, 16083, -2127 }, { 114833, 16099, -2127 }, { 114618, 15848, -2127 }, { 114627, 15637, -2127 }, { 116230, 14822, -1414 }, { 116460, 14922, -1417 }, { 116303, 14973, -1414 }, { 116598, 15466, -1414 } }, /*instancia 66 */ { { 114637, 16223, -2127 }, { 114543, 16083, -2127 }, { 114833, 16099, -2127 }, { 114618, 15848, -2127 }, { 114627, 15637, -2127 }, { 116230, 14822, -1414 }, { 116460, 14922, -1417 }, { 116303, 14973, -1414 }, { 116598, 15466, -1414 } }, /*instancia 76 */ { { 114637, 16223, -2127 }, { 114543, 16083, -2127 }, { 114833, 16099, -2127 }, { 114618, 15848, -2127 }, { 114627, 15637, -2127 }, { 116230, 14822, -1414 }, { 116460, 14922, -1417 }, { 116303, 14973, -1414 }, { 116598, 15466, -1414 } }, /*instancia 86 */ { { 114637, 16223, -2127 }, { 114543, 16083, -2127 }, { 114833, 16099, -2127 }, { 114618, 15848, -2127 }, { 114627, 15637, -2127 }, { 116230, 14822, -1414 }, { 116460, 14922, -1417 }, { 116303, 14973, -1414 }, { 116598, 15466, -1414 } } }; // miniboss info // skill is casted on the boss when miniboss is defeated // npcId, x, y, z, skill id, skill level /* * Miniboss information, null if miniboss not spawned Skill is casted on the boss when miniboss is defeated Default: 5701 (decrease patk) npcId, x, y, z, skillId, skillLvl */ private static final int[][] MINIBOSS = { /*intancia 26 */ { 25616, 115376, 16225, -645, 5701, 1 }, /*intancia 46 */ { 25616, 115376, 16225, -645, 5701, 1 }, /*intancia 66 */ { 25616, 115376, 16225, -645, 5701, 1 }, /*intancia 76 */ { 25616, 115376, 16225, -645, 5701, 1 }, /*intancia 86 */ { 25616, 115376, 16225, -645, 5701, 1 } }; /* * Bosses of the RaidTower Instance ends when boss is defeated npcId, x, y, z */ private static final int[][] BOSS = { /*intancia 26 */ { 18554, 114671, 16976, 928 }, /*intancia 46 */ { 18555, 114671, 16976, 928 }, /*intancia 66 */ { 29129, 114671, 16976, 928 }, /*intancia 76 */ { 18558, 114671, 16976, 928 }, /*intancia 86 */ { 18559, 114671, 16976, 928 } }; /* * Escape telepoters spawns, null if not spawned x, y, z */ private static final int[][] TELEPORTERS = { /*intancia 26 */ { 114649, 17642, 925 }, /*intancia 46 */ { 114649, 17642, 925 }, /*intancia 66 */ { 114649, 17642, 925 }, /*intancia 76 */ { 114649, 17642, 925 }, /*intancia 86 */ { 114649, 17642, 925 } }; /* * Escape teleporter npcId */ private static final int TELEPORTER = 80026; /** RaidTower captains (start npc's) npcIds. */ private static final int[] CAPTAINS = { 80020, 80021, 80022, 80023, 80024, 80026 }; protected class RaidTowerWorld extends InstanceWorld { public int index; // 0-18 index of the Raid type in arrays public int shaman = 0; // objectId of the shaman public List<L2Spawn> firstRoom; // list of the spawns in the first room (excluding shaman) public List<Integer> secondRoom;// list of objectIds mobs in the second room public int miniBoss = 0; // objectId of the miniboss public L2Npc boss = null; // boss } private RaidTower() { super(-1, RaidTower.class.getSimpleName(), "instances"); addFirstTalkId(TELEPORTER); addTalkId(TELEPORTER); for (int cap : CAPTAINS) { addStartNpc(cap); addTalkId(cap); } for (int[] mob : FIRST_ROOM) { if (mob != null) { if (STEALTH_SHAMAN) { addKillId(mob[1]); } else { addKillId(mob[0]); } } } for (int[] mob : SECOND_ROOM) { if (mob != null) { addKillId(mob[0]); } } for (int[] mob : MINIBOSS) { if (mob != null) { addKillId(mob[0]); } } for (int[] mob : BOSS) { addKillId(mob[0]); } } /** * Check if party with player as leader allowed to enter * @param player party leader * @param index (0-18) index of the RaidTower in arrays * @return true if party allowed to enter */ private static final boolean checkConditions(L2PcInstance player, int index) { final L2Party party = player.getParty(); // player must be in party if (party == null) { player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER); return false; } // ...and be party leader if (party.getLeader() != player) { player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER); return false; } // party must not exceed max size for selected instance if (party.getMemberCount() > MAX_PARTY_SIZE[index]) { player.sendPacket(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER); return false; } // get level of the instance final int level = LEVEL[index]; // and client name final String instanceName = InstanceManager.getInstance().getInstanceIdName(TEMPLATE_IDS[index]); Map<Integer, Long> instanceTimes; // for each party member for (L2PcInstance partyMember : party.getMembers()) { // player level must be in range if (Math.abs(partyMember.getLevel() - level) > MAX_LEVEL_DIFFERENCE) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT); sm.addPcName(partyMember); player.sendPacket(sm); return false; } // player must be near party leader if (!partyMember.isInsideRadius(player, 1000, true, true)) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED); sm.addPcName(partyMember); player.sendPacket(sm); return false; } // get instances reenter times for player instanceTimes = InstanceManager.getInstance().getAllInstanceTimes(partyMember.getObjectId()); if (instanceTimes != null) { for (int id : instanceTimes.keySet()) { // find instance with same name (RaidTower or labyrinth) // TODO: Zoey76: Don't use instance name, use other system. if (!instanceName.equals(InstanceManager.getInstance().getInstanceIdName(id))) { continue; } // if found instance still can't be reentered - exit if (System.currentTimeMillis() < instanceTimes.get(id)) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET); sm.addPcName(partyMember); player.sendPacket(sm); return false; } } } } return true; } /** * Removing all buffs from player and pet except BUFFS_WHITELIST * @param ch player */ private static final void removeBuffs(L2Character ch) { Function<BuffInfo, Boolean> removeBuffs = info -> { if ((info != null) && !info.getSkill().isStayAfterDeath() && (Arrays.binarySearch(BUFFS_WHITELIST, info.getSkill().getId()) < 0)) { info.getEffected().getEffectList().stopSkillEffects(true, info.getSkill()); } return true; }; ch.getEffectList().forEach(removeBuffs, false); if (ch.hasSummon()) { ch.getSummon().getEffectList().forEach(removeBuffs, false); } } /** * Handling enter of the players into RaidTower * @param player party leader * @param index (0-18) RaidTower index in arrays */ private final synchronized void enterInstance(L2PcInstance player, int index) { int templateId; try { templateId = TEMPLATE_IDS[index]; } catch (ArrayIndexOutOfBoundsException e) { throw e; } // check for existing instances for this player InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player); // player already in the instance if (world != null) { // but not in RaidTower if (!(world instanceof RaidTowerWorld) || (world.getTemplateId() != templateId)) { player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER); return; } // check for level difference again on reenter if (Math.abs(player.getLevel() - LEVEL[((RaidTowerWorld) world).index]) > MAX_LEVEL_DIFFERENCE) { SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT); sm.addPcName(player); player.sendPacket(sm); return; } // check what instance still exist Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId()); if (inst != null) { removeBuffs(player); teleportPlayer(player, TELEPORTS[index], world.getInstanceId()); } return; } // Creating new RaidTower instance if (!checkConditions(player, index)) { return; } // Creating dynamic instance without template final int instanceId = InstanceManager.getInstance().createDynamicInstance(null); final Instance inst = InstanceManager.getInstance().getInstance(instanceId); // set name for the RaidTower inst.setName(InstanceManager.getInstance().getInstanceIdName(templateId)); // set return location inst.setSpawnLoc(new Location(player)); // disable summon friend into instance inst.setAllowSummon(false); // set duration and empty destroy time inst.setDuration(DURATION[index] * 60000); inst.setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000); // Creating new instanceWorld, using our instanceId and templateId world = new RaidTowerWorld(); world.setInstanceId(instanceId); world.setTemplateId(templateId); // set index for easy access to the arrays ((RaidTowerWorld) world).index = index; InstanceManager.getInstance().addWorld(world); world.setStatus(0); // spawn npcs spawnRaidTower((RaidTowerWorld) world); // and finally teleport party into instance final L2Party party = player.getParty(); for (L2PcInstance partyMember : party.getMembers()) { world.addAllowed(partyMember.getObjectId()); removeBuffs(partyMember); teleportPlayer(partyMember, TELEPORTS[index], instanceId); } return; } /** * Called on instance finish and handles reenter time for instance * @param world instanceWorld */ private static final void finishInstance(InstanceWorld world) { if (world instanceof RaidTowerWorld) { Calendar reenter = Calendar.getInstance(); reenter.set(Calendar.MINUTE, RESET_MIN); // if time is >= RESET_HOUR - roll to the next day if (reenter.get(Calendar.HOUR_OF_DAY) >= RESET_HOUR) { reenter.add(Calendar.DATE, 1); } reenter.set(Calendar.HOUR_OF_DAY, RESET_HOUR); SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_RESTRICTED); sm.addInstanceName(world.getTemplateId()); // set instance reenter time for all allowed players for (int objectId : world.getAllowed()) { L2PcInstance obj = L2World.getInstance().getPlayer(objectId); if ((obj != null) && obj.isOnline()) { InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis()); obj.sendPacket(sm); } } // destroy instance after EXIT_TIME Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId()); inst.setDuration(EXIT_TIME * 60000); inst.setEmptyDestroyTime(0); } } /** * Spawn all NPCs in RaidTower * @param world instanceWorld */ @SuppressWarnings("all") private final void spawnRaidTower(RaidTowerWorld world) { int[] npcs; int[][] spawns; L2Npc npc; final int index = world.index; // first room npcs = FIRST_ROOM[index]; spawns = FIRST_ROOM_SPAWNS[index]; if (npcs != null) { world.firstRoom = new ArrayList<L2Spawn>(spawns.length - 1); int shaman = getRandom(spawns.length); // random position for shaman for (int i = 0; i < spawns.length; i++) { if (i == shaman) { // stealth shaman use same npcId as other mobs npc = addSpawn(STEALTH_SHAMAN ? npcs[1] : npcs[0], spawns[i][0], spawns[i][1], spawns[i][2], 0, false, 0, false, world.getInstanceId()); world.shaman = npc.getObjectId(); } else { npc = addSpawn(npcs[1], spawns[i][0], spawns[i][1], spawns[i][2], 0, false, 0, false, world.getInstanceId()); L2Spawn spawn = npc.getSpawn(); spawn.setRespawnDelay(FIRST_ROOM_RESPAWN_DELAY); spawn.setAmount(1); spawn.startRespawn(); world.firstRoom.add(spawn); // store mobs spawns } npc.setIsNoRndWalk(true); } } // second room npcs = SECOND_ROOM[index]; spawns = SECOND_ROOM_SPAWNS[index]; if (npcs != null) { world.secondRoom = new ArrayList<Integer>(spawns.length); for (int[] spawn : spawns) { npc = addSpawn(npcs[0], spawn[0], spawn[1], spawn[2], 0, false, 0, false, world.getInstanceId()); npc.setIsNoRndWalk(true); world.secondRoom.add(npc.getObjectId()); } } // miniboss if (MINIBOSS[index] != null) { npc = addSpawn(MINIBOSS[index][0], MINIBOSS[index][1], MINIBOSS[index][2], MINIBOSS[index][3], 0, false, 0, false, world.getInstanceId()); npc.setIsNoRndWalk(true); world.miniBoss = npc.getObjectId(); } // escape teleporter if (TELEPORTERS[index] != null) { addSpawn(TELEPORTER, TELEPORTERS[index][0], TELEPORTERS[index][1], TELEPORTERS[index][2], 0, false, 0, false, world.getInstanceId()); } // boss npc = addSpawn(BOSS[index][0], BOSS[index][1], BOSS[index][2], BOSS[index][3], 0, false, 0, false, world.getInstanceId()); ((L2MonsterInstance) npc).setOnKillDelay(100); world.boss = npc; } /** * Handles only player's enter, single parameter - integer RaidTower index */ @Override public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { if (npc == null) { return ""; } try { enterInstance(player, Integer.parseInt(event)); } catch (Exception e) { _log.log(Level.WARNING, "", e); } return ""; } /** * Talk with captains and using of the escape teleporter */ @Override public final String onTalk(L2Npc npc, L2PcInstance player) { final int npcId = npc.getId(); if (npcId == TELEPORTER) { final L2Party party = player.getParty(); // only party leader can talk with escape teleporter if ((party != null) && party.isLeader(player)) { final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId()); if (world instanceof RaidTowerWorld) { // party members must be in the instance if (world.isAllowed(player.getObjectId())) { Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId()); // teleports entire party away for (L2PcInstance partyMember : party.getMembers()) { if ((partyMember != null) && (partyMember.getInstanceId() == world.getInstanceId())) { teleportPlayer(partyMember, inst.getSpawnLoc(), 0); } } } } } } else { return npcId + ".htm"; } return ""; } /** * Only escape teleporters first talk handled */ @Override public final String onFirstTalk(L2Npc npc, L2PcInstance player) { if (npc.getId() == TELEPORTER) { if (player.isInParty() && player.getParty().isLeader(player)) { return "80026.htm"; } return "80026-no.htm"; } return ""; } @Override public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) { final InstanceWorld tmpWorld = InstanceManager.getInstance().getWorld(npc.getInstanceId()); if (tmpWorld instanceof RaidTowerWorld) { final RaidTowerWorld world = (RaidTowerWorld) tmpWorld; final int objectId = npc.getObjectId(); // first room was spawned ? if (world.firstRoom != null) { // is shaman killed ? if ((world.shaman != 0) && (world.shaman == objectId)) { world.shaman = 0; // stop respawn of the minions for (L2Spawn spawn : world.firstRoom) { if (spawn != null) { spawn.stopRespawn(); } } world.firstRoom.clear(); world.firstRoom = null; if (world.boss != null) { final int skillId = FIRST_ROOM[world.index][2]; final int skillLvl = FIRST_ROOM[world.index][3]; if ((skillId != 0) && (skillLvl != 0)) { final Skill skill = SkillData.getInstance().getSkill(skillId, skillLvl); if (skill != null) { skill.applyEffects(world.boss, world.boss); } } } return super.onKill(npc, player, isSummon); } } // second room was spawned ? if (world.secondRoom != null) { boolean all = true; // check for all mobs in the second room for (int i = 0; i < world.secondRoom.size(); i++) { // found killed now mob if (world.secondRoom.get(i) == objectId) { world.secondRoom.set(i, 0); } else if (world.secondRoom.get(i) != 0) { all = false; } } // all mobs killed ? if (all) { world.secondRoom.clear(); world.secondRoom = null; if (world.boss != null) { final int skillId = SECOND_ROOM[world.index][1]; final int skillLvl = SECOND_ROOM[world.index][2]; if ((skillId != 0) && (skillLvl != 0)) { final Skill skill = SkillData.getInstance().getSkill(skillId, skillLvl); if (skill != null) { skill.applyEffects(world.boss, world.boss); } } } return super.onKill(npc, player, isSummon); } } // miniboss spawned ? if ((world.miniBoss != 0) && (world.miniBoss == objectId)) { world.miniBoss = 0; if (world.boss != null) { final int skillId = MINIBOSS[world.index][4]; final int skillLvl = MINIBOSS[world.index][5]; if ((skillId != 0) && (skillLvl != 0)) { final Skill skill = SkillData.getInstance().getSkill(skillId, skillLvl); if (skill != null) { skill.applyEffects(world.boss, world.boss); } } } return super.onKill(npc, player, isSummon); } // boss was killed, finish instance if ((world.boss != null) && (world.boss == npc)) { world.boss = null; finishInstance(world); } } return super.onKill(npc, player, isSummon); } public static void main(String[] args) { new RaidTower(); } }And parts that i think i should do changes...
private static final int[][] FIRST_ROOM = { { 22485, 22486, 5699, 1 }, { 22485, 22486, 5699, 1 }, { 22485, 22486, 5699, 1 }, { 22485, 22486, 5699, 1 }, { 22485, 22486, 5699, 1 }, };_____________________________
private static final int[][] SECOND_ROOM = { { 22487, 5700, 1 }, { 22490, 5700, 2 }, { 22493, 5700, 3 }, { 22496, 5700, 4 }, { 22499, 5700, 5 } };________________________________________
private static final int[][] MINIBOSS = { /*intancia 26 */ { 25616, 115376, 16225, -645, 5701, 1 }, /*intancia 46 */ { 25616, 115376, 16225, -645, 5701, 1 }, /*intancia 66 */ { 25616, 115376, 16225, -645, 5701, 1 }, /*intancia 76 */ { 25616, 115376, 16225, -645, 5701, 1 }, /*intancia 86 */ { 25616, 115376, 16225, -645, 5701, 1 } }; /* * Bosses of the RaidTower Instance ends when boss is defeated npcId, x, y, z */ private static final int[][] BOSS = { /*intancia 26 */ { 18554, 114671, 16976, 928 }, /*intancia 46 */ { 18555, 114671, 16976, 928 }, /*intancia 66 */ { 29129, 114671, 16976, 928 }, /*intancia 76 */ { 18558, 114671, 16976, 928 }, /*intancia 86 */ { 18559, 114671, 16976, 928 } }; /* * Escape telepoters spawns, null if not spawned x, y, z */ private static final int[][] TELEPORTERS = { /*intancia 26 */ { 114649, 17642, 925 }, /*intancia 46 */ { 114649, 17642, 925 }, /*intancia 66 */ { 114649, 17642, 925 }, /*intancia 76 */ { 114649, 17642, 925 }, /*intancia 86 */ { 114649, 17642, 925 } };Spawn thing
private final void spawnRaidTower(RaidTowerWorld world) { int[] npcs; int[][] spawns; L2Npc npc; final int index = world.index; // first room npcs = FIRST_ROOM[index]; spawns = FIRST_ROOM_SPAWNS[index]; if (npcs != null) { world.firstRoom = new ArrayList<L2Spawn>(spawns.length - 1); int shaman = getRandom(spawns.length); // random position for shaman for (int i = 0; i < spawns.length; i++) { if (i == shaman) { // stealth shaman use same npcId as other mobs npc = addSpawn(STEALTH_SHAMAN ? npcs[1] : npcs[0], spawns[i][0], spawns[i][1], spawns[i][2], 0, false, 0, false, world.getInstanceId()); world.shaman = npc.getObjectId(); } else { npc = addSpawn(npcs[1], spawns[i][0], spawns[i][1], spawns[i][2], 0, false, 0, false, world.getInstanceId()); L2Spawn spawn = npc.getSpawn(); spawn.setRespawnDelay(FIRST_ROOM_RESPAWN_DELAY); spawn.setAmount(1); spawn.startRespawn(); world.firstRoom.add(spawn); // store mobs spawns } npc.setIsNoRndWalk(true); } } // second room npcs = SECOND_ROOM[index]; spawns = SECOND_ROOM_SPAWNS[index]; if (npcs != null) { world.secondRoom = new ArrayList<Integer>(spawns.length); for (int[] spawn : spawns) { npc = addSpawn(npcs[0], spawn[0], spawn[1], spawn[2], 0, false, 0, false, world.getInstanceId()); npc.setIsNoRndWalk(true); world.secondRoom.add(npc.getObjectId()); } } // miniboss if (MINIBOSS[index] != null) { npc = addSpawn(MINIBOSS[index][0], MINIBOSS[index][1], MINIBOSS[index][2], MINIBOSS[index][3], 0, false, 0, false, world.getInstanceId()); npc.setIsNoRndWalk(true); world.miniBoss = npc.getObjectId(); } // escape teleporter if (TELEPORTERS[index] != null) { addSpawn(TELEPORTER, TELEPORTERS[index][0], TELEPORTERS[index][1], TELEPORTERS[index][2], 0, false, 0, false, world.getInstanceId()); } // boss npc = addSpawn(BOSS[index][0], BOSS[index][1], BOSS[index][2], BOSS[index][3], 0, false, 0, false, world.getInstanceId()); ((L2MonsterInstance) npc).setOnKillDelay(100); world.boss = npc; }Thanks in advance... i have maaany ideas but my java skills are killing meh... i learn so fcking slow
13 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now