Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
TubularB1Us

Custom Weapon Coding Assistance

Question

Hi all, I've recently coded a Colt .45 into the game with the help of Gunlabs, but am unsure about certain values. The code they provided allowed for me to make an automatic shotgun, but of course I want to make a semiautomatic pistol akin to the default starting pistol. On a similar note, I would really appreciate if someone could explain how I can:

 

  1. Increase the fire rate
  2. Make the sprites animate faster
  3. And have the firing sound play similar to this mockup video?

 

I have both my test wad and the video available here since I can't upload both directly, thanks in advance!

Share this post


Link to post

2 answers to this question

Recommended Posts

  • 0

1 & 2: You can increase the fire rate of a weapon by reducing the frame lengths. Here's my semi-auto pistol with two different fire modes (fast one hand fire here, I also have a slower two hand fire state the player can switch to):

Fire:
  TNT1 A 0 A_JumpIfInventory("BM9SteadyUp", 1, "SteadyFire")
  BRTT A 0 A_JumpIfNoAmmo("DryFire")
  BRTT B 1 A_PlaySound("BERRSHOT",1,1)
  BRTT C 1 A_Quake(1,2,0,2)
  BRTT E 0 Bright A_GunFlash
  BRTT E 0 A_SetPitch(pitch+(random(1,2)))
  BRTT E 0 A_SetPitch(pitch-(random(1,3)))
  BRTT E 1 A_FireCustomMissile("BerettaSmokeSpawn",0,0,6,8)
  BRTT F 1 A_FireBullets(3,4,-1,random(6,8),"BulletPuff",1)
  BRTT G 0 A_SpawnDebris("9mmdebris")
  BRTT GHIJKLGO 1 A_WeaponReady
  Goto Ready

Notice my A_WeaponReady at the end of the Fire state. Frames G through O of my pistol animation all have A_WeaponReady, which means the player can click during any of these frames and fire the pistol again. If I wanted the duration to be longer in between firing, I would remove the amount of frames that have A_WeaponReady and increase the durations of the rest of the frames.

 

In your example, you could simply change the Fire state:

Fire:
PIST BCDEF 3 A_FireBullets(4, 4, 4, 4, "BulletPuff", 1)
PIST F 0 A_WeaponReady
Goto Ready

 

3: You can define weapon sounds using SNDINFO: https://zdoom.org/wiki/SNDINFO

 

Edited by R4L

Share this post


Link to post
  • 0
2 hours ago, R4L said:

1 & 2: You can increase the fire rate of a weapon by reducing the frame lengths. Here's my semi-auto pistol with two different fire modes (fast one hand fire here, I also have a slower two hand fire state the player can switch to):


Fire:
  TNT1 A 0 A_JumpIfInventory("BM9SteadyUp", 1, "SteadyFire")
  BRTT A 0 A_JumpIfNoAmmo("DryFire")
  BRTT B 1 A_PlaySound("BERRSHOT",1,1)
  BRTT C 1 A_Quake(1,2,0,2)
  BRTT E 0 Bright A_GunFlash
  BRTT E 0 A_SetPitch(pitch+(random(1,2)))
  BRTT E 0 A_SetPitch(pitch-(random(1,3)))
  BRTT E 1 A_FireCustomMissile("BerettaSmokeSpawn",0,0,6,8)
  BRTT F 1 A_FireBullets(3,4,-1,random(6,8),"BulletPuff",1)
  BRTT G 0 A_SpawnDebris("9mmdebris")
  BRTT GHIJKLGO 1 A_WeaponReady
  Goto Ready

Notice my A_WeaponReady at the end of the Fire state. Frames G through O of my pistol animation all have A_WeaponReady, which means the player can click during any of these frames and fire the pistol again. If I wanted the duration to be longer in between firing, I would remove the amount of frames that have A_WeaponReady and increase the durations of the rest of the frames.

 

In your example, you could simply change the Fire state:


Fire:
PIST BCDEF 3 A_FireBullets(4, 4, 4, 4, "BulletPuff", 1)
PIST F 0 A_WeaponReady
Goto Ready

 

3: You can define weapon sounds using SNDINFO: https://zdoom.org/wiki/SNDINFO

 

Nice, thank you so much!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×