Package be.demmel.jgws.utils

Examples of be.demmel.jgws.utils.GWVector


  }

  @Override
  public void handlePacket(ChannelHandlerContext ctx, P064_KeyboardMoveStop packet, GameServerSession serverData, List<QueueAction> actions) throws Exception {
    CharacterData character = serverData.getCurrentCharacter();
      character.setPosition(new GWVector(packet.getPosition().getX(), packet.getPosition().getY(), (int) packet.getPlane()));
      character.setMoveType(MovementType.STOP);
      character.setMoveState(MovementState.NOT_MOVING_UNHANDLED);
  }
View Full Code Here


  @Override
  public void handlePacket(ChannelHandlerContext ctx, P054_KeyboardMove packet, GameServerSession serverData, List<QueueAction> actions) throws Exception {
    CharacterData character = serverData.getCurrentCharacter();

      character.setPosition(new GWVector(packet.getPosition().getX(), packet.getPosition().getY(), (int) packet.getPlane()));
      character.setDirection(new GWVector(packet.getDirection().getX(), packet.getDirection().getY(), 0).getUnitVector());
      character.setMoveType(MovementType.toEnum((int) packet.getType()));
      character.setMoveState(MovementState.MOVE_CHANGE_DIR);
  }
View Full Code Here

      for (MapSpawn mapSpawn : mapSpawns) {
        float spawnX = mapSpawn.getSpawnX();
        float spawnY = mapSpawn.getSpawnY();
        int planeZ = mapSpawn.getSpawnPlane();
        mapData.getPossibleSpawns().add(new GWVector(spawnX, spawnY, planeZ));
      }

      if (mapData.getPossibleSpawns().isEmpty()) {
        LOGGER.warn("No possible spawn locations for map {}", mapId);
        mapData.getPossibleSpawns().add(new GWVector(0, 0, 0));
      }

      Set<NpcSpawn> npcSpawns = getNpcSpawns(mapId, mapData.isIsOutpost(), mapData.isIsPve());

      for (NpcSpawn npcSpawn : npcSpawns) {
        int npcId = npcSpawn.getNpcId();
        int nameId = npcSpawn.getNameId();
        float spawnY = npcSpawn.getSpawnY();
        float spawnX = npcSpawn.getSpawnX();
        int planeZ = npcSpawn.getSpawnPlane();
        float rotation = npcSpawn.getRotation();
        float speed = npcSpawn.getSpeed();
        int level = npcSpawn.getLevel();
        int profession = npcSpawn.getProfession();

        // retrieve the NPC
        NpcMasterData npcMasterData = getNpcMasterDataByNpcId(npcId);

        // FIXME: what if no NPCs are found??

        int npcFileId = npcMasterData.getNpcFileId();
        byte[] modelHash = npcMasterData.getModelHash();
        byte[] appearance = npcMasterData.getAppearance();
        int scale = npcMasterData.getScale();
        int professionFlags = npcMasterData.getProfessionFlags();

        // String selectNpcNamesSql = "select * from npcs_names where nameID=" + nameId;
        // CachedRowSet resultingNpcNames = db.executeSelect(selectNpcNamesSql);

        // FIXME: wtf? there probably aren't any NPCs that why we don't get into this loop
        byte[] nameHash = null;// readBlob(resultingNpc.getBlob("nameHash"));

        // FIXME: what if no NPC names are found??
        // resultingNpcNames.next();

        NpcData npcData = new NpcData();
        npcData.setAgentID(mapData.getAgentIDs().borrowId());
        npcData.setLocalID(npcId);
        npcData.setNpcFileID(npcFileId);
        npcData.setModelHash(modelHash);
        npcData.setAppearance(appearance);
        // TODO: verify encoding here
        npcData.setName(new String(nameHash));
        npcData.setScale(scale);
        npcData.setNpcFlags(professionFlags);
        npcData.setPosition(new GWVector(spawnX, spawnY, planeZ));
        npcData.setRotation(rotation);
        npcData.setIsRotating(false);
        npcData.setSpeed(speed);
        npcData.setLevel(level);
        npcData.setProfessionPrimary((byte) profession);
        npcData.setEnergy(100);
        npcData.setEnergyRegen(0.3f);
        npcData.setHealth(100);
        npcData.setHealthRegen(0.3f);
        npcData.setDirection(new GWVector(0, 0, 0));
        npcData.setMorale(100);
        npcData.setVitalStatus(VitalStatus.ALIVE.getValue());
        npcData.setMoveState(MovementState.MOVE_KEEP_DIR);
        npcData.setMoveType(MovementType.STOP);

View Full Code Here

    public CharacterData() {
        appearance = new byte[0];
        lastHeartBeat = new Date();
        lastPingTime = new Date();
        position = new GWVector();
        direction = new GWVector();
        moveState = MovementState.NOT_MOVING;
    }
View Full Code Here

    String charName = character.getCharName();

    // Get spawn point (random from the list of spawn points (zero-based)
    Random r = new Random();
    int chosenSpawnPointIndex = r.nextInt(map.getPossibleSpawns().size());
    GWVector chosenSpwwnPoint = map.getPossibleSpawns().get(chosenSpawnPointIndex);

    if (!map.isIsPve() && playerData.getTeamNumber() < map.getPossibleSpawns().size()) {
      chosenSpwwnPoint = map.getPossibleSpawns().get(playerData.getTeamNumber());
    }

    Account account = this.getAccountByAccountId(playerData.getAccId());

    if (account == null) {
      return null;
    }

    int groupId = account.getGroupId();

    Group group = this.getGroupByGroupId(groupId);
    if (group == null) {
      return null;
    }

    String groupPrefix = group.getGroupPrefix();
    byte groupChatColor = group.getGroupChatColor();

    CharacterData characterData = new CharacterData();
    characterData.setCharID(charId);
    characterData.setName(charName);

    characterData.setGameFileID(map.getGameFileID());
    characterData.setGameMapID(map.getGameMapID());
    characterData.setIsOutpost(map.isIsOutpost());

    characterData.setProfessionPrimary(professionPrimary);
    characterData.setProfessionSecondary(professionSecondary);
    characterData.setLevel(level);
    characterData.setMorale(100);
    characterData.setHealth(12345);
    characterData.setEnergy(1337);


    byte[] skillBar = character.getSkillBar();
    byte[] skillsUnlocked = character.getSkillsAvailable();

    characterData.setAttPtsFree(attrPtsFree);
    characterData.setAttPtsTotal(attrPtsTotal);

    characterData.setAppearance(appearance.array());

    characterData.setPosition(new GWVector(chosenSpwwnPoint.getX(), chosenSpwwnPoint.getY(), chosenSpwwnPoint.getZ()));
    characterData.setDirection(new GWVector(0, 0, 0));
    characterData.setMoveState(MovementState.NOT_MOVING);
    characterData.setRotation(0xBF4FC0B6);
    characterData.setSpeed(288F);
    characterData.setChatPrefix(groupPrefix);
    characterData.setChatColor(groupChatColor);
View Full Code Here

TOP

Related Classes of be.demmel.jgws.utils.GWVector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.