private int getPathToCellValidity(final FightMap fightMap, final Point3 cell) { fightMap.setIgnoreAllMovementObstacles(true); final PathFinder pathFinder = PathFinder.checkOut(); int path = -1; try { pathFinder.setMoverCaracteristics( this.m_caster.getHeight(), this.m_caster.getPhysicalRadius(), ((BasicCharacterInfo) this.m_caster).getJumpCapacity()); pathFinder.setTopologyMapInstanceSet(fightMap); pathFinder.addStartCell(this.m_caster.getPosition()); pathFinder.setStopCell(cell); final PathFinderParameters parameters = new PathFinderParameters(); parameters.m_maxPathLength = fightMap.getHeight() + fightMap.getWidth(); parameters.m_searchLimit = 2048; pathFinder.setParameters(parameters); path = pathFinder.findPath(); } catch (Exception e) { EnutrofDepositPlacement.m_logger.error((Object) "Exception levee", (Throwable) e); } finally { pathFinder.release(); fightMap.setIgnoreAllMovementObstacles(false); } return path; }
private Point3 getRandomCellInEffectArea(final FightMap fightMap) { final AreaOfEffect areaOfEffect = ((WakfuEffect) this.m_genericEffect).getAreaOfEffect(); if (areaOfEffect.getType() == AreaOfEffectEnum.EMPTY) { return fightMap.getInsideRandomCell(); } final Direction8 dir = this.m_caster.getDirection(); final Point3 casterCell = this.m_caster.getPosition(); final Iterable<int[]> iterable = ((WakfuEffect) this.m_genericEffect) .getAreaOfEffect() .getCells( this.m_targetCell.getX(), this.m_targetCell.getY(), this.m_targetCell.getZ(), casterCell.getX(), casterCell.getY(), casterCell.getZ(), dir); final ArrayList<int[]> cells = new ArrayList<int[]>(); for (final int[] next : iterable) { final int cellX = next[0]; final int cellY = next[1]; if (!fightMap.isInMap(cellX, cellY)) { continue; } if (!fightMap.isInside(cellX, cellY)) { continue; } final short cellHeight = fightMap.getCellHeight(cellX, cellY); if (cellHeight == -32768) { continue; } cells.add(next); } if (cells.isEmpty()) { EnutrofDepositPlacement.m_logger.error( (Object) ("Pas de cellule trouvee pour le spawn d'un gisement " + areaOfEffect.getType())); return null; } return new Point3(cells.get(MathHelper.random(cells.size()))); }
private Point3 getRandomCell(final FightMap fightMap) { Point3 cell = null; for (int i = 0; i < 3; ++i) { cell = this.getRandomCellInEffectArea(fightMap); if (cell != null) { cell.setZ(fightMap.getCellHeight(cell.getX(), cell.getY())); final int path = this.getPathToCellValidity(fightMap, cell); if (path == -1) { cell = null; } else { if (this.cellAlreadyContainsCasterDeposit(cell)) { cell = null; } if (cell != null) { return cell; } } } } return cell; }
@Override public boolean onMessage(final ExternalFightCreationMessage msg) { final FightModel fightModel = FightModel.getFromTypeId(msg.getFightType()); if (fightModel == null) { ExternalFightCreationMessageHandler.m_logger.error( (Object) String.format( "FightModel (typeId=%d) inconnu dans la cr\u00e9ation de l'external fight id=%d", msg.getFightType(), msg.getFightId())); return false; } final ExternalFightInfo externalFightInfo = new ExternalFightInfo(fightModel); final FightMap fightMap = new WakfuClientFightMap(); new FightMapSerializer(fightMap).unserialize(ByteBuffer.wrap(msg.getSerializedFightMap())); externalFightInfo.setId(msg.getFightId()); externalFightInfo.setStatus(msg.getFightStatus()); externalFightInfo.setPartition(msg.getPartition()); externalFightInfo.setFightMap(fightMap); fightMap.blockFightingGroundInTopology(true, false); final boolean displayEffect = WakfuGameEntity.getInstance().getLocalPlayer().getCurrentFight() == null; for (int i = 0; i < msg.getFightersCount(); ++i) { final byte teamId = msg.getTeamId(i); final long fighterId = msg.getFighterId(i); externalFightInfo.addFighterToTeamById(teamId, fighterId); } ExternalFightCreationActions.INSTANCE.m_fightIsInFightCreation.add(msg.getFightId()); externalFightInfo.setAttackerCreatorId(msg.getCreators().get(0)); externalFightInfo.setDefenderCreatorId(msg.getCreators().get(1)); final CharacterInfo attackerCreator = externalFightInfo.getFighterFromId((long) msg.getCreators().get(0)); final CharacterInfo defenderCreator = externalFightInfo.getFighterFromId((long) msg.getCreators().get(1)); if (attackerCreator != null && defenderCreator != null) { ExternalFightCreationActions.INSTANCE.m_lookAtTheFoeActions1.put( msg.getFightId(), LookAtTheFoeAction.checkout( 1, FightActionType.LOOK_AT_THE_FOE.getId(), 0, attackerCreator, defenderCreator)); ExternalFightCreationActions.INSTANCE.m_lookAtTheFoeActions2.put( msg.getFightId(), LookAtTheFoeAction.checkout( 2, FightActionType.LOOK_AT_THE_FOE.getId(), 0, defenderCreator, attackerCreator)); ExternalFightCreationActions.INSTANCE.m_lookAtTheFoeActions3.put( msg.getFightId(), LookAtTheFoeAction.checkout( 3, FightActionType.LOOK_AT_THE_FOE.getId(), 0, externalFightInfo.getFightersInTeam(attackerCreator.getTeamId()), defenderCreator)); ExternalFightCreationActions.INSTANCE.m_lookAtTheFoeActions4.put( msg.getFightId(), LookAtTheFoeAction.checkout( 4, FightActionType.LOOK_AT_THE_FOE.getId(), 0, externalFightInfo.getFightersInTeam(defenderCreator.getTeamId()), attackerCreator)); ExternalFightCreationActions.INSTANCE.m_playAnimationAction2.put( msg.getFightId(), PlayAnimationAction.checkout( 6, FightActionType.PLAY_ANIMATION.getId(), 0, defenderCreator, "AnimHit", 250)); if (displayEffect) { ExternalFightCreationActions.INSTANCE.m_tauntAction1.put( msg.getFightId(), TauntAction.checkout(10, FightActionType.TAUNT.getId(), 0, defenderCreator)); final Collection<CharacterInfo> fightersWhoTaunt = new HashSet<CharacterInfo>( externalFightInfo.getFightersInTeam(defenderCreator.getTeamId())); fightersWhoTaunt.remove(defenderCreator); ExternalFightCreationActions.INSTANCE.m_tauntAction2.put( msg.getFightId(), TauntAction.checkout(10, FightActionType.TAUNT.getId(), 0, fightersWhoTaunt)); } externalFightInfo.setAttackerCreator(attackerCreator); externalFightInfo.setDefenderCreator(defenderCreator); } if (displayEffect) { final AbstractBattlegroundBorderEffectArea baseArea = StaticEffectAreaManager.getInstance() .getBorderCellArea(msg.getBattlegroundBorderEffectAreaBaseId()); if (baseArea != null) { final AbstractBattlegroundBorderEffectArea area = (AbstractBattlegroundBorderEffectArea) baseArea.instanceAnother( new EffectAreaParameters( msg.getBattlegroundBorderEffectAreaUID(), fightMap.getMinX(), fightMap.getMinY(), fightMap.getMinZ(), externalFightInfo.getContext(), null, (short) 0, Direction8.NONE)); area.initialize(fightMap); externalFightInfo.getEffectAreaManager().addEffectArea(area); } else { ExternalFightCreationMessageHandler.m_logger.error( (Object) ("Impossible de cr\u00e9er la bulle de combat : la zone d'effet d'index " + msg.getBattlegroundBorderEffectAreaBaseId() + " n'existe pas")); } ((ExternalFightCellLightModifier) externalFightInfo.getCellLightModifier()) .setFightMap(fightMap); } FightManager.getInstance().addFight(externalFightInfo); LocalPartitionManager.getInstance().addExternalFight(externalFightInfo); if (attackerCreator != null && defenderCreator != null) { FightVisibilityManager.getInstance().onExternalFightCreation(externalFightInfo); } return false; }