|
在core的xml里面有这样的定义
[codes=xml] <const id="Burrow" path="CUnit.Collide.index" value="Land1"/>
<const id="Swarm" path="CUnit.Collide.index" value="Land4"/>
<const id="Flying" path="CUnit.Collide.index" value="Air1"/>
...[/codes]
而在unit的xml你看到了。。
[codes=xml] <CUnit default="1" id="XXX">
<PlaneArray index="Flying " value="1"/>
</CUnit>[/codes]
于是乎你想用CatalogFieldValueGet()取得单位XXX是不是飞行单位,所以你写了
TriggerDebugOutput(1, IntToText(CatalogFieldValueGetAsInt(c_gameCatalogUnit, "PointDefenseDrone", "Collide[Flying]", c_playerAny)), true);
结果得到 Trigger Error in 'gt_MeleeInitialization_Func': Catalog field 'Collide[Flying]' could not be read (Core: a required object could not be found)
为什么呢,因为Flying是xml里面定义的const,而触发器是看不懂的
那为什么之前<>触发器能看懂呢,因为Build1是属于游戏自己定义好的枚举类型
也就是说要用CatalogFieldValueGet(),数组的index只能是游戏内置的枚举类型或者是数值
TriggerDebugOutput(1, IntToText(CatalogFieldValueGetAsInt(c_gameCatalogUnit, "PointDefenseDrone", "Collide[Air1]", c_playerAny)), true);
这样写才对
这个是Collide数组的对应表:
[0] = [Land1] = CUnit.Collide.index.Burrow
[1] = [Land2] = CUnit.Collide.index.Ground
[2] = [Land3] = CUnit.Collide.index.Larva
[3] = [Land4] = CUnit.Collide.index.Swarm
[4] = [Land5] = CUnit.Collide.index.Colossus
[5] = [Land6] = CUnit.Collide.index.Structure
[6] = [Land7] = CUnit.Collide.index.RoachBurrow
[7] = [Land8] = CUnit.Collide.index.TinyCritter
[8] = [Land9] = CUnit.Collide.index.ForceField
[9] = [Land10]
[10] = [Land11]
[11] = [Land12]
[12] = [Land13]
//<Collide index="Burrow3" value="1"/> 只在战役D8Charge/D8ClusterBomb单位出现过,不肯定是笔误还是刻意设定
[13] = [Land14]
[14] = [Land15]
[15] = [Land16]
[16] = [Air1] = CUnit.Collide.index.Flying
[17] = [Air2] = CUnit.Collide.index.FlyingImmobile
[18] = [Air3] = CUnit.Collide.index.FlyingEscorts
[19] = [Air4]
[20] = [Air5]
[21] = [Air6]
[22] = [Air7]
[23] = [Air8]
[24] = [Air9]
[25] = [Air10]
[26] = [Air11]
[27] = [Air12]
[28] = [Air13]
[29] = [Air14]
[30] = [Air15]
[31] = [Air16]
xml里面定义的const就是把Flying等同于内置的Air1,也就是触发器你可以用数值0-13或者Land1-16,Air1-16,但是不能用"Flying"
最後鸣谢头目的技术支持。。 |
|