Help! Changing ammo type using altfire
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.
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.
Help! Changing ammo type using altfire
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.
- 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?
Technically, no. But you could fake what ammo the HUD displays.
Re: Changing ammo type with altfire?
But that won´t make the actual ammo the weapon uses change, would it?
Re: Changing ammo type with altfire?
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.
Re: Changing ammo type with altfire?
Hmmm thanks for the suggestion, I will try it later.
Re: Changing ammo type with altfire?
[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.
Re: Changing ammo type with altfire?
Woah, thanks that's exactly what I was going for!
Changing ammo type with altfire
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
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.
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.
- 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
Wrapping it inA.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
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.
Re: Help! Changing ammo type using altfire
Or wrap it in [spoiler][code] [/code][/spoiler] for the best practice! Which is exactly what he has done. 

Re: Help! Changing ammo type using altfire
Both of them have a parent class which is an Inventory Item, not Custom InventoryApart 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

That's my problem, I've seen a thing like that done before, but I can't manage to replicate the effect.Well, from the code I can't really see how you could actually switch back from green to red ammo.
My mistakeAlso, why do you need to have red ammo in order to be able to switch to green? Are you sure it's necessary?

Re: Help! Changing ammo type using altfire
I hate to bump but, I do need help here.
-
- Posts: 5043
- Joined: Sun Nov 14, 2010 12:59 am
Re: Help! Changing ammo type using altfire
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 {}