//$GZDB_SKIP


//Sickles spawns a friendly monster that inmediately attacks other monsters with the same projecitle they shot you at.
//Simulates sickles returning the projectile behaviour, in an very hacky way that works with old sourceports.

//It requires custom projectiles in order to work properly though. That's why a vanilla alternate was made.
ACTOR Sickles_BlockDooskProjectileAttacks 
{
	Game Doom
//	SpawnID 4
	Health 2		//Should grant the monster to be killed in one hit.
	Radius 14		//How much space it covers from the center, reduced it to make it difficult.
	Height 60		//The height it covers. Zombieman sized.
	Speed 0			//It's not supposed to move.
	PainChance 256	//It should always go into pain/death state.
	Monster			//It's a monster.
	+FRIENDLY		//It's a friendly monster, so it theorically prevents the monster to attack you while also hoping it attacks other monsters instead. 
	-FLOORCLIP		// Can spawn mid-air, theorically.
	+FORCEPAIN		//In case that painchance 256 isn't enough.
	-COUNTKILL		//Doesn't mess up with monster count, therefore not breaking the cheevos.
	+noclip			//You can walk through it.
	+ALWAYSFAST		//reaction time is reduced
	+NOTRIGGER		//Disables all line actions for the actor.
	+DONTCORPSE		//Monster can't be crushed by ceiling.
	+NEVERRESPAWN	//Prevents the monster to respawn, even in Nightmare.
	-canusewalls	//Disables actor to activate unlocked doors and lifts.
	-ACTIVATEMCROSS	//This actor can no longer activate 'Monster crosses' lines.
	+NOBLOCKMONST	//Actor can go through monster blocking lines.
	+NOBLOOD
	+NOTIMEFREEZE

//Reflective flags not used on this particular actor. Some of them are set on child actors.

//Bunch of monster sounds are silenced, except its death sound.
	DeathSound "Sword/Deflect"

	SeeSound "sil/encio"
	AttackSound "Sil/Encio"
	PainSound "sil/encio"
	ActiveSound "sil/encio"

//In case it accidentally attack you.
	Obituary "$SICKGLITCH_OB"
	States
	{
//How does this works?

//Friendly monster stays there for 2 tics, hoping that it gets shot, else dies silently.
	Spawn:
	See:
		TNT1 A 0 /*NoDelay*/
		TNT1 AA 1 A_Chase
		Goto Death



//If the monster gets hit and a projectile with custom damagetype is detected, then atak.
//The monster who threw the projectile becomes the target.
	Death.ArachnoProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_ArachnotronPlasmaDeflect")//A_BspiAttack
		Goto XDeath

	Death.BruiserProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_BaronBallDeflect")//A_BruisAttack
		Goto XDeath
		
	Death.CacoProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_CacodemonBallDeflect")//A_HeadAttack
		Goto XDeath

	Death.CyberProj:
//		TNT1 A 0 Thing_ReMove(1998)
		TNT1 A 0 /*NoDelay*/ A_ChangeFlag("REFLECTIVE", true)
		TNT1 A 0 /*NoDelay*/ A_ChangeFlag("SHIELDREFLECT", true)

		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
//		POSS G 0 A_CustomMissile("Dusk_RocketDeflect")//A_CyberAttack
		Goto XDeath

	Death.DoomImpProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_DoomImpBallDeflect")//A_TroopAttack
		Goto XDeath
		
	Death.FatsoProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_FatShotDeflect")//A_BruisAttack
		Goto XDeath

	Death.ReveProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_RevenantTracerDeflect")//A_SkelMissile
		Goto XDeath


//Heretic variants
	Death.beastballProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_BeastBallDeflect")//A_BspiAttack
		Goto XDeath

	Death.Sorcfx1Proj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_SorcererFX1Deflect")//A_BspiAttack
		Goto XDeath

	Death.sorc2fx1Proj:
//		TNT1 A 0 Thing_ReMove(1998)
		TNT1 A 0 /*NoDelay*/ A_ChangeFlag("REFLECTIVE", true)
		TNT1 A 0 /*NoDelay*/ A_ChangeFlag("SHIELDREFLECT", true)

		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
//		POSS G 0 A_CustomMissile("Dusk_RocketDeflect")//A_CyberAttack
		Goto XDeath


	Death.sorc2fx2Proj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 //A_CustomMissile("Dusk_Sorcerer2FX2Deflect")//A_BruisAttack
		Goto XDeath
		
	Death.hereticimpProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_HereticImpBallDeflect")//A_HeadAttack
		Goto XDeath


	Death.knightaxeProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_KnightAxeDeflect")//A_TroopAttack
		Goto XDeath
		
	Death.redaxeProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 //A_CustomMissile("Dusk_RedAxeDeflect")//A_BruisAttack
		Goto XDeath

	Death.mummyfx1Proj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_MummyFX1Deflect")//A_SkelMissile
		Goto XDeath

	Death.snakeprojAProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_SnakeProjADeflect")//A_SkelMissile
		Goto XDeath

	Death.snakeprojBProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_SnakeprojBDeflect")//A_SkelMissile
		Goto XDeath

	Death.wizFX1Proj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Dusk_WizardFX1Deflect")//A_SkelMissile
		Goto XDeath



//Dusk deflects
	Death.SoldierProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Soldier_BulletDeflect")
		Goto XDeath
	Death.PhillipProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Phillip_SpitDeflect")
		Goto XDeath
	Death.WelderProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Welder_BallDeflect")
		Goto XDeath
	Death.MonkProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("bonemonk_ballDeflect")
		Goto XDeath
	Death.MageProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("mage_ballDeflect")
		Goto XDeath
	Death.RedMageProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("redmage_ballDeflect")
		Goto XDeath
	Death.ForkMProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("forkm_ballDeflect")
		Goto XDeath
	Death.BoneballProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Boneball_ballDeflect")
		Goto XDeath
	Death.BigJohnBulProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("BigJohn_bulletDeflect")
		Goto XDeath
	Death.ChomperProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Chomper_spitDeflect")
		Goto XDeath
	Death.ElcocoProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		POSS G 0 A_CustomMissile("Intoxigator_spitDeflect")
		Goto XDeath





		
//Else, proceed to die without attacking/making a sound.
	Death:
	XDeath:
		TNT1 A 0 A_NoBlocking
		TNT1 A 1 //Thing_ReMove(1998)
		Stop
	}
}









//Simulates sickles returning the projectile behaviour, in an even more rudimentary way that works with all projectiles at expenses of accuracy.
ACTOR Sickles_BlockProjectileAttacks : Sickles_BlockDooskProjectileAttacks
{

	+REFLECTIVE 	//make actor reflective
	+SHIELDREFLECT 	//Only reflects in front of the actor.(+/-45 random degrees)
//	+AIMREFLECT		//Perfect for modern gzdoom, but I don't work with modern sourceports.

	DeathSound "Sword/Deflect"
	States
	{
//How does this works?

//Friendly monster stays there for 2 tics, hoping that it gets shot, else dies.
	Spawn:
	See:
		TNT1 A 0 /*NoDelay*/
		TNT1 AA 1 A_Chase
		Goto Death



//If the monster gets hit it should reflect the projectile at random +/-45 degrees. Then goes to death.
	Death.ArachnoProj:
	Death.BruiserProj:
	Death.CacoProj:
	Death.CyberProj:
	Death.DoomImpProj:
	Death.FatsoProj:
	Death.ReveProj:
//Heretic deflects
	Death.beastballProj:
	Death.SorcFX1Proj:
	Death.Sorc2FX2Proj:
	Death.HereticImpProj:
	Death.KnightAxeProj:
	Death.RedAxeProj:
	Death.MummyFX1Proj:
	Death.SnakeprojaProj:
	Death.SnakeprojbProj:
	Death.WizFX1Proj:
//Dusk deflects
	Death.SoldierProj:
	Death.PhillipProj:
	Death.WelderProj:
	Death.MonkProj:
	Death.MageProj:
	Death.RedMageProj:
	Death.ForkMProj:
	Death.BoneballProj:
	Death.BigJohnBulProj:
	Death.ChomperProj:
	Death.ElcocoProj:
//	Death.Proj:

	TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath

		
//Else, proceed to die without attacking/making a sound.
	Death:
	XDeath:
		TNT1 A 0 A_NoBlocking
		TNT1 A 1
		Stop
	}
}








//Simplified code. It only blocks projectiles and doesn't fight back.
//Who needs projectile deflection after all?
ACTOR Sickles_BlockProjectileOnly : Sickles_BlockDooskProjectileAttacks
{
	-Noblood
//	-REFLECTIVE 
//	-SHIELDREFLECT 	

	DeathSound "Sword/Deflect"
	States
	{
	Spawn:
	See:
		TNT1 A 0 /*NoDelay*/
		TNT1 AA 1 A_Chase
		Goto Death


	Death.ArachnoProj:
	Death.BruiserProj:
	Death.CacoProj:
//	Death.CyberProj:
	Death.DoomImpProj:
	Death.FatsoProj:
	Death.ReveProj:
//Heretic deflects
	Death.beastballProj:
	Death.SorcFX1Proj:
	Death.Sorc2FX2Proj:
	Death.HereticImpProj:
	Death.KnightAxeProj:
	Death.RedAxeProj:
	Death.MummyFX1Proj:
	Death.SnakeprojaProj:
	Death.SnakeprojbProj:
	Death.WizFX1Proj:
//Dusk deflects
	Death.SoldierProj:
	Death.PhillipProj:
	Death.WelderProj:
	Death.MonkProj:
	Death.MageProj:
	Death.RedMageProj:
	Death.ForkMProj:
	Death.BoneballProj:
	Death.BigJohnBulProj:
	Death.ChomperProj:
	Death.ElcocoProj:
//	Death.Proj:

	TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath

	Death:
	XDeath:
		TNT1 A 0 A_NoBlocking
		TNT1 A 1
		Stop
	}
}



//Uses code from modern gzdoom. Doesn't work with old gzdoom, but it works with all projectiles.
ACTOR Sickles_AimReflectProjectileAttacks : Sickles_BlockDooskProjectileAttacks
{

//Reflections are set through changeflag to prevent game crashes on older sourceports.
//	+AIMREFLECT		//Perfect for modern gzdoom, but I don't work with modern sourceports.

	DeathSound "Sword/Deflect"

	States
	{
//How does this works?

//Friendly monster stays there for 2 tics, hoping that it gets shot, else dies.
	Spawn:
	See:
		TNT1 A 0 /*NoDelay*/ A_ChangeFlag("REFLECTIVE", true)
		TNT1 A 0 A_ChangeFlag("SHIELDREFLECT", true)
		TNT1 A 0 A_ChangeFlag("AIMREFLECT", true)//It works with modern gzdoom only.
		TNT1 AA 1 A_Chase
		Goto Death


//Doom deflects
	Death.ArachnoProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.BruiserProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.CacoProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.DoomImpProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.CyberProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.FatsoProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.ReveProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath

//Heretic deflects
	Death.beastballProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.SorcFX1Proj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.Sorc2FX2Proj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.HereticImpProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.KnightAxeProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.RedAxeProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.MummyFX1Proj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.SnakeprojaProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.SnakeprojbProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.WizFX1Proj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath


//Dusk deflects
	Death.SoldierProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.PhillipProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.WelderProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.MonkProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.MageProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.RedMageProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.ForkMProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.BoneballProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.BigJohnBulProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.ChomperProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath
	Death.ElcocoProj:
		TNT1 A 0 A_NoBlocking
		POSS G 0 A_Scream
		Goto XDeath





		
//Else, proceed to die without attacking/making a sound.
	Death:
	XDeath:
		TNT1 A 0 A_NoBlocking
		TNT1 A 1
		Stop
	}

}










