Trying to Make A Plasmasgun That Has A Couple Functions

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
[name_withheld]
Posts: 16
Joined: Thu Apr 13, 2023 2:41 pm
Preferred Pronouns: He/Him

Trying to Make A Plasmasgun That Has A Couple Functions

Post by [name_withheld] »

I'm attempting to create a plasma rifle that both overheats from general use, as well as having a secondry attack that can be charged for extra damage. All of it functions well, except for deselecting the weapon if the player attempts to altfire with no cells available (and the weapon also allows the player to fire charged shots even if they have no cells.) What can be done to correct this issue? Below is the code I am currently using to function the weapon in its current state. Any help is greatly appreciated!

Code: Select all

actor "plasmaCharge" : inventory { Inventory.MaxAmount 40 }

actor "PlasmaHeat" : Ammo
{
	Inventory.MaxAmount 100
}

actor "Whatifitwasblue"
{
	Renderstyle Translucent
	Gravity 1
	Height 1
	Radius 1
	Scale 0.4
	+Missile
	+NoTeleport
	+Rollsprite
	Bouncetype Hexen
	+NoBlockMap
	+ForceXYBillboard
	+DONTSPLASH
States
{
Spawn:
	TNT1 A 0 A_SetRoll(frandom(-360,360))
	TNT1 A 0 A_SetRenderStyle(frandom(0.2,1),STYLE_Translucent)
	PLSS A 2 Bright A_SetScale(0.35)
	TNT1 A 0 A_Fadeout(0.1)
	PLSS B 2 Bright A_SetScale(0.30)
	TNT1 A 0 A_Fadeout(0.1)
	PLSE a 2 Bright A_SetScale(0.25)
	TNT1 A 0 A_Fadeout(0.1)
	PLSE b 2 Bright A_SetScale(0.20)
	TNT1 A 0 A_Fadeout(0.1)
	PLSE c 2 Bright A_SetScale(0.15)
	TNT1 A 0 A_Fadeout(0.1)
	PLSE d 2 Bright A_SetScale(0.10)
	TNT1 A 0 A_Fadeout(0.1)
	PLSE e 2 Bright A_SetScale(0.05)
	stop
	}
}

actor "PlasmaProj" : FastProjectile
{
	
	MissileType PlasmaTrail
	MissileHeight 8
	Scale 1
	Alpha 0.75
	Radius 5
	Height 5
	Damage 6
	Speed 25
	Projectile
	DeathSound "weapons/plasmax"
	Renderstyle Add
States
{
Spawn:
	TNT1 A 0 A_Playsound("Pball",1,1,true)
	TNT1 A 0 A_ScaleVelocity(2)
	PLSS AB 6 Bright A_Setroll(frandom(360,-360))
	TNT1 AAAAAA 0 A_SpawnItemEX("PlasmaSparkle",frandom(-10,10),frandom(-10,10),frandom(-10,10),0,0,0,0,0,100)
	loop
Death:
	TNT1 A 0 A_Playsound("Plpop",0)
	TNT1 AAAAAAA   0 A_SpawnItemEx("Whatifitwasblue",0,0,0,random(-1,-5),random(-2,5),random(-2,5))
	PLSE ABCDE 2 Bright 
	stop
XDeath:
	TNT1 A 0 A_Playsound("Plpop",0)
	TNT1 AAAAAAA   0 A_SpawnItemEx("Whatifitwasblue",0,0,0,random(-1,-5),random(-2,5),random(-2,5))
	PLSE ABCDE 2 Bright 
	stop
Crash:
	TNT1 A 0 A_Playsound("Plpop",0)
	TNT1 AAAAAAA   0 A_SpawnItemEx("Whatifitwasblue",0,0,0,random(-1,-5),random(-2,5),random(-2,5))
	PLSE ABCDE 2 Bright 
	stop
	}
}

actor "PlasmaTrail"
{
	Renderstyle Add
	Alpha 0.25
	Scale 0.25
	+NoTeleport
	+Rollsprite
	-Solid
	+NoBlockMap
	Gravity 0
States
{
Spawn:
	TNT1 A 0 A_SetRoll(frandom(-360,360))
	PLSS B 1 A_Fadeout(0.03)
	TNT1 A 0 A_SetRoll(frandom(-360,360))
	TNT1 A 0 A_SetScale(0.50,0.50)
	PLSS C 1 A_Fadeout(0.03)
	TNT1 A 0 A_SetRoll(frandom(-360,360))
	TNT1 A 0 A_SetScale(0.25,0.25)
	stop
	}
}

actor "PlasmaSparkle" : PlasmaTrail
{
	Renderstyle Translucent
	Scale 0.5
	Alpha 1
States
{
Spawn:
	PLSS ABAB 1 A_SetRoll(frandom(-360,360))
	PLSE ABCDE 1 A_Fadeout(0.20)
	stop
	}
}

actor "PlasmaSmoke"
{
	Alpha 1
	+NoTeleport
	+Rollsprite
	-Solid
	+NoBlockMap
	Gravity 0
States
{
Spawn:
	TNT1 A 0 A_SetRoll(frandom(360,-360))
	SMKP AAAA 1 A_Fadeout(0.20)
	stop
	}
}

actor "Plasma Rifle" : Weapon replaces PlasmaRifle
{
	inventory.Pickupmessage "You found a UAC-issued plasma rifle! Time to fry some demon ass!"
	Weapon.AmmoUse 1
	Weapon.AmmoType1 Cell
	Weapon.AmmoType2 plasmaheat
	Weapon.AmmoUse2 0
	Weapon.AmmoGive 40
	Weapon.SlotNumber 6
	+Weapon.Alt_Ammo_Optional
	+Weapon.NoAutoFire
States
{
Spawn:
	PLAS A -1
	stop
	
Select:
	TNT1 A 0 A_Raise
	loop
	
Deselect:
	TNT1 A 1 A_Lower(30) 
	PLSG A 1 Offset(0,34)
	//PLSM A 1 Offset(0,36)
	PLSG A 1 Offset(0,38)
	//PLSM A 1 Offset(0,39)
	PLSG A 1 Offset(1,41)
	PLSG A 1 Offset(6,46)A_Playsound("PLHolst",0)
	PLSG A 1 Offset(4,44)
	PLSG A 1 Offset(2,42)
	PLSG A 5 Offset(0,40) 
	PLSG A 1 Offset(0,35)
	PLSG A 1 Offset(5,35)
	PLSG A 1 Offset(10,40)
	PLSG A 1 Offset(12,50)
	PLSG A 1 Offset(14,60)
	PLSG A 1 Offset(15,70)
	PLSG A 1 Offset(16,80)
	PLSG A 1 Offset(17,90)
	PLSG A 1 Offset(19,100)
	PLSG A 1 Offset(20,120)
	TNT1 a 0 A_checkreload
	Loop
	
Ready:
	TNT1 A 5
	PLSG A 1 Offset(1,120)
	PLSG A 1 Offset(0,110)
	PLSG A 1 Offset(0,100)
	PLSG A 1 Offset(0,80)
	PLSG A 1 Offset(0,60)
	PLSG A 1 Offset(0,50)
	PLSG A 1 Offset(0,45)
	PLSG A 1 Offset(0,40)
	PLSG A 1 Offset(0,38)
	PLSG A 1 Offset(0,36) A_Playsound("PLDraw",0,0.5)
	PLSG A 1 Offset(0,35)
	PLSG A 1 Offset(0,33)
	PLSG A 1 Offset(0,32)
	goto realready
	
RealReady:
	TNT1 A 0 A_TakeInventory("PlasmaHeat",2)
	PLSG A 1 A_WeaponReady(wrf_allowzoom)
	loop
	
Fire:
	TNT1 A 0 A_JumpIfNoAmmo("DryFire")
	TNT1 A 0 A_JumpIfInventory("PlasmaHeat",100,"Overheat")
	TNT1 A 0 A_StopSound(1)
	TNT1 A 0 A_Playsound("plas-1",1,0.75)
	TNT1 A 0 A_GiveInventory("PlasmaHeat",5)
	TNT1 A 0 A_Overlay(-7,"FakeFlash")
	PLSF B 1 Offset(5,35) Bright
	TNT1 A 0 A_FireProjectile("PlasmaProj",frandom(-0.5,0.5),1,5,-5,FPF_NOAUTOAIM,frandom(-0.5,0.5))
	TNT1 A 0 A_Overlay(-8,"RecoilPunch")
	PLSF B 1 Offset(10,40) Bright
	PLSG A 1 Offset(9,39) Bright
	PLSF B 1 Offset(7,37) Bright A_JumpIfInventory("PlasmaHeat",60,"FireWarn")
	PLSF B 1 Offset(5,35) Bright
	PLSF B 1 Offset(4,34) A_Refire
	PLSG A 1 Offset(4,33) A_Refire
	PLSG A 1 Offset(2,32) A_Refire
	PLSG A 1 Offset(0,32) A_Refire
	goto realready
	
Dryfire:
	PLSG A 1 A_Playsound("Plwarn",0,0.5)
	PLSG A 1 Offset(1,33)
	PLSG A 1 Offset(0,32)
	PLSG A 1 Offset(-1,31)
	PLSG A 1 Offset(1,32)
	TNT1 A 0 A_jumpifnoammo("deselect")
	Goto realready
	
RecoilPunch:
	TNT1 A 1 A_SetPitch(pitch-0.5)
	TNT1 A 1 A_SetPitch(pitch-1)
	TNT1 AAA 1 A_SetPitch(pitch+0.5)
	stop
	
Firewarn:
	PLSF B 1 Offset(7,37) Bright A_Playsound("Plwarn",0,0.25)
	PLSG A 1 Offset(5,35) Bright
	PLSF B 1 Offset(4,34) A_Refire("Fire")
	PLSG A 1 Offset(4,33)
	PLSG A 1 Offset(2,32)
	PLSG A 1 Offset(0,32)
	goto realready
	
Overheat:
	TNT1 A 0 A_Overlay(-7,"FakeFlash")
	PLSF B 1 Offset(5,35) Bright A_Playsound("PLHeatS",1)
	TNT1 A 0 A_Overlay(-8,"Recoil")
	PLSF B 1 Offset(10,40) Bright
	PLSG A 1 Offset(9,39) Bright
	PLSG A 1 Offset(5,35)
	PLSF B 1 Offset(7,37)
	PLSG A 1 Offset(5,35)
	PLSF B 1 Offset(4,34) 
	PLSG A 1 Offset(4,33)
	PLSG A 1 Offset(2,32)
	PLSG A 5 Offset(0,32)
	PLSG A 1 Offset(5,35)
	PLSG A 1 Offset(7,40)
	PLSG A 1 Offset(10,45)
	PLSG A 1 Offset(12,50)
	PLSG A 1 Offset(14,55)
	PLSG A 1 Offset(15,60)
	PLSG A 1 Offset(20,70)
	PLSG b 1 Offset(1,100)
	PLSG b 1 Offset(0,80)
	PLSG b 1 Offset(0,60) A_Playsound("PLHeatB",5)
	PLSG b 1 Offset(5,40)
	PLSG b 1 Offset(10,35)
	PLSG b 1 Offset(20,32)
	Overheatloop:
	TNT1 A 0 A_Playsound("PLOverH",1,1,true)
	TNT1 A 0 A_TakeInventory("PlasmaHeat",2)
	PLSG b 1 A_WeaponOffset(frandom(18,22),frandom(34,36))
	TNT1 A 0 A_SpawnitemEX("PlasmaSmoke",5,-5,30,0,0,5)
	TNT1 A 0 A_JumpIfInventory("PlasmaHeat",1,"Overheatloop")
	PLSG b 2 Offset(20,35) A_StopSound(1)
	PLSG b 1 Offset(18,40)
	PLSG b 1 Offset(16,50)
	PLSG b 1 Offset(14,60)
	PLSG b 1 Offset(12,80)
	PLSG b 1 Offset(5,100)
	PLSG b 1 Offset(1,110)
	PLSG A 1 Offset(1,100)
	PLSG A 1 Offset(1,80)
	PLSG A 1 Offset(1,60)
	PLSG A 1 Offset(1,50)
	PLSG A 1 Offset(1,40)
	PLSG A 1 Offset(1,35)
	PLSG A 1
	goto realready
	
OverheatSmoke:
	TNT1 AAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnitemEX("PlasmaSmoke",0,5,30,0,0,5)
	stop
	
FakeFlash:
	PLFF A 2 Bright A_Light(3)
	PLFF B 1 Bright A_Light(2)
	PLFF C 1 Bright A_Light(1)
	TNT1 A 0 A_Light0
	stop
	
AltFire:
	PLSG A 2 Offset(2,34) A_Playsound("bfgstr",5)
	PLSG A 1 Offset(4,36)
	PLSG A 1 Offset(5,40)
	PLSG A 1 Offset(10,45) A_JumpIfNoAmmo("dryfire")
	PLSG A 1 Offset(10,45) A_Refire("Charging")
	PLSG A 1 Offset(8,43) A_Playsound("bfgcan",1)
	PLSG A 1 Offset(6,41)
	PLSG A 1 Offset(4,38)
	PLSG A 1 Offset(2,35)
	PLSG A 1 Offset(1,34)
	PLSG A 1 Offset(0,33)
	goto dryfire
	
Charging:
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",40,"HoldFull")
	TNT1 A 0 A_JumpIfNoAmmo("dryFire")
	TNT1 A 0 A_QuakeEX(0.1*Countinv("plasmaCharge"),0.1*Countinv("plasmaCharge"),0.1*Countinv("plasmaCharge"),8,0,5,"")
	PLSG A 1 A_WeaponOffset(frandom(7,13),frandom(42,48)) 
	PLSF a 1 A_WeaponOffset(frandom(7,13),frandom(42,48))
	PLSG a 1 A_WeaponOffset(frandom(7,13),frandom(42,48))
	TNT1 A 0 A_Overlay(-7,"FakeFlash2")
	TNT1 A 0 A_GiveInventory("plasmaCharge",4)
	TNT1 A 0 A_TakeInventory("Cell",4)
	TNT1 A 0 A_JumpIfNoAmmo("Unleash")
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",40,"HoldFull")
	TNT1 A 0 A_Refire("Charging")
	goto Unleash
	
HoldFull:
	TNT1 A 0 A_QuakeEX(0.1*Countinv("plasmaCharge"),0.1*Countinv("plasmaCharge"),0.1*Countinv("plasmaCharge"),8,0,5,"")
	PLSG A 1 A_WeaponOffset(frandom(5,15),frandom(40,50)) 
	PLSf A 1 A_WeaponOffset(frandom(5,15),frandom(40,50))
	PLSG A 1 A_WeaponOffset(frandom(5,15),frandom(40,50))
	TNT1 A 0 A_Overlay(-7,"FakeFlash2")
	TNT1 A 0 A_Refire("HoldFull")
	goto Unleash
	
Unleash:
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",40,"UnleashMaximum")
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",25,"UnleashLarge")
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",15,"UnleashMedium")
	goto UnleashSmall
	
UnleashSmall:
	TNT1 A 0 Offset(10,45) A_FireProjectile("ChargedProj",frandom(-0.25,0.25)*CountInv("plasmaCharge"),0,10,-5,FPF_NoAutoAim,frandom(-0.25,0.25)*CountInv("plasmaCharge"))
	TNT1 A 0 A_Overlay(-7,"RecoilShake")
	TNT1 A 0 A_Overlay(-8,"RecoilPush")
	TNT1 A 0 A_TakeInventory("plasmaCharge",1)
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",1,"UnleashSmall")
	PLSG a 1 Offset(10,35) A_Playsound("bfgf1",1)
	PLSf b 1 Offset(15,40) A_Light(5)
	PLSf a 1 Offset(25,45) A_Light(4)
	PLSf b 1 Offset(27,50) A_Light(3)
	PLSf a 1 Offset(29,50) A_Light(2)
	PLSf b 1 Offset(30,50) A_Light(1)
	PLSf a 1 Offset(25,45) A_Light(0)
	PLSG A 1 Offset(20,40)
	PLSG b 1 Offset(17,37)
	PLSG b 1 Offset(15,35)
	PLSG b 1 Offset(12,34)
	PLSG b 1 Offset(8,33)
	PLSG b 1 Offset(6,34)
	PLSG b 1 Offset(4,33)
	PLSG b 1 Offset(2,32)
	PLSG b 1 Offset(1,32)
	goto realready
	
UnleashMedium:
	TNT1 A 0 Offset(10,45) A_FireProjectile("ChargedProj",frandom(-0.25,0.25)*CountInv("plasmaCharge"),0,10,-5,FPF_NoAutoAim,frandom(-0.25,0.25)*CountInv("plasmaCharge"))
	TNT1 A 0 A_Overlay(-7,"RecoilShake")
	TNT1 A 0 A_Overlay(-8,"RecoilPush")
	TNT1 A 0 A_TakeInventory("plasmaCharge",1)
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",1,"UnleashMedium")
	PLSG a 1 Offset(10,35) A_Playsound("bfgf2",1)
	PLSf b 1 Offset(15,40) A_Light(10)
	PLSf a 1 Offset(20,45)  A_Light(9)
	PLSf b 1 Offset(30,50)  A_Light(8)
	PLSf a 1 Offset(30,50)  A_Light(7)
	PLSf b 1 Offset(30,50)  A_Light(6)
	PLSf a 1 Offset(30,50)  A_Light(5)
	PLSf b 1 Offset(30,50)  A_Light(4)
	PLSf a 1 Offset(30,50)  A_Light(3)
	PLSf b 1 Offset(30,50)  A_Light(2)
	PLSf a 8 Offset(30,50)  A_Light(0)
	PLSG A 1 Offset(27,47)
	PLSG b 1 Offset(25,45)
	PLSG b 1 Offset(20,40)
	PLSG b 1 Offset(17,37)
	PLSG b 1 Offset(15,35)
	PLSG b 1 Offset(12,34)
	PLSG b 1 Offset(8,33)
	PLSG b 1 Offset(6,34)
	PLSG b 1 Offset(4,33)
	PLSG b 1 Offset(2,32)
	PLSG b 1 Offset(1,32)
	goto realready
	
UnleashLarge:
	TNT1 A 0 Offset(10,45) A_FireProjectile("ChargedProj",frandom(-0.25,0.25)*CountInv("plasmaCharge"),0,10,-5,FPF_NoAutoAim,frandom(-0.25,0.25)*CountInv("plasmaCharge"))
	TNT1 A 0 A_Overlay(-7,"RecoilShake")
	TNT1 A 0 A_Overlay(-8,"RecoilPush")
	TNT1 A 0 A_TakeInventory("plasmaCharge",1)
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",1,"UnleashLarge")
	PLSG A 1 Offset(20,50) A_Playsound("bfgf3",1)
	PLSG A 1 Offset(30,60) 
	PLSG A 1 Offset(50,70)
	PLSf b 1 Offset(50,75) A_LightInverse
	PLSf A 1 Offset(50,80) A_Light(15)
	PLSf b 1 Offset(50,80) A_Light(13)
	PLSf A 1 Offset(50,80) A_Light(11)
	PLSf b 1 Offset(50,80) A_Light(9)
	PLSf A 1 Offset(50,80) A_Light(7)
	PLSf b 1 Offset(50,80) A_Light(5)
	PLSf A 1 Offset(50,80) A_Light(3)
	PLSf b 1 Offset(50,80) A_Light(1)
	PLSf A 8 Offset(50,80) A_Light(0)
	PLSG a 1 Offset(45,75)
	PLSG b 1 Offset(40,70)
	PLSG b 1 Offset(35,60)
	PLSG b 1 Offset(30,50)
	PLSG b 1 Offset(20,40)
	PLSG b 1 Offset(15,37)
	PLSG b 1 Offset(10,35)
	PLSG b 1 Offset(7,34)
	PLSG b 1 Offset(5,33)
	PLSG b 1 Offset(3,32)
	PLSG b 1 Offset(1,32)
	TNT1 A 0
	goto realready
	
UnleashMaximum:
	TNT1 A 0 Offset(10,45) A_FireProjectile("ChargedProj",frandom(-0.25,0.25)*CountInv("plasmaCharge"),0,10,-5,FPF_NoAutoAim,frandom(-0.25,0.25)*CountInv("plasmaCharge"))
	TNT1 A 0 A_Overlay(-7,"RecoilShake")
	TNT1 A 0 A_Overlay(-8,"RecoilPush")
	TNT1 A 0 A_TakeInventory("plasmaCharge",1)
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",1,"UnleashMaximum")
	PLSG A 1 Offset(20,50) A_Playsound("bfgf4",1)
	PLSf b 1 Offset(30,60) A_LightInverse
	PLSf A 1 Offset(50,70)
	PLSf b 1 Offset(50,80) A_Light(20)
	PLSf A 1 Offset(50,80) A_Light(18)
	PLSf b 1 Offset(50,80) A_Light(16)
	PLSf A 1 Offset(50,80) A_Light(14)
	PLSf b 1 Offset(50,80) A_Light(12)
	PLSf A 1 Offset(50,80) A_Light(10)
	PLSf b 1 Offset(50,80) A_Light(8)
	PLSf A 1 Offset(50,80) A_Light(6)
	PLSf b 1 Offset(50,80) A_Light(4)
	PLSf A 1 Offset(50,80) A_Light(2)
	PLSf b 1 Offset(50,80) A_Light(0)
	PLSG A 8 Offset(50,80)
	PLSG b 1 Offset(45,75)
	PLSG b 1 Offset(40,70)
	PLSG b 1 Offset(35,60)
	PLSG b 1 Offset(30,50)
	PLSG b 1 Offset(20,40)
	PLSG b 1 Offset(15,37)
	PLSG b 1 Offset(10,35)
	PLSG b 1 Offset(7,34) 
	PLSG b 1 Offset(5,33)
	PLSG b 1 Offset(3,32)
	PLSG b 1 Offset(1,32) 
	TNT1 A 0
	goto realready
	
RecoilShake:
	TNT1 A 0 A_QuakeEX(0.2*Countinv("plasmaCharge"),0.2*Countinv("plasmaCharge"),0.2*Countinv("plasmaCharge"),1*Countinv("plasmaCharge"),0,5,"",QF_SCALEDOWN)
	stop
	
RecoilPush:
	TNT1 A 0 A_Recoil(0.5*cos(pitch))
	TNT1 A 0 A_ChangeVelocity(0,0,0.005*pitch)
	stop
	
Fakeflash2:
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",40,"FakeFlashMaximum")
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",25,"FakeFlashLarge")
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",15,"FakeFlashMedium")
	goto FakeFlashSmall
	
FakeFlashSmall:
	TNT1 A 0 A_Playsound("bfgloo1",1,1,true)
	BFFS ABC 1 Bright
	stop
	
FakeFlashMedium:
	TNT1 A 0 A_Playsound("bfgloo2",1,1,true)
	BFFM ABC 1 Bright
	stop
	
FakeFlashLarge:
	TNT1 A 0 A_Playsound("bfgloo3",1,1,true)
	BFFG ABC 1 Bright
	stop
	
FakeFlashMaximum:
	TNT1 A 0 A_Playsound("bfgloo4",1,1,true)
	BFFS AB 1 Bright
	BFFM CDE 1 Bright
	BFFG ABC 1 Bright
	stop
	}
}

actor "ChargedProj" : FastProjectile
{
	Scale 0.25
	Radius 3
	Height 3
	Damage 5
	Speed 50
	+Rollsprite
	+Extremedeath
	Deathsound "BFGProj"
	Projectile
	Renderstyle Translucent
States
{
Spawn:
	CPS1 AB 1 Bright A_SetRoll(roll+frandom(-360,360))
	loop
Death:
	CPE1 A 1 Bright A_SetScale(0.20,2)
	TNT1 A 0 A_Fadeout(0.25)
	CPE1 B 1 Bright A_SetScale(0.15,1.5)
	TNT1 A 0 A_Fadeout(0.25)
	CPE1 C 1 Bright A_SetScale(0.10,1)
	TNT1 A 0 A_Fadeout(0.25)
	CPE1 D 1 Bright A_SetScale(0.05,0.5)
	CPE1 D 1 Bright A_SetScale(0.05,0.4)
	CPE1 D 1 Bright A_SetScale(0.05,0.3)
	CPE1 E 1 Bright A_SetScale(0.05,0.2)
	CPE1 F 1 Bright A_SetScale(0.05,0.1)
	stop
	}
}
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Trying to Make A Plasmasgun That Has A Couple Functions

Post by Jarewill »

Because AmmoUse2 is set to 0, A_JumpIfNoAmmo won't work.
What you need to do here is use A_JumpIfInventory in Altfire and Charging states:

Code: Select all

AltFire:
	PLSG A 2 Offset(2,34) A_Playsound("bfgstr",5)
	PLSG A 1 Offset(4,36)
	PLSG A 1 Offset(5,40)
	PLSG A 1 Offset(10,45) A_JumpIfInventory("Cell",4,1) //If cells 4 or more, jump to the next frame
	Goto dryfire //Otherwise go to dryfire
	PLSG A 1 Offset(10,45) A_Refire("Charging")
	PLSG A 1 Offset(8,43) A_Playsound("bfgcan",1)
	PLSG A 1 Offset(6,41)
	PLSG A 1 Offset(4,38)
	PLSG A 1 Offset(2,35)
	PLSG A 1 Offset(1,34)
	PLSG A 1 Offset(0,33)
	goto dryfire
	
Charging:
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",40,"HoldFull")
	TNT1 A 0 A_JumpIfInventory("Cell",4,1)
	Goto HoldFull //Personal suggestion: if out of ammo but still had a charge then it should still be able to fire
	TNT1 A 0 A_QuakeEX(0.1*Countinv("plasmaCharge"),0.1*Countinv("plasmaCharge"),0.1*Countinv("plasmaCharge"),8,0,5,"")
	PLSG A 1 A_WeaponOffset(frandom(7,13),frandom(42,48)) 
	PLSF a 1 A_WeaponOffset(frandom(7,13),frandom(42,48))
	PLSG a 1 A_WeaponOffset(frandom(7,13),frandom(42,48))
	TNT1 A 0 A_Overlay(-7,"FakeFlash2")
	TNT1 A 0 A_GiveInventory("plasmaCharge",4)
	TNT1 A 0 A_TakeInventory("Cell",4)
	TNT1 A 0 A_JumpIfNoAmmo("Unleash")
	TNT1 A 0 A_JumpIfInventory("plasmaCharge",40,"HoldFull")
	TNT1 A 0 A_Refire("Charging")
	goto Unleash
Post Reply

Return to “Scripting”