魔兽世界怀旧服自定义物品和NPC

前言

学习不能一步登天,修改代码存在困难,于是从数据库方面下手。基于数据库可以实现自定义添加npc和物品。

工具

在自定义添加的过程中,需要一些命令工具。

获取指定目标的位置信息

.gps
image.png

获取npc的详细信息

.npc info
image.png

获取 指定目标的 id

.guid
image.png

过程

  • 添加一个物品。
    物品表只需要处理 item_template 即可。
    下面的sql添加了一个 物品,叫 苏州超的大便
INSERT INTO `item_template` (`entry`, `class`, `subclass`, `name`, `displayid`, `Quality`, `Flags`, `BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace`, `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell`, `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank`, `maxcount`, `stackable`, `ContainerSlots`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`, `stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`, `stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`, `dmg_min1`, `dmg_max1`, `dmg_type1`, `dmg_min2`, `dmg_max2`, `dmg_type2`, `dmg_min3`, `dmg_max3`, `dmg_type3`, `dmg_min4`, `dmg_max4`, `dmg_type4`, `dmg_min5`, `dmg_max5`, `dmg_type5`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial`, `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `block`, `itemset`, `MaxDurability`, `area`, `Map`, `BagFamily`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`, `Duration`, `ExtraFlags`)
VALUES
    (85818, 0, 0, '苏州超的大便', 6399, 1, 0, 5, 25, 1, 0, -1, -1, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 433, 0, -1, 0, 0, 11, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 4, 0, 0, 0, 0);

该表中字段众多,比较重要的字段含义如下:

entry 物品ID,不允许与其它物品重复
class 物品类型,有以下这些值。
ID Name
0 Consumable
1 容器
2 武器
3 Gem
4 护甲
5 Reagent
6 Projectile
7 商品
8 Generic(OBSOLETE)
9 Recipe
10 Money(OBSOLETE)
11 Quiver
12 任务物品
13 钥匙
14 Permanent(OBSOLETE)
15 杂物
16 Glyph
subclass 物品子类型。
name 物品名称。
displayid 物品对应模型的ID。
Quality 物品品质:
ID Color Quality
0 灰色
1 白色 Common
2 绿色 Uncommon
3 蓝色 Rare
4 紫色 Epic
5 橙色 Legendary
6 红色 Artifact
BuyPrice 物品在商店里的售价。
SellPrice物品卖给商店的价格。
InventoryType 物品可以被装备在哪个装备栏:
ID Slot Name
0 不可装备
1 头
2 项链
3 肩膀
4 衬衣
5 胸部
6 腰
7 腿
8 脚
9 护腕
10 手套
11 手指
12 饰品
13 武器
14 盾牌
15 Ranged
16 背部
17 双手武器
18 背包
19 Tabard
20 Robe
21 Main hand
22 Off hand
23 Holdable (Tome)
24 Ammo
25 Thrown
26 Ranged right
27 Quiver
28 Relic
ItemLevel物品等级。
RequiredLevel能够使用该物品的人物等级。
requiredhonorrank能够使用该物品的军衔等级。
maxcount一个玩家可以拥有的最大值,0 代表没有上限。
stackable是否可叠加。
ContainerSlots如果物品是个背包,拥有多少个格子。
bonding物品绑定方式。
ID Bonding Type
1 拾取后绑定
2 装备后绑定
3 使用后绑定
4 任务物品
description物品描述信息。

  • 再添加npc

需要操作2个表
creature_template 表示生物模板表。
creature 表示生物实例表。
下面的sql表示在 矮人出生地 增加有一个npc 。名字叫 猪猪侠·爸爸

INSERT INTO `creature_template` (`Entry`, `Name`, `SubName`, `MinLevel`, `MaxLevel`, `ModelId1`, `ModelId2`, `ModelId3`, `ModelId4`, `Faction`, `Scale`, `Family`, `CreatureType`, `InhabitType`, `RegenerateStats`, `RacialLeader`, `NpcFlags`, `UnitFlags`, `DynamicFlags`, `ExtraFlags`, `CreatureTypeFlags`, `SpeedWalk`, `SpeedRun`, `Detection`, `CallForHelp`, `Pursuit`, `Leash`, `Timeout`, `UnitClass`, `Rank`, `HealthMultiplier`, `PowerMultiplier`, `DamageMultiplier`, `DamageVariance`, `ArmorMultiplier`, `ExperienceMultiplier`, `MinLevelHealth`, `MaxLevelHealth`, `MinLevelMana`, `MaxLevelMana`, `MinMeleeDmg`, `MaxMeleeDmg`, `MinRangedDmg`, `MaxRangedDmg`, `Armor`, `MeleeAttackPower`, `RangedAttackPower`, `MeleeBaseAttackTime`, `RangedBaseAttackTime`, `DamageSchool`, `MinLootGold`, `MaxLootGold`, `LootId`, `PickpocketLootId`, `SkinningLootId`, `KillCredit1`, `KillCredit2`, `MechanicImmuneMask`, `SchoolImmuneMask`, `ResistanceHoly`, `ResistanceFire`, `ResistanceNature`, `ResistanceFrost`, `ResistanceShadow`, `ResistanceArcane`, `PetSpellDataId`, `MovementType`, `TrainerType`, `TrainerSpell`, `TrainerClass`, `TrainerRace`, `TrainerTemplateId`, `VendorTemplateId`, `GossipMenuId`, `EquipmentTemplateId`, `Civilian`, `AIName`, `ScriptName`)
VALUES
    (85878, '猪猪侠·爸爸', '杂货供应商', 5, 5, 3388, 0, 0, 0, 55, 0, 0, 7, 3, 3, 0, 6, 0, 0, 2, 0, 1, 1.14286, 20, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, -1, 1, 166, 166, 0, 0, 6, 8, 8.624, 11.858, 20, 3, 100, 1960, 2156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 829, 0, '', '');

INSERT INTO `creature` (`guid`, `id`, `map`, `modelid`, `equipment_id`, `position_x`, `position_y`, `position_z`, `orientation`, `spawntimesecsmin`, `spawntimesecsmax`, `spawndist`, `currentwaypoint`, `curhealth`, `curmana`, `DeathState`, `MovementType`)
VALUES
    (1007531, 85878, 0, 0, 0, -6221.53, 320.804, 383.19, 1.62316, 180, 180, 0, 0, 166, 0, 0, 0);

  • 指定npc出售指定的物品。

需要操作 npc_vendor 表

entry 表示的是 npc 模板表中的 entry

item 表示的物品模板表中 entry

INSERT INTO `npc_vendor` (`entry`, `item`, `maxcount`, `incrtime`, `condition_id`, `comments`)
VALUES
    (85878, 159, 0, 0, 0, NULL),
    (85878, 2512, 0, 0, 0, NULL),
    (85878, 2516, 0, 0, 0, NULL),
    (85878, 4540, 0, 0, 0, NULL);

结果

image.png
image.png

你可能感兴趣的:(魔兽世界怀旧服自定义物品和NPC)