[Tutorial] New Guide on creating weapons

Discuss and distribute tools and methods for modding. Moderator - Grognak
User avatar
Arfy
Posts: 206
Joined: Mon Apr 11, 2016 4:14 am

Re: [Tutorial] New Guide on creating weapons

Postby Arfy » Thu May 24, 2018 8:42 pm

TeamEXAngus wrote:I can't seem to get it working! Anyone know what could be going wrong?

File
(Mod Name)/data/blueprints.xml


You need to name blueprints.xml as blueprints.xml.append.
Discord: ATLAS#9226
TeamEXAngus
Posts: 48
Joined: Thu May 17, 2018 5:38 am

Re: [Tutorial] New Guide on creating weapons

Postby TeamEXAngus » Fri May 25, 2018 4:13 am

Arfy wrote:
TeamEXAngus wrote:I can't seem to get it working! Anyone know what could be going wrong?

File
(Mod Name)/data/blueprints.xml


You need to name blueprints.xml as blueprints.xml.append.


I tried that too. I worked out the problem though. When I turned the file into a .zip file, it renamed data to (mod name)
TeamEXAngus
Posts: 48
Joined: Thu May 17, 2018 5:38 am

Re: [Tutorial] New Guide on creating weapons

Postby TeamEXAngus » Fri May 25, 2018 9:53 am

anyone know what's wrong with this? It won't work.

Code: Select all

<weaponBlueprint name="MASS_DRIVER">
   <type>MISSILE</type>
   <title>Mass Driver Cannon</title>
   <short>Mass Driver</short>
   <tip>tip_beams</tip>
   <desc>This weapon fires an explosive ball surrounded with Plasma.</desc>
   <tooltip id="weapon_BEAM_3_tooltip" />
   <damage>4</damage>
   <sp>5</sp>
   <speed>10</speed>
   <missiles>1</missiles>
   <fireChance>0</fireChance>
   <breachChance>10</breachChance>
   <cooldown>25</cooldown>
   <power>4</power>
   <cost>150</cost>
   <bp>12</bp>
   <rarity>5</rarity>
   <explosion>explosion_random</explosion>
   <image>missile_hull</image>
   <launchSounds>
      <sound>smallExplosion</sound>
   </launchSounds>
   <weaponArt>beam_3</weaponArt>
   <iconImage>missile</iconImage>
</weaponBlueprint>
User avatar
mr_easy_money
Posts: 625
Joined: Fri May 29, 2015 9:05 pm

Re: [Tutorial] New Guide on creating weapons

Postby mr_easy_money » Fri May 25, 2018 11:26 pm

TeamEXAngus wrote:anyone know what's wrong with this? It won't work.

here is your problem:
TeamEXAngus wrote:

Code: Select all

...
   <type>MISSILE</type>
...

"MISSILE" is not a possible value for the 'type' stat -- it needs to be "MISSILES", one of the 5 weapon types the game will recognize (the other ones being: BEAM, LASER, BOMB, and BURST).
TeamEXAngus
Posts: 48
Joined: Thu May 17, 2018 5:38 am

Re: [Tutorial] New Guide on creating weapons

Postby TeamEXAngus » Sat May 26, 2018 12:20 am

mr_easy_money wrote:
TeamEXAngus wrote:anyone know what's wrong with this? It won't work.

here is your problem:
TeamEXAngus wrote:

Code: Select all

...
   <type>MISSILE</type>
...

"MISSILE" is not a possible value for the 'type' stat -- it needs to be "MISSILES", one of the 5 weapon types the game will recognize (the other ones being: BEAM, LASER, BOMB, and BURST).


Now the game crashes when I fire it. Any ideas why?
User avatar
mr_easy_money
Posts: 625
Joined: Fri May 29, 2015 9:05 pm

Re: [Tutorial] New Guide on creating weapons

Postby mr_easy_money » Sat May 26, 2018 4:49 am

TeamEXAngus wrote:Now the game crashes when I fire it. Any ideas why?

oh in my haste, I didn't see something essential -- the weapon is missing a <shots> stat. I've had this 'weapon crashes when trying to fire' problem before and this was exactly the problem. no <shots> specified and the game doesn't know what you mean by firing the weapon -- what is there to fire?

in case of confusion, the <missiles> tag specifies how many missiles (the resource) the weapon uses per shot, not how many missiles are fired.

also, you should add <hitShipSounds>, <hitShieldSounds> and <missSounds>, for what happens in those cases. otherwise, the weapon will only make noise when it fires -- nothing when it hits its target or misses.
TeamEXAngus
Posts: 48
Joined: Thu May 17, 2018 5:38 am

Re: [Tutorial] New Guide on creating weapons

Postby TeamEXAngus » Sat May 26, 2018 8:55 am

mr_easy_money wrote:
TeamEXAngus wrote:Now the game crashes when I fire it. Any ideas why?

oh in my haste, I didn't see something essential -- the weapon is missing a <shots> stat. I've had this 'weapon crashes when trying to fire' problem before and this was exactly the problem. no <shots> specified and the game doesn't know what you mean by firing the weapon -- what is there to fire?

in case of confusion, the <missiles> tag specifies how many missiles (the resource) the weapon uses per shot, not how many missiles are fired.

also, you should add <hitShipSounds>, <hitShieldSounds> and <missSounds>, for what happens in those cases. otherwise, the weapon will only make noise when it fires -- nothing when it hits its target or misses.

thanks
User avatar
Kacpo
Posts: 9
Joined: Tue May 22, 2018 10:13 pm

Re: [Tutorial] New Guide on creating weapons

Postby Kacpo » Sun May 27, 2018 1:10 pm

Hey, thanks for help.

There are 2 more things I want to know tho:

1st: How to change the colour of the BEAM or change the LASER projectile. I found the originals in unpacked files, and I can make my own models, but I don't know how to put them into the mod then.
Should I create another file in my_weapon/img?

2nd thing:

While I know how to pack a file into an .ftl file, I noticed that guide states:
Dont simply pack your my_weapon folder directly or else you have the worng structure within the package. GMM needs to have the files in the right directory and a my_weapon directory he will ignore rendering your entire work useless.


so, how should I do this? Pack these two into seperate .ftl files and thne put them together into My_weapon folder, AND THEN add it as a mod?
User avatar
mr_easy_money
Posts: 625
Joined: Fri May 29, 2015 9:05 pm

Re: [Tutorial] New Guide on creating weapons

Postby mr_easy_money » Sun May 27, 2018 3:29 pm

Kacpo wrote:Hey, thanks for help.

no problem :mrgreen:
Kacpo wrote:1st: How to change the colour of the BEAM

by adding a <color> stat. let's look how it's done in the vanilla Anti-Bio Beam, which is orange:

Code: Select all

<weaponBlueprint name="BEAM_BIO">
   <type>BEAM</type>
   ...
   <color> <!-- Color only works for beams -->
      <r>255</r>
      <g>110</g>
      <b>0</b>
   </color>
   ...
</weaponBlueprint>

where <r>, <g>, <b> are your RGB (Red Green Blue) values. you can find a "color picker" online or use some image editing software to determine the perfect color.
Kacpo wrote:how to change the LASER projectile. I found the originals in unpacked files, and I can make my own models, but I don't know how to put them into the mod then.

so basically you are asking, how do I load a new image for the projectile?
Kacpo wrote:Should I create another file in my_weapon/img?

yes, you'll need to make a new file. it would have been nice if we could just add a <color> stat like with BEAM but this is not the case. note also that you should create a folder in my_weapon/img called "weapons" and place the file there. I'll cover this later on.

let's look at the Basic Laser's projectile. first we'll need to look at its weaponBlueprint:

Code: Select all

<weaponBlueprint name="LASER_BURST_1">  <!-- 1 shot 1power-->
   <type>LASER</type>
   ...
   <image>laser_light1</image>
   ...
</weaponBlueprint>

the <image> stat tells us the name of the "anim" that will be found in the animations files. the "anim" will reference an "animSheet", which describes the image's dimensions and such. so let's have a look at the "anim" named "laser_light1":

Code: Select all

<animSheet name="laser_light1" w="200" h="20" fw="50" fh="20">weapons/laser_light_strip4.png</animSheet>

<anim name="laser_light1">
   <sheet>laser_light1</sheet>
   <desc length="4" x="0" y="0"/>
   <time>0.5</time>
</anim>

let's first look at the animSheet, because this describes the image. NOTE: the animSheet of an anim must always come before the anim itself, otherwise the anim will be unable to find it, and the game will break. the animSheet has 5 stats:
  • w: the width of the entire image (in pixels)
  • h: the height of the entire image (in pixels)
  • fw: the width of one frame of the image (in pixels)... therefore, each frame must have the same dimensions
  • fh: the height of one frame of the image (in pixels)... therefore, each frame must have the same dimensions
  • [the value of the animSheet]: the location of the image, with its path starting from the "img" folder. that's why first it says weapons/, then it says the image name (with extension), because from the "img" folder, we go into the "weapons" folder to find the image.
next we'll look at the anim, which references the animSheet. the anim has 3 stats:
  • sheet: the name of the animSheet which describes the image itself. convention is for the animSheet to have the same name as the anim.
  • desc: how many frames the image has. in this case, the length is 4, because the image has 4 frames. multiplying this number by the frame width should yield the image width. 4*50 = 200, which is the image width.
  • time: the duration of the animation, in seconds.
now that we know what all of this means, we can create our own projectile images and load them in correctly. but let's just go over that anyway.

let's suppose you wanted to make a version of the Basic Laser that has a red projectile. you recolor the projectile image to red. so then in our mod, we'll create a folder called "img" next to "data". inside the "img" folder we'll make a folder called "weapons", and place the recolored image there. let's just call it "laser_light_strip4_red.png".

next, we'll add the following to a new file we make in the "data" folder called "animations.xml.append":

Code: Select all

<animSheet name="laser_light1_red" w="200" h="20" fw="50" fh="20">weapons/laser_light_strip4_red.png</animSheet>

<anim name="laser_light1_red">
   <sheet>laser_light1_red</sheet>
   <desc length="4" x="0" y="0"/>
   <time>0.5</time>
</anim>

then, in our weaponBlueprint, we'll make sure to reference the new anim:

Code: Select all

<weaponBlueprint name="LASER_BURST_1_EVIL">
   <type>LASER</type>
   ...
   <image>laser_light1_red</image>
   ...
</weaponBlueprint>

there, we've made an Evil Basic Laser :twisted: ... well okay not really... :lol: :oops:

if you wanted to create and load a new image for the weapon itself (not the projectile), it is quite similar (looking at <weaponArt> now, not <image>) except it does not reference an anim, but instead a weaponAnim. everything else is pretty similar if not the same.
Kacpo wrote:2nd thing:

While I know how to pack a file into an .ftl file, I noticed that guide states:
Dont simply pack your my_weapon folder directly or else you have the worng structure within the package. GMM needs to have the files in the right directory and a my_weapon directory he will ignore rendering your entire work useless.

so, how should I do this? Pack these two into seperate .ftl files and thne put them together into My_weapon folder, AND THEN add it as a mod?

all this is saying is that you need to pack the folders within "my_weapon" into a .zip archive:

Code: Select all

my_weapon -> data
          -> img
          -> mod-appendix

so here you'd select the "data", "img", and "mod-appendix" folders and add them to a .zip archive. it's saying that you should NOT be selecting the "my_weapon" folder and adding it to a .zip, because then there will be an intermediate folder and Slipstream will just ignore the "my_weapon" folder entirely , so then when you patch the mod nothing will change.

---
I endeavour to completely and thoroughly answer any questions posted. if you have any further questions, if I missed something or if something I said is unclear, please let me know. :)
User avatar
Kacpo
Posts: 9
Joined: Tue May 22, 2018 10:13 pm

Re: [Tutorial] New Guide on creating weapons

Postby Kacpo » Sun May 27, 2018 11:00 pm

Ok, that third file: "mod-appendix" is something I see first time.
What is it? What does it contain? What it's for?

As for the animation process: There's a thing:

Just to get this out of the way, so we're clear and there's no misunderstandings

I want to change the image of a weapon itself (the gun) and the projectile (the shell, laser, missile, etc.)
I also want to make the weapon animation (charging, firing), BUT the projectile is a single picture (a single frame)

How should I go about this, because I found myself confused with which part of a animations.xml is supposed to refer to gun and which to projectile.

The file (this is animations.xml) I have right now looks like:

Code: Select all

<animSheet name="rod" w="50" h="10" fw="50" fh="10">weapons/rod.png</animSheet>

<weaponAnim name="railgun">
   <sheet>railgun</sheet>
   <desc length="11" x="0" y="0"/>
   <chargedFrame>7</chargedFrame>
   <fireFrame>11</fireFrame>
   <firePoint  x="15" y="22"/>
   <mountPoint x="2" y="65"/>
</weaponAnim>


the Railgun is the name of Weapon animation strip
Image
and Rod is the name of the projectile pic.
Image

Is that correct (and I'm almost certian it is not), or should I create another paragraph within file, or new file altogether?

(The clearest explanation I think would be an example code with
codecodecode <---this is about projectile

code <---this is about weapon
codecode
code

codecode
code
)
sort of thing.


And one last thing:
How should I save the files as?

Because the guide mentiones Filename.xml.append, while unpacked game files I found them simply saved as Filename.xml or some even simply as .txt
Is there a significant difference between .xml and .xml.append ?


P.S: Yes, I remember to have my_weapon/img/weapons subfolder.