Package be.demmel.jgws

Examples of be.demmel.jgws.CharacterData


    super(P057_KeyboardRotate.class);
  }

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

    // Rotation will be +Infinite when LEFT, -Infinite when RIGHT
    character.setRotation(packet.getRotation());
  }
View Full Code Here


  @Override
  public void handlePacket(ChannelHandlerContext ctx, P138_InstanceLoadRequestItems packet, GameServerSession serverData, List<QueueAction> actions)
      throws Exception {
    // Retrieve the map this user is on
    CharacterData character = serverData.getCurrentCharacter();

    short itemStreamId = 1;

    P314_ItemStreamCreate itemStreamHead = new P314_ItemStreamCreate();
    itemStreamHead.setStreamID(itemStreamId);
    ctx.write(itemStreamHead);

    P318_UpdateActiveWeaponSet updateActiveWeaponSet = new P318_UpdateActiveWeaponSet();
    updateActiveWeaponSet.setItemStreamid(itemStreamId);
    ctx.write(updateActiveWeaponSet);

    // TODO: I didn't want to implement what they did in their latest version so old version of this packet was taken for now!
    // Note: ITEM STREAM WEAPON BAR SLOTS
    // (would go here)

    // Note: ITEM STREAM END
    // (would go here)

    P393_ItemStreamTerminator itemStreamTerminator = new P393_ItemStreamTerminator();
    itemStreamTerminator.setGameMapId((int) character.getGameMapID());
    ctx.write(itemStreamTerminator);
  }
View Full Code Here

    super(P064_KeyboardMoveStop.class);
  }

  @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

    super(P129_RequestSpawnPoint.class);
  }

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

    P391_InstanceLoadSpawnPoint instanceLoadSpawnPoint = new P391_InstanceLoadSpawnPoint();
    instanceLoadSpawnPoint.setMapFile(character.getGameFileID());
    Vector2 spawn = new Vector2(character.getPosition().getX(), character.getPosition().getY());
    instanceLoadSpawnPoint.setPosition(spawn);
    instanceLoadSpawnPoint.setPlane(character.getPosition().getZ());
    ctx.write(instanceLoadSpawnPoint);
  }
View Full Code Here

    super(P054_KeyboardMove.class);
  }

  @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

            ex.printStackTrace();
        }
    }

    private void rotatePlayer(Channel rotatingPlayer, Channel recipient) throws Exception {
        CharacterData character = rotatingPlayer.attr(SessionKey.SESSION_KEY).get().getCurrentCharacter();
       
        P035_RotateAgent rotateAgent = new P035_RotateAgent();
        rotateAgent.setAgentId(character.getAgentID());
        rotateAgent.setRotation(character.getRotation());
        rotateAgent.setUnknown3(0x40060A92);
        recipient.write(rotateAgent);
    }
View Full Code Here

            ex.printStackTrace();
        }
    }

    private void movePlayer(Channel movingPlayer, Channel recipient) throws Exception {
        CharacterData character = movingPlayer.attr(SessionKey.SESSION_KEY).get().getCurrentCharacter();
        MovementType moveType = character.getMoveType();

        if (moveType == MovementType.FORWARD || moveType == MovementType.DIAG_FW_LEFT || moveType == MovementType.DIAG_FW_RIGHT || moveType == MovementType.STOP) {
            character.setSpeedModifier(1f);
        } else if (moveType == MovementType.BACKWARD || moveType == MovementType.DIAG_BW_LEFT || moveType == MovementType.DIAG_BW_RIGHT) {
            character.setSpeedModifier(.066f);
        } else if (moveType == MovementType.SIDE_LEFT || moveType == MovementType.SIDE_RIGHT) {
            character.setSpeedModifier(0.75f);
        } else if (moveType == MovementType.COLLISION) {
            // dont change speed modifier, as it is dynamically set.
            // reset movetype, cause 10 is non existant for the client
            moveType = MovementType.FORWARD;
        }

        if (moveType != MovementType.STOP && character.getMoveState() == MovementState.MOVE_CHANGE_DIR) {
            P026_MovementDirection movementDirection = new P026_MovementDirection();
            movementDirection.setAgentId(character.getAgentID());
            Vector2 direction = new Vector2(character.getDirection().getX(), character.getDirection().getY());
            movementDirection.setDirection(direction);
            movementDirection.setMoveType((short) moveType.getValue());
            recipient.write(movementDirection);
           
            // reset the moving state here
            character.setMoveState(MovementState.MOVE_KEEP_DIR);
        }

        P032_MovementSpeedModifier movementSpeedModifier = new P032_MovementSpeedModifier();
        movementSpeedModifier.setAgentId(character.getAgentID());
        movementSpeedModifier.setSpeed(character.getSpeedModifier());
        movementSpeedModifier.setMoveType((short) moveType.getValue());
        recipient.write(movementSpeedModifier);

        P030_MovementAim movementAim = new P030_MovementAim();
        movementAim.setAgentId(character.getAgentID());
        Vector2 position = new Vector2(character.getPosition().getX(), character.getPosition().getY());
        movementAim.setPosition(position);
        movementAim.setPlane(character.getPosition().getZ());
        recipient.write(movementAim);
    }
View Full Code Here

          // TODO: what to do in this case? review the exceptions possible?
        }

        GameServerSession playerData = channel.attr(SessionKey.SESSION_KEY).get();
        // Retrieve the Character the player is currently playing
        CharacterData character = playerData.getCurrentCharacter();

        P085_GeneralChatOwner generalChatOwner = new P085_GeneralChatOwner();
        generalChatOwner.setUnknown1((int) character.getLocalID());
        generalChatOwner.setUnknown2(chatColor);
        try {
          channel.write(generalChatOwner);
        } catch (Exception e) {
          // TODO: idem
View Full Code Here

  }

  @Override
  public void handlePacket(ChannelHandlerContext ctx, P005_Ping packet, GameServerSession serverData, List<QueueAction> actions) throws Exception {
    P002_PingReply pingReply = new P002_PingReply();
    CharacterData character = serverData.getCurrentCharacter();
    long timeBetweenNowAndLastPing = new Date().getTime() - character.getLastPingTime().getTime();
    pingReply.setUnknown1(timeBetweenNowAndLastPing);
    ctx.write(pingReply);
  }
View Full Code Here

  }

  @Override
  public void handlePacket(ChannelHandlerContext ctx, P003_PingReply packet, GameServerSession serverData, List<QueueAction> actions) throws Exception {
    // Retrieve the Character the player is currently playing
    CharacterData character = serverData.getCurrentCharacter();
    long timeBetweenNowAndLastPing = new Date().getTime() - character.getLastPingTime().getTime();

    P002_PingReply pingReply = new P002_PingReply();
    pingReply.setUnknown1(timeBetweenNowAndLastPing);
    ctx.write(pingReply);
  }
View Full Code Here

TOP

Related Classes of be.demmel.jgws.CharacterData

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.