11op三国群英传

 找回密码
 立即注册
搜索
热搜: 三国群英传
查看: 2523|回复: 0
打印 上一主题 下一主题

关于台湾单机端在内核加入假人系统的方法

[复制链接]

1580

主题

1930

帖子

6915

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
6915
跳转到指定楼层
楼主
发表于 2018-9-22 23:28:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
话就不多说了!看有很多朋友喜欢游戏里添加假人系统!

那么我就把台湾端内核加入假人的方法告诉大家;喜欢的可以去按照说的去尝试!
这个原作者为“半月”,禁止在本论坛发布其他论坛网址!

补充说明:数据库npcchardata 第一栏位已由npc_id 变更为npcId;
NpcTable.java;
文件头加入
//add by L2CN<
import com.l2jserver.gameserver.model.L2NpcCharData;
import javolution.util.FastList;
//add by L2CN>
搜索
loadNpcsAI(0);
在其后加入:
loadNpcsChar(0);//add by L2CN
搜索
loadNpcsAI(id);
在其后加入:
loadNpcsChar(id);//add by L2CN
搜索
public void loadNpcsElement(int id)
在其前面加入
//add by L2CN<
public void loadNpcsChar(int id)
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = null;
if (id > 0)
{
statement = con.prepareStatement("SELECT * FROM npcchardata WHERE npcId = ?");
statement.setInt(1, id);
}
else
{
statement = con.prepareStatement("SELECT * FROM npcchardata ORDER BY npcId");
}
ResultSet rset = statement.executeQuery();
L2NpcCharData npcCharDat = null;
L2NpcTemplate npcDat = null;
int cont = 0;
int npcId;
while (rset.next())
{
npcId = rset.getInt("npcId");
npcDat = _npcs.get(npcId);
if (npcDat == null)
{
_log.severe(getClass().getSimpleName() + ": Char Data Error with id : " + npcId);
continue;
}
npcCharDat = new L2NpcCharData();
npcCharDat.setIsChar(rset.getInt("ischar"));
npcCharDat.setCharClass(rset.getInt("charclass"));
npcCharDat.setCharRace(rset.getInt("charrace"));
npcCharDat.setCharFace(rset.getInt("charface"));
npcCharDat.setCharHair(rset.getInt("charhair"));
npcCharDat.setCharHairColor(rset.getInt("charhaircolor"));
npcCharDat.setCharColor(rset.getString("charcolor"));
npcCharDat.setCharSex(rset.getInt("charsex"));
npcCharDat.setCharHero(rset.getInt("charhero"));
npcCharDat.setLrhand(rset.getInt("lrhand"));
npcCharDat.setArmor(rset.getInt("armor"));
npcCharDat.setPant(rset.getInt("pant"));
npcCharDat.setHead(rset.getInt("head"));
npcCharDat.setBoot(rset.getInt("boot"));
npcCharDat.setGlove(rset.getInt("glove"));
npcCharDat.setBack(rset.getInt("back"));
npcCharDat.setHair(rset.getInt("hair"));
npcCharDat.setDHair(rset.getInt("dhair"));
npcCharDat.setFace(rset.getInt("face"));
npcCharDat.setEnchLvl(rset.getInt("enchlvl"));
npcCharDat.setAugmentation(rset.getInt("augmentation"));
npcDat.setCharData(npcCharDat);
cont++;
}
rset.close();
statement.close();
_log.info(getClass().getSimpleName() + ": Loaded " + cont + " Char Data.");
}
catch (Exception e)
{
_log.log(Level.SEVERE, getClass().getSimpleName() + ": Error reading NPC Char Data: " + e.getMessage(), e);
}
finally
{
L2DatabaseFactory.close(con);
}
}
//add by L2CN>
L2Npc.java;
文件头加入
//add by L2CN<
import javolution.util.FastList;
import com.l2jserver.gameserver.model.L2NpcCharData;
import com.l2jserver.gameserver.datatables.NpcTable;
//add by L2CN>
搜索
private double _currentCollisionRadius; // used for npc grow effect skills
在其后加入
//add by L2CN<
private final L2NpcCharData _ChardataStatic = getTemplate().getCharDataStatic();
public int getIsChar()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getIsChar();
}
public int getCharClass()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharClass();
}
public int getCharRace()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharRace();
}
public int getLrhand()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getLrhand();
}
public int getArmors()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getArmor();
}
public int getPant()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getPant();
}
public int getHead()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getHead();
}
public int getGlove()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getGlove();
}
public int getBoot()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getBoot();
}
public int getBack()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getBack();
}
public int getDHair()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getDHair();
}
public int getFace()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getFace();
}
public int getHair()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getHair();
}
public int getAugmentation()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getAugmentation();
}
public int getEnchLvl()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getEnchLvl();
}
public int getCharFace()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharFace();
}
public int getCharHair()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharHair();
}
public int getCharHairColor()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharHairColor();
}
public String getCharColor()
{
if (_ChardataStatic == null)
return "0xFFFFFF";
return _ChardataStatic.getCharColor();
}
public int getCharSex()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharSex();
}
public int getCharHero()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharHero();
}
//add by L2CN>


L2Summon.java;
文件头加入
//add by L2CN<
import com.l2jserver.gameserver.datatables.NpcTable;
import com.l2jserver.gameserver.model.L2NpcCharData;
//add by L2CN>
搜索
public boolean isSummon()
{
return true;
}
在其后加入
//add by L2CN<
private final L2NpcCharData _ChardataStatic = getTemplate().getCharDataStatic();
public int getIsChar()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getIsChar();
}
public int getCharClass()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharClass();
}
public int getCharRace()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharRace();
}
public int getLrhand()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getLrhand();
}
public int getArmors()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getArmor();
}
public int getPant()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getPant();
}
public int getHead()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getHead();
}
public int getGlove()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getGlove();
}
public int getBoot()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getBoot();
}
public int getBack()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getBack();
}
public int getDHair()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getDHair();
}
public int getFace()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getFace();
}
public int getHair()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getHair();
}
public int getAugmentation()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getAugmentation();
}
public int getEnchLvl()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getEnchLvl();
}
public int getCharFace()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharFace();
}
public int getCharHair()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharHair();
}
public int getCharHairColor()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharHairColor();
}
public String getCharColor()
{
if (_ChardataStatic == null)
return "0xFFFFFF";
return _ChardataStatic.getCharColor();
}
public int getCharSex()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharSex();
}
public int getCharHero()
{
if (_ChardataStatic == null)
return 0;
return _ChardataStatic.getCharHero();
}
//add by L2CN>


L2NpcTemplate.java;
文件头加入
//add by L2CN<
import com.l2jserver.gameserver.model.L2NpcCharData;
//add by L2CN>
搜索
public L2NpcAIData getAIDataStatic()
{
return _AIdataStatic;
}
在其后加入
//add by L2CN<
public L2NpcCharData getCharDataStatic()
{
return _ChardataStatic;
}
//add by L2CN>
搜索
public boolean isUndead()
{
return _race == Race.UNDEAD;
}
在其后加入
//add by L2CN<
public void setCharData(L2NpcCharData chardata)
{
_ChardataStatic = new L2NpcCharData();
_ChardataStatic = chardata;
}
//add by L2CN>

AbstractNpcInfo.java;
因格式问题,请完整替换文件代码。
/*
* This program 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.
*
* This program 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
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.instancemanager.TownManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.L2Trap;
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.effects.AbnormalEffect;
import com.l2jserver.gameserver.datatables.MessageTable;
/**
* This class ...
*
* @version $Revision: 1.7.2.4.2.9 $ $Date: 2005/04/11 10:05:54 $
*/
public abstract class AbstractNpcInfo extends L2GameServerPacket
{
// ddddddddddddddddddffffdddcccccSSddd dddddc
// ddddddddddddddddddffffdddcccccSSddd dddddccffd

private static final String _S__22_NPCINFO = "[S] 0c NpcInfo";
protected int _x, _y, _z, _heading;
protected int _idTemplate;
protected boolean _isAttackable, _isSummoned;
protected int _mAtkSpd, _pAtkSpd;

/**
* Run speed, swimming run speed and flying run speed
*/
protected int _runSpd;

/**
* Walking speed, swimming walking speed and flying walking speed
*/
protected int _walkSpd;

protected int _rhand, _lhand, _chest, _enchantEffect;
protected double _collisionHeight, _collisionRadius;
protected String _name = "";
protected String _title = "";
//add by L2CN<
protected int _lrhand, enchlvl, armor, head, boot, pant, glove, back, charrace, charhair, charface,
charhaircolor, charcolor, charclass, charhero, charsex, dhair, hair, face, augmentation;
protected boolean IsChar;
//add by L2CN>

public AbstractNpcInfo(L2Character cha)
{
_isSummoned = cha.isShowSummonAnimation();
_x = cha.getX();
_y = cha.getY();
_z = cha.getZ();
_heading = cha.getHeading();
_mAtkSpd = cha.getMAtkSpd();
_pAtkSpd = cha.getPAtkSpd();
_runSpd = cha.getTemplate().getBaseRunSpd();
_walkSpd = cha.getTemplate().getBaseWalkSpd();
}

@Override
public String getType()
{
return _S__22_NPCINFO;
}

/**
* Packet for Npcs
*/
public static class NpcInfo extends AbstractNpcInfo
{
private final L2Npc _npc;
private int _clanCrest = 0;
private int _allyCrest = 0;
private int _allyId = 0;
private int _clanId = 0;
private int _displayEffect = 0;
public NpcInfo(L2Npc cha, L2Character attacker)
{
super(cha);
_npc = cha;
_idTemplate = cha.getTemplate().getIdTemplate(); // On every subclass
_rhand = cha.getRightHandItem(); // On every subclass
_lhand = cha.getLeftHandItem(); // On every subclass
_enchantEffect = cha.getEnchantEffect();
_collisionHeight = cha.getCollisionHeight();// On every subclass
_collisionRadius = cha.getCollisionRadius();// On every subclass
_isAttackable = cha.isAutoAttackable(attacker);
if (cha.getTemplate().isServerSideName())
_name = cha.getName();// On every subclass
if (Config.L2JMOD_CHAMPION_ENABLE && cha.isChampion())
_title = (Config.L2JMOD_CHAMP_TITLE); // On every subclass
else if (cha.getTemplate().isServerSideTitle())
_title = cha.getTemplate().getTitle(); // On every subclass
else
_title = cha.getTitle(); // On every subclass
if (Config.SHOW_NPC_LVL && _npc instanceof L2MonsterInstance)
{
/* Move To MessageTable For L2JTW
String t = "Lv " + cha.getLevel() + (cha.getAggroRange() > 0 ? "*" : "");
*/
String t = MessageTable.Messages[211].getExtra(1) + cha.getLevel() + (cha.getAggroRange() > 0 ? MessageTable.Messages[211].getExtra(2) : "");
if (_title != null)
t += " " + _title;
_title = t;
}
// npc crest of owning clan/ally of castle
if (cha instanceof L2NpcInstance && cha.isInsideZone(L2Character.ZONE_TOWN) && (Config.SHOW_CREST_WITHOUT_QUEST || cha.getCastle().getShowNpcCrest()) && cha.getCastle().getOwnerId() != 0)
{
int townId = TownManager.getTown(_x, _y, _z).getTownId();
if (townId != 33 && townId != 22)
{
L2Clan clan = ClanTable.getInstance().getClan(cha.getCastle().getOwnerId());
_clanCrest = clan.getCrestId();
_clanId = clan.getClanId();
_allyCrest = clan.getAllyCrestId();
_allyId = clan.getAllyId();
}
}
_displayEffect = cha.getDisplayEffect();
//add by L2CN<
if (cha.getIsChar() > 0)
{
IsChar = true;
armor = cha.getArmors();
pant = cha.getPant();
head = cha.getHead();
boot = cha.getBoot();
glove = cha.getGlove();
back = cha.getBack();
face = cha.getFace();
dhair = cha.getDHair();
hair = cha.getHair();
_lrhand = cha.getLrhand();
charrace = cha.getCharRace();
charclass = cha.getCharClass();
charface = cha.getCharFace();
charhaircolor = cha.getCharHairColor();
charcolor = Integer.decode("0x"+cha.getCharColor());
charhair = cha.getCharHair();
charhero = cha.getCharHero();
charsex = cha.getCharSex();
augmentation = cha.getAugmentation();
if (cha.getEnchLvl()>0)
{
enchlvl = Math.min(127, cha.getEnchLvl());
}
else enchlvl= 0;
}
//add by L2CN>
}
@Override
protected void writeImpl()
//add by L2CN<
{
if (IsChar)
{
writeC(0x31);
writeD(_x);
writeD(_y);
writeD(_z);
writeD(0x00);
writeD(_npc.getObjectId());
writeS(_npc.getTemplate().getName());
writeD(charrace);
writeD(charsex);
writeD(charclass);
writeD(dhair);
writeD(head);
writeD(_rhand);
writeD(_lhand);
writeD(glove);
writeD(armor);
writeD(pant);
writeD(boot);
writeD(back);
writeD(_lrhand);
writeD(hair);
writeD(face);
// T1 new d's
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
// end of t1 new d's
// c6 new h's
writeD(0x00);
writeD(0x00);
writeD(augmentation);
writeD(augmentation);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(augmentation);
writeD(0x00);
writeD(0x00);
// T1 new h's
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x01);
// end of t1 new h's
writeD(0x00);
writeD(0x00);
writeD(_mAtkSpd);
writeD(_pAtkSpd);
writeD(0x00);
writeD(_runSpd); // TODO: the order of the speeds should be confirmed
writeD(_walkSpd);
writeD(_runSpd); // swim run speed
writeD(_walkSpd); // swim walk speed
writeD(_runSpd); // fly run speed
writeD(_walkSpd); // fly walk speed
writeD(_runSpd); // fly run speed ?
writeD(_walkSpd); // fly walk speed ?
writeF(_runSpd * 1f / 120); // _activeChar.getProperMultiplier()
writeF(((1.1) * _pAtkSpd / 300)); // _activeChar.getAttackSpeedMultiplier()
writeF(_collisionRadius);
writeF(_collisionHeight);
writeD(charhair);
writeD(charhaircolor);
writeD(charface);
writeS(_title);
writeD(0);
writeD(0);
writeD(0);
writeD(0);
writeC(1); // standing = 1 sitting = 0
writeC(_npc.isRunning() ? 1 : 0); // running = 1 walking = 0
writeC(_npc.isInCombat() ? 1 : 0);
writeC(_npc.isAlikeDead() ? 1 : 0);
writeC(0); // invisible = 1 visible =0
writeC(0); // 1-on Strider, 2-on Wyvern, 3-on Great Wolf, 0-no mount
writeC(1); // 1 - sellshop
writeH(0);
writeC(0x00);
writeD(_npc.getAbnormalEffect());
writeC(0); //Changed by Thorgrim
writeH(0); //Blue value for name (0 = white, 255 = pure blue)
writeD(0);
writeD(charclass);
writeD(0);
writeC(enchlvl);
writeC(0x00); //team circle around feet 1= Blue, 2 = red
writeD(0);
writeC(0);
writeC(charhero); // Hero Aura
writeC(0); //0x01: Fishing Mode (Cant be undone by setting back to 0)
writeD(0);
writeD(0);
writeD(0);
writeD(charcolor);
writeD(_heading); // isRunning() as in UserInfo?
writeD(0);
writeD(0); // ??
writeD(0xFFFF77);
writeD(0x00);
writeD(0x00);
// T1
writeD(0x00);
writeD(0x00);
// T2
writeD(0x01);
// T2.3
writeD(_npc.getSpecialEffect());
}
else
//add by L2CN>
{
writeC(0x0c);
writeD(_npc.getObjectId());
writeD(_idTemplate + 1000000); // npctype id
writeD(_isAttackable ? 1 : 0);
writeD(_x);
writeD(_y);
writeD(_z);
writeD(_heading);
writeD(0x00);
writeD(_mAtkSpd);
writeD(_pAtkSpd);
writeD(_runSpd);
writeD(_walkSpd);
writeD(_runSpd); // swim run speed
writeD(_walkSpd); // swim walk speed
writeD(_runSpd); // swim run speed
writeD(_walkSpd); // swim walk speed
writeD(_runSpd); // fly run speed
writeD(_walkSpd); // fly run speed
writeF(_npc.getMovementSpeedMultiplier());
writeF(_npc.getAttackSpeedMultiplier());
writeF(_collisionRadius);
writeF(_collisionHeight);
writeD(_rhand); // right hand weapon
writeD(_chest);
writeD(_lhand); // left hand weapon
writeC(1); // name above char 1=true ... ??
writeC(_npc.isRunning() ? 1 : 0);
writeC(_npc.isInCombat() ? 1 : 0);
writeC(_npc.isAlikeDead() ? 1 : 0);
writeC(_isSummoned ? 2 : 0); // 0=teleported 1=default 2=summoned
writeD(-1); // High Five NPCString ID
writeS(_name);
writeD(-1); // High Five NPCString ID
writeS(_title);
writeD(0x00); // Title color 0=client default
writeD(0x00); //pvp flag
writeD(0x00); // karma
writeD(_npc.getAbnormalEffect()); // C2
writeD(_clanId); //clan id
writeD(_clanCrest); //crest id
writeD(_allyId); // ally id
writeD(_allyCrest); // all crest
writeC(_npc.isFlying() ? 2 : 0); // C2
writeC(_npc.getTeam()); // team color 0=none, 1 = blue, 2 = red
writeF(_collisionRadius);
writeF(_collisionHeight);
writeD(_enchantEffect); // C4
writeD(_npc.isFlying() ? 1 : 0); // C6
writeD(0x00);
writeD(_npc.getColorEffect());// CT1.5 Pet form and skills, Color effect
writeC(_npc.isShowName() ? 0x01 : 0x00);
writeC(_npc.isTargetable() ? 0x01 : 0x00);
writeD(_npc.getSpecialEffect());
writeD(_displayEffect);
}
}
}

public static class TrapInfo extends AbstractNpcInfo
{
private final L2Trap _trap;
public TrapInfo(L2Trap cha, L2Character attacker)
{
super(cha);
_trap = cha;
_idTemplate = cha.getTemplate().getIdTemplate();
_isAttackable = cha.isAutoAttackable(attacker);
_rhand = 0;
_lhand = 0;
_collisionHeight = _trap.getTemplate().getfCollisionHeight();
_collisionRadius = _trap.getTemplate().getfCollisionRadius();
if (cha.getTemplate().isServerSideName())
_name = cha.getName();
_title = cha.getOwner() != null ? cha.getOwner().getName() : "";
_runSpd = _trap.getRunSpeed();
_walkSpd = _trap.getWalkSpeed();
}
@Override
protected void writeImpl()
{
writeC(0x0c);
writeD(_trap.getObjectId());
writeD(_idTemplate + 1000000); // npctype id
writeD(_isAttackable ? 1 : 0);
writeD(_x);
writeD(_y);
writeD(_z);
writeD(_heading);
writeD(0x00);
writeD(_mAtkSpd);
writeD(_pAtkSpd);
writeD(_runSpd);
writeD(_walkSpd);
writeD(_runSpd); // swim run speed
writeD(_walkSpd); // swim walk speed
writeD(_runSpd); // fly run speed
writeD(_walkSpd); // fly walk speed
writeD(_runSpd); // fly run speed
writeD(_walkSpd); // fly walk speed
writeF(_trap.getMovementSpeedMultiplier());
writeF(_trap.getAttackSpeedMultiplier());
writeF(_collisionRadius);
writeF(_collisionHeight);
writeD(_rhand); // right hand weapon
writeD(_chest);
writeD(_lhand); // left hand weapon
writeC(1); // name above char 1=true ... ??
writeC(1);
writeC(_trap.isInCombat() ? 1 : 0);
writeC(_trap.isAlikeDead() ? 1 : 0);
writeC(_isSummoned ? 2 : 0); // 0=teleported 1=default 2=summoned
writeD(-1); // High Five NPCString ID
writeS(_name);
writeD(-1); // High Five NPCString ID
writeS(_title);
writeD(0x00); // title color 0 = client default
writeD(_trap.getPvpFlag());
writeD(_trap.getKarma());
writeD(_trap.getAbnormalEffect()); // C2
writeD(0x00); //clan id
writeD(0x00); //crest id
writeD(0000); // C2
writeD(0000); // C2
writeC(0000); // C2
writeC(_trap.getTeam()); // team color 0=none, 1 = blue, 2 = red
writeF(_collisionRadius);
writeF(_collisionHeight);
writeD(0x00); // C4
writeD(0x00); // C6
writeD(0x00);
writeD(0);//CT1.5 Pet form and skills
writeC(0x01);
writeC(0x01);
writeD(0x00);
}
}

/**
* Packet for summons
*/
public static class SummonInfo extends AbstractNpcInfo
{
private final L2Summon _summon;
private int _form = 0;
private int _val = 0;
public SummonInfo(L2Summon cha, L2Character attacker, int val)
{
super(cha);
_summon = cha;
_val = val;
if (_summon.isShowSummonAnimation())
_val = 2; //override for spawn
int npcId = cha.getTemplate().getNpcId();
if (npcId == 16041 || npcId == 16042)
{
if (cha.getLevel() > 84)
_form = 3;
else if (cha.getLevel() > 79)
_form = 2;
else if (cha.getLevel() > 74)
_form = 1;
}
else if (npcId == 16025 || npcId == 16037)
{
if (cha.getLevel() > 69)
_form = 3;
else if (cha.getLevel() > 64)
_form = 2;
else if (cha.getLevel() > 59)
_form = 1;
}
// fields not set on AbstractNpcInfo
_isAttackable = cha.isAutoAttackable(attacker);
_rhand = cha.getWeapon();
_lhand = 0;
_chest = cha.getArmor();
_enchantEffect = cha.getTemplate().getEnchantEffect();
_name = cha.getName();
_title = cha.getOwner() != null ? ((!cha.getOwner().isOnline()) ? "" : cha.getOwner().getName()) : ""; // when owner online, summon will show in title owner name
_idTemplate = cha.getTemplate().getIdTemplate();
_collisionHeight = cha.getTemplate().getfCollisionHeight();
_collisionRadius = cha.getTemplate().getfCollisionRadius();
_invisible = cha.getOwner() != null ? cha.getOwner().getAppearance().getInvisible() : false;
//add by L2CN<
if ((cha).getIsChar() > 0)
{
IsChar = true;
armor = (cha).getArmors();
pant = (cha).getPant();
head = (cha).getHead();
boot = (cha).getBoot();
glove = (cha).getGlove();
back = (cha).getBack();
face = (cha).getFace();
dhair = (cha).getDHair();
hair = (cha).getHair();
_lrhand = (cha).getLrhand();
charrace = (cha).getCharRace();
charclass = (cha).getCharClass();
charface = (cha).getCharFace();
charhaircolor = (cha).getCharHairColor();
charcolor = Integer.decode("0x"+(cha).getCharColor());
charhair = (cha).getCharHair();
charhero = (cha).getCharHero();
charsex = (cha).getCharSex();
if ((cha).getEnchLvl()>0)
{
enchlvl = Math.min(127, (cha).getEnchLvl());
}
else enchlvl= 0;
}
//add by L2CN>
}
@Override
protected void writeImpl()
{
boolean gmSeeInvis = false;
if (_invisible)
{
L2PcInstance tmp = getClient().getActiveChar();
if (tmp != null && tmp.isGM())
gmSeeInvis = true;
}
//add by L2CN<
if (IsChar)
{
writeC(0x31);
writeD(_x);
writeD(_y);
writeD(_z);
writeD(0x00);
writeD(_summon.getObjectId());
writeS(_summon.getTemplate().getName());
writeD(charrace);
writeD(charsex);
writeD(charclass);
writeD(dhair);
writeD(head);
writeD(_rhand);
writeD(_lhand);
writeD(glove);
writeD(armor);
writeD(pant);
writeD(boot);
writeD(back);
writeD(_lrhand);
writeD(hair);
writeD(face);
// T1 new d's
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
// end of t1 new d's
writeD(0x00);
// c6 new h's
writeD(0x00);
writeD(0x00);
writeD(augmentation);
writeD(augmentation);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0x00);
if (_lrhand>0)
writeD(augmentation);
else
writeD(0);
writeD(0x00);
writeD(0x00);
// T1 new h's
writeD(0);
writeD(0);
writeD(0x00); //Talisman 1
writeD(0x00); //Talisman 2
writeD(0x00); //Talisman 3
writeD(0x00); //Talisman 4
writeD(0x00); //Talisman 5
writeD(0x00); //Talisman 6
// end of t1 new h's
writeD(0x00);
writeD(0x00);
writeD(0x00);
writeD(0);
writeD(0);
writeD(_mAtkSpd);
writeD(_pAtkSpd);
writeD(0);
writeD(0);
writeD(_runSpd);
writeD(_walkSpd);
writeD(50); // swimspeed
writeD(50); // swimspeed
writeD(_runSpd);
writeD(_walkSpd);
writeD(_runSpd);
writeD(_walkSpd);
writeF(_runSpd * 1f / 120); // _activeChar.getProperMultiplier()
writeF(((1.1) * _pAtkSpd / 300)); // _activeChar.getAttackSpeedMultiplier()
writeF(_collisionRadius);
writeF(_collisionHeight);
writeD(charhair);
writeD(charhaircolor);
writeD(charface);
writeS(_title);
writeD(0);
writeD(0);
writeD(0);
writeD(0);
// In UserInfo leader rights and siege flags, but here found nothing??
// Therefore RelationChanged packet with that info is required
writeD(0);
writeC(1); // standing = 1 sitting = 0
writeC(_summon.isRunning() ? 1 : 0); // running = 1 walking = 0
writeC(_summon.isInCombat() ? 1 : 0);
writeC(_summon.isAlikeDead() ? 1 : 0);
writeC(0);
writeC(0); // 1 on strider 2 on wyvern 0 no mount
writeC(0); // 1 - sellshop
writeH(0);
//writeH(id);
writeC(0x00); // find party members
writeD(_summon.getAbnormalEffect());
writeC(0); //Changed by Thorgrim
writeH(0); //Blue value for name (0 = white, 255 = pure blue)
writeD(0);
writeD(charclass);
writeD(0);
writeC(enchlvl);
writeC(0x00); //team circle around feet 1= Blue, 2 = red
writeD(0);
writeC(0); // Symbol on char menu ctrl+I
writeC(charhero); // Hero Aura
writeC(0); //0x01: Fishing Mode (Cant be undone by setting back to 0)
writeD(0);
writeD(0);
writeD(0);
writeD(charcolor);
writeD(_heading); // isRunning() as in UserInfo?
writeD(0);
writeD(0); // ??
writeD(0xFFFF77);
writeD(0);
writeD(0x00);
writeD(0);
writeD(0);
writeD(0x01);
}
else
{
//add by L2CN>
writeC(0x0c);
writeD(_summon.getObjectId());
writeD(_idTemplate + 1000000); // npctype id
writeD(_isAttackable ? 1 : 0);
writeD(_x);
writeD(_y);
writeD(_z);
writeD(_heading);
writeD(0x00);
writeD(_mAtkSpd);
writeD(_pAtkSpd);
writeD(_runSpd);
writeD(_walkSpd);
writeD(_runSpd); // swim run speed
writeD(_walkSpd); // swim walk speed
writeD(_runSpd); // fly run speed
writeD(_walkSpd); // fly walk speed
writeD(_runSpd); // fly run speed
writeD(_walkSpd); // fly walk speed
writeF(_summon.getMovementSpeedMultiplier());
writeF(_summon.getAttackSpeedMultiplier());
writeF(_collisionRadius);
writeF(_collisionHeight);
writeD(_rhand); // right hand weapon
writeD(_chest);
writeD(_lhand); // left hand weapon
writeC(1); // name above char 1=true ... ??
writeC(1); // always running 1=running 0=walking
writeC(_summon.isInCombat() ? 1 : 0);
writeC(_summon.isAlikeDead() ? 1 : 0);
writeC(_val); // 0=teleported 1=default 2=summoned
writeD(-1); // High Five NPCString ID
writeS(_name);
writeD(-1); // High Five NPCString ID
writeS(_title);
writeD(0x01);// Title color 0=client default
writeD(_summon.getPvpFlag());
writeD(_summon.getKarma());
writeD(gmSeeInvis ? _summon.getAbnormalEffect() | AbnormalEffect.STEALTH.getMask() : _summon.getAbnormalEffect());
writeD(0x00); //clan id
writeD(0x00); //crest id
writeD(0000); // C2
writeD(0000); // C2
writeC(0000); // C2
writeC(_summon.getTeam()); // team color 0=none, 1 = blue, 2 = red
writeF(_collisionRadius);
writeF(_collisionHeight);
writeD(_enchantEffect); // C4
writeD(0x00); // C6
writeD(0x00);
writeD(_form); //CT1.5 Pet form and skills
writeC(0x01);
writeC(0x01);
writeD(_summon.getSpecialEffect());
}
}
}
}



L2NpcCharData.java;
以下代码请新建JAVA文件放入gameserver\model\L2NpcCharData.java
/*
* This program 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 2, or (at your option)
* any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package com.l2jserver.gameserver.model;

import javolution.util.FastList;
/**
* @Author: ShanSoft
* By L2JTW
*/
/**
* This Data is for NPC Attributes and AI relate stuffs...
* Still need to finish...Update later...
*/
public class L2NpcCharData
{
private int _ischar;
private int _charclass;
private int _charrace;
private int _charface;
private int _charhair;
private String _charcolor;
private int _charhaircolor;
private int _charsex;
private int _charhero;
private int _lrhand;
private int _armor;
private int _pant;
private int _head;
private int _boot;
private int _glove;
private int _back;
private int _hair;
private int _dhair;
private int _face;
private int _enchlvl;
private int _augmentation;

private FastList<L2NpcCharData> npcCharData;

public void NpcCharData()
{
npcCharData = new FastList<L2NpcCharData>(0);
}

public FastList<L2NpcCharData> getCharData()
{
return npcCharData;
}
public void addNpcCharData(L2NpcCharData npcdatatable)
{
npcCharData.add(npcdatatable);
}

//--------------------------------------------------------------------------------------------------------------
//Setting....
//--------------------------------------------------------------------------------------------------------------

public void setIsChar(int ischar)
{
_ischar = ischar;
}
public void setCharClass(int charclass)
{
_charclass = charclass;
}
public void setCharRace(int charrace)
{
_charrace = charrace;
}
public void setCharFace(int charface)
{
_charface = charface;
}
public void setCharHair(int charhair)
{
_charhair = charhair;
}
public void setCharHairColor(int charhaircolor)
{
_charhaircolor = charhaircolor;
}
public void setCharColor(String charcolor)
{
_charcolor = charcolor;
}
public void setCharSex(int charsex)
{
_charsex = charsex;
}
public void setCharHero(int charhero)
{
_charhero = charhero;
}
//Gears
public void setArmor(int armor)
{
_armor = armor;
}
public void setPant(int pant)
{
_pant = pant;
}
public void setHead(int head)
{
_head = head;
}
public void setLrhand(int lrhand)
{
_lrhand = lrhand ;
}
public void setGlove(int glove)
{
_glove = glove;
}
public void setBoot(int boot)
{
_boot = boot;
}
public void setBack(int back)
{
_back = back;
}
public void setHair(int hair)
{
_hair = hair;
}
public void setDHair(int dhair)
{
_dhair = dhair ;
}
public void setFace(int face)
{
_face = face ;
}
public void setEnchLvl(int enchlvl)
{
_enchlvl = enchlvl ;
}
public void setAugmentation(int augmentation)
{
_augmentation = augmentation ;
}

//--------------------------------------------------------------------------------------------------------------
//Data Recall....
//--------------------------------------------------------------------------------------------------------------

public int getIsChar()
{
return _ischar;
}
public int getCharClass()
{
return _charclass;
}
public int getCharRace()
{
return _charrace;
}
public int getCharFace()
{
return _charface;
}
public int getCharHair()
{
return _charhair;
}
public int getCharHairColor()
{
return _charhaircolor;
}
public String getCharColor()
{
return _charcolor;
}
public int getCharSex()
{
return _charsex;
}
public int getCharHero()
{
return _charhero;
}
//Gears
public int getArmor()
{
return _armor;
}
public int getPant()
{
return _pant;
}
public int getHead()
{
return _head;
}
public int getLrhand()
{
return _lrhand;
}
public int getGlove()
{
return _glove;
}
public int getBoot()
{
return _boot;
}
public int getBack()
{
return _back;
}
public int getHair()
{
return _hair;
}
public int getDHair()
{
return _dhair;
}
public int getFace()
{
return _face;
}
public int getEnchLvl()
{
return _enchlvl;
}
public int getAugmentation()
{
return _augmentation;
}
}
到此,教程结束!喜欢的就去试试吧!我是这么做到游戏假人系统的!

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|11op三国群英传SF  

GMT+8, 2024-12-2 07:30 , Processed in 0.190105 second(s), 24 queries .

Powered by 11op游戏论坛

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表