本帖最后由 Ser_Charles 于 2012-8-27 17:42 编辑
先给出MS里module_items.py文件的注释:
##############################################################
# Each item record contains the following fields:
# 1) Item id: used for referencing items in other files.
# The prefix itm_ is automatically added before each item id.
# 2) Item name. Name of item as it'll appear in inventory window
# 3) List of meshes. Each mesh record is a tuple containing the following fields:
# 3.1) Mesh name.
# 3.2) Modifier bits that this mesh matches.
# Note that the first mesh record is the default.
# 4) Item flags. See header_items.py for a list of available flags.
# 5) Item capabilities. Used for which animations this item is used with. See header_items.py for a list of available flags.
# 6) Item value.
# 7) Item stats: Bitwise-or of various stats about the item such as:
# weight, abundance, difficulty, head_armor, body_armor,leg_armor, etc...
# 8) Modifier bits: Modifiers that can be applied to this item.
# 9) [Optional] Triggers: List of simple triggers to be associated with the item.
# 10) [Optional] Factions: List of factions that item can be found as merchandise.
#############################################################
一般来说对TXT进行解析时上面这个注释帮助很大,因为TXT里数据的顺序就是按注释里的来。不过物品稍显例外,一是TXT里的顺序和MS里不完全一致,二是比如“weight, abundance, difficulty, head_armor, body_armor,leg_armor, etc...”没有说清楚到底有哪些属性以及在TXT里的顺序。
我们挑取itm_sword_medieval_a这把剑为例:
itm_sword_medieval_a Sword Sword 2 sword_medieval_a 0 sword_medieval_a_scabbard 3458764513820540928 4259842 9223388564182532111 163 155668 1.500000 100 0 0 0 0 27648 99 0 95 0 278 27
0
0
为了方便下面的解释,我也给出MS里这个物品的代码:
["sword_medieval_a", "Sword", [("sword_medieval_a",0),("sword_medieval_a_scabbard", ixmesh_carry)], itp_type_one_handed_wpn|itp_merchandise|itp_primary, itc_longsword|itcf_carry_sword_left_hip|itcf_show_holster_when_drawn,
163, weight(1.5)|difficulty(0)|spd_rtng(99) | weapon_length(95)|swing_damage(27 , cut) | thrust_damage(22, pierce),imodbits_sword_high ],
解析这一条TXT码,第一步是拆分这些字段和数据。而且不仅是拆分字符和数字,空格和回车的拆分也是有讲究的。我先给出我拆分的结果,再来解释为什么。被拆分的字段我会用引号括起来,回车我用[crlf]表示。