您正在使用一款已經過時的瀏覽器!部分功能不能正常使用。
請嘗試升級或使用
其他瀏覽器。
hqdefault.jpg (34.84 KB, 下載次數: 1)
下載附件 保存到相冊
2021-8-11 19:37 上傳
輪迴 各自寫法不同 有興趣可以研究看看 自行調用 僅供參考!
新增MobConstants.java
- /**
- * 怪物輪迴
- */
- public class MobConstants {
- // 輪迴怪物 代碼
- public static int[] REINCARNATION_MOB = new int[]{8641020, 2}; // 怪物代碼, 倍率
- public static int isMonsterSpawn(MapleMap map) { // 回傳生怪數量倍率
- int addition = 1;
- if (MapConstants.isBossMap(map.getId()) || MapConstants.isEventMap(map.getId())) { // 判斷是否為特殊地圖
- return 1;
- }
- for (MapleMapObject obj : map.getAllMonstersThreadsafe()) { // 判斷地圖有boss 回傳倍率1
- final MapleMonster mob = (MapleMonster) obj;
- if (mob.getStats().isBoss() && !isReincarnationMob(mob.getId())) {
- return 1;
- }
- }
- if (map.getMonsterById(REINCARNATION_MOB[0]) != null) { // 判斷是否有輪迴
- addition *= REINCARNATION_MOB[1];
- }
- return addition;
- }
- public static boolean isReincarnationMob(int mobid) {
- if (REINCARNATION_MOB[0] == mobid) {
- return true;
- }
- return false;
- }
- public static boolean isSpawnSpeed(MapleMap map) {
- if (WorldConstants.輪迴開關 && map.getMonsterById(REINCARNATION_MOB[0]) != null) {
- return true;
- }
- return false;
- }
- }
每個端不同 自己研究一下~
- public final static boolean is宇宙船(int skillid) { // 當作輪迴技能
- switch (skillid) {
- case 1013:
- case 10001014:
- case 20011046:
- case 20021013:
- case 30011013:
- case 30001013:
- return true;
- }
- return false;
- }
-
- public final static boolean is雪吉拉騎士(int skillid) { // 當作輪迴技能
- switch (skillid){
- case 1017:
- case 10001019:
- case 20001019:
- return true;
- }
- return false;
- }
每個端不同 自己研究一下~
- public static boolean 輪迴開關 = false;
- public static int 輪迴代碼 = 0;
- --------------------分隔線--------------------
- 輪迴開關 = ServerProperties.getProperty("server.settings.Reincarnation.Enable", 輪迴開關);
- 輪迴代碼 = ServerProperties.getProperty("server.settings.Reincarnation.ItemID", 輪迴代碼);
找到 if (skillid != 5221006) {
c.sendPacket(MaplePacketCreator.skillCooldown(skillid, effect.getCooldown()));
chr.addCooldown(skillid, System.currentTimeMillis(), effect.getCooldown() * 1000);
}
}
在以下新增:
- // 怪物輪迴 施放技能
- if (SkillConstants.is宇宙船(skillid) || SkillConstants.is雪吉拉騎士(skillid)) {
- if (WorldConstants.輪迴開關) {
- if (chr.getItemQuantity(WorldConstants.輪迴代碼, false) > 0) {
- if (chr.getMap().countMonsterById(MobConstants.REINCARNATION_MOB[0]) == 0) {
- MapleMonster onemob = MapleLifeFactory.getMonster(MobConstants.REINCARNATION_MOB[0]);
- chr.getMap().spawnMonsterOnGroundBelow(onemob, chr.getPosition());
- } else {
- chr.dropMessage("地圖上已有輪迴碑石!");
- }
- } else {
- chr.dropMessage(1, "你沒有輪迴碑石!");
- }
- }
- c.sendPacket(MaplePacketCreator.enableActions());
- return;
- }
MapleMap.java
- public void respawn(final boolean force) {
- lastSpawnTime = System.currentTimeMillis();
- if (force) {
- final int numShouldSpawn = monsterSpawn.size() * MobConstants.isMonsterSpawn(this) - spawnedMonstersOnMap.get(); // 輪迴倍率
- // final int numShouldSpawn = monsterSpawn.size() - spawnedMonstersOnMap.get();
- if (numShouldSpawn > 0) {
- int spawned = 0;
- for (Spawns spawnPoint : monsterSpawn) {
- spawnPoint.spawnMonster(this);
- spawned++;
- if (spawned >= numShouldSpawn) {
- break;
- }
- }
- }
- } else if (GameConstants.isCarnivalMaps(mapid)) {
- final List<Spawns> randomSpawn = new ArrayList(monsterSpawn);
- int team0NumShouldSpawn = 0;
- int team1NumShouldSpawn = 0;
- int numShouldSpawn = 0;
- for (Spawns spawnPoint : randomSpawn) {
- switch (spawnPoint.getCarnivalTeam()) {
- case 0:
- team0NumShouldSpawn++;
- break;
- case 1:
- team1NumShouldSpawn++;
- break;
- case -1:
- numShouldSpawn++;
- break;
- default:
- break;
- }
- }
- List<MapleMapObject> monsters = getMapObjects(Arrays.asList(MapleMapObjectType.MONSTER));
- for (MapleMapObject mmo : monsters) {
- if (!(mmo instanceof MapleMonster)) {
- continue;
- }
- MapleMonster monster = (MapleMonster) mmo;
- switch (monster.getCarnivalTeam()) {
- case 0:
- team0NumShouldSpawn--;
- break;
- case 1:
- team1NumShouldSpawn--;
- break;
- default:
- numShouldSpawn--;
- break;
- }
- }
- if (numShouldSpawn > 0 || team0NumShouldSpawn > 0 || team1NumShouldSpawn > 0 || GameConstants.isForceRespawn(mapid)) {
- int team0Spawned = 0;
- int team1Spawned = 0;
- int spawned = 0;
- Collections.shuffle(randomSpawn);
- for (Spawns spawnPoint : randomSpawn) {
- if (spawnPoint.shouldSpawn() || GameConstants.isForceRespawn(mapid)) {
- if (spawnPoint.getCarnivalTeam() == 0 && team0NumShouldSpawn > 0) {
- spawnPoint.spawnMonster(this);
- team0Spawned++;
- } else if (spawnPoint.getCarnivalTeam() == 1 && team1NumShouldSpawn > 0) {
- spawnPoint.spawnMonster(this);
- team1Spawned++;
- } else if (spawnPoint.getCarnivalTeam() == -1 && numShouldSpawn > 0) {
- spawnPoint.spawnMonster(this);
- spawned++;
- }
- }
- if (team0Spawned >= team0NumShouldSpawn && team1Spawned >= team1NumShouldSpawn && spawned >= numShouldSpawn) {
- break;
- }
- }
- }
- } else {
- final int numShouldSpawn = maxRegularSpawn * MobConstants.isMonsterSpawn(this) - spawnedMonstersOnMap.get(); // 乘輪迴倍率
- // final int numShouldSpawn = maxRegularSpawn - spawnedMonstersOnMap.get();
- if (numShouldSpawn > 0 || GameConstants.isForceRespawn(mapid)) {
- int spawned = 0;
- final List<Spawns> randomSpawn = new ArrayList<>(monsterSpawn);
- Collections.shuffle(randomSpawn);
- for (Spawns spawnPoint : randomSpawn) {
- if (spawnPoint.shouldSpawn() || GameConstants.isForceRespawn(mapid)) {
- spawnPoint.spawnMonster(this);
- spawned++;
- }
- if (spawned >= numShouldSpawn) {
- break;
- }
- }
- }
- }
- }
MapleMap.java
- public final boolean canSpawn() {
- createMobInterval = (short) (MobConstants.isSpawnSpeed(this) ? 0 : 9000); // 怪物輪迴 生怪速度
- return lastSpawnTime > 0 && isSpawns && lastSpawnTime + createMobInterval < System.currentTimeMillis();
- }
#文章轉自AICL |