Author Topic: how to remove shotgun barrel flash?  (Read 1807 times)

0 Members and 1 Guest are viewing this topic.

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
how to remove shotgun barrel flash?
« on: October 30, 2014, 11:56:55 AM »
After searching and experimenting for a couple hours, I think I've discovered that the shotgun barrel flash is part of the animation model.

So... how can I remove the flash from the model (and the double barrel as well)? I want to use particles only for that effect....not whatever is coded into the models. I tried removing the -keep barrel eject shell flash from the .md5anim fire files commandline, and tried changing the "flash"  39 0 0 // body line....but neither worked. (I know my way around def and script files, but I'm not a modeling guy....so these were just shots in the dark).

*****

On a related subject, why are there three fire files (fire1.md5anim, fire2.md5anim, and fire3.md5anim)? They seem almost identical, and have the same number of frames and frame rate.

EDIT: Okay, I think I figured out my last question... to provide some randomness to the fire animation (one of the three is randomly selected in the code I assume?) I just set all three to "fire1.md5anim" in the model viewmodel_shotgun {} defnition for testing.

« Last Edit: October 30, 2014, 12:04:15 PM by calan »
Old bastard but kid at heart...

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #1 on: October 30, 2014, 12:15:00 PM »
I'm getting closer.   :)

I found the mesh file, and searched for "flash" in it. It looks like the last three meshes are for the flash, so I changed this:

shader "models/weapons/shotgun/shotgun_mflashb"

to this:

shader ""

...for all three.

My thought was that with no shader, the mesh simply wouldn't be rendered....which is partially true. Now I have a purple tag in place of the flash that says "No draw".

How do I get rid of that? Is there an empty (invisible) tga file that I could define as the shader for the flash?
« Last Edit: October 30, 2014, 12:35:49 PM by calan »
Old bastard but kid at heart...

Ivan_the_B

  • Newbie
  • *
  • Posts: 18
  • Karma: +3/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #2 on: October 30, 2014, 03:14:41 PM »
Hi calan.
You are on the right track, but you shouldn't change the model itself.

You simply need to create a new skin to replace the material with nodraw.

Code: [Select]
skin calan/shotgun_nomflash {
models/weapons/shotgun/shotgun_mflashb textures/common/nodraw
}

and set the skin in the weapon def
Code: [Select]
"skin" "calan/shotgun_nomflash"

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #3 on: October 30, 2014, 06:39:39 PM »
Ivan...

Where should I put the skin def? In my custom material file?

I figured out a hack for it, by creating a new shader that didn't do anything and then referencing that in the mesh file.... but it wasn't pretty. Your method looks much cleaner.

EDIT:

That doesn't seem to work. I get an error about a missing token on the nodraw.

Here is how I did it:

I made this shader that never does anything, although I don't know how to make it cleaner without the goofy if statement.

Code: [Select]
models/weapons/nomuzzleflash
{
{
if 2 < 1
blend add
map models/weapons/nomuzzleflash
}
}


And then in the "viewshotgun.md5mesh" file, I just changed the three flash meshes to use that new shader:

Code: [Select]
mesh {
// meshes: sgfx3mesh
// shader "models/weapons/shotgun/shotgun_mflashb"
shader "models/weapons/nomuzzleflash"

numverts 4
vert 0 ( 1 0 ) 2 1
        ...
        ...
        ...
}

etc
etc

It works fine, but is a bit ugly. :)
« Last Edit: October 30, 2014, 07:07:45 PM by calan »
Old bastard but kid at heart...

Ivan_the_B

  • Newbie
  • *
  • Posts: 18
  • Karma: +3/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #4 on: October 31, 2014, 04:44:16 AM »
The skin approach does work.
That's how missiles are hidden on rocket launcher model.

Put the skin definition in a new .skin file inside a "skins" folder.

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #5 on: October 31, 2014, 10:45:02 AM »
Thanks Ivan...I'll give it another shot.

In the mean time, how can I get this to work, without having to include that if statement?

Code: [Select]
models/weapons/nomuzzleflash
{
{
if 2 < 1
blend add
map models/weapons/nomuzzleflash
}
}
Old bastard but kid at heart...

Ivan_the_B

  • Newbie
  • *
  • Posts: 18
  • Karma: +3/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #6 on: October 31, 2014, 11:29:36 AM »
You cannot create a material that does nothing.
The "if" trick you used was also used by ID in a couple of materials. You cannot get rid of it.
In your case anyway you don't need it this material at all. Just use nodraw.

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #7 on: October 31, 2014, 12:19:53 PM »
I still can't get it to work for some reason.

I created a folder called "skins" in the sikkmod folder (at the same level as def, script, particles, etc).. and in it is one file called "CAS.skin". That file contains the following:

Code: [Select]
skin calan/shotgun_nomuzzleflash {
models/weapons/shotgun/shotgun_mflashb textures/common/nodraw
}

In "weapon_shotgun.def", I added this line:

Code: [Select]
"skin" "calan/shotgun_nomuzzleflash"

I removed my hack from the first mesh in "viewshotgun.md5mesh" to test the new skin, so it now reads as this:

Code: [Select]

...
...

mesh {
// meshes: sgfx3mesh
shader "models/weapons/shotgun/shotgun_mflashb"
// shader "models/weapons/nomuzzleflash"

numverts 4
vert 0 ( 1 0 ) 2 1
        ...
        ...
        ...
}

(The other two meshes still use my hack, so they are out of the picture for testing).

When I start the game and load a test map, the shotgun still has the cartoon muzzle flash. If I comment the first line and uncomment my hack line in the first mesh, the canned flash is gone. I don't see any warnings about my skin....so, What am I missing?

*****

Couple of questions:

1. Why did you include the "calan/" in front of the new skin name? Is it needed as a sub-folder?

2. The "viewshotgun.md5mesh" actually has three meshes for the flash, which in turn use three shaders; "models/weapons/shotgun/shotgun_mflashb", "models/weapons/shotgun/shotgun_mflash2", and "models/weapons/shotgun/shotgun_mflash". Do I need to create a new skin for each of those and assign them in the def file, or can all three go under one skin, like this:

Code: [Select]
skin calan/shotgun_nomuzzleflash {
models/weapons/shotgun/shotgun_mflashb textures/common/nodraw
models/weapons/shotgun/shotgun_mflash2 textures/common/nodraw
models/weapons/shotgun/shotgun_mflash textures/common/nodraw
}

Appreciate all your help!
Old bastard but kid at heart...

Ivan_the_B

  • Newbie
  • *
  • Posts: 18
  • Karma: +3/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #8 on: October 31, 2014, 12:44:51 PM »
I used the "calan/" prefix as a placeholder.
That piece of the name is not required, but I expect you to group all your custom skins with a meaningful prefix. Say "yourproject/weapons/...".
It's just a naming convention I got used to by looking at the original D3 files.

You can indeed put multiple lines in the same skin. In fact, it's rather common.
You need to include all the flash materials to hide them.
I cannot test your skin code because I'm at work, but it looks correct to me :D

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #9 on: October 31, 2014, 01:31:09 PM »
Ok... I put the viewshotgun.md5mesh file back to default, and put this in my .skin file:

Code: [Select]
skin cas/shotgun_nomuzzleflash {
models/weapons/shotgun/shotgun_mflashb textures/common/nodraw
models/weapons/shotgun/shotgun_mflash2 textures/common/nodraw
models/weapons/shotgun/shotgun_mflash textures/common/nodraw
}

(using my initials instead of forum name)

This is in the weapon_shotgun.def file:

Code: [Select]
// cas - remove muzzle flash
"skin"     "cas/shotgun_nomuzzleflash"

Still not working. Uhggg....

EDIT:

Where is the nodraw shader defined? I wonder if that file is getting over-written somewhere?
« Last Edit: October 31, 2014, 01:36:51 PM by calan »
Old bastard but kid at heart...

Ivan_the_B

  • Newbie
  • *
  • Posts: 18
  • Karma: +3/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #10 on: October 31, 2014, 03:16:57 PM »
nodraw is a standard D3 material.

The problem here (sorry I forgot this until now) is that all weapon scripts inherit from weapon_base.script, which has this nice function:

Code: [Select]
/*
=====================
weapon_base::UpdateSkin

Required by game code for when the skin needs to change (for example, when the player has a power up).  Implemented in subclasses.
Code is called is only guaranteed to execute for one frame, so any code should either set the weapon state or start a new thread.
=====================
*/
void weapon_base::UpdateSkin() {
if ( isInvisible() ) {
setSkin( getKey( "skin_invisible" ) );
} else {
setSkin( "" );
}
}
... that resets the skin to "" unless you have the invisibility powerup.
It's invoked when the weapon is selected and when the invisibility powerup is picked up.

You have to override the funtion in weapon_shotgun.script like this:

Code: [Select]
void weapon_shotgun::UpdateSkin() {
if ( isInvisible() ) {
setSkin( getKey( "skin_invisible" ) );
} else {
setSkin( getKey("skin") );
}
}

Now your skin will work :)

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: how to remove shotgun barrel flash?
« Reply #11 on: October 31, 2014, 06:41:49 PM »
Looks like that did the trick!

Thanks much Ivan. Feel free to jump on all my other posts that you haven't already.   :D
Old bastard but kid at heart...