Jump to content

Changing a units visual weapon - can it be done purely via code?


LordStark
 Share

Recommended Posts

Hi team,

Just wanted to say thank you to everyone who has helped me so far. There are limits on the number of posts that can be made so I am not able to reply to everyone who helps and thank them personally - but I do very much appreciate all the advice.

On to my question, I am modding the millenium mod and I wanted to make my anglo-saxon units upgradable to a unit ("Master at Arms")that looks like the norse huscarl - the only problem is, the huscarl carries and axe over his soldier rather than a sword or a spear. Is there anyway for me to change this?

Also, is there away to change the wording of so that instead of it saying "Upgrade to Master at Arms" it says "Appoint to Master at Arms"?

Link to comment
Share on other sites

10 minutes ago, LordStark said:

On to my question, I am modding the millenium mod and I wanted to make my anglo-saxon units upgradable to a unit ("Master at Arms")that looks like the norse huscarl - the only problem is, the huscarl carries and axe over his soldier rather than a sword or a spear. Is there anyway for me to change this?

You can create another actor that uses the sword animation and props (props are the tools and weapons carried by the unit) See XML.Actor – Wildfire Games

Link to comment
Share on other sites

Unfortunately it is "hardcoded" here https://github.com/0ad/0ad/blob/aaf6271b47686a17b9b995b7cf83064e1234a02b/binaries/data/mods/public/gui/session/selection_panels.js#L1142

You can mod that file, but keep in mind it will break all the translations of your mod.

As it is required to be translated. It could be expanded in the future. cc @Freagarach

Link to comment
Share on other sites

When you say "it will break all the translations of your mod" do you mean that if my mod had upgrades elsewhere (it doesn't) that they would simply not say "upgrade"?

If that is the only issue I would be more than happy to change it. Where would I find that file to mod? Also, do I just change it to:

"

if (data.item.tooltip)
  tooltips.push(sprintf(translate("%(primaryName)s %(tooltip)s"), {
  "primaryName": primaryName,
  "secondaryName": secondaryName,
  "tooltip": translate(data.item.tooltip)
  }));"

And this would have the ingame effect of:

"Master at Arm - Appoint this unit as the Master at Arms"

That seems super easy...

Link to comment
Share on other sites

I mean that your mod relies on translations that are inside the public mod. So if you change the four occurences of the string in that file (see the url for the path of that file) the game engine will no longer be able to match the strings and the translations. So it will default to english and whatever you put there.
Link to comment
Share on other sites

So I ended up extracting the public zip file (into the same folder as the zip file). So I ended up with public.zip and public (normal folder). I then went into the public folder and found the code you referred to and deleted the green highlighted parts:

Quote
if (g_ShowSecondaryNames)
  {
  if (data.item.tooltip)
  tooltips.push(sprintf(translate("Upgrade to a %(primaryName)s (%(secondaryName)s). %(tooltip)s"), {
  "primaryName": primaryName,
  "secondaryName": secondaryName,
  "tooltip": translate(data.item.tooltip)
  }));
  else
  tooltips.push(sprintf(translate("Upgrade to a %(primaryName)s (%(secondaryName)s)."), {
  "primaryName": primaryName,
  "secondaryName": secondaryName
  }));
  }
  else
  {
  if (data.item.tooltip)
  tooltips.push(sprintf(translate("Upgrade to a %(primaryName)s. %(tooltip)s"), {
  "primaryName": primaryName,
  "tooltip": translate(data.item.tooltip)
  }));
  else
  tooltips.push(sprintf(translate("Upgrade to a %(primaryName)s."), {
  "primaryName": primaryName
  }));
  }
 

But nothing happened in game....

I then tried removing the public.zip file but that caused technical issues.

What am I doing wrong here?

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...