Jump to content

Inti's Questions (Make a unit not be able to gather?)


intipablo
 Share

Recommended Posts

Hello, modders! I'm back and decided to just make a thread where I will post all my questions in one, so I don't "spam" this forum.

Here's my question today. I'm adding a new unit to the game called a Spartan Youth. However, I keep getting this error when I launch a match as the Spartans.

 

'Expecting an element entity: got nothing'

 

In my script for the unit, I'm using this template: template_unit_infantry_melee_spearman
As my parent entity, however, when I change it to template_unit_champion_infantry_spearman
It works? Thoughts?

the problem with using the champion template is that the unit is meant to be available from the start, at the civic centre.

 

MORE QUESTIONS DOWN BELOW

Edited by intipablo
Link to comment
Share on other sites

Spoiler

<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_unit_infantry_melee_spearman">
  <Cost>
    <Resources>
      <food>60</food>
    </Resources>
  </Cost>
  <Attack>
    <Melee>
      <Hack>2.5</Hack>
    </Melee>
  </Attack>
  <Identity>
    <Civ>spart</Civ>
    <GenericName>Light Infantry</GenericName>
    <SpecificName>Spartan Youth</SpecificName>
    <History>Young Spartans, not yet ready to fight in a proper phalanx, are tasked with chasing off skirmishers in battle.</History>
    <Icon>units/spart_infantry_spearman.png</Icon>
    <SelectionGroupName>units/spart_spearman_youth</SelectionGroupName>
  </Identity>
  <UnitMotion>
    <WalkSpeed>14.0</WalkSpeed>
    <Run>
      <Speed>22.0</Speed>
    </Run>
  </UnitMotion>
  <VisualActor>
    <Actor>units/spartans/infantry_youth.xml</Actor>
  </VisualActor>
</Entity>

 

 

Link to comment
Share on other sites

I think I might know what the issue is. You haven't specified the Promotion tag (which templates it promotes to after collection enough XP)

You can do two things:

1. Specify a template:

  <Promotion>
    <Entity>units/athen_infantry_spearman_a</Entity>
  </Promotion>

2. Disable promotion:

  <Promotion disable=""/>

 

  • Like 3
Link to comment
Share on other sites

16 hours ago, niektb said:

I think I might know what the issue is. You haven't specified the Promotion tag (which templates it promotes to after collection enough XP)

You can do two things:

1. Specify a template:


  <Promotion>
    <Entity>units/athen_infantry_spearman_a</Entity>
  </Promotion>

2. Disable promotion:


  <Promotion disable=""/>

 

Thankyou very much! It's working fine now.

  • Like 1
Link to comment
Share on other sites

Hello! Anyone know how to make your custom/new unit show up in the atlas scenario editor (I want to view my custom units in the actor viewer)? I couldn't find any tutorials online and am unsure of what to do...No matter what I do, the name does not want to show up in the list of entities/actors  in the atlas editor.

Thanks again!

Edited by intipablo
Link to comment
Share on other sites

Just to rule out the obvious, but did you restart atlas after adding that unit (hotloading could be broken in atlas (on some platforms))? Are you doing your work in a mod? If yes, is that mod enabled? You could try adding your custom template to the public mod to rule out any mod related issues, if none of the above worked.

Link to comment
Share on other sites

12 hours ago, leper said:

Just to rule out the obvious, but did you restart atlas after adding that unit (hotloading could be broken in atlas (on some platforms))? Are you doing your work in a mod? If yes, is that mod enabled? You could try adding your custom template to the public mod to rule out any mod related issues, if none of the above worked.

Hello and thanks for replying! Fortunately, your last solution worked for me (The other did not however), I put the custom template in the public mod and now it shows up in the actor viewer. Is this a common problem or?

Link to comment
Share on other sites

Another problem! The icon for my custom unit doesn't seem to be working.

This is the line of code for in the unit template file:

<Icon>units/spartan_youth.png</Icon>

The icon is located in this directory:

\art\textures\ui\session\portraits

Any problems with that? I have tried a 128x128 file, as well as a 256x256 file. The image is a .png file.

Link to comment
Share on other sites

2 hours ago, niektb said:

That's pretty obvious I think: your icon should be in art\textures\ui\session\portraits\units not art\textures\ui\session\portraits

Sorry typo on my part! The icon is actually in the correct directory "\portraits\units\" sorry! (Still not working)

Edited by intipablo
Link to comment
Share on other sites

24 minutes ago, leper said:

Was the mod enabled and did you save that config? (If not there might be either a bug or a limitation in atlas)

Yes, it was enabled and save what config? Everything is saved and everything works in the game perfectly, however, it doesn't show up in atlas. Help with the unit icon would also be appreciated!

Edited by intipablo
Link to comment
Share on other sites

Just looked at the code, the Actor Editor indeed hard-codes the public mod, though you might be able to manually open a file from another mod. They should show up (if the mod config is saved (enable the mod, press the save button in the mod selection screen) in Atlas though. (Also the Actor Editor is broken on *nix #1553, so removing that hard-coding (and making it use the vfs like mentioned in a commit from 2008 (r6395) would be nice if someone is inclined to work on that.)

As for the icon issue (and I guess a few other questions) having your mod in a public repository or something can be quite helpful (as debugging remote and blind is quite hard most of the time).

(Also keep asking questions, this helps a lot with figuring out where documentation could be improved (also feel free to do that if you find something lacking) and it tends to expose bugs or limiations.)

  • Like 3
Link to comment
Share on other sites

Hello again! I managed to fix the unit icon issue, must have been a typo or something as I decided to re-write all the files.

Now I'm moving onto the next part of my mod and I'm wondering if there is a way to make units be able to build however not gather? If so, how?

Link to comment
Share on other sites

3 hours ago, niektb said:
 

Ah, thankyou! Is there any way to do the opposite? As in only gathering not building? Also, is there any way to prevent a unit from being able to build a certain building, for example, I want a unit to be able to only build military based structures. Sorry to ask so many questions! I'm a complete noob!

Link to comment
Share on other sites

Adding only ResourceGatherer but not Builder will do that. Since you inherit from some unit template you will most likely need to disable them by using


<builder disable=""></builder>
.

As for restricting what buildings a unit can build, no there is no way to do that currently. If you really need that you should open a ticket on trac. (I suspect the actually needed changes to restrict building to only those present in the Builder list shouldn't be very complicated.) Edited by leper
Work around forum software idiocy
  • Like 1
Link to comment
Share on other sites

7 hours ago, leper said:

Female citizens are able to build military buildings, they just can't place the foundations for them. If you want that you can just remove the entries from the Builder list by adding -template in the token list.

Oh yes, I see, I had a complete mind blank my bad!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...