• 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 [Request] xplosive rounds

So, I've been thinking of just using the code from the AA12 to make a new weapon for the Demo. Nothing fancy at all, just modified code, maybe a new name.

Anyhow, the title says it all, I think. I'm basically wondering how to code explosive rounds (say, FRAG-12) into an AA12. I was playing around with the WTFMod and they managed to code the AA12 (I think it's called ASF12 or something) to fire explosive rounds when wielded by a Demo.

I can make the mutator, but I'm utterly at a loss how to make the rounds explosive (i.e. they damage specimens as well as you if fired too close).

I've tried changing damage classes to the grenades, but no dice. When the specimen gets shot, he'll gib as if he's been hit by a grenade, but the others around him won't. I also don't take damage if I fire into the floor at my feet.

Anyway, for the TL;DR verion, I'm wondering what parameters to change to make shotgun "bullets" explosive.

Thanks for the help.
 
Since you already brought up WTFMut: The AFS12 spawns custom Shotgun bullets that explode and deal damage in a radius

Code:
class WTFEquipAFS12ExplosiveRound extends ShotgunBullet;

var() array<Sound> ExplodeSounds;

simulated function Explode(vector HitLocation,vector HitNormal)
{
    if ( Role == ROLE_Authority )
    {
        HurtRadius(Damage*0.75, DamageRadius, MyDamageType, 0.0, HitLocation );
        HurtRadius(Damage*0.25, DamageRadius*2.0, MyDamageType, MomentumTransfer, HitLocation );
        
        //does full damage within DamageRadius (dealt in two chunks), but less damage to things outside of DamageRadius but within
        //DamageRadius*2.0
    }

    //why would it matter if instigator exists or not for spawning an fx???
    //if ( KFHumanPawn(Instigator) != none )
    //{
    
        PlaySound(ExplodeSounds[rand(ExplodeSounds.length)],,1.0);
        
        if ( EffectIsRelevant(Location,false) )
        {
            Spawn(class'WTF.WTFEquipAFS12ExplosiveRoundEmitter',self,,Location);
        }
        
    //}

    Destroy();
}

simulated function ProcessTouch (Actor Other, vector HitLocation)
{
    if ( Other != Instigator && !Other.IsA('PhysicsVolume') && (Other.IsA('Pawn') || Other.IsA('ExtendedZCollision')) )
    {
        Other.Velocity.X = Self.Velocity.X * 0.05;
        Other.Velocity.Y = Self.Velocity.Y * 0.05;
        Other.Velocity.Z = Self.Velocity.Z * 0.05;
        Other.Acceleration = vect(0,0,0); //0,0,0
        
        Explode(Other.Location,Other.Location);
    }
}

defaultproperties
{
     ExplodeSounds(0)=SoundGroup'KF_GrenadeSnd.Nade_Explode_1'
     ExplodeSounds(1)=SoundGroup'KF_GrenadeSnd.Nade_Explode_2'
     ExplodeSounds(2)=SoundGroup'KF_GrenadeSnd.Nade_Explode_3'
     Damage=250.000000
     DamageRadius=75.000000
     MomentumTransfer=1000.000000
     MyDamageType=Class'KFMod.DamTypeM79Grenade'
     StaticMesh=StaticMesh'kf_generic_sm.Bullet_Shells.40mm_Warhead'
     DrawScale=0.500000
}
 
Upvote 0
Sorry for the lateness. I got it to work. However, since I just want a code change, and not the fancy textures and models of WTF, I deleted the relevant code pointing to the custom sprites or whatever they are. Are there any spirtes or something in stock KF that I can call up to make it a little more... flashy? In the WTFMod the Demo AA12 had these pretty white flashes that poofed up on impact. As of right now, they just... impact.

I mean, yeah, the zombies blow up and everything. But I need flash, haha. If it's impossible, no skin off my back. I'm just curious, is all.

EDIT: I'm thinking, the sparks that fly when you shoot metal, like the trader door. Any way to call those up?
 
Last edited:
Upvote 0
So I have AA12f bullet (which is slightly modified from the WTF version:
Spoiler!

The "class'AA12F.AA12FExplosiveRoundEmitter" in the bullet code points to this. The highlighted line near the bottom was deleted so I wouldn't have to call up external sprite files.

Spoiler!
 
Upvote 0
Spoiler!

It seems to be using the default sprites/texture from KF so what you should do is simply rename the yellow line to correspond your own code I guess. Altho I simply used Emitters(2)=SpriteEmitter'Blast' in my own weapon code, not the exact form ofc but I didnt point it to any specific package. Basically its the emitter name from the top line where it says "Name=Blast".

You could try that.

Also if you have only 1 emitter it might have to be called Emitters(0) not Emitters(2). Not 100% sure but at least the last time I had that wrong it gave me an error while compiling. Not sure how it is with only 1 emitter.
 
Last edited:
Upvote 0
What I was wondering was what sprite/emitter would I summon? The
Code:
Emitters(2)=SpriteEmitter'WTF.WTFEquipAFS12ExplosiveRoundEmitter.Blast'
points to a something in the WTF sprites/models/whatever, and I don't want to inflict downloads from my measly 2mbps server. I just want the effect to look like the sparks you get when you shoot something metal, or a different emitter is someone has any suggestions. Something that has a little more oomph, you know, since I'm firing explosive rounds.


And goddammit this weapon is so frigtastically overpowered. I love it. Now there's something to kill the eight people's worth of zeds and Doom beasties.
 
Last edited:
Upvote 0
Okaydokes. I deleted all WTFMod related files, put
Code:
Emitters(0)=SpriteEmitter'Blast'
In the relevant spot, and it seems to be throwing up some nice effects upon impact. I didn't need to download anything and I didn't get any errors, so I assume it's a purely code effect. When I uploaded to server it seemed fine there, too.

No way for me to be 100% sure until I get some of my clan people to try it out, but I'm pretty sure we're golden on this. Thanks for all the help, guys.
 
Upvote 0
Okaydokes. I deleted all WTFMod related files, put
Code:
Emitters(0)=SpriteEmitter'Blast'
In the relevant spot, and it seems to be throwing up some nice effects upon impact. I didn't need to download anything and I didn't get any errors, so I assume it's a purely code effect. When I uploaded to server it seemed fine there, too.

No way for me to be 100% sure until I get some of my clan people to try it out, but I'm pretty sure we're golden on this. Thanks for all the help, guys.

What I did to create a custom effect on impact was simply make a custom emitter in the SDK and then copy/pasted it on a notepad, then copied the code from there into my weapon and it was called something like "SpriteEmitter1" and at the bottom saying "Emitters(0)=SpriteEmitter'SpriteEmitter1'" and everything worked fine so it should work the way you put it.

From what I can tell, it CREATES the emitter there, it doesnt load it up from anywhere. The only part it loads is the possible sprite/texture you used and in this case its the "kf_fx_trip_t.Misc.smoke_animated" which is already in the game.
 
Upvote 0
Take a look at the code from the WTFmod. This is the code for the ASF12 (the specific file is WTFEquipAFS12Fire.UC), which changes to explosive rounds when wielded by a Demo.
Spoiler!

I'm not sure as to how the actual programming language works, but the highlighter portion is what switches the gun to explosive rounds based on perk.
 
Upvote 0
Does anyone perchance know how I would go about using this explosive rounds code in a manner that the Demo exclusively gets explosive rounds on a weapon without it being a different weapon entirely?


Im guessing youd have to edit the weapon code for each weapon separately which is basically like making your own weapon. Unless someone more experienced has a workaround.
 
Upvote 0
Im guessing youd have to edit the weapon code for each weapon separately which is basically like making your own weapon. Unless someone more experienced has a workaround.

For what i've learnt so far, this is the way to do it. Only problem you'd probably have is whether you'd want to make these weapons replacement of the current weapon or as a seperate weapon.
 
Upvote 0