/*
 * Copyright © 2024 Nicole O'Connor
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * 	http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class RapidZorcherHGA : RapidZorcher replaces RapidZorcher {
	Default {
		Weapon.SisterWeapon "RapidZorcherBuffed";
	}
	
	action void A_FireRailgun() {
		if (player == null) { return; }
		
		// every time i use this weapon sound, i think fondly of my wife
		//A_StartSound("weapons/railgf", CHAN_WEAPON);
		Weapon weap = player.ReadyWeapon;
		if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) {
			if (!weap.DepleteAmmo (weap.bAltFire, true, 6)) { return; }
			
			player.SetPsprite(PSP_FLASH, weap.FindState('Flash'), true);
		}
		player.mo.PlayAttacking2();
		
		A_RailAttack(70, 0, false, "1f91ff", "b7dcff", RGF_SILENT | RGF_FULLBRIGHT, 1.5, range:16384);
	}
}

class RapidZorcherBuffed : RapidZorcherHGA {
	Default {
		+WEAPON.POWERED_UP;
		Weapon.SisterWeapon "RapidZorcherHGA";

		Weapon.AmmoUse 6;
		Weapon.AmmoGive 0;
	}
	
	States
	{
	Ready:
		SCHG A 1 A_WeaponReady;
		Loop;
	Deselect:
		SCHG A 1 A_Lower;
		Loop;
	Select:
		SCHG A 1 A_Raise;
		Loop;
	Fire:
		SCHG AB 4 A_FireRailgun;
		SCHG B 0 A_ReFire;
		Goto Ready;
	Flash:
		SCHF A 5 Bright A_Light1;
		Goto LightDone;
		SCHF B 5 Bright A_Light2;
		Goto LightDone;
	Spawn:
		MGUN A -1;
		Stop;
	}
}