Jump to content

Freagarach

WFG Programming Team
  • Posts

    1.125
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Freagarach

  1. Aye, it can be done. But it needs quite some files to be changed, so I'm not sure this is the right place to post that? If anyone wants to make a ticket for it I'm happy to upload my code there. The only part I see some challenges ahead is the bartering, because there are both a selling row and a buying row and a modder might want to be able to sell food for wood, but not food for coin or something. Hmm
  2. I've also got a few questions. I took the liberty of continuing your numbering Nescio. 58. Is it possible to change an actor's look (i.e. VisualActor) using a tech (explicitly not via upgrading to another template)? Preferably just part of the entity, like when one upgrades the shields of pikemen in the Blacksmith the shields actually change. The reason why I'm asking is because I've introduced a more fluent experience system, like in the Batalion-mod, but now the only way to see the difference between a basic and an elite soldier is by looking at its rank icon (which is not too bad I guess). If it is possible, could one point me in the right direction? The only VisualActor (c-)component I could find was in simulation2/components where I did find a MT_ValueModification listener, so I tried: let newActorName = []; newActorName.push("units/athenians/infantry_spearman_a.xml"); warn(uneval(newActorName)); Engine.BroadcastMessage(MT_ValueModification, { "entities": [this.entity], "component": "VisualActor", "valueNames": newActorName}); as a test using an Athenian Hoplite, but it does not work. No error, but also no change in appearance. Any help would be appreciated. 59. Another "is it possible" I want to change the ability to select a single entity, e.g. when a unit goes berserk, it should not be selectable for a while. I found out that one can do that by using an upgrade, so the template changes, but any ideas how I can do it without the template-changing? (To make it reversible.)
  3. If you want this (that all resources can only be bartered into coin and vice versa, that is wat you want right?) you need to change barterButton.Buy.hidden in the menu.js in gui/session to if (g_BarterSell == "coin"){ barterButton.Buy.hidden = isSelected;} else {barterButton.Buy.hidden = resourceCode != "coin";} provided that you want coin to be bartered. I could also write some code to do this more cleanly, if anyone wants that? More cleanly: setting up a barterable parameter in the resource. But since I'm not going to use this I stop here for now.
  4. Oh yeah, sorry. I was too enthousiastically trying to fix it: menu.js in gui/session (not very suprising and I've looked in that folder more often trying to fix this but not in this particular file).
  5. Yep, and grep was my friend here again. I managed to exclude all other resources (except coin) from the trade menu. I'll now try to make sure one can only pay for resources with coin, as I've noticed that some people would like that (I don't but hey I'm almost there I guess). Thanks once again!
  6. Sadly not. It does a good job in preventing the error message, but I can still click the arrow there. If I do that it gives the error that sumProba != 100, which is logical because I get 5% off the coin, but it can't add it anywhere FYI, I've changed the error message so I could discriminate between them. Thank you!
  7. That is indeed what I did not do. But I thought it was strange that the warning was posted only once every time the Resource.js was processed, because I only added the tradable-data to the coin resource. But that is of no concern anymore That would indeed get rid of the error message, but I don't think the error is bad at the moment, because I have yet to find a way to prevent a player from pressing the arrow-button. Now a player is visually warned that the changes (s)he makes won't be saved That's right, it is only stored on my hard-drive. It is a submod of DE, with elements from e.g. 0abc (like entities costing resources steadily) and Batalion-mod (like morale and fatigue systems) together with many of my own thoughts on how to make the game more realistic. It is probably totally unbalanced and I use it only to code features and test fun stuff, like: When hitting delete a unit converts to GAIA, because it is strange for a unit to kill itself on the lightly taken decision of some girl/guy behind a computer screen
  8. WARNING: JavaScript warning: globalscripts/Resources.js line 33 reference to undefined property data.tradable And for this to make sense you need my Resources.js so you can find it attached. The strange part is that it all works as advertised, yet it does give the warning. This is the warning sent on initialisation. The (second) error: ERROR: Invalid trading goods: ({coin:95, food:5, wood:0, stone:0, metal:0}) comes from the Player.js component, the SetTradingGoods-function and comes from the fact that the arrow button is clickable, so SetTradingGoods is called trying to get the percentage of food up, but I have coded earlier that only coin is tradable. So I would very much like to have an option to disable the arrow if the resource is not tradable, but I haven't found it yet Resources.js
  9. So there is a trickle of coin I guess? Then it would seem logical that mercenaries and champions would have a negative trickle of coin, as their salary? Or is it just a one-time payment to recruit them? Looking at his code he didn't, although I'm happy to be proven wrong! I've fiddled around in the resource code and I have succeeded in ensuring that traders can only trade coin, but it is not finished yet. There is a JS-warning of which I cannot get rid of during initialisation and one can still press the arrows on the trade menu (although that just throws an error and coin is set to 100% again). So it basically works All resources can still be bartered and send to allies though. If you (or someone else) are (is) interested in the code I can upload it here?
  10. 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?
  11. 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.
  12. 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?
  13. 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.
  14. 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,,,
  15. It can indeed be done. For anyone interested: add the "capturable" element in "templates/special/filter/foundation.xml".
  16. 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).
  17. 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.
  18. 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...