@Override public boolean run(final Item item) { final LocalPlayerCharacter character = WakfuGameEntity.getInstance().getLocalPlayer(); if (character.getBags().getItemFromInventories(item.getUniqueId()) == null) { ReduceDeadStateItemAction.m_logger.error( (Object) "[ItemAction] On essaye de lancer une action avec un item qui n'est pas dans les bags"); return false; } boolean hasDeadState = false; final List<StateRunningEffect> states = character.getRunningEffectManager().getRunningState(); for (int i = 0; i < states.size(); ++i) { final StateRunningEffect effect = states.get(i); if (effect.getState() == null || effect.getState().isStateForDeath()) { hasDeadState = true; break; } } if (!hasDeadState) { ReduceDeadStateItemAction.m_logger.warn( (Object) "Tentative d'utilisation d'un item de reduction de DEAD_STATE sans en avoir"); return false; } this.sendRequest(item.getUniqueId()); return true; }
@Override public boolean isRunnable() { final LocalPlayerCharacter localPlayer = WakfuGameEntity.getInstance().getLocalPlayer(); return !localPlayer.isWaitingForResult() && !localPlayer.isOnFight() && !ClientTradeHelper.INSTANCE.isTradeRunning(); }
@Override public void onFrameRemove(final FrameHandler frameHandler, final boolean isAboutToBeRemoved) { if (!isAboutToBeRemoved) { WakfuGameEntity.getInstance().removeFrame(UICharacterCreationFrame.getInstance()); this.m_characterId = -1L; this.m_characterName = null; this.m_creationType = CreationType.DEFAULT; this.m_model = null; } }
@Override public boolean isRunnable(final Item item) { if (!super.isRunnable(item)) { return false; } final LocalPlayerCharacter localPlayer = WakfuGameEntity.getInstance().getLocalPlayer(); final ClientAchievementsContext achievementsContext = localPlayer.getAchievementsContext(); return !achievementsContext.isAchievementActive(this.m_achievementId) || achievementsContext.isAchievementComplete(this.m_achievementId); }
@Override public boolean onMessage(final Message message) { switch (message.getId()) { case 2050: { final boolean success = NetCharacterChoiceFrame.onCharacterSelectionResult( (CharacterSelectionResultMessage) message, this); if (!success) { WakfuProgressMonitorManager.getInstance().done(); WakfuGameEntity.getInstance().removeFrame(this); NetCharacterChoiceFrame.getInstance().enableLoadUI(true); WakfuGameEntity.getInstance().pushFrame(NetCharacterChoiceFrame.getInstance()); } return false; } case 2054: { final CharacterCreationResultMessage msg = (CharacterCreationResultMessage) message; NetCharacterCreationFrame.m_logger.info( (Object) ("R\u00e9sultat de la cr\u00e9ation de perso : succes=" + msg.isCreationSuccessful() + ", code=" + msg.getCreationCode())); if (msg.isCreationSuccessful()) { WakfuProgressMonitorManager.getInstance() .getProgressMonitor(true) .beginTask(WakfuTranslator.getInstance().getString("loadingWorld.progress"), 0); } else { WakfuProgressMonitorManager.getInstance().done(); displayNameError(msg.getCreationCode()); CharacterCreationDialogActions.setCreateCharacterFlag(false); } return false; } default: { return true; } } }
@Override public void onFrameAdd(final FrameHandler frameHandler, final boolean isAboutToBeAdded) { if (!isAboutToBeAdded) { UICharacterCreationFrame.getInstance().setCharacterId(this.m_characterId); UICharacterCreationFrame.getInstance().setCharacterName(this.m_characterName); UICharacterCreationFrame.getInstance().setCreationType(this.m_creationType); UICharacterCreationFrame.getInstance().setRecustomType(this.m_recustomType); UICharacterCreationFrame.getInstance().setSource(this.m_source); UICharacterCreationFrame.getInstance().setModel(this.m_model); WakfuGameEntity.getInstance().pushFrame(UICharacterCreationFrame.getInstance()); } }
@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; }