<commit_before>// --------------------------------------------------------------------------
//
// Missile Launcher
//
// --------------------------------------------------------------------------

class EriMissileLauncher : EriWeapon
{
	const SPLIT_TRIGGER_OVERLAY = 10;

	Default
	{
		Weapon.SelectionOrder 2500;
		Weapon.AmmoUse 2;
		Weapon.AmmoGive 8;
		Weapon.AmmoType "RocketAmmo";
		Inventory.PickupMessage "$GOTMISSILE";
		Tag "$TAG_MISSILE";
		VisibleToPlayerClass "AltPlayer";
		Inventory.RestrictedTo "AltPlayer";
		+INVENTORY.RESTRICTABSOLUTELY;
		+WEAPON.NOAUTOFIRE;
	}
	States
	{
	Ready:
		DMLG A 1 A_WeaponReady();
		Loop;
	Deselect:
		DMLG A 1 A_Lower();
		Loop;
	Select:
		DMLG A 0 X_InitSplitTrigger();
		DMLG A 1 A_Raise();
		Loop;
	Fire:
		DMLG A 2 A_GunFlash();
		DMLF AB 2 Bright;
		DMLF C 2 Bright X_FireMissileLauncher();
		DMLF DE 2;
		DMLG C 6;
		DMLG B 3;
		DMLG A 3;
		DMLG A 0 A_ReFire();
		Goto Ready;
	Flash:
		TNT1 A 2 Bright A_Light(1);
		TNT1 A 2 Bright A_Light(2);
		TNT1 A 2 Bright A_Light(3);
		TNT1 A 2 Bright A_Light(2);
		TNT1 A 2 Bright A_Light(1);
		Goto LightDone;
	SplitTrigger:
		TNT1 A 1 X_CheckSplit();
		Loop;
	Spawn:
		DEML A -1;
		Stop;
	}

	action void X_FireMissileLauncher()
	{
		A_PlaySound("weapons/missilefire");
		X_FireSplitMissile(false, -2, 45);
		X_FireSplitMissile(true ,  2,-45);
	}

	action void X_FireSplitMissile(bool useAmmo, double spawnofs_xy, double splitAngle)
	{
		let missile = EriMissile(A_FireProjectile("EriMissile", 0, useAmmo, spawnofs_xy));
		if(missile) {
			missile.splitAngle = splitAngle;
			missile.master = self;
		}
	}

	action void X_InitSplitTrigger()
	{
		A_Overlay(SPLIT_TRIGGER_OVERLAY, "SplitTrigger");
	}

	action void X_CheckSplit()
	{
		if(self.player && (self.player.buttons & BT_ALTATTACK) && !(self.player.oldbuttons & BT_ALTATTACK)) {
			X_SplitMissiles();
		}
	}

	action void X_SplitMissiles()
	{
		// iterate through each missile that belongs to the player and split 'em.
		ThinkerIterator missileIterator = ThinkerIterator.Create("EriMissile");
		EriMissile missile;
		while(missile = EriMissile(missileIterator.Next() ) ) {
			if(missile.master == self) {
				missile.X_MissileSplit();
			}
		}
	}
}

class EriMissile : EriRocket
{
	int splitAngle;
	bool isSplit;

	Default
	{
		Speed 25;
		SeeSound "";
		DeathSound "weapons/missileexplode";
		Obituary "$OB_MPMISSILE";
		Damagetype "Missile";
		MaxTargetRange 64;
		+SEEKERMISSILE;
	}
	States
	{
	Spawn:
		XMIS A 0 Bright NoDelay A_PlaySound("weapons/missilefly", CHAN_BODY, 0.35, 1, ATTN_NORM);
		XMIS A 1 Bright X_MissileFly();
		Wait;
	Death:
		XMIS B 3 Bright X_MissileExplode();
		XMIS CDEFG 3 Bright;
		Stop;
	}

	void X_MissileFly()
	{
		if(self.isSplit) {
			A_SeekerMissile(8,8, SMF_LOOK | SMF_PRECISE, 256, 16);
		}
		A_SpawnItemEx("MissileTrail",0,0,0,-5,0,0,0,0);
	}

	void X_MissileSplit()
	{
		if(!self.isSplit) {
			A_PlaySound("weapons/missilelock", CHAN_AUTO, 0.5);
			self.angle += splitAngle;
			self.vel = (vel.x + (speed * cos(angle)), vel.y + (speed * sin(angle)), vel.z);
			self.isSplit = true;
		}
	}

	void X_MissileExplode()
	{
		// deal more damage post-split, a la ROTT
		A_Explode(self.isSplit ? 128 : 64, 128, 1);
		A_SetTranslucent(1.0,1);
	    A_StopSound(CHAN_BODY);
		self.isSplit = true; // to prevent being able to split an exploded missile.
	}
}<commit_msg>corrected split missile math stuffs<commit_after>// --------------------------------------------------------------------------
//
// Missile Launcher
//
// --------------------------------------------------------------------------

class EriMissileLauncher : EriWeapon
{
	const SPLIT_TRIGGER_OVERLAY = 10;

	Default
	{
		Weapon.SelectionOrder 2500;
		Weapon.AmmoUse 2;
		Weapon.AmmoGive 8;
		Weapon.AmmoType "RocketAmmo";
		Inventory.PickupMessage "$GOTMISSILE";
		Tag "$TAG_MISSILE";
		VisibleToPlayerClass "AltPlayer";
		Inventory.RestrictedTo "AltPlayer";
		+INVENTORY.RESTRICTABSOLUTELY;
		+WEAPON.NOAUTOFIRE;
	}
	States
	{
	Ready:
		DMLG A 1 A_WeaponReady();
		Loop;
	Deselect:
		DMLG A 1 A_Lower();
		Loop;
	Select:
		DMLG A 0 X_InitSplitTrigger();
		DMLG A 1 A_Raise();
		Loop;
	Fire:
		DMLG A 2 A_GunFlash();
		DMLF AB 2 Bright;
		DMLF C 2 Bright X_FireMissileLauncher();
		DMLF DE 2;
		DMLG C 6;
		DMLG B 3;
		DMLG A 3;
		DMLG A 0 A_ReFire();
		Goto Ready;
	Flash:
		TNT1 A 2 Bright A_Light(1);
		TNT1 A 2 Bright A_Light(2);
		TNT1 A 2 Bright A_Light(3);
		TNT1 A 2 Bright A_Light(2);
		TNT1 A 2 Bright A_Light(1);
		Goto LightDone;
	SplitTrigger:
		TNT1 A 1 X_CheckSplit();
		Loop;
	Spawn:
		DEML A -1;
		Stop;
	}

	action void X_FireMissileLauncher()
	{
		A_PlaySound("weapons/missilefire");
		X_FireSplitMissile(false, -2, 45);
		X_FireSplitMissile(true ,  2,-45);
	}

	action void X_FireSplitMissile(bool useAmmo, double spawnofs_xy, double splitAngle)
	{
		let missile = EriMissile(A_FireProjectile("EriMissile", 0, useAmmo, spawnofs_xy));
		if(missile) {
			missile.splitAngle = splitAngle;
			missile.master = self;
		}
	}

	action void X_InitSplitTrigger()
	{
		A_Overlay(SPLIT_TRIGGER_OVERLAY, "SplitTrigger");
	}

	action void X_CheckSplit()
	{
		if(self.player && (self.player.buttons & BT_ALTATTACK) && !(self.player.oldbuttons & BT_ALTATTACK)) {
			X_SplitMissiles();
		}
	}

	action void X_SplitMissiles()
	{
		// iterate through each missile that belongs to the player and split 'em.
		ThinkerIterator missileIterator = ThinkerIterator.Create("EriMissile");
		EriMissile missile;
		while(missile = EriMissile(missileIterator.Next() ) ) {
			if(missile.master == self) {
				missile.X_MissileSplit();
			}
		}
	}
}

class EriMissile : EriRocket
{
	int splitAngle;
	bool isSplit;

	Default
	{
		Speed 25;
		SeeSound "";
		DeathSound "weapons/missileexplode";
		Obituary "$OB_MPMISSILE";
		Damagetype "Missile";
		MaxTargetRange 64;
		+SEEKERMISSILE;
	}
	States
	{
	Spawn:
		XMIS A 0 Bright NoDelay A_PlaySound("weapons/missilefly", CHAN_BODY, 0.35, 1, ATTN_NORM);
		XMIS A 1 Bright X_MissileFly();
		Wait;
	Death:
		XMIS B 3 Bright X_MissileExplode();
		XMIS CDEFG 3 Bright;
		Stop;
	}

	void X_MissileFly()
	{
		if(self.isSplit) {
			A_SeekerMissile(8,8, SMF_LOOK | SMF_PRECISE, 256, 16);
		}
		A_SpawnItemEx("MissileTrail",0,0,0,-5,0,0,0,0);
	}

	void X_MissileSplit()
	{
		if(!self.isSplit) {
			A_PlaySound("weapons/missilelock", CHAN_AUTO, 0.5);
			self.angle += splitAngle;
			self.vel = (speed * cos(angle), speed * sin(angle), vel.z);
			self.isSplit = true;
		}
	}

	void X_MissileExplode()
	{
		// deal more damage post-split, a la ROTT
		A_Explode(self.isSplit ? 128 : 64, 128, 1);
		A_SetTranslucent(1.0,1);
		A_StopSound(CHAN_BODY);
		self.isSplit = true; // to prevent being able to split an exploded missile.
	}
}
{'fraction_non_alphanumeric': 0.16087151171466946, 'fraction_numerical': 0.025667810774511267, 'mean_word_length': 3.1015911872705018, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5446554', 'n_tokens_mistral': 3089, 'n_tokens_neox': 2694, 'n_words': 586}