红警DIY论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 8267|回复: 20

【代码篇】给喜欢把建造列表塞满满的Moder一个方法

  [复制链接]
发表于 2011-2-4 21:26:32 | 显示全部楼层 |阅读模式
群里聊天的时候突然想起这个方法 可惜这方法不是我原创的 T_T 是来自Moddb一个Mod的作者放出来的 现在那Mod已经没有下载了,里面有不少有价值的代码 可惜。。
------------------------------------------------------------------------------------------------------------------------------------
拿 苏联 战争工厂 举例

1.在<Behaviors>...</Behaviors>里添加如下代码

  1.    <RemoveUpgradeUpgrade id="CS1">
  2.     <TriggeredBy>Upgrade_CommandSetSwitch1</TriggeredBy>
  3.     <UpgradeToRemove>Upgrade_CommandSetSwitch2</UpgradeToRemove>
  4.    </RemoveUpgradeUpgrade>
  5.    
  6.    <CommandSetUpgrade
  7.     id="ModuleTag_CommandSetUpgradeCS1"
  8.     CommandSet="SovietWarFactoryCommandSet_Switch">
  9.     <TriggeredBy>Upgrade_CommandSetSwitch1</TriggeredBy>
  10.    </CommandSetUpgrade>
  11.    
  12.    <RemoveUpgradeUpgrade id="CS2">
  13.     <TriggeredBy>Upgrade_CommandSetSwitch2</TriggeredBy>
  14.     <UpgradeToRemove>Upgrade_CommandSetSwitch1</UpgradeToRemove>
  15.    </RemoveUpgradeUpgrade>
  16.    
  17.    <CommandSetUpgrade
  18.     id="ModuleTag_CommandSetUpgradeCS2"
  19.     CommandSet="SovietWarFactoryCommandSet">
  20.     <TriggeredBy>Upgrade_CommandSetSwitch2</TriggeredBy>
  21.    </CommandSetUpgrade>
复制代码


2.在id="SovietWarFactoryCommandSet"的<LogicCommandSet ... </LogicCommandSet>里添加

  1.   <Cmd>Command_UpgradeCommandSetSwitch1</Cmd>
复制代码


3.新增如下代码

  1. <LogicCommandSet
  2.   id="SovietWarFactoryCommandSet_Switch">
  3.   <Cmd>Command_ConstructSovietAntiVehicleVehicleTech2</Cmd>
  4.   <Cmd>Command_UpgradeCommandSetSwitch2</Cmd>
  5. </LogicCommandSet>
复制代码

  1. <UpgradeTemplate id="Upgrade_CommandSetSwitch1" Type="OBJECT" />
  2. <UpgradeTemplate id="Upgrade_CommandSetSwitch2" Type="OBJECT" />
复制代码

  1. <LogicCommand
  2.   Type="OBJECT_UPGRADE"
  3.   id="Command_UpgradeCommandSetSwitch1">
  4.   <Upgrade>Upgrade_CommandSetSwitch1</Upgrade>
  5.   <AISpecialPowerInfo Heuristic="UPGRADE" Manager="BUILDER"/>
  6. </LogicCommand>
  7. <LogicCommand
  8.   Type="OBJECT_UPGRADE"
  9.   id="Command_UpgradeCommandSetSwitch2">
  10.   <Upgrade>Upgrade_CommandSetSwitch2</Upgrade>
  11.   <AISpecialPowerInfo Heuristic="UPGRADE" Manager="BUILDER"/>
  12. </LogicCommand>
复制代码

  1. <ButtonSingleStateData id="CommandSwitch1">
  2.   <State Image="Allied_topmenu_groups"/>
  3. </ButtonSingleStateData>
  4. <ButtonSingleStateData id="CommandSwitch2">
  5.   <State Image="Allied_topmenu_groups"/>
  6. </ButtonSingleStateData>
复制代码

  1. <UnitAbilityButtonTemplate
  2.   id="CommandSwitch1_"
  3.   LogicCommand="Command_UpgradeCommandSetSwitch1">
  4.   <Data><ObjectUpgrade StateData="CommandSwitch1"/></Data>
  5. </UnitAbilityButtonTemplate>
  6. <UnitAbilityButtonTemplate
  7.   id="CommandSwitch2_"
  8.   LogicCommand="Command_UpgradeCommandSetSwitch2">
  9.   <Data><ObjectUpgrade StateData="CommandSwitch2"/></Data>
  10. </UnitAbilityButtonTemplate>
复制代码


原理:通过 升级Upgrade 撤销升级RemoveUpgrade 的方法制造出像列表翻页的效果
          下面让我们回想下,当我们用 盟军 或 帝国 的时候,升级完T2之后T2升级项图标消失,T3升级项图标出现在同一个地方..
          细心的Moder会在 盟军建造场 以及 帝国所有出兵建筑 源码里面找到CommandSetUpgrade,它们也是用这种方法切换列表,虽然没有RemoveUpgradeUpgrade,因为升级完T3之后不会有人再倒回去升级T2的..

方法的优缺点:优点是理论上能让Mod的建造列表无限加单位..
                         缺点是要是运用于盟军跟帝国的话会有冲突,原来的切换效果没了,T2 T3升级项同时出现,但问题不大,出现T3升级项你没升级T2还是不能按的..


这里附上本人P的翻页图标
AlliedPageUpAndDown.rar (19.63 KB, 下载次数: )

评分

参与人数 1威严 +1 DIY币 +3 收起 理由
yangqs + 1 + 3 我很赞同

查看全部评分

发表于 2011-2-4 21:28:15 | 显示全部楼层
本帖最后由 740066290 于 2011-2-4 21:30 编辑

AK你终于发了,明天看看,然后实验下,估计我有俩工厂要报废了
刚接触mod就有这想法,可是不会弄...
 楼主| 发表于 2011-2-4 21:29:36 | 显示全部楼层
回复 2# 740066290

神速度。。
发表于 2011-2-4 22:05:23 | 显示全部楼层
幸好我没有加怪单位`列表没满座哟`猴子我盯上你了`万一以后列表满了找你啊`
发表于 2011-2-4 22:54:43 | 显示全部楼层
恩,这是一个保留代码,等列表排满后使用
之前我在某个开源代码里见过。估计紫霞也是用了类似的代码(虽然他编的是ZH)
发表于 2011-2-5 07:13:04 | 显示全部楼层
我在ZHmod里经常看到翻页...可是...咱太白...不会弄翻页..等会啃教程
发表于 2011-2-5 09:52:40 | 显示全部楼层
翻页!太有价值了。收入保险箱去。{:3_46:}
发表于 2011-2-5 19:03:19 | 显示全部楼层
日军怎么弄
发表于 2011-2-5 19:37:35 | 显示全部楼层
日军怎么弄
hly97 发表于 2011-2-5 19:03


缺点是要是运用于盟军跟帝国的话会有冲突,原来的切换效果没了,T2 T3升级项同时出现,但问题不大,出现T3升级项你没升级T2还是不能按的..

你啥眼神..
发表于 2011-2-6 11:08:15 | 显示全部楼层
本帖最后由 hly97 于 2011-2-6 18:38 编辑

这样怎么不行
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <AssetDeclaration xmlns="uri:ea.com:eala:asset">

  3. <Tags/>
  4. <Includes/>
  5. <LogicCommandSet
  6. id="JapanWarFactoryCommandSetBase">
  7. <Cmd>Command_ConstructJapanLightTransportVehicle</Cmd>
  8. <Cmd>Command_ConstructJapanAntiInfantryVehicle</Cmd>
  9. <Cmd>Command_ConstructJapanAntiVehicleVehicleTech1</Cmd>
  10. <Cmd>Command_ConstructJapanAntiAirVehicleTech1</Cmd>
  11. <Cmd>Command_ConstructJapanAntiVehicleVehicleTech3</Cmd>
  12. <Cmd>Command_ConstructJapanAntiStructureVehicle</Cmd>
  13. <Cmd>Command_UpgradeCommandSetSwitch3</Cmd>


  14. <Cmd>Command_ConstructJapanMCV</Cmd>
  15. </LogicCommandSet>
  16. <LogicCommandSet
  17. id="JapanWarFactoryCommandSetBase_Switch">
  18. <Cmd>Command_ConstructJapanAntiVehicleVehicleTech1</Cmd>
  19. <Cmd>Command_UpgradeCommandSetSwitch4</Cmd>
  20. </LogicCommandSet>

  21. <UpgradeTemplate id="Upgrade_CommandSetSwitch3" Type="OBJECT" />
  22. <UpgradeTemplate id="Upgrade_CommandSetSwitch4" Type="OBJECT" />

  23. <LogicCommand
  24. Type="OBJECT_UPGRADE"
  25. id="Command_UpgradeCommandSetSwitch3">
  26. <Upgrade>Upgrade_CommandSetSwitch3</Upgrade>
  27. <AISpecialPowerInfo Heuristic="UPGRADE" Manager="BUILDER"/>
  28. </LogicCommand>
  29. <LogicCommand
  30. Type="OBJECT_UPGRADE"
  31. id="Command_UpgradeCommandSetSwitch4">
  32. <Upgrade>Upgrade_CommandSetSwitch4</Upgrade>
  33. <AISpecialPowerInfo Heuristic="UPGRADE" Manager="BUILDER"/>
  34. </LogicCommand>

  35. <ButtonSingleStateData id="CommandSwitch3">
  36. <State Image="Allied_topmenu_groups"/>
  37. </ButtonSingleStateData>
  38. <ButtonSingleStateData id="CommandSwitch4">
  39. <State Image="Allied_topmenu_groups"/>
  40. </ButtonSingleStateData>

  41. <UnitAbilityButtonTemplate
  42. id="CommandSwitch3_"
  43. LogicCommand="Command_UpgradeCommandSetSwitch3">
  44. <Data><ObjectUpgrade StateData="CommandSwitch3"/></Data>
  45. </UnitAbilityButtonTemplate>
  46. <UnitAbilityButtonTemplate
  47. id="CommandSwitch4_"
  48. LogicCommand="Command_UpgradeCommandSetSwitch4">
  49. <Data><ObjectUpgrade StateData="CommandSwitch4"/></Data>
  50. </UnitAbilityButtonTemplate>
  51. </AssetDeclaration>
复制代码
上面是CommandData文件我
  1. <RemoveUpgradeUpgrade id="CS1">
  2. <TriggeredBy>Upgrade_CommandSetSwitch3</TriggeredBy>
  3. <UpgradeToRemove>Upgrade_CommandSetSwitch4</UpgradeToRemove>
  4. </RemoveUpgradeUpgrade>

  5. <CommandSetUpgrade
  6. id="ModuleTag_CommandSetUpgradeCS1"
  7. CommandSet="JapanWarFactoryCommandSetBase_Switch">
  8. <TriggeredBy>Upgrade_CommandSetSwitch3</TriggeredBy>
  9. </CommandSetUpgrade>

  10. <RemoveUpgradeUpgrade id="CS2">
  11. <TriggeredBy>Upgrade_CommandSetSwitch4</TriggeredBy>
  12. <UpgradeToRemove>Upgrade_CommandSetSwitch3</UpgradeToRemove>
  13. </RemoveUpgradeUpgrade>

  14. <CommandSetUpgrade
  15. id="ModuleTag_CommandSetUpgradeCS2"
  16. CommandSet="JapanWarFactoryCommandSetBase">
  17. <TriggeredBy>Upgrade_CommandSetSwitch4</TriggeredBy>
  18. </CommandSetUpgrade>
复制代码

上面是日军车厂加的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|Archiver|手机版|管理员邮箱|红警DIY官方论坛

GMT+8, 2017-12-19 02:43 , Processed in 0.123203 second(s), 18 queries , XCache On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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