things/enemies/SpitterSpecial.cs
using Sandbox;
public class SpitterSpecial : Spitter
{
protected override void OnAwake()
{
base.OnAwake();
Health = 165f;
MaxHealth = Health;
Radius = 0.35f;
Scale = 1.3f;
Sprite.LocalScale = new Vector3( Scale * Game.Random.Float( 1f - HeightVariance, 1f + HeightVariance ), Scale * Game.Random.Float( 1f - WidthVariance, 1f + WidthVariance ), 1f ) * Globals.SPRITE_SCALE;
ShadowScale = 1.3f;
ShadowSpriteDirty = true;
ShootRange = 8f;
PushStrength = 45f;
SHOOT_DELAY_MIN = 4f;
SHOOT_DELAY_MAX = 12f;
CoinChance = 1f;
CoinValueMin = 3;
CoinValueMax = 7;
AggroRange = 1f;
}
protected override Vector2 GetTargetPos()
{
if(IsAttacking)
return base.GetTargetPos();
if(Target.IsValid() && Target.Velocity.LengthSquared > 0f)
{
var rangeSqr = (Target.Position2D - Position2D).LengthSquared;
if ( rangeSqr > 6f * 6f )
return Target.Position2D;
return Position2D + Utils.GetPerpendicularVector( Target.Velocity ) * (Target.Position2D.x < Position2D.x ? -1f : 1f);
}
return Position2D - Velocity;
//return (IsCharmed ? Manager.Instance.Player.Position2D : Position2D);
}
public override void Shoot()
{
var target_pos = Target.IsValid() ? Target.Position2D + Target.Velocity * Game.Random.Float( 0.5f, 1.5f ) : Position2D + Utils.GetRandomVector() * 5f;
var dir = Utils.RotateVector( (target_pos - Position2D).Normal, Game.Random.Float( -10f, 10f ) );
//Manager.Instance.SpawnEnemyBullet( Position2D + new Vector2( 0f, 0.45f ) + dir * 0.05f, dir, speed: 2f );
var bullet = Manager.Instance.SpawnEnemyBullet( Position2D + dir * 0.05f, dir, speed: 2f );
//bullet.Radius = 0.11f;
if ( IsCharmed )
{
bullet.Creator = this;
bullet.BecomeCharmed();
}
if(Target.IsValid())
{
bullet.SetColor( new Color( 1f, 0f, 1f ) );
bullet.BecomeHoming( dir * 3f, Target);
}
bullet.Damage = 7f;
Velocity *= 0.25f;
_hasShot = true;
Manager.Instance.PlaySfxNearby( "spitter.shoot", Position2D, pitch: Game.Random.Float( 0.8f, 0.9f ), volume: 0.9f, maxDist: 5f );
Sprite.PlayAnimation( "shoot_reverse" );
}
}