@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; }
@Override public long getLongValue( final Object criterionUser, final Object criterionTarget, final Object criterionContent, final Object criterionContext) { if (criterionContext == null) { throw new CriteriaExecutionException("Pas de contexte..."); } final AbstractFight<?> fight = CriteriaUtils.getFight(criterionUser, criterionContext); if (fight == null) { throw new CriteriaExecutionException("Impossible de r\u00e9cup\u00e9rer le combat"); } this.hook(criterionUser, criterionTarget, criterionContext, criterionContent); final CriterionUser user = CriteriaUtils.getTargetCriterionUserFromParameters( false, criterionUser, criterionTarget, criterionContext, criterionContent); Point3 center = null; CriterionUser targetCharacter = null; if (!this.m_target) { if (user != null) { center = user.getPosition(); } } else if (criterionTarget instanceof Point3) { center = (Point3) criterionTarget; } else { targetCharacter = CriteriaUtils.getTargetCriterionUserFromParameters( true, criterionUser, criterionTarget, criterionContext, criterionContent); if (targetCharacter != null) { center = targetCharacter.getPosition(); } } if (center == null) { return 0L; } final Collection<? extends EffectUser> fighters = this.getFighters(fight, user); final Iterator<? extends EffectUser> it = fighters.iterator(); while (it.hasNext()) { final EffectUser fighter = (EffectUser) it.next(); if (fighter.isActiveProperty(FightPropertyType.CANNOT_BE_EFFECT_TARGET)) { it.remove(); } } final long maxRange = this.m_maxRange.getLongValue( criterionUser, criterionTarget, criterionContent, criterionContext); if (maxRange <= 0L) { return super.getSign() * fighters.size(); } final long minRange = (this.m_minRange == null) ? 0L : this.m_minRange.getLongValue( criterionUser, criterionTarget, criterionContent, criterionContext); final boolean inLine = this.m_inLine != null && this.m_inLine.isValid( criterionUser, criterionTarget, criterionContent, criterionContext); final boolean testLoS = this.m_testLoS != null && this.m_testLoS.isValid( criterionUser, criterionTarget, criterionContent, criterionContext); long value = 0L; for (final EffectUser fighter2 : fighters) { int distanceBetweenUserAndFighter; if (targetCharacter != null) { distanceBetweenUserAndFighter = DistanceUtils.getIntersectionDistance(fighter2, targetCharacter); } else { distanceBetweenUserAndFighter = DistanceUtils.getIntersectionDistance(fighter2, center); } if (distanceBetweenUserAndFighter <= maxRange && distanceBetweenUserAndFighter >= minRange) { final Point3 fighterPosition = fighter2.getPosition(); if (inLine && center.getX() != fighterPosition.getX() && center.getY() != fighterPosition.getY()) { continue; } if (testLoS) { final FightMap fightMap = fight.getFightMap(); final LineOfSightChecker losChecker = LineOfSightChecker.checkOut(); losChecker.setTopologyMapInstanceSet(fightMap); losChecker.setStartPoint(center.getX(), center.getY(), center.getZ()); losChecker.setEndPoint( fighterPosition.getX(), fighterPosition.getY(), fighterPosition.getZ()); if (!losChecker.checkLOS()) { continue; } } ++value; } } return super.getSign() * value; }