Jump to content

How to Add a New Type of Smoke/Gas (Smoke Grenade Example)


Recommended Posts

In the most recent builds a new file, gas_gc.xml, has been added to the game. This file is used to add different smoke effects when explosions occur. The different gasses/smokes have a number of properties that can be modified to change how they affect your soldiers and aliens. To start find the file in the assets folder of Xenonauts and it using Notepad.

You should see a file with about 8 different types of smoke/gasses. The first three are hardcoded to the game and linked to environmental effects whereas the remaining five are the result of weapon explosions. Each gas entry has a name, an animation associated with it, and a number of properties that have an effect on how your soldier interacts with it. The properties include how much damage it causes per turn, stundamage, how quickly it dissipates, and how it affects your ability to shoot into it (this parameter is not currently functioning). It is important to note that the damage/stundamage caused by smoke is not currently mitigated by armor (to the author's best knowledge).

To provide an example of how to add a new gas/smoke we will be adding the smoke grenade to the game (image files exist, but not currently implemented). None of the existing gas/smoke entries is currently a viable option for this weapon, because they give a potential smoke grenade a very strong offensive use because they do a lot of damage or stun damage. Additionally the other smoke/gas entries dissipate too quickly. To add a new smoke grenade effect add the following to the file around the FragGrenadeSmoke entry:

<GasType name="SmokeGrenadeSmoke">

<Anim name="particles/lightsmoke/lightsmoke" />

<Props damage="0" stunDamage="0" dissipationChance="20" accuracyReduction="25" LOSReduction="3" />

</GasType>

This creates a special type of smoke that will look like grenade smoke, but will not cause damage to the target, will better obfuscate your solders, and take longer to dissipate. Now that we have this new type of smoke, we need a method to deliver it to the battlefield. Namely we need a smoke grenade. Before proceeding, save and close gas_gc.xml.

Open weapons_gc.xml next and find the entry for "weapon.grenade.smoke". The outline for the weapon is there, but has not been fleshed out yet. Replace the entry with the following:

<Weapon name="weapon.grenade.smoke" bulletType="grenade" emptySound="Empty Click 1">

<props range="10" hands="1" recoil="0" weight="1" clipSize="1" reloadAPCost="0" />

<SingleShot delay="0.85">

<Set1 ap="20" accuracy="50" />

</SingleShot>

<BurstFire />

<GUIImage name="weapons/ballistic/grenadesmoke.png" />

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

<Ammos>

<Ammo name="ammo.none" type="chemical" damage="5" stunDamage="5" mitigation="0">

<Projectile spectre="projectiles/grenade" />

<Impact spectre="particles/smallgrenade/small_grenade" gasType="SmokeGrenadeSmoke" fireChance="1" smokeChance="95" radius="5.1" sound="Weapon Gas Grenade" />

</Ammo>

</Ammos>

</Weapon>

The main effect of this smoke grenade can be seen in the line that begins with "<Impact". As you may have noticed, we have set the type of gas that the explosion it creates to our new smoke. The other properties control what the explosion looks like, how big of a radious the smoke will fill, the probability that an affected tile will be filled with smoke (95%), the sound of the explosion, and the probability of a tile having fire in this (I made this 1% because that actually happened in basic training during a training excercise). Once you are done save and close the file.

To fully add the weapon, add an entry for the smoke grenade to weapons.xml with the following values (in order of how they should be entered for a single row:

weapon.grenade.smoke, weapons/ballistic/grenadesmoke, weapons/ballistic/grenadesmoke, ballistic, FALSE, 5, 10, 1, 0.5, 1, 1, 1, ammo.none, 0

Once you save and exit weapons.xml, add an entry to strings.xml for what the smoke grenade should be referred to as. Namely add the following two values in a new row: weapon.grenade.smoke and Smoke Grenade. The final step is to allow you to play with it in game by adding an entry for the Smoke Grenade to the Items.xml file. Add a new line with the following values (in order of how they should be entered for a single row: weapon.smoke.grenade, 0, Unlimited, weapons/airplane/rocket, Item.Dispose.Destroyed. Once you save this file, open up Xenonauts, start a new regular game, and equip the new grenade to your soldiers.

Note:

You can stop at this point if you want if you do not plan on equipping the smoke grenade as the sole weapon and use it from the quick throw option. However, if you stop here, this is not a full implementation, because you have to create the special spectres (files that control how the soldier's movement is portrayed) for a soldier equipped with the smoke grenade for each armor. If you want to fully implement it do the following: Go to the folder "/assets/units/xenonaut" in your Xenonauts directory. You will see folders for each of the armors listed. For each armor (except "none") open the folder and create a new folder within it titled "weapon.grenade.smoke". Copy the file "solder_spectre" from the weapon.grenade.frag folder for that armor and then paste it into your new folder. Once you have done this you have fully added the smoke grenade to the game.

Hope you like the new tactical option!

Edited by Quartermaster
Based on further testing I realized that the obfuscation aspect of the grenade is not functioning yet.
Link to comment
Share on other sites

Hey, thanks for doing all this stuff. It will come real in handy when the game is out and people start changing stuff in earnest.

Is the "accuracyReduction" a percentage or a fixed value?

I just ran a little experiment and the accuracyReduction aspect must not be implemented... I looked at the parameter and assumed it was probably functioning since the rest of the gas stuff seems to working (other than the LOS reduction). When I tested it earlier I focused primarily on getting the explosion/gas set up correctly and implementing the smoke grenade. So frustratingly it does not look like it can actually function as a "smoke grenade" even though it looks to behave as such on the screen.

Link to comment
Share on other sites

I still want to go back to the vehicle smoke grenade I added a while back and try to get it to rapid fire several small grenades instead of a single larger one.

Sadly it looks like the grenade bullet type locks out burst fire so might have to have them as direct fire instead.

Have you actually done any experiments on it?

I know the display doesn't update on your accuracy but I don't know if that is just a display issue or if they don't have an effect.

Incidentally the aliens I have used the smoke on when testing if mine worked did seem to reaction fire less often.

That could have been co-incidence or it may be that their sight range was reduced.

Link to comment
Share on other sites

I still want to go back to the vehicle smoke grenade I added a while back and try to get it to rapid fire several small grenades instead of a single larger one.

Sadly it looks like the grenade bullet type locks out burst fire so might have to have them as direct fire instead.

Have you actually done any experiments on it?

I know the display doesn't update on your accuracy but I don't know if that is just a display issue or if they don't have an effect.

Incidentally the aliens I have used the smoke on when testing if mine worked did seem to reaction fire less often.

That could have been co-incidence or it may be that their sight range was reduced.

My experiment was simply to look at the observed accuracy at different distances with and without smoke, but you might be right in that it is a display error. Maybe this weekend I will have time to run an experiment that actually tests whether or not that is the case.

From what I know about the weapons, you will probably have to use the rocket launcher as a base type. However you will be able to swap out the projectile spectre so that it looks okay. As a side note, when the flamethrower is implemented I really want to add a version of the Hunter that is like the Crocodile from WWII. Something about filling buildings and ships with delicious fire sounds satisfying to me.

Link to comment
Share on other sites

I think a flamethrowing tank may already be on the cards.

Too tempting for the team to pass by I reckon :P

I could use the rocket launcher but they also don't have burst fire, they have a couple of other issues as well.

Might have to be a standard bullet with the projectile and impact spectres swapped for grenades.

The downside to both of these is that although they look like grenades they fly directly towards the target, rather than with an arc.

Off topic for the thread though, got a bit distracted!

Have to try and see if the aliens can see our troops from as long a range once they are in the smoke as well.

No way to tell until they shoot you though.

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.

×
×
  • Create New...