Improved revolver hitreg, shooting structures affects karma, fixed 5th server being blocked in server list
Closes #70
This commit is contained in:
@@ -96,7 +96,7 @@ namespace Barotrauma
|
||||
|
||||
int y = 180;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 30), "Filter servers:", "", menu);
|
||||
new GUITextBlock(new Rectangle(0, y, 200, 30), "Filter servers:", "", menu);
|
||||
searchBox = new GUITextBox(new Rectangle(0, y + 30, 200, 30), "", menu);
|
||||
searchBox.OnTextChanged += (txtBox, txt) => { FilterServers(); return true; };
|
||||
filterPassword = new GUITickBox(new Rectangle(0, y + 60, 30, 30), "No password required", Alignment.TopLeft, menu);
|
||||
|
||||
@@ -1524,7 +1524,7 @@ namespace Barotrauma
|
||||
speechBubbleColor = color;
|
||||
}
|
||||
|
||||
public virtual void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker)
|
||||
private void AdjustKarma(IDamageable attacker,float amount)
|
||||
{
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
@@ -1546,7 +1546,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker)
|
||||
{
|
||||
Health = health-amount;
|
||||
if (amount > 0.0f)
|
||||
{
|
||||
@@ -1554,6 +1557,7 @@ namespace Barotrauma
|
||||
|
||||
DamageHUD(amount);
|
||||
}
|
||||
AdjustKarma(attacker, amount);
|
||||
if (health <= minHealth) Kill(causeOfDeath);
|
||||
}
|
||||
partial void DamageHUD(float amount);
|
||||
|
||||
@@ -139,6 +139,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
subs = new Submarine[] { Submarine.MainSubs[0], Submarine.MainSubs[1] };
|
||||
subs[0].TeamID = 1; subs[1].TeamID = 2;
|
||||
subs[1].SetPosition(Level.Loaded.EndPosition - new Vector2(0.0f, 2000.0f));
|
||||
subs[1].FlipX();
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 rayStart = item.SimPosition;
|
||||
Vector2 rayEnd = item.SimPosition + dir * 1000.0f;
|
||||
|
||||
bool hitSomething = false;
|
||||
List<Tuple<Fixture, Vector2, Vector2>> hits = new List<Tuple<Fixture, Vector2, Vector2>>();
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
{
|
||||
if (fixture == null || fixture.IsSensor) return -1;
|
||||
@@ -150,14 +150,34 @@ namespace Barotrauma.Items.Components
|
||||
!fixture.CollisionCategories.HasFlag(Physics.CollisionWall) &&
|
||||
!fixture.CollisionCategories.HasFlag(Physics.CollisionLevel)) return -1;
|
||||
|
||||
/*item.body.SetTransform(point, rotation);
|
||||
if (OnProjectileCollision(fixture, normal))
|
||||
{
|
||||
Character.Controlled.AnimController.Teleport(point - Character.Controlled.SimPosition, Vector2.Zero);
|
||||
hitSomething = true;
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
hits.Add(new Tuple<Fixture, Vector2, Vector2>(fixture,point,normal));
|
||||
|
||||
return hits.Count<25 ? 1 : 0;
|
||||
}, rayStart, rayEnd);
|
||||
|
||||
bool hitSomething = false;
|
||||
hits = hits.OrderBy(t => Vector2.DistanceSquared(rayStart, t.Item2)).ToList();
|
||||
foreach (Tuple<Fixture, Vector2, Vector2> t in hits)
|
||||
{
|
||||
Fixture fixture = t.Item1;
|
||||
Vector2 point = t.Item2;
|
||||
Vector2 normal = t.Item3;
|
||||
item.body.SetTransform(point, rotation);
|
||||
if (OnProjectileCollision(fixture, normal))
|
||||
{
|
||||
hitSomething = true;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}, rayStart, rayEnd);
|
||||
//Character.Controlled.AnimController.Teleport(point - Character.Controlled.SimPosition, Vector2.Zero);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//the raycast didn't hit anything -> the projectile flew somewhere outside the level and is permanently lost
|
||||
if (!hitSomething)
|
||||
|
||||
@@ -139,6 +139,14 @@ namespace Barotrauma
|
||||
get { return prefab.InteractPriority; }
|
||||
}
|
||||
|
||||
public override Vector2 Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return (body == null) ? base.Position : ConvertUnits.ToDisplayUnits(SimPosition);
|
||||
}
|
||||
}
|
||||
|
||||
public override Vector2 SimPosition
|
||||
{
|
||||
get
|
||||
|
||||
@@ -555,7 +555,7 @@ namespace Barotrauma
|
||||
return (isHorizontal ? sections[sectionIndex].rect.Width : sections[sectionIndex].rect.Height);
|
||||
}
|
||||
|
||||
public void AddDamage(int sectionIndex, float damage)
|
||||
public void AddDamage(int sectionIndex, float damage, IDamageable attacker=null)
|
||||
{
|
||||
if (!prefab.Body || prefab.Platform) return;
|
||||
|
||||
@@ -580,7 +580,7 @@ namespace Barotrauma
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GameMain.Client == null) SetDamage(sectionIndex, section.damage + damage);
|
||||
if (GameMain.Client == null) SetDamage(sectionIndex, section.damage + damage, attacker);
|
||||
}
|
||||
|
||||
public int FindSectionIndex(Vector2 displayPos)
|
||||
@@ -622,6 +622,27 @@ namespace Barotrauma
|
||||
return sectionPos;
|
||||
}
|
||||
|
||||
private void AdjustKarma(IDamageable attacker, float amount)
|
||||
{
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
if (Submarine == null) return;
|
||||
if (attacker == null) return;
|
||||
if (attacker is Character)
|
||||
{
|
||||
Character attackerCharacter = attacker as Character;
|
||||
Barotrauma.Networking.Client attackerClient = GameMain.Server.ConnectedClients.Find(c => c.Character == attackerCharacter);
|
||||
if (attackerClient != null)
|
||||
{
|
||||
if (attackerCharacter.TeamID == Submarine.TeamID)
|
||||
{
|
||||
attackerClient.Karma -= amount * 0.001f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false)
|
||||
{
|
||||
if (Submarine != null && Submarine.GodMode) return new AttackResult(0.0f, 0.0f);
|
||||
@@ -635,7 +656,7 @@ namespace Barotrauma
|
||||
|
||||
float damageAmount = attack.GetStructureDamage(deltaTime);
|
||||
|
||||
AddDamage(i, damageAmount);
|
||||
AddDamage(i, damageAmount, attacker);
|
||||
|
||||
#if CLIENT
|
||||
GameMain.ParticleManager.CreateParticle("dustcloud", SectionPosition(i), 0.0f, 0.0f);
|
||||
@@ -650,18 +671,21 @@ namespace Barotrauma
|
||||
return new AttackResult(damageAmount, 0.0f);
|
||||
}
|
||||
|
||||
private void SetDamage(int sectionIndex, float damage)
|
||||
private void SetDamage(int sectionIndex, float damage, IDamageable attacker=null)
|
||||
{
|
||||
if (Submarine != null && Submarine.GodMode) return;
|
||||
if (!prefab.Body) return;
|
||||
|
||||
if (!MathUtils.IsValid(damage)) return;
|
||||
|
||||
float damageDiff = damage - sections[sectionIndex].damage;
|
||||
|
||||
if (GameMain.Server != null && damage != sections[sectionIndex].damage)
|
||||
{
|
||||
GameMain.Server.CreateEntityEvent(this);
|
||||
}
|
||||
|
||||
|
||||
AdjustKarma(attacker, damageDiff);
|
||||
if (damage < prefab.MaxHealth*0.5f)
|
||||
{
|
||||
if (sections[sectionIndex].gap != null)
|
||||
@@ -685,6 +709,7 @@ namespace Barotrauma
|
||||
gapRect.Height += 20;
|
||||
sections[sectionIndex].gap = new Gap(gapRect, !isHorizontal, Submarine);
|
||||
sections[sectionIndex].gap.ConnectedWall = this;
|
||||
AdjustKarma(attacker, 300);
|
||||
#if CLIENT
|
||||
if(CastShadow) GenerateConvexHull();
|
||||
#endif
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace Barotrauma
|
||||
|
||||
partial class Submarine : Entity, IServerSerializable
|
||||
{
|
||||
public byte TeamID = 1;
|
||||
|
||||
public static string SavePath = "Submarines";
|
||||
|
||||
public static readonly Vector2 HiddenSubStartPosition = new Vector2(-50000.0f, 10000.0f);
|
||||
|
||||
Reference in New Issue
Block a user