• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code [Help] Constant Fire Sound/Animation Limitation

FluX

Grizzled Veteran
Oct 26, 2010
5,378
234
www.fluxiserver.co.uk
Hey all. Im trying to play around with the MP7 and change it a bit to see what I can do. I have implemented a automatic/semi-automatic onto the alt-fire BUT I have ran into a problem. When I have it on semi-auto, the sound and animation keep playing when I hold the button down.

Can someone help me try limit the this to only loop when in firstfire mode? This probably is an extra on a if statement but I don't want to go playing about too much.

Another thing, is there a way of removing the scope to it without changing the model itself?

Cheers in advance.
 
Last edited:
The best way to get the semi/auto fire working correctly is look through the code for the Ak or something similar and check to see if anything is missing.

As for the scope, the easiest way is to alpha out the scope part in the texture and apply that texture in your weapon code. You could also alpha the medic shot as well being as you are not going to be using it.
 
Upvote 0
The best way to get the semi/auto fire working correctly is look through the code for the Ak or something similar and check to see if anything is missing.
Basically I copied below into the gun.uc itself.
Code:
// Use alt fire to switch fire modes
simulated function AltFire(float F)
{
    if(ReadyToFire(0))
    {
        DoToggle();
    }
}
// Toggle semi/auto fire
simulated function DoToggle ()
{
 local PlayerController Player;
 Player = Level.GetLocalPlayerController();
 if ( Player!=None )
 {
  //PlayOwnedSound(sound'Inf_Weapons_Foley.stg44_firemodeswitch01',SLOT_None,2.0,,,,false);
  FireMode[0].bWaitForRelease = !FireMode[0].bWaitForRelease;
  if ( FireMode[0].bWaitForRelease )
   Player.ReceiveLocalizedMessage(class'KFmod.BullpupSwitchMessage',0);
  else Player.ReceiveLocalizedMessage(class'KFmod.BullpupSwitchMessage',1);
 }
 Super.DoToggle();
 ServerChangeFireMode(FireMode[0].bWaitForRelease);
}
// Set the new fire mode on the server
function ServerChangeFireMode(bool bNewWaitForRelease)
{
    FireMode[0].bWaitForRelease = bNewWaitForRelease;
}
and then I changed the replication to
Code:
replication
{
    // Things the server should send to the client.
    reliable if( Role==ROLE_Authority )
        HealAmmoCharge;
 
 reliable if(Role < ROLE_Authority)
  ServerChangeFireMode;
}

I then changed the alt-fire to KFMod.NoFire. I don't think there is anything missing. I'll re-check this just incase. As you can see I haven't done really any clearing up of the medic code.

As for the scope, the easiest way is to alpha out the scope part in the texture and apply that texture in your weapon code. You could also alpha the medic shot as well being as you are not going to be using it.

Any chance you could help me out with this? Never done this before so not sure how to implement this at all.

EDIT: I have all the code for the mode switching. Still no matter what plays the animation/sound and only shoots the one bullet.
Thinking about it, would it be much easier to just use the AK's code and change the model/sounds/animations etc or will this muck up parts of the gun?
 
Last edited:
Upvote 0
ok, to start with, stop thinking of your new weapon as the current MP7 and think of it as a completely new weapon, derived from the AK47 code.

You do not need to copy the mp7 code at all, therefore no need to try and change them, just copy the complete AK class files first and then select the MP7 skeletal mesh as the weapon mesh.

This will give you the base MP7 with ak rules. or you could just extend your class files from the AK, which will then inherit the AK rules. Again, all you have to do is point the skeletal mesh to the mp7 instead of the ak.

then you can go through the properties one by one and change them to desired speeds and sounds. using the info from the mp7 class files.

This way you do not have to worry about any properties for the medic stuff etc.

Once you have created new AK classes, to start with the only lines you need to change to get the weapon working is:

Code:
     Mesh=SkeletalMesh'KF_Weapons2_Trip.MP7_Trip'
     Skins(0)=Combiner'KF_Weapons2_Trip_T.Special.MP_7_cmb'
     Skins(1)=Shader'KF_Weapons2_Trip_T.Special.Aimpoint_sight_shdr'
I'll try and whip up an alpha texture for you today some time. :)
 
Last edited:
Upvote 0
Cheers this has worked better. I just need to try adjust the sounds to fit the original sounds. The only problem I have currently is that the sight itself is now covered in some character texture? I can see black with the horzine army suit hand.

By the way you sure about doing the alpha texture for us? You can easily just explain how to do this if you really want. I have GIMP which im gathering is where you would do it.
 
Upvote 0
Cool glad it worked better.

The texture on the site, is probably because the skins(1) is overwriting the hand skin of the AK47, so add this line in to the weapon file:

SleeveNum=2

that should fix the textures for you.

I haven't had a chance to start the texture yet so if you want to have a stab at it, export the MP7 texture and the shine texture as well which makes up the final combiner.
In PS or gimp, select which parts make up the site and the healing dart and apply an alpha mask to them.
Reimport your textures to a new package and make the combiner up using you new textures.

Then SKins(0) should point to you new package and combiner file.

For the holographic site, import a blank alpha texture and apply that as Skins(1). you should then have a gun with an invisible site and no healing dart tool connected,
If you get any problems give me a shout and I will see if I can get time to put one together for you.
 
Upvote 0
Cool glad it worked better.

The texture on the site, is probably because the skins(1) is overwriting the hand skin of the AK47, so add this line in to the weapon file:

SleeveNum=2

that should fix the textures for you.
Thanks worked great! I wondered what that was for.

I haven't had a chance to start the texture yet so if you want to have a stab at it, export the MP7 texture and the shine texture as well which makes up the final combiner.
Any chance you could explain this a little more for us? I can see three different textures for the weapon.
 
Upvote 0
lol i had all those problems with the mg34, i set sleevenum=7, just to keep it far enought out of the way in case i have lots of skins.

i still have the single fire mode playing a loopanim/loopsound though...
For what I have learnt it is the sounds itself. The MP7 was coded to have a looped sound but when I changed it to use the AK47 fire sound, it was fine...

EDIT: Fixed sound BUT I now have problem where I can't export the MP7 texture. When I open it up in GIMP it just shows some grey lines and the medic cross symbol. Rest is invisible.
 
Last edited:
Upvote 0
you mean the .dds file you exported form texture browser?
do you have image converter plus (works sometimes)?
or photoshop? (works best)
or paint.net? (works most times)

i dont have gimp so i dont know how it handles rgb+alpha channels.

so you just used the singlefire sound/anim from ak47 and worked for semi?

i used the mp7 because i need the ambietsound, loopend anims, and end sound code.

so i guess i could super.postbeginplay link to ak47assaultrifle...i think thats how you call functions from other files...
 
Last edited:
Upvote 0
you mean the .dds file you exported form texture browser?
do you have image converter plus (works sometimes)?
or photoshop? (works best)
or paint.net? (works most times)

i dont have gimp so i dont know how it handles rgb+alpha channels.
No I used GIMP. Usually when I expert the textures, it comes out fine cause this is how I did the perk changes I wanted.
so you just used the singlefire sound/anim from ak47 and worked for semi?

i used the mp7 because i need the ambietsound, loopend anims, and end sound code.

so i guess i could super.postbeginplay link to ak47assaultrifle...i think thats how you call functions from other files...
Basically I just changed the sounds to the ambientsounds inside of the original MP7 code. These were I think the end of the shooting sounds with "trial/trailST" at the end? Sounds slightly different but more unique (better to me anyway).


Cheers once again Braindead! Now I got some things to try sort out with it to improve it.
 
Upvote 0
i thought i knew, but i dont, sorry.

i was messing with the zoomed mesh location using:

in console type:
editactor class=(package).(weaponname)

and just playing with the view offsets under "none", which changes the mesh location when zoomed in, but when you zoomout, it reverts it to the old numbers.

so what i did was:

1. zoomed in
2. typed editactor class=mgpack.mg42
3. under none, the playerviewoffset=000
4. changed it to something whatever, then the mesh moved on screen to that.
5. when i zoom out, playerviewoffset changes to nonzoom numbers (have to reload editactor window)
6. when i zoom in playerviewoffset changes to 000, so basically have to find the section of code in whichever file that says "zoomin=change playerviewoffset=000, zoomout=change playerviewoffset=4,5,6"
 
Upvote 0