Help! Changing ammo type using altfire

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
A.Gamma
Posts: 216
Joined: Mon Dec 13, 2010 12:11 am

Help! Changing ammo type using altfire

Post by A.Gamma »

Basically, is it possible to change the ammo type a weapon is using by pressing the altfire button?
Last edited by A.Gamma on Wed Mar 21, 2012 3:05 am, edited 2 times in total.
User avatar
Ryan Cordell
Posts: 4349
Joined: Sun Feb 06, 2005 6:39 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia (Modern GZDoom)
Location: Capital of Explodistan

Re: Changing ammo type with altfire?

Post by Ryan Cordell »

Technically, no. But you could fake what ammo the HUD displays.
User avatar
A.Gamma
Posts: 216
Joined: Mon Dec 13, 2010 12:11 am

Re: Changing ammo type with altfire?

Post by A.Gamma »

But that won´t make the actual ammo the weapon uses change, would it?
User avatar
Blitzky
Posts: 29
Joined: Tue Jan 25, 2011 6:02 pm
Location: Chicagoland, Illinois

Re: Changing ammo type with altfire?

Post by Blitzky »

Theoretically, you could use altfire to give the player a dummy item and cause a jump to a different fire state based on whether or not they have that item.
User avatar
A.Gamma
Posts: 216
Joined: Mon Dec 13, 2010 12:11 am

Re: Changing ammo type with altfire?

Post by A.Gamma »

Hmmm thanks for the suggestion, I will try it later.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Changing ammo type with altfire?

Post by Gez »

[wiki=Final_Heretic:_The_Docks]Here[/wiki]'s an example of a mod featuring a weapon where you use altfire to change firing mode and ammo used.
User avatar
A.Gamma
Posts: 216
Joined: Mon Dec 13, 2010 12:11 am

Re: Changing ammo type with altfire?

Post by A.Gamma »

Woah, thanks that's exactly what I was going for!
User avatar
A.Gamma
Posts: 216
Joined: Mon Dec 13, 2010 12:11 am

Changing ammo type with altfire

Post by A.Gamma »

Necro Bump!
Since I'm having issues with this, I decided to post them here instead of making a new thread.
Anyway, I got a weapon that's supposed to change the ammo type, needles to say, it's not
Spoiler:
Any ideas on what I'm doing wrong?
Edit:
I think I should mention that what I'm aiming at, is changing the ammo type with altfire AND fire it using the main "Fire" button, (like in the wad Gez linked) while the ammo appears to change (the ready sound playing) I fire normal ammo when pressing the "Fire" button.
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1118
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: Help! Changing ammo type using altfire

Post by Jekyll Grim Payne »

A.Gamma wrote:Necro Bump!
Since I'm having issues with this, I decided to post them here instead of making a new thread.
Anyway, I got a weapon that's supposed to change the ammo type, needles to say, it's not
Wrapping it in

Code: Select all

 is better than in [spoiler] :)

Well, from the code I can't really see how you could actually switch back from green to red ammo. Also, why do you need to have red ammo in order to be able to switch to green? Are you sure it's necessary?
Apart from that, switching to green ammo should work as it is. But check if that ChangeGreen item is Inventory, not CustomInventory (as have experienced it, JumpIfInventory doesn't work with CustomInventory). Same goes for your BonnieClydeCheck.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Help! Changing ammo type using altfire

Post by Gez »

Or wrap it in [spoiler][code] [/code][/spoiler] for the best practice! Which is exactly what he has done. :p
User avatar
A.Gamma
Posts: 216
Joined: Mon Dec 13, 2010 12:11 am

Re: Help! Changing ammo type using altfire

Post by A.Gamma »

Apart from that, switching to green ammo should work as it is. But check if that ChangeGreen item is Inventory, not CustomInventory (as have experienced it, JumpIfInventory doesn't work with CustomInventory). Same goes for your BonnieClydeCheck
Both of them have a parent class which is an Inventory Item, not Custom Inventory :wink:
Well, from the code I can't really see how you could actually switch back from green to red ammo.
That's my problem, I've seen a thing like that done before, but I can't manage to replicate the effect.
Also, why do you need to have red ammo in order to be able to switch to green? Are you sure it's necessary?
My mistake :oops:
User avatar
A.Gamma
Posts: 216
Joined: Mon Dec 13, 2010 12:11 am

Re: Help! Changing ammo type using altfire

Post by A.Gamma »

I hate to bump but, I do need help here.
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: Help! Changing ammo type using altfire

Post by Blue Shadow »

Would this simplistic example of a weapon help?

Code: Select all

ACTOR DualAmmoShotgun : Shotgun replaces Shotgun
{
  Weapon.SlotNumber 8
  Weapon.AmmoGive1 40
  Weapon.AmmoGive2 10
  Weapon.AmmoType1 "Cell"
  Weapon.AmmoType2 "RocketAmmo"
  States
  {
  Fire:
    TNT1 A 0 A_JumpIfInventory("UseAmmo2", 0, "FireAmmo2")
    TNT1 A 0 A_JumpIfInventory("Cell", 1, 1)
    Goto Ready
    SHTG A 3
    TNT1 A 0 A_TakeInventory("Cell", 1)
    TNT1 A 0 A_GunFlash
    SHTG A 7 A_FireCustomMissile("PlasmaBall", 0, 0)
    SHTG BC 5
    SHTG D 4
    SHTG CB 5
    SHTG A 3
    SHTG A 7 A_ReFire
    Goto Ready
  FireAmmo2:
    TNT1 A 0 A_JumpIfInventory("RocketAmmo", 1, 1)
    Goto Ready
    SHTG A 3
    TNT1 A 0 A_TakeInventory("RocketAmmo", 1)
    TNT1 A 0 A_GunFlash
    SHTG A 7 A_FireCustomMissile("Rocket", 0, 0)
    SHTG BC 5
    SHTG D 4
    SHTG CB 5
    SHTG A 3
    SHTG A 7 A_ReFire
    Goto Ready
  AltFire:
    TNT1 A 0 A_JumpIfInventory("UseAmmo2", 0, "SetAmmo1")
    TNT1 A 0 A_Log("Ammo 2 is set (Rockets)") // Just a debug message
    SHTG A 3 A_GiveInventory("UseAmmo2", 1)
    Goto Ready
  SetAmmo1:
    TNT1 A 0 A_Log("Ammo 1 is set (Energy Cells)") // Just a debug message
    SHTG A 3 A_TakeInventory("UseAmmo2", 1)
    Goto Ready
  }
}	

ACTOR UseAmmo2 : Inventory {}
Locked

Return to “Editing (Archive)”