Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Фикс зомбей #258

Merged
merged 9 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Content.Server/Zombies/ZombieSystem.Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void ZombifyEntity(EntityUid target, MobStateComponent? mobState = null)
{
{ "Slash", 15 },
{ "Piercing", 15 },
{ "Structural", 150 } // Sunrise-Edit
{ "Structural", 15 } // Sunrise-Edit
}
};
melee.Damage = dspec;
Expand Down
59 changes: 57 additions & 2 deletions Content.Server/Zombies/ZombieSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Linq;
using System.Text.RegularExpressions; // Sunrise
using Content.Server.Actions;
using Content.Server.Body.Systems;
using Content.Server.Chat;
using Content.Server.Chat.Systems;
using Content.Server.Emoting.Systems;
using Content.Server.Pinpointer; // Sunrise
using Content.Server.Speech.EntitySystems;
using Content.Shared.Bed.Sleep;
using Content.Shared.Cloning;
Expand All @@ -20,6 +22,7 @@
using Content.Shared.Throwing;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Zombies;
using Robust.Server.GameObjects; // Sunrise
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
Expand All @@ -44,6 +47,8 @@ public sealed partial class ZombieSystem : SharedZombieSystem
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly NavMapSystem _navMap = default!; // Sunrise-Zombies
[Dependency] private readonly TransformSystem _transform = default!; // Sunrise-Zombies

public const SlotFlags ProtectiveSlots =
SlotFlags.FEET |
Expand Down Expand Up @@ -91,6 +96,9 @@ private void OnThrowDoHit(EntityUid uid, ZombieComponent component, ThrowDoHitEv
return;
if (!_mobState.IsAlive(args.Target))
return;
if (_timing.CurTime - component.LastThrowHit < component.ThrowHitDelay)
return;
component.LastThrowHit = _timing.CurTime;

_stun.TryParalyze(args.Target, TimeSpan.FromSeconds(component.ParalyzeTime), false);
_damageable.TryChangeDamage(args.Target, component.Damage, origin: args.Thrown);
Expand All @@ -101,12 +109,54 @@ private void OnFlair(EntityUid uid, ZombieComponent component, ZombieFlairAction
if (args.Handled)
return;

_popup.PopupEntity("Мне было лень это делать, напишите админам, пускай скажут вам где выжившие.",
uid, uid, PopupType.LargeCaution);
var zombieXform = Transform(uid);
EntityUid? nearestUid = default!;
TransformComponent? nearestXform = default!;
float? minDistance = null;
var query = AllEntityQuery<HumanoidAppearanceComponent>();
while (query.MoveNext(out var targetUid, out var humanoidAppearanceComponent))
{
// Зомби не должны чувствовать тех, у кого иммунитет к ним.
if (HasComp<ZombieComponent>(targetUid) || HasComp<ZombieImmuneComponent>(targetUid))
continue;
var xform = Transform(targetUid);

// Почему бы и нет, оптимизация наху
var distance = Math.Abs(zombieXform.Coordinates.X - xform.Coordinates.X) +
Math.Abs(zombieXform.Coordinates.Y - xform.Coordinates.Y);

if (distance > component.MaxFlairDistance)
continue;

if (minDistance == null || nearestUid == null || minDistance > distance)
{
nearestUid = targetUid;
minDistance = distance;
nearestXform = xform;
}
}

if (nearestUid == null || nearestUid == default!)
{
_popup.PopupEntity($"Ближайших выживших не найдено.", uid, uid, PopupType.LargeCaution);
}
else
{
_popup.PopupEntity($"Ближайший выживший находится {RemoveColorTags(_navMap.GetNearestBeaconString(nearestUid.Value))}", uid, uid, PopupType.LargeCaution);
}

args.Handled = true;
}

private string RemoveColorTags(string input)
{
// Регулярное выражение для поиска тэгов [color=...] и [/color]
var pattern = @"\[\s*\/?\s*color(?:=[^\]]*)?\]";
// Заменяем найденные тэги на пустую строку
var result = Regex.Replace(input, pattern, string.Empty, RegexOptions.IgnoreCase);
return result;
}

private void OnJump(EntityUid uid, ZombieComponent component, ZombieJumpActionEvent args)
{
if (args.Handled)
Expand All @@ -125,6 +175,11 @@ private void OnJump(EntityUid uid, ZombieComponent component, ZombieJumpActionEv
var mapCoords = args.Target.ToMap(EntityManager);
var direction = mapCoords.Position - xform.MapPosition.Position;

if (direction.Length() > component.MaxThrow)
{
direction = direction.Normalized() * component.MaxThrow;
}

_throwing.TryThrow(uid, direction, 7F, uid, 10F);
_chatSystem.TryEmoteWithChat(uid, "ZombieGroan");
}
Expand Down
34 changes: 26 additions & 8 deletions Content.Shared/Zombies/ZombieComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed partial class ZombieComponent : Component
public float MinZombieInfectionChance = 0.6f; // Sunrise-Edit

[ViewVariables(VVAccess.ReadWrite)]
public float ZombieMovementSpeedBuff = 1.3f; // Sunrise-Edit
public float ZombieMovementSpeedBuff = 1f; // Sunrise-Edit

/// <summary>
/// The skin color of the zombie
Expand Down Expand Up @@ -100,9 +100,9 @@ public sealed partial class ZombieComponent : Component
{
DamageDict = new ()
{
{ "Blunt", -2.5 }, // Sunrise-Edit
{ "Slash", -2.5 }, // Sunrise-Edit
{ "Piercing", -2.5 }, // Sunrise-Edit
{ "Blunt", -5 }, // Sunrise-Edit
{ "Slash", -5 }, // Sunrise-Edit
{ "Piercing", -5 }, // Sunrise-Edit
{ "Heat", -0.02 },
{ "Shock", -0.02 }
}
Expand All @@ -112,7 +112,7 @@ public sealed partial class ZombieComponent : Component
/// A multiplier applied to <see cref="PassiveHealing"/> when the entity is in critical condition.
/// </summary>
[DataField("passiveHealingCritMultiplier")]
public float PassiveHealingCritMultiplier = 5f; // Sunrise-Edit
public float PassiveHealingCritMultiplier = 2f; // Sunrise-Edit

/// <summary>
/// Healing given when a zombie bites a living being.
Expand All @@ -122,9 +122,9 @@ public sealed partial class ZombieComponent : Component
{
DamageDict = new()
{
{ "Blunt", -5 }, // Sunrise-Edit
{ "Slash", -5 }, // Sunrise-Edit
{ "Piercing", -5 } // Sunrise-Edit
{ "Blunt", -2 }, // Sunrise-Edit
{ "Slash", -2 }, // Sunrise-Edit
{ "Piercing", -2 } // Sunrise-Edit
}
};

Expand Down Expand Up @@ -170,5 +170,23 @@ public sealed partial class ZombieComponent : Component
{ "Slash", 30 },
},
};

/// <summary>
/// Нельзя пролететь через толпу и всех переубивать
/// </summary>
[DataField]
public TimeSpan? LastThrowHit;

[DataField]
public TimeSpan ThrowHitDelay = TimeSpan.FromSeconds(15);

[DataField]
public float MaxThrow = 10f;

/// <summary>
/// Зомби не должны чувствовать очень далеко.
/// </summary>
[DataField]
public float MaxFlairDistance = 300f;
// Sunrise-End
}
6 changes: 3 additions & 3 deletions Resources/Prototypes/Damage/modifier_sets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@
- type: damageModifierSet
id: Zombie #Blunt resistant and immune to biological threats, but can be hacked apart and burned
coefficients:
Blunt: 0.1
Piercing: 0.1
Cold: 0.1
Blunt: 0.2 # Sunrise-edit
Piercing: 0.2 # Surnise-edit
Cold: 0.2 # Sunrise-edit
Heat: 1.25
Poison: 0.0
Radiation: 0.0
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Voice/auto_emotes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
id: ZombieGroan
emote: Scream
interval: 5.0
chance: 0.8 # Sunrise-Edit
chance: 0.5 # Sunrise-Edit если ставить меньше, то от спама звуками голова болит
withChat: false
# Cluwne
- type: autoEmote
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/_Sunrise/Actions/zombie_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
components:
- type: WorldTargetAction
useDelay: 15
icon: _Sunrise/Zombie/Actions/test.png # TODO: Спрайты
icon: _Sunrise/Zombie/Actions/jump.png
itemIconStyle: NoItem
checkCanAccess: false
range: 200
Expand All @@ -16,6 +16,6 @@
components:
- type: InstantAction
useDelay: 15
icon: _Sunrise/Zombie/Actions/test.png # TODO: Спрайты
icon: _Sunrise/Zombie/Actions/the_look.png
itemIconStyle: NoItem
event: !type:ZombieFlairActionEvent
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading