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

Double Weapon Trouble

Question

Hi everybody! I'm in a dilly of a pickle now, and gosh darned it if I ain't stuck like a bullfrog up a hickory stump! I'm working on a mod for GZDoom (currently version 4.10) and I want the player to be able to dual wield chain guns. Several strange things have been happening with the weapon when it runs out of ammo. Initially, instead of switching to another weapon when it ran out of ammo, it would continue firing (without shooting bullet puffs). This was strange looking to say the least so I tried to fix it. putting the -WEAPON.AMMO_OPTIONAL flag on it didn't help, so I tried to make a less ugly thing for the weapon to do that would let the player know instantly that they were out of ammo. What is happening is easy to notice but it's pretty ugly.

Giving it a A_Jumpifnoammo("Deselect") state before firing results in the weapon disappearing and becoming unusable. A_jumpifnoammo("nobullets") results in a weird flickering behavior that isn't much better than firing blanks. Working with Jekyllgrim's EDW weapon and ctlcdn's Mismatched pistols as templates I've rebuilt the weapon several times and always come down to this same behavior.

Ditto when I use

 

if (CountInv("Bullets") <= 0)
        return ResolveState("Nobullets"); //if no ammo, jump to Reload sequence
    return ResolveState(null); //otherwise, don't jump, move on to the next frame

 

Does anyone know anything that can be done about it?

 

This is the most recent attempt:

Class DChainGuns : Weapon 
{

  Default
  {
		Inventory.PickupMessage "You Got The Chainguns! (2)";
		Weapon.SelectionOrder 750;
		Weapon.Slotnumber	4;
		Weapon.AmmoType1 	"Bullets";
		Weapon.AmmoGive1 	25; //50
		Weapon.Ammouse1 	1;

		Weapon.Bobstyle		'InverseSmooth';
		Weapon.BobRangeX	0.7;
		Weapon.BobRangeY	0.5;
		Weapon.BobSpeed		1.85;

		Inventory.PickupSound "CHGNPKUP";
		Weapon.UpSound "CHGNPKUP";
}
	
  States
  {
  
  Spawn:
	DMGN A -1;
    Loop;
  
  Ready:
    TNT1 A 1 A_WeaponReady(WRF_NOFIRE);
	Loop;

  Select:
    TNT1 A 0 {
		A_PlaySound("Weapon/WhooshSFX", 6, 1);
		A_PlaySound("Weapon/AKPRaise",  5, 1);
		A_ZoomFactor(1);
	}
	TNT1 A 1  A_Raise();
	TNT1 AAAAAAAAAAAAAA 0 A_Raise();
	Goto RaiseAnim;
  
  RaiseAnim:
	AKPL DCBA 1;
	TNT1 A 0 {A_Overlay(3, "IdleR"); A_Overlay(-3, "IdleL");}

    Goto Ready;
  
  Deselect:
    TNT1 A 0 {
		A_ClearOverlays(3,-3);
		A_PlaySound("Weapon/WhooshSFX", 6, 1);	
		A_ZoomFactor(1);
	}
	AKPL ABCD 1;
	Goto LowerAnim;
	
  LowerAnim:
	TNT1 AAAAAAAAAAAA 0 A_Lower();
	TNT1 A 1 A_Lower();
	Loop;
	
Fire:
    Goto Ready;
	
IdleL:
    DBCG I 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK, "FireL");
	TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ALTATTACK && (CountInv("Bullets") <= 0), "Left.NoBullets"); 
	Loop;

IdleR:
	DBCG A 1 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK, "FireR");
	TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_ATTACK && (CountInv("Bullets") <= 0), "Right.NoBullets");
	Loop;
	
FireR:
	TNT1 A 0 A_JumpIfNoAmmo("Right.NoBullets");
DBCG B 1
		{
			TakeInventory("Bullets",1);
			A_OverlayOffset(OverlayID(),0,0,WOF_INTERPOLATE);
			A_OverlayScale(OverlayID(),1,1,WOF_INTERPOLATE);
			//Do the same with the muzzle flash so it's synced
			A_StartSound("weapons/dblchngun", CHAN_WEAPON);
			A_FireBullets(5.6, 0, 1, 5, "BulletPuff");
			A_AlertMonsters();
		}
		DBCG CDEF 1;
Goto IdleR;

Right.NoBullets:
	DBCG C 1
			{
			A_StartSound("CGCLIK", CHAN_WEAPON);
		}
	DGCG DE 1;
	DGCG F 1 A_Refire("Right.NoBullets");
	Goto IdleR;

Left.NoBullets:
	DBCG K 1 {
	
			A_StartSound("CGCLIK", CHAN_WEAPON);
			}
	DGCG LM 1;
	DGCG N 1 A_Refire("Left.NoBullets");
	Goto IdleL;

	FireL:
		TNT1 A 0 A_JumpIfNoAmmo("Left.NoBullets");
		DBCG J 1
		{
			TakeInventory("Bullets",1);
			A_OverlayOffset(OverlayID(),0,0,WOF_INTERPOLATE);
			A_OverlayScale(OverlayID(),1,1,WOF_INTERPOLATE);
			A_StartSound("weapons/dblchngun", CHAN_WEAPON);
			A_FireBullets(5.6, 0, 1, 5, "BulletPuff");
			A_AlertMonsters();
		}
		DBCG KLMN 1;
		Goto IdleL;
	}
}

Class Bullets : Ammo 
{
  Default
  {
  Scale 0.25;
  Inventory.PickupMessage "Got some Bullets"; // "Picked up a clip."
  Inventory.Amount 11;
  Inventory.MaxAmount 300;
  Ammo.BackpackAmount 11;
  Ammo.BackpackMaxAmount 600;
  Inventory.Icon "BHUDB0";
  }
  States
  {
  Spawn:
    AMM1 A -1;
    Stop;
  }
}

Class BulletBox : Bullets 
{
  Default
  {
  Scale 1;
  Inventory.PickupMessage "$GOTCLIPBOX"; // "Picked up a box of bullets."
  Inventory.Amount 100;
  Inventory.PickupSound "P_AMMOB";
  }
  States
  {
  Spawn:
    AMMO A -1;
    Stop;
  }
}

 Which results in this:

 

Woe is me, for I am the saddest man who ever wielded two chain-guns! 

Share this post


Link to post

4 answers to this question

Recommended Posts

  • 0

This is the most complicated attempt at making something like that I've ever seen x)

But I get it, sometimes it can get frustrating making different weapons.

 

The thing is that I don't really know what you're trying to achieve here...

You just say that you want the player to be able to wield 2 chainguns, ok, but in the video (and the code actually) you show that it is just a single weapon that "draws" 2 chainguns on the HUD.

And if it's just a single weapon, what's the problem here?

Do you want to be able to fire with the chainguns separately?

Do you want to be able to reload the weapon?

Share this post


Link to post
  • 0
15 minutes ago, Kan3 said:

This is the most complicated attempt at making something like that I've ever seen x)

But I get it, sometimes it can get frustrating making different weapons.

 

The thing is that I don't really know what you're trying to achieve here...

You just say that you want the player to be able to wield 2 chainguns, ok, but in the video (and the code actually) you show that it is just a single weapon that "draws" 2 chainguns on the HUD.

And if it's just a single weapon, what's the problem here?

Do you want to be able to fire with the chainguns separately?

Do you want to be able to reload the weapon?

 

Oh this code let's you shoot each chaingun autonomously. I just fire both of them in the video so that I run out of ammo faster. 

What I want is for a new weapon to be selected when ammo runs out or failing that for the weapon to dry fire without flickering in and out of existence. 

Share this post


Link to post
  • 0
14 hours ago, Nihlith said:

 

Oh this code let's you shoot each chaingun autonomously. I just fire both of them in the video so that I run out of ammo faster. 

What I want is for a new weapon to be selected when ammo runs out or failing that for the weapon to dry fire without flickering in and out of existence. 

I don't know if it's possible to basically get a standard weapon mechanic (the switch to higher priority weapon when out of ammo thing) when you have convoluted code like this, even though I don't actually know if there's another way to obtain the possibility to separately shoot with left or right.

 

While looking around the ZDoom forum I found this:

https://forum.zdoom.org/viewtopic.php?f=39&amp;t=62228

 

Where the guy just "gives away" functions that would help making exactly what you want

and then this:

https://forum.zdoom.org/viewtopic.php?t=67189

 

Where another guy has been able to make a dual wielding weapon succesfully

 

So I suggest you to go for those solutions, otherwise you'll find yourself in too hacky ways of doing this D:

Share this post


Link to post
  • 0
15 hours ago, Kan3 said:

I don't know if it's possible to basically get a standard weapon mechanic (the switch to higher priority weapon when out of ammo thing) when you have convoluted code like this, even though I don't actually know if there's another way to obtain the possibility to separately shoot with left or right.

 

While looking around the ZDoom forum I found this:

https://forum.zdoom.org/viewtopic.php?f=39&amp;t=62228

 

Where the guy just "gives away" functions that would help making exactly what you want

and then this:

https://forum.zdoom.org/viewtopic.php?t=67189

 

Where another guy has been able to make a dual wielding weapon succesfully

 

So I suggest you to go for those solutions, otherwise you'll find yourself in too hacky ways of doing this D:

 

Thanks man, I really appreciate it. I had seen those, I even made a dual wield melee weapon with Matt's Combo Friendly Weapon, but for whatever reason I hadn't thought to try it with the chain-guns. Did it this morning and THE EXACT SAME THING HAPPENED! I might be retarded, but I looked at ctlcdn's Mismatched pistols again and decided that if brute force wasn't working, I probably wasn't using enough of it. I overhauled the Decorate code to make it look and act like I wanted, called it "Chainguns" and then I made this dummy zscript actor so that I could see it in the editor.

Class DChainGuns : ACTOR
{
Default
{
}

Override Void BeginPlay()
	{
		Super.BeginPlay();
		
		A_SpawnItemEx("Chainguns",0,0,0,0,0,0,0,0);
	}
	
States
{
Spawn:
TNT1 A 1;
Stop;
}
}

It worked. Thanks again, sometimes you need some input to knock you out of a rut of circular thinking.  

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
×