<commit_before>//------------------------------------------------------------------------------
// Revenge Of The Cats: Ethernet
// Copyright (C) 2008, mEthLab Interactive
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Revenge Of The Cats - disc.seeker.cs
// Target-seeking disc projectile
//------------------------------------------------------------------------------

exec("./disc.seeker.gfx.red.cs");
exec("./disc.seeker.gfx.blue.cs");

//-----------------------------------------------------------------------------
// projectile datablock...

datablock NortDiscData(RedSeekerDisc)
{
	stat = "seeker";

	// script damage properties...
	impactDamage       = 0;
	impactImpulse      = 0;
	splashDamage       = 0;
	splashDamageRadius = 0;
	splashImpulse      = 0;
	
	energyDrain = 0; // how much energy does firing this projectile drain?

	sound = DiscProjectileSound;
	
	targetLockTimeMS = 0;

	maxTrackingAbility = 1000;
	trackingAgility = 2;

	explodesNearEnemies = false;
	explodesNearEnemiesRadius = 5;

	muzzleVelocity		= 30;
    maxVelocity         = 75;
    acceleration        = 4;
	velInheritFactor	 = 0.0;

	armingDelay			= 0*1000;
	lifetime				= 10*1000;
	fadeDelay			  = 3*1000;

	isBallistic = true;
	gravityMod			 = 1.0;
	bounceElasticity	 = 0.99;
	bounceFriction		 = 0.0;
    numBounces           = 3;

	projectileShapeName = "share/shapes/rotc/weapons/disc/projectile_red.dts";

	explosion             = RedSeekerDiscExplosion;
	hitEnemyExplosion     = RedSeekerDiscExplosion;
// nearEnemyExplosion	 = ThisDoesNotExist;
	hitTeammateExplosion  = RedSeekerDiscHitEnemy;
	hitDeflectorExplosion = RedSeekerDiscDeflectedEffect;
	bounceExplosion       = RedSeekerDiscHit;

	laserTrail[0]		= RedSeekerDiscInnerLaserTrail;
	laserTrail[1]		= RedSeekerDiscOuterLaserTrail;
	
	decals[0] = SlashDecalOne;

	hasLight	 = true;
	lightRadius = 10.0;
	lightColor  = "1.0 0.0 0.0";
 
    startVertical = true;
};

function RedSeekerDisc::onAdd(%this,%obj)
{
	Parent::onAdd(%this,%obj);
    %obj.setTargetingMask($TargetingMask::Disc);
}

function RedSeekerDisc::onRemove(%this,%obj)
{
	Parent::onRemove(%this,%obj);
    if(%obj.state() == $NortDisc::Attacking)
        %obj.getTarget().removeAttackingDisc(%obj);

	%source = %obj.sourceObject;
	%source.incDiscs();
}

function RedSeekerDisc::onCollision(%this,%obj,%col,%fade,%pos,%normal,%dist)
{
	Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal,%dist);

	if( !(%col.getType() & $TypeMasks::ShapeBaseObjectType) )
		return;

	if(%col.getType() & $TypeMasks::PlayerObjectType)
	{
 		// collision with player:
		// give 20 points of energy to the attacker...
		%source = %obj.sourceObject;
		if(%source.getDamageState() $= "Enabled")
			%source.setEnergyLevel(%source.getEnergyLevel() + 20);

		// remove possible barrier from enemy...
		%col.deactivateBarrier();

		// remove enemy's anchoring...
		%col.setGridConnection(0);

		// push enemy away from player...
		%vec = VectorSub(%col.getPosition(), %source.getPosition());
		%vec = VectorNormalize(%vec);
		%vec = getWord(%vec,0) SPC getWord(%vec,1) SPC "0.5";
		//%vec = "0 0 1";
		%vec = VectorScale(%vec, 3000);
		%col.impulse(%col.getPosition(), %vec);
   
        // give another disc-lock to the attacker
//        %src =  %obj.getSourceObject();
//        if(%src)
//            %src.setDiscTarget(%col);
	}
}

function RedSeekerDisc::onDeflected(%this, %obj)
{
    if(%obj.state() == $NortDisc::Attacking)
        %obj.getTarget().removeAttackingDisc(%obj);
}

function RedSeekerDisc::onHitTarget(%this, %obj)
{
    %obj.getTarget().removeAttackingDisc(%obj);
    %obj.stopAttacking();
}

function RedSeekerDisc::onMissedTarget(%this, %obj)
{
    if(%obj.state() == $NortDisc::Attacking)
        %obj.getTarget().removeAttackingDisc(%obj);

    %obj.stopAttacking();
}

function RedSeekerDisc::onLostTarget(%this, %obj)
{
    %obj.stopAttacking();
}

//-----------------------------------------------------------------------------

datablock NortDiscData(BlueSeekerDisc : RedSeekerDisc)
{
	projectileShapeName = "share/shapes/rotc/weapons/disc/projectile_blue.dts";

	explosion             = BlueSeekerDiscExplosion;
	hitEnemyExplosion     = BlueSeekerDiscExplosion;
	hitTeammateExplosion  = BlueSeekerDiscHitEnemy;
	hitDeflectorExplosion = BlueSeekerDiscDeflectedEffect;
	bounceExplosion       = BlueSeekerDiscHit;

	laserTrail[0]		= BlueSeekerDiscInnerLaserTrail;
	laserTrail[1]		= BlueSeekerDiscOuterLaserTrail;

	fxLight				 = BlueSeekerDiscFxLight;

	hasLight	 = true;
	lightRadius = 10.0;
	lightColor  = "0.0 0.0 1.0";
};

function BlueSeekerDisc::onAdd(%this,%obj)
{
	RedSeekerDisc::onAdd(%this,%obj);
}

function BlueSeekerDisc::onRemove(%this,%obj)
{
	RedSeekerDisc::onRemove(%this,%obj);
}

function BlueSeekerDisc::onCollision(%this,%obj,%col,%fade,%pos,%normal,%dist)
{
	RedSeekerDisc::onCollision(%this,%obj,%col,%fade,%pos,%normal,%dist);
}

function BlueSeekerDisc::onDeflected(%this, %obj)
{<commit_msg>Make sure disc explosion appears on clients on disc hits.<commit_after>//------------------------------------------------------------------------------
// Revenge Of The Cats: Ethernet
// Copyright (C) 2008, mEthLab Interactive
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Revenge Of The Cats - disc.seeker.cs
// Target-seeking disc projectile
//------------------------------------------------------------------------------

exec("./disc.seeker.gfx.red.cs");
exec("./disc.seeker.gfx.blue.cs");

//-----------------------------------------------------------------------------
// projectile datablock...

datablock NortDiscData(RedSeekerDisc)
{
	stat = "seeker";

	// script damage properties...
	impactDamage       = 0;
	impactImpulse      = 0;
	splashDamage       = 0;
	splashDamageRadius = 0;
	splashImpulse      = 0;
	
	energyDrain = 0; // how much energy does firing this projectile drain?

	sound = DiscProjectileSound;
	
	targetLockTimeMS = 0;

	maxTrackingAbility = 1000;
	trackingAgility = 2;

	explodesNearEnemies = false;
	explodesNearEnemiesRadius = 5;

	muzzleVelocity		= 30;
    maxVelocity         = 75;
    acceleration        = 4;
	velInheritFactor	 = 0.0;

	armingDelay			= 0*1000;
	lifetime				= 10*1000;
	fadeDelay			  = 3*1000;

	isBallistic = true;
	gravityMod			 = 1.0;
	bounceElasticity	 = 0.99;
	bounceFriction		 = 0.0;
    numBounces           = 3;

	projectileShapeName = "share/shapes/rotc/weapons/disc/projectile_red.dts";

	explosion             = RedSeekerDiscExplosion;
	hitEnemyExplosion     = RedSeekerDiscHit;
// nearEnemyExplosion	 = ThisDoesNotExist;
	hitTeammateExplosion  = RedSeekerDiscHit;
	hitDeflectorExplosion = RedSeekerDiscDeflectedEffect;
	bounceExplosion       = RedSeekerDiscHit;

	laserTrail[0]		= RedSeekerDiscInnerLaserTrail;
	laserTrail[1]		= RedSeekerDiscOuterLaserTrail;
	
	decals[0] = SlashDecalOne;

	hasLight	 = true;
	lightRadius = 10.0;
	lightColor  = "1.0 0.0 0.0";
 
    startVertical = true;
};

function RedSeekerDisc::onAdd(%this,%obj)
{
	Parent::onAdd(%this,%obj);
    %obj.setTargetingMask($TargetingMask::Disc);
}

function RedSeekerDisc::onRemove(%this,%obj)
{
	Parent::onRemove(%this,%obj);
    if(%obj.state() == $NortDisc::Attacking)
        %obj.getTarget().removeAttackingDisc(%obj);

	%source = %obj.sourceObject;
	%source.incDiscs();
}

function RedSeekerDisc::onCollision(%this,%obj,%col,%fade,%pos,%normal,%dist)
{
	Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal,%dist);

	if( !(%col.getType() & $TypeMasks::ShapeBaseObjectType) )
		return;

	if(%col.getType() & $TypeMasks::PlayerObjectType)
	{
 		// collision with player:
		// give 20 points of energy to the attacker...
		%source = %obj.sourceObject;
		if(%source.getDamageState() $= "Enabled")
			%source.setEnergyLevel(%source.getEnergyLevel() + 20);

		// remove possible barrier from enemy...
		%col.deactivateBarrier();

		// remove enemy's anchoring...
		%col.setGridConnection(0);

		// push enemy away from player...
		%vec = VectorSub(%col.getPosition(), %source.getPosition());
		%vec = VectorNormalize(%vec);
		%vec = getWord(%vec,0) SPC getWord(%vec,1) SPC "0.5";
		//%vec = "0 0 1";
		%vec = VectorScale(%vec, 3000);
		%col.impulse(%col.getPosition(), %vec);

		createExplosion(%this.explosion, %pos, %normal);
   
        // give another disc-lock to the attacker
//        %src =  %obj.getSourceObject();
//        if(%src)
//            %src.setDiscTarget(%col);
	}
}

function RedSeekerDisc::onDeflected(%this, %obj)
{
    if(%obj.state() == $NortDisc::Attacking)
        %obj.getTarget().removeAttackingDisc(%obj);
}

function RedSeekerDisc::onHitTarget(%this, %obj)
{
    %obj.getTarget().removeAttackingDisc(%obj);
    %obj.stopAttacking();
}

function RedSeekerDisc::onMissedTarget(%this, %obj)
{
    if(%obj.state() == $NortDisc::Attacking)
        %obj.getTarget().removeAttackingDisc(%obj);

    %obj.stopAttacking();
}

function RedSeekerDisc::onLostTarget(%this, %obj)
{
    %obj.stopAttacking();
}

//-----------------------------------------------------------------------------

datablock NortDiscData(BlueSeekerDisc : RedSeekerDisc)
{
	projectileShapeName = "share/shapes/rotc/weapons/disc/projectile_blue.dts";

	explosion             = BlueSeekerDiscExplosion;
	hitEnemyExplosion     = BlueSeekerDiscHit;
	hitTeammateExplosion  = BlueSeekerDiscHit;
	hitDeflectorExplosion = BlueSeekerDiscDeflectedEffect;
	bounceExplosion       = BlueSeekerDiscHit;

	laserTrail[0]		= BlueSeekerDiscInnerLaserTrail;
	laserTrail[1]		= BlueSeekerDiscOuterLaserTrail;

	fxLight				 = BlueSeekerDiscFxLight;

	hasLight	 = true;
	lightRadius = 10.0;
	lightColor  = "0.0 0.0 1.0";
};

function BlueSeekerDisc::onAdd(%this,%obj)
{
	RedSeekerDisc::onAdd(%this,%obj);
}

function BlueSeekerDisc::onRemove(%this,%obj)
{
	RedSeekerDisc::onRemove(%this,%obj);
}

function BlueSeekerDisc::onCollision(%this,%obj,%col,%fade,%pos,%normal,%dist)
{
	RedSeekerDisc::onCollision(%this,%obj,%col,%fade,%pos,%normal,%dist);
}

function BlueSeekerDisc::onDeflected(%this, %obj)
{
{'fraction_non_alphanumeric': 0.22693364742834707, 'fraction_numerical': 0.01707891637220259, 'mean_word_length': 2.721329437545654, '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': '4313183', 'n_tokens_mistral': 3908, 'n_tokens_neox': 3346, 'n_words': 538}