帝国时代3如何修改能打开与关闭城门?




这个是城门开门与锁门的教程,像帝国时代2那样,城门可以根据玩家需要开门或锁门,只可惜敌人不能穿过打开的城门。





方法:

1.在protounitcommands.xml将开城门按钮的语句复制,顺便把那个图标提取出来





2.随便找一个游戏内没有出现过的按钮,然后修改。(怎样判断游戏内没有这个按钮?去protoy.xml搜索按钮调用名,搜索不出就是游戏内没有的。)



将截图所说的语句替换到你修改的按钮,我随便找了一个没有用上Stance1按钮

修改前:


<protounitcommand>
<name>Stance1</name>
<icon>art\ui\command\stance_aggresive_on</icon>
<command>unitSetStanceAggressive</command>
<rollovertextid>19143</rollovertextid>
<helptopic>stances</helptopic>
</protounitcommand>

修改后:


<protounitcommand>
<name>Stance1</name>
<icon>art\ui\command\close</icon>
<command>uiTransformSelectedUnit("CWallGate2")</command>
<rollovertextid>00301</rollovertextid>
</protounitcommand>


3. 复制一个城门,注意一下调用名,你的命令写什么调用名,这个城门的调用名就应该写什么。你在复制城门之前,应该先给城门添加你刚才修改的按钮,顺便把城门的建造成本删掉。

(原有的)城门


<Unit id ='482' name ='CWallGate'>
<DBID>523</DBID>
<DisplayNameID>29634</DisplayNameID>
<ObstructionRadiusX>5.0000</ObstructionRadiusX>
<ObstructionRadiusZ>1.0000</ObstructionRadiusZ>
<MaxVelocity>0.0000</MaxVelocity>
<MovementType>land</MovementType>
<AnimFile>buildings\wall\wall_gate.xml</AnimFile>
<AllowedHeightVariance>4.0000</AllowedHeightVariance>
<ImpactType>Stone</ImpactType>
<Icon>buildings\wall\wall_portrait</Icon>
<PortraitIcon>buildings\wall\gate_portrait</PortraitIcon>
<RolloverTextID>29633</RolloverTextID>
<ShortRolloverTextID>29632</ShortRolloverTextID>
<InitialHitpoints>3000.0000</InitialHitpoints>
<MaxHitpoints>3000.0000</MaxHitpoints>
<LOS>7.0000</LOS>
<BuildPoints>15.0000</BuildPoints>
<Cost resourcetype ='Wood'>0.0000</Cost> <!-- 建造成本改成0或删掉 -->
<BuildingWorkRate>1.0000</BuildingWorkRate>
<AllowedAge>0</AllowedAge>
<Decay delay ='0.0000' duration ='0.0000'></Decay>
<Armor type ='Siege' value ='0.0000'></Armor>
<UnitType>LogicalTypeValidSabotage</UnitType>
<UnitType>LogicalTypeVillagersAttack</UnitType>
<UnitType>LogicalTypeHandUnitsAttack</UnitType>
<UnitType>LogicalTypeShipsAndBuildings</UnitType>
<UnitType>LogicalTypeRangedUnitsAttack</UnitType>
<UnitType>LogicalTypeMinimapFilterMilitary</UnitType>
<UnitType>BuildingClass</UnitType>
<UnitType>ColonyBuilding</UnitType>
<UnitType>AbstractWall</UnitType>
<UnitType>MilitaryBuilding</UnitType>
<UnitType>Building</UnitType>
<UnitType>CountsTowardMilitaryScore</UnitType>
<UnitType>HasBountyValue</UnitType>
<Flag>CollidesWithProjectiles</Flag>
<Flag>Doppled</Flag>
<Flag>Immoveable</Flag>
<Flag>NoBloodOnDeath</Flag>
<Flag>NonAutoFormedUnit</Flag>
<Flag>ObscuresUnits</Flag>
<Flag>PlayerOwnsObstruction</Flag>
<Flag>SelectWithObstruction</Flag>
<Flag>UseAlignedObstructionOnMinimap</Flag>
<Flag>wallBuild</Flag>
<Flag>ColonyBuilding</Flag>
<Flag>Tracked</Flag>
<Command page ='10' column ='1'>Delete</Command>
<Command page ='6' column ='1'>Stance1</Command> <!-- 把按钮加上去 -->
</Unit>

(新增的)已关闭的城门


<Unit id ='1482' name ='CWallGate2'>
<DBID>523</DBID>
<DisplayNameID>00300</DisplayNameID>
<ObstructionRadiusX>5.0000</ObstructionRadiusX>
<ObstructionRadiusZ>1.0000</ObstructionRadiusZ>
<MaxVelocity>0.0000</MaxVelocity>
<MovementType>land</MovementType>
<AnimFile>buildings\wall\wall_gate.xml</AnimFile>
<AllowedHeightVariance>0.0000</AllowedHeightVariance> <!-- 4.0修改成0.0 -->
<ImpactType>Stone</ImpactType>
<Icon>buildings\wall\wall_portrait</Icon>
<PortraitIcon>buildings\wall\gate_portrait</PortraitIcon>
<RolloverTextID>29633</RolloverTextID>
<ShortRolloverTextID>29632</ShortRolloverTextID>
<InitialHitpoints>3000.0000</InitialHitpoints>
<MaxHitpoints>3000.0000</MaxHitpoints>
<LOS>7.0000</LOS>
<BuildPoints>15.0000</BuildPoints>
<Cost resourcetype ='Wood'>0.0000</Cost> <!-- 建造成本改成0或删掉-->
<BuildingWorkRate>1.0000</BuildingWorkRate>
<AllowedAge>0</AllowedAge>
<Decay delay ='0.0000' duration ='0.0000'></Decay>
<Armor type ='Siege' value ='0.0000'></Armor>
<UnitType>LogicalTypeValidSabotage</UnitType>
<UnitType>LogicalTypeVillagersAttack</UnitType>
<UnitType>LogicalTypeHandUnitsAttack</UnitType>
<UnitType>LogicalTypeShipsAndBuildings</UnitType>
<UnitType>LogicalTypeRangedUnitsAttack</UnitType>
<UnitType>LogicalTypeMinimapFilterMilitary</UnitType>
<UnitType>BuildingClass</UnitType>
<UnitType>ColonyBuilding</UnitType>
<UnitType>AbstractWall</UnitType>
<UnitType>MilitaryBuilding</UnitType>
<UnitType>Building</UnitType>
<UnitType>CountsTowardMilitaryScore</UnitType>
<UnitType>HasBountyValue</UnitType>
<Flag>CollidesWithProjectiles</Flag>
<Flag>Doppled</Flag>
<Flag>Immoveable</Flag>
<Flag>NoBloodOnDeath</Flag>
<Flag>NonAutoFormedUnit</Flag>
<Flag>ObscuresUnits</Flag>
<Flag>ShowTactics</Flag> <!-- 添加<Flag>ShowTactics</Flag> --> <!-- <Flag>PlayerOwnsObstruction</Flag> --> <!-- 删掉<Flag>PlayerOwnsObstruction</Flag> -->
<Flag>SelectWithObstruction</Flag>
<Flag>UseAlignedObstructionOnMinimap</Flag>
<Flag>wallBuild</Flag>
<Flag>ColonyBuilding</Flag>
<Flag>Tracked</Flag>
<Command page ='10' column ='1'>Delete</Command>
<Command page ='6' column ='1'>Transform</Command> <!-- 将开城门的按钮加上去 -->
</Unit>


把名称与按钮的介绍写上:
<String _locID="00300">已关闭的城门</String>
<String _locID="00301">关闭这座城门,任何人均不能通过这座城门。</String>


4.添加声音,最简单的办法是在Sound文件夹的SoundXML.bar提取原有的城门的文件(CWallGate_snds),然后直接把调用名修改了,放到sound文件夹。

CWallGate2_snds.xml

<?xml version="1.0" encoding="utf-8"?>
<protounitsounddef>
<protounit name="CWallGate2">
<soundtype name="Select">
<soundset name="UI_Building_Economic"/>
</soundtype>
<soundtype name="Death">
<soundset name="BuildingDestruction"/>
</soundtype>
<soundtype name="Creation">
<soundset name="UI_Building_Economic"/>
</soundtype>
</protounit>
</protounitsounddef>




完成了,进入游戏看看吧,效果图跟顶部两张截图一样。



有人可能会说,为什么不多改一个按钮,然后制作一个新城门,这样就不需要使用建造城门那个按钮了,其实我也想这样做,但是城门的动画直接写到主程序里面去了,开门动画只认城门的调用名,导致新添加的城门有单位经过时,不会自动上升。 为了平衡性,适当把所有城墙的价格与生命值调高吧,将墙柱、2号城墙、5号城墙成本改成20木头,生命值改成4000,城门与已关闭的城门生命值也改成4000。