by Void Weaver » Sun May 19, 2019 9:24 am
Alexagon wrote:Void Weaver wrote:Alexagon, maybe my english are too bad but I still don't understand what (alt-)firing effects you want to achieve? Should is Altfire mode supposed to be are sorta of toggleable (by alt-fire button) wind-up "awaited-for-Fire-button" state?
I want it so that while holding the altfire key, the barrel on the minigun spins and only spins. Then if I press fire while the barrel is spinning, I want it to fire without any delay.
Essentially I want to be able to be prepared to shoot with the minigun instead of waiting for the first few frames to pass before actually firing.
Oh, got it.
Well that's easy, even without any scripts. There are 2 variants:
VAR #1 - this is the same mechanics which you looking for. While you hold Alt-fire barrels are spin, if you press Fire at the same time it will immediately shoots.
Code: Select all
Actor WindUpChecker : Inventory {Inventory.MaxAmount 1}
Actor HoldChaingun : Chaingun replaces Chaingun
{
Weapon.AmmoUse1 1
Weapon.AmmoUse2 1
Weapon.AmmoType1 "Clip"
Weapon.AmmoType2 "Clip"
Weapon.SlotNumber 4
States
{
Fire:
TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
TNT1 A 0 A_PlaySound ("weapons/minig/start")
TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"Hold")
CHGG B 2
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG CD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_Refire
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABC 2 A_WeaponReady
CHGG DABCDAB 3 A_WeaponReady
CHGG CD 4 A_WeaponReady
Goto Ready
Altfire:
TNT1 A 0 A_TakeInventory("WindUpChecker")
TNT1 A 0 A_PlaySound ("weapons/minig/start")
AltHold:
TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
CHGG ABCD 1
{
A_WeaponReady(WRF_DISABLESWITCH|WRF_NOSWITCH|WRF_NOSECONDARY);
A_GiveInventory("WindUpChecker");
}
VLCN A 0 A_Refire
AltWinddown:
CHGG ABCDAABBCCDD 1
TNT1 A 0 A_TakeInventory("WindUpChecker")
goto ready
Hold:
TNT1 A 0 A_TakeInventory("WindUpChecker")
TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("ToggleMinigun")==0, "NoReloadHold")
TNT1 A 0 A_JumpIfNoAmmo("EmptyWindDown")
TNT1 A 0 A_AlertMonsters
TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
TNT1 A 0 A_GunFlash
CHGG A 1 Offset(0,35) A_FireBullets (5, 5, 1, 8, "BulletPuff")
TNT1 A 0 Radius_Quake (1, 2, 0, 1, 0)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch-1.0)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG B 1 Offset(0,37) A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG C 1 Offset(0,39) A_FireBullets (5, 5, 1, 8, "BulletPuff")
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch-0.6)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG D 1 Offset(0,37)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch+1.6)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_ReFire
Goto Ready
}
}
VAR #2 - this a bit different mechanics. Alt-fire itself consist from 2 toggleable modes: spin on\spin off. While in spin mode it also will immediately shoots while Fire is pressed.
Code: Select all
Actor ToggleChaingun : Chaingun replaces Chaingun
{
Weapon.AmmoUse1 1
Weapon.AmmoUse2 1
Weapon.AmmoType1 "Clip"
Weapon.AmmoType2 "Clip"
Weapon.SlotNumber 4
States
{
Fire:
TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
TNT1 A 0 A_PlaySound ("weapons/minig/start")
TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"Hold")
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG B 2
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG CD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_Refire
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABC 2 A_WeaponReady
CHGG DABCDAB 3 A_WeaponReady
CHGG CD 4 A_WeaponReady
Goto Ready
Altfire:
CHGG ABCD 1
TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,3)
TNT1 A 0 A_GiveInventory("WindUpChecker")
TNT1 A 0 A_PlaySound ("weapons/minig/start")
Goto AltHoldd
TNT1 A 0 A_TakeInventory("WindUpChecker")
Goto AltWinddown
AltHoldd:
TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
CHGG ABCD 1
{
A_WeaponReady(WRF_DISABLESWITCH|WRF_NOSWITCH);
If(CountInv("WindUpChecker")==0){Return state("AltWinddown");}
Else{Return state("");}
}
Loop
AltWinddown:
CHGG ABCDAABBCCDD 1
CHGG AABBCCDD 2
Goto Ready
Hold:
TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("ToggleMinigun")==0, "NoReloadHold")
TNT1 A 0 A_JumpIfNoAmmo("EmptyWindDown")
TNT1 A 0 A_AlertMonsters
TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
TNT1 A 0 A_GunFlash
CHGG A 1 Offset(0,35) A_FireBullets (5, 5, 1, 8, "BulletPuff")
TNT1 A 0 Radius_Quake (1, 2, 0, 1, 0)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch-1.0)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG B 1 Offset(0,37) A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG C 1 Offset(0,39) A_FireBullets (5, 5, 1, 8, "BulletPuff")
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch-0.6)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG D 1 Offset(0,37)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch+1.6)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_ReFire
TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"AltHoldd")
Goto Ready
}
}
I did use your basic code, so I have replace your sprites with vanilla CHgun ones.
EDIT:
Code bugs fixed.
[quote="Alexagon"][quote="Void Weaver"][b]Alexagon[/b], maybe my english are too bad but I still don't understand what (alt-)firing effects you want to achieve? Should is Altfire mode supposed to be are sorta of toggleable (by alt-fire button) wind-up "awaited-for-Fire-button" state?[/quote]
I want it so that while holding the altfire key, the barrel on the minigun spins and only spins. Then if I press fire while the barrel is spinning, I want it to fire without any delay.
Essentially I want to be able to be prepared to shoot with the minigun instead of waiting for the first few frames to pass before actually firing.[/quote]Oh, got it. :) Well that's easy, even without any scripts. There are 2 variants:
VAR #1 - this is the same mechanics which you looking for. While you hold Alt-fire barrels are spin, if you press Fire at the same time it will immediately shoots.
[code]Actor WindUpChecker : Inventory {Inventory.MaxAmount 1}
Actor HoldChaingun : Chaingun replaces Chaingun
{
Weapon.AmmoUse1 1
Weapon.AmmoUse2 1
Weapon.AmmoType1 "Clip"
Weapon.AmmoType2 "Clip"
Weapon.SlotNumber 4
States
{
Fire:
TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
TNT1 A 0 A_PlaySound ("weapons/minig/start")
TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"Hold")
CHGG B 2
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG CD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_Refire
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABC 2 A_WeaponReady
CHGG DABCDAB 3 A_WeaponReady
CHGG CD 4 A_WeaponReady
Goto Ready
Altfire:
TNT1 A 0 A_TakeInventory("WindUpChecker")
TNT1 A 0 A_PlaySound ("weapons/minig/start")
AltHold:
TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
CHGG ABCD 1
{
A_WeaponReady(WRF_DISABLESWITCH|WRF_NOSWITCH|WRF_NOSECONDARY);
A_GiveInventory("WindUpChecker");
}
VLCN A 0 A_Refire
AltWinddown:
CHGG ABCDAABBCCDD 1
TNT1 A 0 A_TakeInventory("WindUpChecker")
goto ready
Hold:
TNT1 A 0 A_TakeInventory("WindUpChecker")
TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("ToggleMinigun")==0, "NoReloadHold")
TNT1 A 0 A_JumpIfNoAmmo("EmptyWindDown")
TNT1 A 0 A_AlertMonsters
TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
TNT1 A 0 A_GunFlash
CHGG A 1 Offset(0,35) A_FireBullets (5, 5, 1, 8, "BulletPuff")
TNT1 A 0 Radius_Quake (1, 2, 0, 1, 0)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch-1.0)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG B 1 Offset(0,37) A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG C 1 Offset(0,39) A_FireBullets (5, 5, 1, 8, "BulletPuff")
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch-0.6)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG D 1 Offset(0,37)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch+1.6)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_ReFire
Goto Ready
}
}[/code]
VAR #2 - this a bit different mechanics. Alt-fire itself consist from 2 toggleable modes: spin on\spin off. While in spin mode it also will immediately shoots while Fire is pressed.
[code]Actor ToggleChaingun : Chaingun replaces Chaingun
{
Weapon.AmmoUse1 1
Weapon.AmmoUse2 1
Weapon.AmmoType1 "Clip"
Weapon.AmmoType2 "Clip"
Weapon.SlotNumber 4
States
{
Fire:
TNT1 A 0 A_JumpIfNoAmmo("Dryfire")
TNT1 A 0 A_PlaySound ("weapons/minig/start")
TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"Hold")
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG B 2
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG CD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_Refire
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABCD 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG ABC 2 A_WeaponReady
CHGG DABCDAB 3 A_WeaponReady
CHGG CD 4 A_WeaponReady
Goto Ready
Altfire:
CHGG ABCD 1
TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,3)
TNT1 A 0 A_GiveInventory("WindUpChecker")
TNT1 A 0 A_PlaySound ("weapons/minig/start")
Goto AltHoldd
TNT1 A 0 A_TakeInventory("WindUpChecker")
Goto AltWinddown
AltHoldd:
TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
CHGG ABCD 1
{
A_WeaponReady(WRF_DISABLESWITCH|WRF_NOSWITCH);
If(CountInv("WindUpChecker")==0){Return state("AltWinddown");}
Else{Return state("");}
}
Loop
AltWinddown:
CHGG ABCDAABBCCDD 1
CHGG AABBCCDD 2
Goto Ready
Hold:
TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("ToggleMinigun")==0, "NoReloadHold")
TNT1 A 0 A_JumpIfNoAmmo("EmptyWindDown")
TNT1 A 0 A_AlertMonsters
TNT1 A 0 A_PlaySound("weapons/minig/spin",6)
TNT1 A 0 A_GunFlash
CHGG A 1 Offset(0,35) A_FireBullets (5, 5, 1, 8, "BulletPuff")
TNT1 A 0 Radius_Quake (1, 2, 0, 1, 0)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch-1.0)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG B 1 Offset(0,37) A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG C 1 Offset(0,39) A_FireBullets (5, 5, 1, 8, "BulletPuff")
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch-0.6)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
CHGG D 1 Offset(0,37)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_SetPitch(pitch+1.6)
TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
TNT1 A 0 A_ReFire
TNT1 A 0 A_JumpIfInventory("WindUpChecker",1,"AltHoldd")
Goto Ready
}
}[/code]I did use your basic code, so I have replace your sprites with vanilla CHgun ones.
[b]EDIT[/b]:
Code bugs fixed.