com.tera.gsaion.network.packethandler.server.W_NPC_INFO.java Source code

Java tutorial

Introduction

Here is the source code for com.tera.gsaion.network.packethandler.server.W_NPC_INFO.java

Source

/**
 * This file is part of tera-api.
 *
 * tera-api is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
    
 * tera-api is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
    
 * You should have received a copy of the GNU General Public License
 * along with tera-api.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.tera.gsaion.network.packethandler.server;

import org.apache.commons.lang.StringUtils;

import com.tera.gapi.npc.model.Npc;
import com.tera.gapi.world.model.WorldPosition;
import com.tera.gsaion.network.packet.server.S_NPC_INFO;
import com.tera.gsaion.npc.template.ANpcTemplate;

/**
 * @author ATracer
 * @since 0.1.0
 */
public class W_NPC_INFO extends GAionServerPacket<S_NPC_INFO> {

    @Override
    protected void writeImpl(S_NPC_INFO cp, Object buf) {
        final Npc npc = cp.getNpc();
        final WorldPosition position = npc.getPosition();
        final ANpcTemplate template = (ANpcTemplate) npc.getTemplate();
        writeF(buf, position.getX());
        writeF(buf, position.getY());
        writeF(buf, position.getZ());
        writeD(buf, npc.getObjectId());
        writeD(buf, template.getTemplateId());
        writeD(buf, template.getTemplateId());

        writeC(buf, 38);// TODO npc type id
        writeH(buf, 65);// TODO npc state
        writeC(buf, position.getHeading());
        writeD(buf, template.getNameId());
        writeD(buf, 0);// TODO title id

        writeH(buf, 0x00);// unk
        writeC(buf, 0x00);// unk
        writeD(buf, 0x00);// unk

        writeD(buf, 0);// TODO masterObjectId
        writeS(buf, StringUtils.EMPTY);// TODO masterName

        writeC(buf, 100);// TODO %hp
        writeD(buf, 100);// TODO maxhp
        writeC(buf, template.getLevel());

        writeH(buf, 0x00); // TODO gear

        writeF(buf, 1.5f);// unk
        writeF(buf, template.getHeight());
        writeF(buf, template.getWalkSpeed());// TODO current speed

        writeH(buf, 2000);// 0x834 (depends on speed ? )
        writeH(buf, 2000);// 0x834

        writeC(buf, 0x00);// unk

        // TODO movement same as for player
        writeF(buf, position.getX());// x
        writeF(buf, position.getY());// y
        writeF(buf, position.getZ());// z
        writeC(buf, 0x00); // move type
        writeH(buf, 0);// TODO static id from spawn
        writeC(buf, 0);
        writeC(buf, 0);
        writeC(buf, 0);
        writeC(buf, 0);
        writeC(buf, 0);
        writeC(buf, 0);
        writeC(buf, 0);
        writeC(buf, 0);
        writeC(buf, 0); // TODO visualState

        writeH(buf, 1);// TODO npc object type id
        writeC(buf, 0x00);// unk
        writeD(buf, 0);// TODO npc target obj id
    }

}