Package be.demmel.jgws

Examples of be.demmel.jgws.CharacterData


        RC4Encoder rc4Encoder = new RC4Encoder(rc4Key);
        ctx.pipeline().addFirst("rc4EnCoder", rc4Encoder);
       
        // Retrieve the map this user is on
        MapData map = serverData.getMap();
        CharacterData character = serverData.getCurrentCharacter();

        P370_InstanceLoadHead instanceLoadHeader = new P370_InstanceLoadHead();
        instanceLoadHeader.setUnknown1(character.isIsOutpost() ? (short) 0x3F : (short) 0x1F);
        instanceLoadHeader.setUnknown2(character.isIsOutpost() ? (short) 0x3F : (short) 0x1F);
        instanceLoadHeader.setUnknown3((short) 0x00);
        instanceLoadHeader.setUnknown4((short) 0x00);
        ctx.write(instanceLoadHeader);

        P371_InstanceLoadCharName instanceLoadCharName = new P371_InstanceLoadCharName();
        instanceLoadCharName.setCharName(character.getName());
        ctx.write(instanceLoadCharName);

        P395_InstanceLoadDistrictInfo instanceLoadDistrictInfo = new P395_InstanceLoadDistrictInfo();
        instanceLoadDistrictInfo.setCharAgent(character.getLocalID());
        instanceLoadDistrictInfo.setMapID(map.getGameMapID());
        instanceLoadDistrictInfo.setDistrictAndRegion((character.isIsOutpost() ? map.getDistrictNumber() : 0)
            | (character.isIsOutpost() ? map.getDistrictCountry() : 0));
        instanceLoadDistrictInfo.setIsExplorable(character.isIsOutpost() ? (short) 1 : 0);
        instanceLoadDistrictInfo.setIsObserver((byte) 0);
        instanceLoadDistrictInfo.setLanguage(character.isIsOutpost() ? 0 : (short) 3);

        ctx.write(instanceLoadDistrictInfo);
      }
    });
  }
View Full Code Here


    super(P004_RequestHeartBeat.class);
  }

  @Override
  public void handlePacket(final ChannelHandlerContext ctx, P004_RequestHeartBeat packet, final GameServerSession serverData, List<QueueAction> actions) throws Exception {
      CharacterData character = serverData.getCurrentCharacter();
      character.setPlayer(PlayStatus.READY_TO_PLAY);
      character.setLastHeartBeat(new Date());
     
      ctx.channel().eventLoop().scheduleAtFixedRate(() -> { // start sending heartbeats to this client
        // Retrieve the Character the player is currently playing
              CharacterData currentCharacter = serverData.getCurrentCharacter();
             
              if(currentCharacter.getPlayer() != PlayStatus.READY_TO_PLAY) {
                return;
              }

              // Even if we sleep 250 ms we need to calcaulate this. Why? I dunno.
              long timeBetweenNowAndLastHeartbeat = new Date().getTime() - currentCharacter.getLastHeartBeat().getTime();

              LOGGER.debug("{} Sending HeartBeat for character with charId: {}", ctx.channel(), currentCharacter.getCharID());

              P019_Heartbeat heartbeat = new P019_Heartbeat();
              heartbeat.setUnknown1(timeBetweenNowAndLastHeartbeat);
              ctx.write(heartbeat);

              currentCharacter.setLastHeartBeat(new Date());
    }, 250, 250, TimeUnit.MILLISECONDS);
  }
View Full Code Here

    // serverData.getSecurityKeys()[1] = newKeys2;
    serverData.setAccId((int) foundPlayerData.getAccId());

    // Load the character on the map
    // TODO: how do we share maps between teams? We're not going to have all chars on the same map, right??
    CharacterData addedCharacter = loadCharacterById(packet, (int) foundPlayerData.getCharId(), serverData, map);
    serverData.setCurrentCharacter(addedCharacter);

    // add this Player to the map by adding its clientdata!
    //map.addPlayer(clientData); //FIXME: this was commented as the player will be in the general group already and this should be changed to have a group per map/district
View Full Code Here

    }

    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);

    // TODO: add chat commands, although not necessary for the basic version

    characterData.setAgentID(map.getAgentIDs().borrowId());
    characterData.setLocalID(map.getLocalIDs().borrowId());

    return characterData;
  }
View Full Code Here

      for(Channel channel : channels) {
        MDC.put("channel", String.format("[id: 0x%08x]",channel.hashCode()));
        GameServerSession playerData = channel.attr(SessionKey.SESSION_KEY).get();
       
        // Retrieve the Character the player is currently playing
            CharacterData character = playerData.getCurrentCharacter();
           
            if(character == null) {// character not loaded yet
              continue;
            }

            MovementState movementState = character.getMoveState();

            switch (movementState) {
                case MOVE_CHANGE_DIR:
                    MovePlayerAction movePlayerActionChangeDir = new MovePlayerAction(channel, channels);
                    this.actionQueue.addAction(movePlayerActionChangeDir);

                    character.setMoveState(MovementState.MOVE_KEEP_DIR);
                    break;
                case MOVE_KEEP_DIR:
                    // Only move the player each 250ms (if the direction is kept)
                    if ((new Date().getTime() - character.getLastHeartBeat().getTime()) > 250) {
                        MovePlayerAction movePlayerActionKeepDir = new MovePlayerAction(channel, channels);
                        this.actionQueue.addAction(movePlayerActionKeepDir);
                    }
                    break;
                case NOT_MOVING_UNHANDLED:
                    MovePlayerAction movePlayerActionUnhandled = new MovePlayerAction(channel, channels);
                    this.actionQueue.addAction(movePlayerActionUnhandled);
                   
                    // Calculate the rotation
                    character.setRotation((float)Math.atan2(character.getDirection().getY(), character.getDirection().getX()));
                    RotatePlayerAction rotatePlayerAction = new RotatePlayerAction(channel, channels);
                    this.actionQueue.addAction(rotatePlayerAction);
                   
                    character.setMoveState(MovementState.NOT_MOVING);
                    break;
            }
      }
    }
View Full Code Here

    super(P093_ChatMessage.class);
  }

  @Override
  public void handlePacket(ChannelHandlerContext ctx, P093_ChatMessage packet, GameServerSession serverData, List<QueueAction> actions) throws Exception {
    CharacterData character = serverData.getCurrentCharacter();
    ChannelGroup allChannels = ctx.attr(AllChannelsKey.ALL_CHANNELS_KEY).get();
    actions.add(new ChatMessageAction(character, packet.getMessage(), allChannels));
  }
View Full Code Here

  @Override
  public void handlePacket(ChannelHandlerContext ctx, P137_InstanceLoadRequestPlayerData packet, GameServerSession serverData, List<QueueAction> actions)
      throws Exception {
    // Retrieve the map this user is on
    // FIXME: the login server could actually pass all the data directly to the GameServer (via RMI) instead of loading it while treating packets!!!
    CharacterData character = serverData.getCurrentCharacter();
    LOGGER.debug("The Character: {}", character);

    P230_ZoneDataBeginCharInfo zoneDataBeginCharInfo = new P230_ZoneDataBeginCharInfo();
    zoneDataBeginCharInfo.setUnknown1(1886151033); // "yalp" ???
    ctx.write(zoneDataBeginCharInfo);

    P044_AgentAttributeCreate updateAttributePoints = new P044_AgentAttributeCreate();
    updateAttributePoints.setAgentID(character.getAgentID());
    updateAttributePoints.setFreePoints((short) character.getAttPtsFree());
    updateAttributePoints.setMaxPoints((short) character.getAttPtsTotal());
    ctx.write(updateAttributePoints);

    P171_UpdatePrivProfessions updatePrivProfessions = new P171_UpdatePrivProfessions();
    updatePrivProfessions.setAgentID(character.getAgentID());
    updatePrivProfessions.setProfession1(character.getProfessionPrimary());
    updatePrivProfessions.setProfession2(character.getProfessionSecondary());
    ctx.write(updatePrivProfessions);

    P206_UpdateSkillBar updateSkillBar = new P206_UpdateSkillBar();
    updateSkillBar.setAgentID(character.getAgentID());
    updateSkillBar.setSkillBar(new long[8]);
    updateSkillBar.setSkillBarPvpMask(new long[8]);
    updateSkillBar.setUnknown4((byte) 1);
    ctx.write(updateSkillBar);

    P147_UpdateGenericValueInt updateEnergy = new P147_UpdateGenericValueInt();
    updateEnergy.setAgentId(character.getAgentID());
    updateEnergy.setValueId(GenericValues.Energy.getValue());
    updateEnergy.setValue(character.getEnergy());
    ctx.write(updateEnergy);

    P150_UpdateGenericValueFloat updateEnergyRegen = new P150_UpdateGenericValueFloat();
    updateEnergyRegen.setAgentId(character.getAgentID());
    updateEnergyRegen.setValueId(GenericValues.EnergyRegen.getValue());
    updateEnergyRegen.setValue(character.getEnergyRegen());
    ctx.write(updateEnergyRegen);

    P147_UpdateGenericValueInt updateHealth = new P147_UpdateGenericValueInt();
    updateHealth.setAgentId(character.getAgentID());
    updateHealth.setValueId(GenericValues.Health.getValue());
    updateHealth.setValue(character.getHealth());
    ctx.write(updateHealth);

    P150_UpdateGenericValueFloat updateHealthRegen = new P150_UpdateGenericValueFloat();
    updateHealthRegen.setAgentId(character.getAgentID());
    updateHealthRegen.setValueId(GenericValues.HealthRegen.getValue());
    updateHealthRegen.setValue(character.getHealthRegen());
    ctx.write(updateHealthRegen);

    P147_UpdateGenericValueInt updatelevel = new P147_UpdateGenericValueInt();
    updatelevel.setAgentId(character.getAgentID());
    updatelevel.setValueId(GenericValues.PublicLevel.getValue());
    updatelevel.setValue(character.getLevel());
    ctx.write(updatelevel);

    P127_ZoneDataPrepMapData prepMap = new P127_ZoneDataPrepMapData();
    prepMap.setUnknown1(64);
    prepMap.setUnknown2(128);
    prepMap.setUnknown3(27);
    ctx.write(prepMap);

    P126_ZoneDataMapData mapData = new P126_ZoneDataMapData();
    mapData.setUnknown1(new long[] { (0x0B << 16), (0xff | 0xff << 8 | 0x54 << 16 | 0x03 << 24), (0x3b | 0x04 << 8 | 0x3a << 16 | 0x04 << 24),
        (0x3a | 0x04 << 8 | 0xe8 << 16), 0, 0, (0x17 << 24) });
    ctx.write(mapData);

    P221_UpdateFaction faction = new P221_UpdateFaction();
    faction.setKurzFree(0);
    faction.setKurzTotal(0);
    faction.setLuxFree(0);
    faction.setLuxTotal(0);
    faction.setImpFree(0);
    faction.setImpTotal(0);
    faction.setBalthFree(0);
    faction.setBalthMax(0);
    faction.setLevel(character.getLevel());
    faction.setMorale(character.getMorale());
    ctx.write(faction);

    P207_UpdateAvailableSkills updateAvailableSkills = new P207_UpdateAvailableSkills();
    // TODO: convert the skills from the char to the right integer values (because the client uses the length of ints, we have bytes)
    // empty for now, database doesn't support it for now anyway
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.