Jump to content

Freagarach

WFG Programming Team
  • Posts

    1.126
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Freagarach

  1. Thank you for your explanation! But what I fail to understand is what the benefit of the ternary is? Is it cheaper in resources? More reliable in different situations? Or just visually more appealing? I'm sorry if this is a dumb question, as said earlier: I'm no programmer. I've also seen just now that there are trac-tickets for this problem (I assumed earlier it was an error only found in DE). This could be a fix for #4189 but it would be not needed with #4000 so I'm not sure if I should try and commit this as a patch?
  2. Please correct me if I'm wrong. What you say is that there ought to be a check whether the entitiy is actually able to capture (cmpAttack.GetAttackTypes().indexOf("Capture") != -1) AND that the issued command is to capture (this.order.data.attackType == "Capture")? If that is the case the fix would be replacing "cmpAttack.template.Capture" with "((cmpAttack.GetAttackTypes().indexOf("Capture") != -1) && (this.order.data.attackType == "Capture"))", I guess. (I tested it and it works.) I see now that only testing the latter is wrong in the same way "cmpAttack.template.Capture" is wrong, it skips the BuildingAI targeting for an entity which has the "Capture"-component.
  3. Just quickly tested both other solutions, I don't know why I've overlooked them earlier, but they both seem to work. thanks! I guess the first one you proposed is preferred, since the "Attack"-component does not have to be queried?
  4. I know you use techs now to increase the ranks, but you might want to take a look at Experience method of the Batalion mod (https://github.com/SlavomirSlovenkai/0ad-gameplay-mode). As far as I can tell from the code used it uses "experience"-files (in the simulation/data-folder) to upgrade a unit after every promotion (currently only the first template is applied over and over again untill the maximum level). I don't know whether it is useful for you, but I have had some fun tinkering with it.
  5. I agree on the second point, but I'm no programmer and have just started modifying 0AD, so I'm unsure how to check for that. My attempts to go through "Attack.GetAttackTypes()" to look for the "Capture"-attack failed, so any improvement would be welcome (especially with Siege Ladders in mind). Edit: I fixed the code above, I could not stand it was not working and it was actually easier than expected,,,
  6. It can indeed be done. For anyone interested: add the "capturable" element in "templates/special/filter/foundation.xml".
  7. Hi! Personally, I like the idea of the siege towers being able to capture (of which I see code in their template), however in the game it does not work (at least not for me). To fix this I have changed two little pieces of code in the "UnitAI.js"-component, I hope it is of any use for you. Just after "// TODO: we should probably only bother syncing projectile attacks, not melee" (it is around line 1896) I changed var cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); if (cmpBuildingAI) cmpBuildingAI.SetUnitAITarget(this.order.data.target); to var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); var cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); if (cmpBuildingAI && !((cmpAttack.GetAttackTypes().indexOf("Capture") != -1) && (this.order.data.attackType == "Capture")) ) cmpBuildingAI.SetUnitAITarget(this.order.data.target); AND // BuildingAI has it's own attack-routine var cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); if (!cmpBuildingAI) { let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); cmpAttack.PerformAttack(this.order.data.attackType, target); } to // BuildingAI has it's own attack-routine var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); var cmpBuildingAI = Engine.QueryInterface(this.entity, IID_BuildingAI); if (!cmpBuildingAI || ((cmpAttack.GetAttackTypes().indexOf("Capture") != -1) && (this.order.data.attackType == "Capture")) ) { let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); cmpAttack.PerformAttack(this.order.data.attackType, target); } I have tested this, though not extensively, so there might be some unwanted behaviour (buildings are still attacking and siege towers fire arrows at nearby units).
  8. The elephant stable spam is a typo in the headquarters.js: at line 2003 (whether to build the elephant stables, line reference to Git-version of DE) it says: !gameState.getOwnEntitiesByClass("ElephantStables", true) but in the template it has the Elephant_Stable class. For the AI they never match, so it keeps building the stables. A fix would be to make the classes match.
  9. Hi! I don't know whether this has already been fixed for you, but for the first part of your question it worked for me to find in the ResourceSupply.js the entry ResourceSupply.prototype.TakeResources. There I changed: // Remove entities that have been exhausted if (this.amount === 0) Engine.DestroyEntity(this.entity); to // Remove entities that have been exhausted. if ("RemoveWhenEmpty" in this.template) { if (this.amount == 0 && this.template.RemoveWhenEmpty == "true") Engine.DestroyEntity(this.entity); } else if (this.amount == 0) Engine.DestroyEntity(this.entity); And of course for that to work one needs: "<optional>" + "<element name='RemoveWhenEmpty' a:help='Whether this entity must be removed from the world when its supply is emptied'>" + "<data type='boolean'/>" + "</element>" + "</optional>" + in the ResourceSupply.prototype.Schema and the appropriate flag in the fruit tree's XML-file. I've used this so I can let farms be exhausted due to farming, but they still can regenerate (but only when worked with at least one villager (some extra code is needed for that)). Note that I don't use the SVN-version of 0AD, just A23b with a modified version of DE. While I'm at it, I have a question myself: Is it possible to give capture points to a building foundation? So that one could finish a building an enemy had begun to construct but was unable to finish?
×
×
  • Create New...