Jump to content

My try at adding a new weapon to the current build.


Max_Caine

Recommended Posts

I've been interested for a while learning how to make new weapons and equipment for Xenonauts, and having had some successful attempts, I would like to share what I did to create a new gun for the game. At this point, I'd like to give a big shoutout to Gauddlike and Quartermaster. I found their posts and the work they did on the Xenonauts wiki very useful.

The design brief I set for myself was to create a stun rifle, basically a ranged version of the stun baton. It should be researched (after Alien Biology is researched) and manufacturable (both rifle and ammo). The weapon is a high-powered rifle, adapted to fire a dart which delivers a powerful electrical shock to the victim.

First place to go is weapons_gc.xml, where you set up the stats for the weapon.

<Weapon name="weapon.stungun" bulletType="normal" emptySound="Empty Click 1" reactionModifier="0.8">

<props range="26" hands="2" recoil="0" weight="6.5" isHeavy="1" clipSize="1"

reloadAPCost="15" reloadSound="Weapon Precision Rifle Reload" />

<SingleShot sound="Weapon Sniper Single" suppressionValue="0" suppressionRadius="0">

<Set1 ap="21" accuracy="75" />

<Set2 ap="25" accuracy="95" />

<Set3 ap="28" accuracy="120" />

<Set4 ap="31" accuracy="150" />

</SingleShot>

<BurstFire/>

<GUIImage name="weapons/ballistic/alternative/PSG1.png"/>

<GroundImage name="grounditemimages/assaultrifle.png"/>

<Ammos>

<Ammo name="ammo.ballistic.sniper" type="kinetic" damage="1" stunDamage="40" mitigation="100">

<Projectile spectre="projectiles/bullet/bullet" speed="1200" delay="2.5"/>

<Impact spectre="particles/bulletplume/bulletplume"/>

</Ammo>

</Ammos>

This is basically a cut-and-paste of the precision rifle entry, with some of the stats adjusted, a new name (weapon.stungun), and an alternate graphic used for the weapon. Note that the weapon has an absurdly high mitigation value and a very low damage value. This is because I found out that stun damage is currently dealt in addition to actual damage. No actual damage = no stun damage. So I set it to cause 1 point of damage, and to ensure it caused that point of damage, it mitigates all known armour.

EDIT: Also please note I am using the ammo type for the precision rifle. This will come in important later.

After the weapon is made, it has to be registered with several other files to make it a usable item. You have to add it to weapons.xml.This adds it to the base layout, along with statistics which will be displayed when you click on it.

<Row ss:AutoFitHeight="0">

<Cell ss:StyleID="s63"><Data ss:Type="String">weapon.stungun</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s63"><Data ss:Type="String">weapons/ballistic/alternative/PSG1</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s63"><Data ss:Type="String">weapons/ballistic/alternative/PSG1</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s63"><Data ss:Type="String">ballistic</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="Boolean">1</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="Number">1</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="Number">260</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="Number">1</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="Number">1.25</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="Number">6.5</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="Number">5</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="Number">2</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s63"><Data ss:Type="String">ammo.ballistic.sniper</Data><NamedCell

ss:Name="_FilterDatabase"/></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="Number">18</Data></Cell>

</Row>

You then have to add it to items.xml. This registers the item with the game in general.

<Row ss:AutoFitHeight="0">

<Cell ss:StyleID="s69"><Data ss:Type="String">weapon.stungun</Data></Cell>

<Cell><Data ss:Type="Number">1000</Data></Cell>

<Cell><Data ss:Type="String">Unlimited</Data></Cell>

<Cell><Data ss:Type="String">weapons/airplane/rocket</Data></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="String">Item.Dispose.Destroyed</Data></Cell>

</Row>

Take a look at the third data row “Unlimited”. This variable when set to unlimited will make the item appear on the solider screen straight away. (I do this for testing purposes). Now, we're not done yet! The name weapon.stungun is understood by the game, but may be confusing to the player. There is a file called strings.xml, where I then put a description string for weapon.stungun so it comes up all pretty if I mouseover on it.

<Row ss:AutoFitHeight="0">

<Cell><Data ss:Type="String">weapon.stungun</Data></Cell>

<Cell><Data ss:Type="String">Stun Rifle</Data></Cell>

</Row>

Then finally, you have to add spectre files for the weapon so soldiers can carry it in the ground combat. To do that, from the /assets directory go into the /units/xenonaut/ directory. Then for every armour type (basic, jackal, wolf), go into the respective directory (e.g. for jackal /units/xenonaut/jackal/) and create a new directory with the weapon name as defined in weapons_gc.xml. So I created a weapon.stungun directory ( /units/xenonaut/jackal/weapon.stungun/ ), then copy and paste the most appropriate soldier spectre file from the other directories, or make up your own spectre file if you have unique art assets. (so I copied soldier_spectre.xml from weapon.sniper as the rifles look the same).

At that point, I've done enough to create a new weapon. If I now start a game and go to the solider tab in the base, I will see the stun rifle. If I mouseover on the stun rifle, it will give up the description “stun rifle”. I will discuss research and manufacture in my next post (when I have written something worthwhile).

Edited by Max_Caine
Link to comment
Share on other sites

Looks good so far. The only suggestion I would make is that it is better to edit the strings.xml, weapons.xml, and items.xml through Excel. As Excel files they have some tag that keeps track of how many items are in it so what happens if you add items to the list is that sometimes they get ignored by Xenonauts even though they look like they are there. My guess is that it the program looks at how many items it says are in the list and then only goes through that many.

Link to comment
Share on other sites

I'm still working on the second half - it's taking time to compose my thoughts coherantly. QM, unfortunately I don't have Excel, only OpenOffice, which is good most of the time but not when it comes to these files - I had to alter them manually. That said, yes, I agree that they should be altered in Excel if at all possible.

Link to comment
Share on other sites

I pointed out that I used the precision rifle ammo type earlier on. This is because I don't have a unique ammo graphic for the stun rifle, so I used the closest fit. But by doing this, I can't make the ammo researchable or manufacturable, only the rifle. If I altered the precision rifle ammo to do that, then it would (as far as I can tell) affect ammo for the precision rifle as well (i.e. I would have to manufacture it). However, I can alter the ammo statistic within the weapon descriptor in weapons_gc.xml without affecting how precision rifle ammo works.

But, let's say that I did have a unique ammo graphic. Then I would have altered several files. After putting the ammo graphic in /weapons/ballistic/ I would have altered ammos.xml.

<Ammo name="ammo.ballistic.stungun">

<stockTextureName>weapons/ballistic/stungun_ammo</stockTextureName>

<dragTextureName>weapons/ballistic/stungun_ammo</dragTextureName>

<slotsizex>1</slotsizex>

<slotsizey>1</slotsizey>

</Ammo>

I would have to make sure this ammo type was also in weapons.xml and weapons_gc.xml in the stungun ammo markup. I would also have to make up new markups and content (hopefully in Excel) in items.xml and strings.xml, using the same process as previously described.

Link to comment
Share on other sites

Part 2.

Let's start this post with researching an item. The first step is to introduce the researchable item to the list of things that can be researched, and what they unlock when finished researching.

Before I make it researchable or manufacturable, I have to make a change to the “finished product” in items.xml (weapons.stungun). I have to change the third data entry from “Unlimited” to “Normal”. By setting it so, the game will automatically treat it as a manufacturable item.

A “finished good” has three stages. Research. Manufacture. Finished Item. These are discrete phases, and each phase has its own markup and content. And yes, you will have to put the same item in multiple times into strings.xml and once more into items.xml to reflect these changes.

There are three similar files which affect what can be researched. researches_public.xml, which seems to be a master list of everything that can be researched. researches_.xml which looks like a cut down version of researches_public and researches.xml, which looks like an even furture cut down version of both. As far as I can tell, Xenonauts draws all the items that you can research only from researches.xml. This may change, who knows, but researches_ didn't seem to do anything when I altered it and changed it back.

I have to add a new entry to researches.xml for the new item. This will be for the stun rifle only, as I don't have a unique graphic for the ammo, I can't make it researchable or manufacturable. Arse. Something for the future then!

So, adding the new researchable item:

<Row ss:AutoFitHeight="0" ss:Height="76.5">

<Cell ss:StyleID="s71"><Data ss:Type="String">Researches.StunGun</Data></Cell>

<Cell ss:StyleID="s70"><Data ss:Type="Number">10</Data></Cell>

<Cell ss:StyleID="s72"><Data ss:Type="String">Weaponary</Data></Cell>

<Cell ss:StyleID="s77"><Data ss:Type="String">Researches.AlienBiology</Data></Cell>

<Cell ss:StyleID="s70"/>

<Cell ss:StyleID="s78"><Data ss:Type="String">UnlockKnowledge( "Researches.StunGun" );

UnlockManufacture( "ManTech.StunGun" );</Data></Cell>

<Cell ss:StyleID="s73"><Data ss:Type="String">Researches.StunGun</Data></Cell>

</Row>

Naturally, you should do this in Excel. Either that or keep a good count of the cell numbers and add it to the end. It only takes 10 days to research, so to get an “Excellent” rating you only require 5 scientists. But this is all for example purposes. Always start a researchable item's descriptor as “Researches”. While “Weaponary” looks wrong, don't correct it. That's what the game reads “Weaponry” to be. The forth line indicates which researches (if any) you have to do before you can research this item. This being a simple example only has one prerequisite, but if you take a look at the more involved items, you can see how complex it can get!

The next file to adjust is xenopedia.xml. This is perhaps the most pleasurable of all the files to adjust, as you can do a little creative writing here when adding your new bit of kit.

<Row ss:AutoFitHeight="0" ss:Height="229.5">

<Cell><Data ss:Type="String">Researches.StunGun</Data></Cell>

<Cell><Data ss:Type="String">Stun Rifle</Data></Cell>

<Cell><Data ss:Type="String">xenopediaimages/placeholder</Data></Cell>

<Cell><Data ss:Type="String">Xenonaut Weaponry</Data></Cell>

<Cell><Data ss:Type="String">Weapon Classes</Data></Cell>

<Cell><Data ss:Type="String">NULL</Data></Cell>

<Cell ss:StyleID="s68"><Data ss:Type="String">This is test text</Data></Cell>

<Cell><Data ss:Type="String">xenopediaimages/placeholder</Data></Cell>

<Cell ss:StyleID="s66"><Data ss:Type="String"><font size="19" face="fonts/xenonauts.mvec">SUMMARY:</font><font size="5">

</font><font size="12"> <font face="fonts/tahoma.mvec">>> </font><font face="fonts/xenonauts.mvec">we have developed a weapon capable of stunning aliens <font size="6">

</font> <font face="fonts/tahoma.mvec">>> </font>Shocker ammo deals high stun but low physical damage<font size="6">

</font> <font face="fonts/tahoma.mvec">>> </font>shocker darts must be loaded one at a time<font size="6">

</font

<font size="30">

</font>><font size="19" face="fonts/xenonauts.mvec">REPORT:</font><font size="15" face="fonts/tahoma.mvec">

If we are to win this war we need to interrogate live specimens, but we have had difficulty in subduing aliens. The most effective means to date is are stun batons which deliver a powerful incapacitating electrical shock, but this puts our soldiers in an unacceptably hazardous situation.

Experiments with tranquilisers have so far met with failure. We have not yet found a broad-spectrum drug that will affect all the different racial types encountered so far with equal force.

However, our greater understanding of alien nervous systems has lead to a ranged version of the stun baton. The stun gun fires a heavy dart which delivers a calibrated series of electrical shocks, designed to cause maximum disorientation to nervous systems and logic processing centres, while minimising physical damage. Due to limitations in battery technology the amount of damage a single dart can cause is limited, so be aware that you may need more than one dart to stun a target.

The darts require a variety of rare earths which makes them expensive to manufacture. Our engineers have adapted a powerful high-end sniper rifle to ensure they hit their target at a reasonable range. Darts must be loaded into the rifle one at a time, so ensure that your ablest snipers are equipped.

</font></Data></Cell>

</Row>

EDIT: Please note that there are some sections in this code fragment which I cannot replicate, no matter how I try. The best solutio is to look at other xenopedia entries to see how it was done.

There are two different xenopedia entries. The first entry is whatever you choose to put in the Xenopedia. The second entry is whatever you choose to enter in the popup that appears when you research an item. Note that you can make both very different. You can have two completely different graphics, one for the popup, one for the xenopedia. The popup research text must follow the format of SUMMARY: <text> then REPORT: <text>.

Once I've added the xenopedia entry, I have to then make a strings.xml entry for it.

<Row ss:AutoFitHeight="0">

<Cell><Data ss:Type="String">Researches.StunGun</Data></Cell>

<Cell><Data ss:Type="String">Stun Rifle</Data></Cell>

</Row>

Or it will be listed as #### in the research screen.

Now we can research it, it needs to be manufactured. Off we go to manufactures.xml

<Row>

<Cell><Data ss:Type="String">ManTech.StunGun</Data></Cell>

<Cell><Data ss:Type="String">SoldierWeapons</Data></Cell>

<Cell><Data ss:Type="Number">10</Data></Cell>

<Cell><Data ss:Type="Number">5000</Data></Cell>

<Cell ss:Index="8"><Data ss:Type="String">StockItem( "weapon.stungun" );</Data></Cell>

</Row>

You can cut and paste from the laser gun setup to do this (I did). The important thing to remember is to start your description of the manufacturable good with “ManTech”.

Almost done! Now you have to update strings.xml

As a stocked item:

<Row ss:AutoFitHeight="0">

<Cell><Data ss:Type="String">Items.StunGun</Data></Cell>

<Cell><Data ss:Type="String">Stun Rifle</Data></Cell>

</Row>

And as manufacturable item name:

<Row ss:AutoFitHeight="0">

<Cell><Data ss:Type="String">ManTech.StunGun</Data></Cell>

<Cell><Data ss:Type="String">Stun Rifle</Data></Cell>

</Row>

Then update items.xml

As a stocked item:

<Row ss:AutoFitHeight="0">

<Cell><Data ss:Type="String">Items.StunGun</Data></Cell>

<Cell><Data ss:Type="Number">20000</Data></Cell>

<Cell><Data ss:Type="String">Normal</Data></Cell>

<Cell><Data ss:Type="String">items/assaultrifle</Data></Cell>

<Cell ss:StyleID="s64"><Data ss:Type="String">Item.Dispose.Destroyed</Data></Cell>

</Row>

The second thing to remember is whatever you name the researchable item does not have to marry up with the manufactured item, or the finished good. i.e. I could have Researches.FunnyBone unlock ManTech.TickleStick which makes weapon.nuclearbomb.

And that's all! It worked for me, but I may have missed out something. The only thing I couldn't work out is how to get a “research description” or “manufacture description”. QM, Gauddlike, any ideas?

Edited by Max_Caine
Link to comment
Share on other sites

Also did you try adding a desc entry in strings.xml for your new weapons?

For example the laser pistol has:

mantech.laserpistol

and:

mantech.laserpistoldesc

Laser weaponry research has:

researches.laserweaponry

and:

researches.laserweaponrydesc

The desc entry has the details to be displayed in the description window of the relevant screen.

Note the <left> modifier for the text in those examples.

The text will be misplaced without it.

Link to comment
Share on other sites

  • 10 months later...

Ok after reviewing this I have a few questions.

I am trying to add an M16 with the M203 grenade launcher attachment. I already have PNG files for the rifle as well as the individual grenades But I am curious how you would recommend adding the alternate fire mode for the grenades and the use of the second ammunition

Link to comment
Share on other sites

Ok after reviewing this I have a few questions.

I am trying to add an M16 with the M203 grenade launcher attachment. I already have PNG files for the rifle as well as the individual grenades But I am curious how you would recommend adding the alternate fire mode for the grenades and the use of the second ammunition

Creating a secondary fire would be exceptionally difficult with the current games mechanics, but I do know a way you could TECHNICALLY make it work.

	<Weapon name="weapon.rifle" bulletType="normal" emptySound="Empty Click 1">	<props range="20" hands="2" recoil="0" weight="5" isHeavy="0" clipSize="20" reloadAPCost="30" reloadSound="Weapon Assault Rifle Reload" reactionModifier="1" hpLimit="80" />	<SingleShot sound="Weapon Rocketlauncher Single" delay="1.05" suppressionValue="60" suppressionRadius="3">		<Set1 ap="40" accuracy="30" />	</SingleShot>	<BurstFire ap="20" accuracy="30" sound="Weapon Assault Rifle Single" delay="0.9" burstdelay="0.1" shotCount="1" suppressionValue="40" suppressionRadius="3" />                <BurstFire ap="30" accuracy="60" sound="Weapon Assault Rifle Single" delay="0.9" burstdelay="0.1" shotCount="1" suppressionValue="40" suppressionRadius="3" />                <BurstFire ap="40" accuracy="80" sound="Weapon Assault Rifle Single" delay="0.9" burstdelay="0.1" shotCount="1" suppressionValue="40" suppressionRadius="3" />                <BurstFire ap="40" accuracy="20" sound="Weapon Assault Rifle Burst" delay="0.9" burstdelay="0.1" shotCount="3" suppressionValue="40" suppressionRadius="3" />	<GUIImage name="gui/weapons/AssaultRifle.png"/>	<GroundImage name="grounditemimages/assaultrifle.png"/>	<Ammos>		<Ammo name="ammo.ballistic.rifle" type="Incindiary" damage="30" mitigation="0">			<Projectile spectre="projectiles/bullet/bullet" speed="1200"/>                        <Impact spectre="particles/explosion/explosion" radius="3" sound="Weapon Rocketlauncher Explosion" fireChance="10" smokeChance="20" gasType="GrenadeFragSmoke" />		</Ammo>	</Ammos></Weapon>

Do note...

This is going to be a EXCEPTIONALLY weird, buggy, and slightly overpowered weapon, however, it exploits the fact that burst shots cannot explode...

Your grenades will pull ammo from the magazine, but this is as close as you can get for now.

Link to comment
Share on other sites

I don't believe it does.

Allowing multiple burst levels was part of my suggestion thread on making weapons more individual but that was one of the changes Chris had no interest in making.

At this point.

Not now is not never.

His major concern is finishing the game, currently.

In the future, when the game is a more finished product, I am sure we will get a lot of love.

Link to comment
Share on other sites

  • 2 months later...

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.

×
×
  • Create New...