/*
 * 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 LargeZorcherHGA : LargeZorcher replaces LargeZorcher {
	Default {
		Weapon.SisterWeapon "LargeZorcherBuffed";
	}
	
	action void A_FireShotgunBuffed() {
		// largely the same as the standard A_FireShotgun, with some changes because it's... buffed...
		if (player == null) { return; }
	
		A_StartSound("weapons/shotgf", CHAN_WEAPON);
		Weapon weap = player.ReadyWeapon;
		if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) {
			if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) { return; }
			
			player.SetPsprite(PSP_FLASH, weap.FindState('Flash'), true);
		}
		player.mo.PlayAttacking2 ();
	
		double pitch = BulletSlope ();
		for (int i = 0; i < 7; i++) {
			int damage = 7 * random[GunShot](2, 4);
				double ang = angle;
				let accurate = false;
				if (!accurate) {
					ang += Random2[GunShot]() * (3.125 / 256);
					if (GetCVar ("vertspread") && !sv_novertspread) {
						pitch += Random2[GunShot]() * (1.675 / 256);
					}
				}
			LineAttack(ang, PLAYERMISSILERANGE, pitch, damage, 'Hitscan', "BulletPuff");
		}
	}
}

class LargeZorcherBuffed : LargeZorcherHGA {
	Default {
		+WEAPON.POWERED_UP;
		Weapon.SisterWeapon "LargeZorcherHGA";

		Weapon.AmmoUse 2;
		Weapon.AmmoGive 0;
	}
	
	States {
	Ready:
		SSHT A 1 A_WeaponReady;
		Loop;
	Deselect:
		SSHT A 1 A_Lower;
		Loop;
	Select:
		SSHT A 1 A_Raise;
		Loop;
	Fire:
		SSHT A 3;
		SSHT A 7 A_FireShotgunBuffed;
		SSHT A 3;
		SSHT A 7 A_FireShotgunBuffed;
		SSHT BC 5;
		SSHT D 4;
		SSHT CB 3;
		SSHT A 3;
		SSHT A 7 A_ReFire;
		Goto Ready;
	Flash:
		SSHF A 4 Bright A_Light1;
		SSHF B 3 Bright A_Light2;
		Goto LightDone;
	}
}