LetswaveaBook Posted July 27 Report Share Posted July 27 Does anyone know a quick way to restrict ranged units from attacking fields? The template_unit_dog shows that such things can be done, but I wouldn't want to update every single template. Also, I would like to ban Archers/Javelineers from attacking completed structures with their ranged attack. Attacking uncompleted structures is something I would consider a gamplay mechanic. But banning Archers/Javelineers from attacking completed only structures with their ranged attack, would seem tedious. Any suggestions if that can be done in an efficient way? Quote Link to comment Share on other sites More sharing options...
Atrik Posted July 27 Report Share Posted July 27 https://github.com/0ad/0ad/blob/master/binaries/data/mods/public/simulation/templates/template_unit_infantry_ranged.xml Can't adding it here just work? Quote Link to comment Share on other sites More sharing options...
LetswaveaBook Posted July 27 Author Report Share Posted July 27 19 minutes ago, Atrik said: https://github.com/0ad/0ad/blob/master/binaries/data/mods/public/simulation/templates/template_unit_infantry_ranged.xml Can't adding it here just work? The unit template is not suitable: It seems to mess with units that don't have a ranged attack (healers, fishing ships&trades escpecially) I could edit many parent templates, but that is not what I was looking for. Quote Link to comment Share on other sites More sharing options...
LetswaveaBook Posted July 27 Author Report Share Posted July 27 I was wondering if there could be a statement like "if the attack type is ranged, then add "Field" to restricted attack classes" https://github.com/0ad/0ad/blob/master/binaries/data/mods/public/simulation/components/Attack.js Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 27 Report Share Posted July 27 See http://docs.wildfiregames.com/entity-docs/a26.html Look for restrictedclasses 1 Quote Link to comment Share on other sites More sharing options...
LetswaveaBook Posted July 27 Author Report Share Posted July 27 @Stan` Any suggestion on modding the Attack.js script? I tried the code below, but it did not work. I suppose the code does not return the "Field" string/token/whatever correctly Attack.prototype.GetRestrictedClasses = function(type) { if (this.template[type] && this.template[type].RestrictedClasses && this.template[type].RestrictedClasses._string) { let max = +this.template[type].MaxRange; if ( max > 55 ) { return ["Field"];} else {return this.template[type].RestrictedClasses._string.split(/\s+/);}} return []; }; Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 27 Report Share Posted July 27 Why don't you use the feature I highlighted? Quote Link to comment Share on other sites More sharing options...
real_tabasco_sauce Posted July 27 Report Share Posted July 27 https://code.wildfiregames.com/source/0ad/browse/ps/trunk/binaries/data/mods/public/simulation/templates/mixins/fireship.xml#:~:text=<RestrictedClasses datatype%3D"tokens">!Ship</RestrictedClasses> see this example in the fireship Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted July 27 Report Share Posted July 27 DE does this in the templates and prevents units from attacking the Shrine and Merc Camp map objects. In template_unit_cavalry_melee.xml <Attack> <Melee> <AttackName>Knife</AttackName> <Damage> <Hack>8.0</Hack> <Pierce>0.0</Pierce> <Crush>0.0</Crush> </Damage> <MaxRange>6.0</MaxRange> <PrepareTime>500</PrepareTime> <RepeatTime>1000</RepeatTime> <Bonuses> <ElephantStench> <Classes>Elephant</Classes> <Multiplier>0.5</Multiplier> </ElephantStench> <CamelStench> <Classes>Camel</Classes> <Multiplier>0.5</Multiplier> </CamelStench> <BonusSiege> <Classes>Siege</Classes> <Multiplier>2.0</Multiplier> </BonusSiege> </Bonuses> <PreferredClasses datatype="tokens">Ranged+Unit Siege</PreferredClasses> <RestrictedClasses datatype="tokens">Permanent Ship</RestrictedClasses> </Melee> </Attack> I have a custom class called Permanent for certain things in DE. You can put Field there instead. 2 Quote Link to comment Share on other sites More sharing options...
LetswaveaBook Posted July 28 Author Report Share Posted July 28 On 27/07/2024 at 7:35 PM, LetswaveaBook said: The template_unit_dog shows that such things can be done, but I wouldn't want to update every single template. I dont fancy updating every template, especially since I would also consider not allowing ranged units to attack rams or siege towers. Doing it template by template means that with every change of mind, I need to change all the templates again. The templates would be inf_skirm_sling_crossbow_archer Jav archer and javelin champion archer, cav archer and crossbow, the hero templates for archers, cav archers javelineer and mounted javelineer and of course the bolt shooter. Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 28 Report Share Posted July 28 Well all templates inherit from one another, so you only have to update the highest parent you can find. 2 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted July 28 Report Share Posted July 28 To piggyback on what @Stan` has said, imagine it's a hierarchal structure. Everything you do on a higher level of the pyramid trickles down to the templates on the lower levels unless you specify something different in those templates. Quote Link to comment Share on other sites More sharing options...
LetswaveaBook Posted July 30 Author Report Share Posted July 30 On 28/07/2024 at 10:49 PM, wowgetoffyourcellphone said: To piggyback on what @Stan` has said, imagine it's a hierarchal structure. Everything you do on a higher level of the pyramid trickles down to the templates on the lower levels unless you specify something different in those templates. Maybe I don't fully understand. But in order to fix the "restricted classes", I assign an "attack" element to the unit template while some units shouldn't get any attack element. Am I wrong on this? The unit template is not suitable: It seems to mess with units that don't have a ranged attack (healers, fishing ships&trades escpecially) Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 30 Report Share Posted July 30 33 minutes ago, LetswaveaBook said: But in order to fix the "restricted classes", I assign an "attack" element to the unit template while some units shouldn't get any attack element. Am I wrong on this? The unit template is not suitable: It seems to mess with units that don't have a ranged attack (healers, fishing ships&trades escpecially) I assume you're referring to the template_unit.xml file. Obviously that would be the easiest thing to do, one file to change, and boom. Unfortunately all the template_unit_*.xml files for units inherit from it. The templates you're interested in are in that folder https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/templates No need to go down, all the templates in the subfolder inherit from those. The files you should change are probably: For cavalry template_unit_cavalry_ranged_archer.xml template_unit_cavalry_ranged_crossbowman.xml template_unit_cavalry_ranged_javelineer.xml For infantry template_unit_infantry_ranged_archer.xml template_unit_infantry_ranged_crossbowman.xml template_unit_infantry_ranged_javelineer.xml template_unit_infantry_ranged_slinger.xml You might be able to get away with only editing those two files template_unit_infantry_ranged.xml template_unit_cavalry_ranged.xml As you can see by looking at https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_infantry_ranged_archer.xml <Entity parent="template_unit_infantry_ranged"> This line indicates the template inherits from all the stuff you put in the parent, here template_unit_infantry_ranged.xml It sadly seems no one unified the champion templates for ranged so you need to edit: template_unit_champion_cavalry_archer.xml template_unit_champion_cavalry_crossbowman.xml template_unit_champion_cavalry_javelineer.xml template_unit_champion_infantry_archer.xml template_unit_champion_infantry_crossbowman.xml template_unit_champion_infantry_javelineer.xml I have not tested, but you should only have to add <Attack> <Ranged> <RestrictedClasses datatype="tokens">Field</RestrictedClasses> </Ranged> </Attack> in each of the templates. Does that make more sense to you? Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 30 Report Share Posted July 30 Assuming you'd want to go nuts, or only change classes in one place you can use what we call mixins (basically small part of templates, that can be reused) Here is an example for the african elephants, that stacks modifiers on top of normal elephants https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/templates/mixins/elephant_african.xml This mixin is referenced in https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/templates/units/kush/champion_elephant.xml like this: <Entity parent="elephant_african|template_unit_champion_elephant_melee"> Yours would look like this maybe called ranged_restrictions.xml in the mixins directory <?xml version="1.0" encoding="utf-8" standalone="no"?> <Entity> <Attack> <Ranged> <RestrictedClasses datatype="tokens">Field</RestrictedClasses> </Ranged> </Attack> </Entity> and be referenced like this: <Entity parent="ranged_restrictions|original_parent"> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.