-
Notifications
You must be signed in to change notification settings - Fork 242
[ADD] Zombie tweak and Add #2579
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
Open
CrimeMoot
wants to merge
6
commits into
AdventureTimeSS14:master
Choose a base branch
from
CrimeMoot:tweaxc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b047a0c
update zombie
CrimeMoot 12d0c2a
remove boots jump stun
CrimeMoot 68e4b37
revert base boots Shared jump
CrimeMoot e023536
fix end tweak
CrimeMoot 1d9fdaf
Update ZombieSystem.Transform.cs
CrimeMoot 7e19840
Merge branch 'master' into tweaxc
Darkiich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using Content.Shared.ADT.ZombieJump; | ||
|
|
||
| namespace Content.Client.ADT.ZombieJump; | ||
| public sealed partial class ZombieJumpSystem : SharedZombieJumpSystem | ||
| { | ||
| protected override void TryStunAndKnockdown(EntityUid uid, TimeSpan duration) | ||
| { | ||
| // На клиенте ничего не делаем | ||
| } | ||
| } |
101 changes: 101 additions & 0 deletions
101
Content.Server/ADT/ZombieJump/Operators/ZombieJumpAttackOperator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Content.Server.ADT.ZombieJump; | ||
| using Content.Server.ADT.ZombieJump.Preconditions; | ||
| using Content.Server.NPC; | ||
| using Content.Server.NPC.Components; | ||
| using Content.Server.NPC.HTN; | ||
| using Content.Server.NPC.HTN.PrimitiveTasks; | ||
| using Content.Shared.ADT.ZombieJump; | ||
| using Content.Shared.Mobs; | ||
| using Content.Shared.Mobs.Components; | ||
| using Content.Shared.Zombies; | ||
| using Robust.Shared.GameObjects; | ||
| using Robust.Shared.Map; | ||
| using Robust.Shared.Physics.Components; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Server.ADT.ZombieJump.Operators; | ||
| public sealed partial class ZombieJumpAttackOperator : HTNOperator | ||
| { | ||
| [Dependency] private readonly IEntityManager _entManager = default!; | ||
| [Dependency] private readonly IGameTiming _gameTiming = default!; | ||
|
|
||
| [DataField("targetKey", required: true)] | ||
| public string TargetKey = default!; | ||
|
|
||
| [DataField("cooldown")] | ||
| public float Cooldown = 10f; | ||
|
|
||
| private ZombieJumpSystem _jumpSystem = default!; | ||
|
|
||
| public override void Initialize(IEntitySystemManager sysManager) | ||
| { | ||
| base.Initialize(sysManager); | ||
| _jumpSystem = sysManager.GetEntitySystem<ZombieJumpSystem>(); | ||
| } | ||
|
|
||
| public override void Startup(NPCBlackboard blackboard) | ||
| { | ||
| base.Startup(blackboard); | ||
|
|
||
| var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner); | ||
|
|
||
| if (!blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entManager)) | ||
| return; | ||
|
|
||
| if (!_entManager.EntityExists(target)) | ||
| return; | ||
|
|
||
| if (!_entManager.TryGetComponent<ZombieJumpComponent>(owner, out var jumpComp)) | ||
| return; | ||
|
|
||
| if (!_entManager.TryGetComponent<TransformComponent>(owner, out var ownerXform) || | ||
| !_entManager.TryGetComponent<TransformComponent>(target, out var targetXform) || | ||
| ownerXform.MapID != targetXform.MapID) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| _jumpSystem.ExecuteJump(owner, jumpComp); | ||
| blackboard.SetValue("LastJumpTime", _gameTiming.CurTime.TotalSeconds); | ||
| } | ||
|
|
||
| public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard, | ||
| CancellationToken cancelToken) | ||
| { | ||
| if (!blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entManager)) | ||
| return (false, null); | ||
|
|
||
| if (_entManager.TryGetComponent<MobStateComponent>(target, out var mobState) && | ||
| mobState.CurrentState > MobState.Critical) | ||
| return (false, null); | ||
|
|
||
| var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner); | ||
|
|
||
| if (!_entManager.HasComponent<ZombieJumpComponent>(owner)) | ||
| return (false, null); | ||
|
|
||
| if (blackboard.TryGetValue<double>("LastJumpTime", out var lastJumpTime, _entManager)) | ||
| { | ||
| var currentTime = _gameTiming.CurTime.TotalSeconds; | ||
| if (currentTime - lastJumpTime < Cooldown) | ||
| return (false, null); | ||
| } | ||
|
|
||
| if (!_entManager.TryGetComponent<TransformComponent>(owner, out var ownerXform) || | ||
| !_entManager.TryGetComponent<TransformComponent>(target, out var targetXform)) | ||
| return (false, null); | ||
|
|
||
| if (ownerXform.MapID != targetXform.MapID) | ||
| return (false, null); | ||
|
|
||
| return (true, null); | ||
| } | ||
|
|
||
| public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime) | ||
| { | ||
| base.Update(blackboard, frameTime); | ||
| return HTNOperatorStatus.Finished; | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
Content.Server/ADT/ZombieJump/Preconditions/ZombieJumpCooldownPrecondition.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using Content.Server.NPC; | ||
| using Content.Server.NPC.HTN; | ||
| using Content.Server.NPC.HTN.Preconditions; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Server.ADT.ZombieJump.Preconditions; | ||
|
|
||
| public sealed partial class ZombieJumpCooldownPrecondition : HTNPrecondition | ||
| { | ||
| [Dependency] private readonly IEntityManager _entManager = default!; | ||
| [Dependency] private readonly IGameTiming _gameTiming = default!; | ||
|
|
||
| [DataField("cooldown")] | ||
| public float Cooldown = 10f; | ||
|
|
||
| public override void Initialize(IEntitySystemManager sysManager) | ||
| { | ||
| base.Initialize(sysManager); | ||
| } | ||
|
|
||
| public override bool IsMet(NPCBlackboard blackboard) | ||
| { | ||
| try | ||
| { | ||
| if (blackboard.TryGetValue<double>("LastJumpTime", out var lastJumpTime, _entManager)) | ||
| { | ||
| var currentTime = _gameTiming.CurTime.TotalSeconds; | ||
| if (currentTime - lastJumpTime < Cooldown) | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| catch | ||
| { | ||
| return true; | ||
| } | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
Content.Server/ADT/ZombieJump/Preconditions/ZombieJumpRangePrecondition.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| using Content.Server.NPC; | ||
| using Content.Server.NPC.HTN; | ||
| using Content.Server.NPC.HTN.Preconditions; | ||
| using Robust.Shared.Map; | ||
|
|
||
| namespace Content.Server.ADT.ZombieJump.Preconditions; | ||
| public sealed partial class ZombieJumpRangePrecondition : HTNPrecondition | ||
| { | ||
| [Dependency] private readonly IEntityManager _entManager = default!; | ||
|
|
||
| private SharedTransformSystem _transformSystem = default!; | ||
|
|
||
| [DataField("targetKey", required: true)] public string TargetKey = default!; | ||
|
|
||
| [DataField("rangeKey", required: true)] | ||
| public string RangeKey = default!; | ||
|
|
||
| public override void Initialize(IEntitySystemManager sysManager) | ||
| { | ||
| base.Initialize(sysManager); | ||
| _transformSystem = sysManager.GetEntitySystem<SharedTransformSystem>(); | ||
| } | ||
|
|
||
| public override bool IsMet(NPCBlackboard blackboard) | ||
| { | ||
| try | ||
| { | ||
| if (!blackboard.TryGetValue<EntityCoordinates>(NPCBlackboard.OwnerCoordinates, out var coordinates, _entManager)) | ||
| return false; | ||
|
|
||
| if (!blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entManager)) | ||
| return false; | ||
|
|
||
| if (!_entManager.TryGetComponent<TransformComponent>(target, out var targetXform)) | ||
| return false; | ||
|
|
||
| var jumpRange = blackboard.GetValueOrDefault<float>(RangeKey, _entManager); | ||
|
|
||
| if (jumpRange <= 0f) | ||
| return false; | ||
|
|
||
| return _transformSystem.InRange(coordinates, targetXform.Coordinates, jumpRange); | ||
| } | ||
| catch | ||
| { | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| using Content.Shared.ADT.ZombieJump; | ||
| using Content.Shared.Stunnable; | ||
| using Content.Shared.Throwing; | ||
| using Robust.Shared.GameObjects; | ||
| using Robust.Shared.Physics.Components; | ||
| using Robust.Shared.Physics.Systems; | ||
|
|
||
| namespace Content.Server.ADT.ZombieJump; | ||
| public sealed partial class ZombieJumpSystem : SharedZombieJumpSystem | ||
| { | ||
| [Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
| [Dependency] private readonly SharedStunSystem _stun = default!; | ||
| [Dependency] private readonly SharedPhysicsSystem _physics = default!; | ||
| [Dependency] private readonly SharedTransformSystem _transform = default!; | ||
| [Dependency] private readonly ThrowingSystem _throwing = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| SubscribeLocalEvent<ZombieJumpEvent>(OnZombieJumpServer); | ||
| } | ||
| public void ExecuteJump(EntityUid uid, ZombieJumpComponent jumpComp) | ||
| { | ||
| if (!TryComp<TransformComponent>(uid, out var xform) || | ||
| !TryComp<PhysicsComponent>(uid, out var physics)) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if (xform.Anchored) | ||
| { | ||
| _transform.Unanchor(uid, xform); | ||
| } | ||
|
|
||
| _physics.SetAwake(uid, physics, true); | ||
|
|
||
| var direction = xform.LocalRotation.ToWorldVec(); | ||
| var targetCoords = xform.Coordinates.Offset(direction * jumpComp.JumpDistance); | ||
| _throwing.TryThrow(uid, targetCoords, jumpComp.JumpThrowSpeed); | ||
|
|
||
| EnsureComp<ActiveZombieLeaperComponent>(uid, out var leaperComp); | ||
| leaperComp.KnockdownDuration = jumpComp.CollideKnockdown; | ||
| } | ||
CrimeMoot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private void OnZombieJumpServer(ZombieJumpEvent args) | ||
| { | ||
| if (args.Handled) | ||
| return; | ||
|
|
||
| var uid = args.Performer; | ||
|
|
||
| if (!TryComp<ZombieJumpComponent>(uid, out var jumpComp)) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| ExecuteJump(uid, jumpComp); | ||
|
|
||
| args.Handled = true; | ||
| } | ||
|
|
||
| protected override void TryStunAndKnockdown(EntityUid uid, TimeSpan duration) | ||
| { | ||
| _stun.TryAddStunDuration(uid, TimeSpan.FromSeconds(1)); | ||
|
|
||
| if (TryComp(uid, out StunVisualsComponent? starsComp) && | ||
| TryComp(uid, out AppearanceComponent? appearance)) | ||
| { | ||
| _appearance.SetData(uid, SharedStunSystem.StunVisuals.SeeingStars, true, appearance); | ||
| } | ||
|
|
||
| if (duration > TimeSpan.FromSeconds(1)) | ||
| { | ||
| _stun.TryKnockdown(uid, duration, force: true); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
Content.Shared/ADT/ZombieJump/ActiveZombieLeaperComponent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using Robust.Shared.GameStates; | ||
|
|
||
| namespace Content.Shared.ADT.ZombieJump; | ||
|
|
||
| [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
| public sealed partial class ActiveZombieLeaperComponent : Component | ||
| { | ||
| [DataField, AutoNetworkedField] | ||
| public TimeSpan KnockdownDuration; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.