retrogamer97 Posted January 19, 2023 (edited) Hey guys , I am adding a zoom/aim feature for my railgun, however it already has a primary fire and alternate fire. I am trying to use the reload key to act as the aim/unaim button. It works kind of , its really janky , I can press reload then nothing happens or theres a race condition (it quickly cycles between aim/unaim). Any idea to make this more solid, press reload once it aims, press again unaims. ACTOR Zoomed : Inventory { Inventory.MaxAmount 1 } ACTOR Railgun : Weapon { Weapon.SelectionOrder 41 Weapon.BobStyle Normal Weapon.BobSpeed 1.4 Weapon.BobRangeX 0.85 Weapon.BobRangeY 0.6 Weapon.AmmoUse1 10 Weapon.AmmoUse2 5 Weapon.AmmoGive 200 Weapon.AmmoType1 "TaintedSouls" Weapon.AmmoType2 "TaintedSouls" Obituary "%o was burned by %k's railgun." //Inventory.PickupMessage "\cnRailgun!" Tag "Railgun" Inventory.PickupSound "UPrailx" Scale 0.62 +WEAPON.AMMO_OPTIONAL +WEAPON.ALT_AMMO_OPTIONAL +WEAPON.NOALERT States { Spawn: RADU Z 1 loop Ready: RADU A 0 A_JumpIfInventory("Zoomed", 1, "Scopesready") RADU A 0 A_weaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU A 15 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU B 3 A_WeaponReady (WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU C 2 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU D 3 A_WeaponReady (WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU E 2 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU F 3 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU G 2 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU H 3 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU G 2 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU F 3 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU E 2 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU D 3 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU C 2 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU B 3 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU A 15 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) //RADU A 0 A_JumpIfInventory("Waiting",15,"Knuckles") //RADU AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_WeaponReady RADU A 0 A_GiveInventory("Waiting",1) Loop Deselect: RADU AAA 0 A_JumpIfInventory("Zoomed", 1, "ScopedDeselect") RADU AAAAA 1 A_Lower RADU A 0 A_TakeInventory("Waiting",15) RADU A 0 A_Lower Goto Deselect+1 Select: RADU A 1 A_Raise //RADU A 0 A_PlaySound("magic/rail",6) RADU C 0 A_Raise RADU A 1 A_Raise RADU C 0 A_Raise RADU A 1 A_Raise RADU C 0 A_Raise RADU A 1 A_Raise RADU C 0 A_Raise RADU A 1 A_Raise RADU C 0 A_Raise RADU CACAC 1 A_Raise RADU ACACACACAC 2 A_Raise Loop Fire: TNT1 A 0 A_JumpIfInventory("Zoomed", 1, "ScopedFire") RADU I 0 A_PlaySound("magic/rail",6) RADU I 0 A_JumpIfInventory("TaintedSouls",5,5) RADU I 0 A_JumpIfInventory("TaintedSouls",4,"FireFail") RADU I 0 A_JumpIfInventory("TaintedSouls",3,"FireFail") RADU I 0 A_JumpIfInventory("TaintedSouls",2,"FireFail") RADU I 0 A_JumpIfInventory("TaintedSouls",1,"FireFail") RADU I 0 RADU I 0 A_JumpIfNoAmmo("FireFail") RADU I 0 A_GunFlash RADU III 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU I 0 A_FireBullets(-5,0,1,0,"RailgunThunderPuff",0,5000) ///////////////////////////////////////////////////////////////////////////////////////////////////// TNT1 A 0 A_Quake(3,5,0,20,"") // TNT1 A 0 A_Recoil(1.6) //////////////////////////////////////////////////////////////////////////////////////////////////////// RADU I 0 A_RailAttack(250,7,1,"000000","000000",RGF_SILENT,0,"RailgunThunder2Puff",0,0,0,0,5,1.0,"DukeRailGunTrail") RADU I 0 A_SetPitch(pitch-3.65) //MODIFY ME RADU I 0 A_TakeInventory("Waiting",15) RADU I 0 A_AlertMonsters RADU I 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU IIIIIIIIII 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU JJJJJJJJJJJJJJJJJ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) Goto Ready AltFire: RADU A 0 A_JumpIfInventory("Zoomed", 1, "ScopedFiree") RADU J 0 A_JumpIfNoAmmo("FireFail") RADU X 0 A_Quake(5,2,0,20,"") RADU X 3 Bright RADU X 8 Bright {A_GunFlash; A_PlayWeaponSound("magic/railalt");} RADU X 8 Bright A_FireCustomMissile("FireShot1",0,1,0,0) RADU X 8 RADU X 7 A_Refire goto ready Flash: RADU B 0 A_Light1 RADU A 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU B 0 A_Light1 RADU C 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU B 0 A_Light1 RADU A 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU B 0 A_Light1 RADU C 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU B 0 A_Light2 RADU A 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU B 0 A_Light2 RADU C 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU A 0 A_Light2 RADU H 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU C 1 A_Light1 RADU B 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU A 0 A_Light1 RADU B 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU C 0 A_Light0 RADU BABACACAB 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) Goto LightDone //AltFire: // Goto Ready AltFlash: RADU AAAAAAAAAAAAAAAAA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) Stop FireFail: //RADU A 0 A_PlaySound("magic/rail",6) RADU A 0 A_TakeInventory("Waiting",15) RADU AAAAAAAAAAAAAAAAAAAA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) Goto Ready /////////////////////////////////////////////////////////////////////////////////////// // NEW CODE /////////////////////////////////////////////////////////////////////////////////////// ScopedFiree: RADU Y 0 A_JumpIfNoAmmo("FireFail") RADU Y 0 A_Quake(5,2,0,20,"") RADU Y 3 Bright RADU Y 8 Bright A_PlayWeaponSound("magic/railalt") RADU Y 8 Bright A_FireCustomMissile("FireShot1",0,1,0,0) RADU Y 8 RADU Y 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU Y 7 A_Refire Goto ScopesReady ScopedFire: RADU Y 0 A_PlaySound("magic/rail",6) RADU YYY 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) RADU Y 0 A_JumpIfInventory("TaintedSouls",5,5) RADU Y 0 A_JumpIfInventory("TaintedSouls",4,"FireFail") RADU Y 0 A_JumpIfInventory("TaintedSouls",3,"FireFail") RADU Y 0 A_JumpIfInventory("TaintedSouls",2,"FireFail") RADU Y 0 A_JumpIfInventory("TaintedSouls",1,"FireFail") RADU Y 0 RADU Y 0 A_JumpIfNoAmmo("FireFail") ///////////////////////////////////////////////////////////////////////////////////////////////////// TNT1 A 0 A_Quake(3,5,0,20,"") TNT1 A 0 A_Recoil(1.6) //////////////////////////////////////////////////////////////////////////////////////////////////////// RADU Y 0 A_RailAttack(250,0,1,"000000","000000",RGF_SILENT,0,"RailgunThunder2Puff",0,0,0,0,5,1.0,"DukeRailGunTrail",9) RADU Y 0 A_SetPitch(pitch-3.65) //MODIFY ME // RADU Y 0 A_TakeInventory("Waiting",15) RADU Y 0 A_AlertMonsters RADU Y 8 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU Y 10 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM) RADU Y 8 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM) Goto ScopesReady Reload: TNT1 A 0 A_Playsound("SCOPE") TNT1 A 0 A_JumpIfInventory("Zoomed", 1, "ZoomOut") TNT1 A 0 A_GiveInventory("Zoomed", 1) TNT1 A 0 A_ZoomFactor(7.0,ZOOM_INSTANT) Goto Ready ZoomOut: RADU A 0 A_TakeInventory("Zoomed", 1) RADU A 1 A_ZoomFactor(1.0, ZOOM_INSTANT) Goto Ready ScopesReady: RADU Y 1 A_WeaponReady(WRF_ALLOWRELOAD) Loop ScopedDeselect: RADU A 0 A_TakeInventory("Zoomed", 1) RADU A 2 A_ZoomFactor(1.0) RADU AAAAA 1 A_Lower RADU A 0 A_Lower Goto ScopedDeselect+5 } } Edited January 19, 2023 by retrogamer97 0 Quote Share this post Link to post
retrogamer97 Posted January 19, 2023 I fixed the bug, sorry for the wasted thread. 0 Quote Share this post Link to post
ramon.dexter Posted January 20, 2023 You've started the thread, so please post how you've solved it, so it could help others in the future. 0 Quote Share this post Link to post
retrogamer97 Posted January 20, 2023 30 minutes ago, ramon.dexter said: You've started the thread, so please post how you've solved it, so it could help others in the future. Reload: TNT1 A 2 A_Playsound("SCOPE") TNT1 A 2 A_JumpIfInventory("Zoomed", 1, "ZoomOut") TNT1 A 2 A_GiveInventory("Zoomed", 1) TNT1 A 2 A_ZoomFactor(7.0,ZOOM_INSTANT) Goto Ready 0 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.