Adds stunbaton

This commit is contained in:
zumorica
2020-05-13 20:21:03 +02:00
parent a524eca44b
commit 6428cdd596
5 changed files with 65 additions and 3 deletions

View File

@@ -191,7 +191,7 @@ namespace Content.Server.GameObjects
if(entity.TryGetComponent(out StunnableComponent stun)) if(entity.TryGetComponent(out StunnableComponent stun))
stun.CancelAll(); stun.CancelAll();
StandingStateHelper.Down(entity); StandingStateHelper.Down(entity, playSound:false);
if (entity.TryGetComponent(out CollidableComponent collidable)) if (entity.TryGetComponent(out CollidableComponent collidable))
{ {

View File

@@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Mobs
private float _stunCap = 20f; private float _stunCap = 20f;
private float _knockdownCap = 20f; private float _knockdownCap = 20f;
private float _helpKnockdownRemove = 1f; private float _helpKnockdownRemove = 1f;
private float _helpInterval = 0.5f; private float _helpInterval = 1f;
private float _stunnedTimer = 0f; private float _stunnedTimer = 0f;
private float _knockdownTimer = 0f; private float _knockdownTimer = 0f;
@@ -46,7 +46,7 @@ namespace Content.Server.GameObjects.Components.Mobs
base.ExposeData(serializer); base.ExposeData(serializer);
serializer.DataField(ref _stunCap, "stunCap", 20f); serializer.DataField(ref _stunCap, "stunCap", 20f);
serializer.DataField(ref _knockdownCap, "knockdownCap", 20f); serializer.DataField(ref _knockdownCap, "knockdownCap", 20f);
serializer.DataField(ref _helpInterval, "helpInterval", 0.5f); serializer.DataField(ref _helpInterval, "helpInterval", 1f);
serializer.DataField(ref _helpKnockdownRemove, "helpKnockdownRemove", 1f); serializer.DataField(ref _helpKnockdownRemove, "helpKnockdownRemove", 1f);
} }

View File

@@ -75,6 +75,10 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
serializer.DataField(ref _cooldownTime, "cooldownTime", 1f); serializer.DataField(ref _cooldownTime, "cooldownTime", 1f);
} }
public virtual void OnHitEntities(IEnumerable<IEntity> entities)
{
}
void IAttack.Attack(AttackEventArgs eventArgs) void IAttack.Attack(AttackEventArgs eventArgs)
{ {
var curTime = IoCManager.Resolve<IGameTiming>().CurTime; var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
@@ -101,6 +105,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
} }
} }
OnHitEntities(hitEntities);
var audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>(); var audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
var emitter = hitEntities.Count == 0 ? eventArgs.User : hitEntities[0]; var emitter = hitEntities.Count == 0 ? eventArgs.User : hitEntities[0];
audioSystem.Play(hitEntities.Count > 0 ? _hitSound : "/Audio/weapons/punchmiss.ogg", emitter); audioSystem.Play(hitEntities.Count > 0 ? _hitSound : "/Audio/weapons/punchmiss.ogg", emitter);

View File

@@ -0,0 +1,32 @@
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Weapon.Melee
{
[RegisterComponent]
public class StunbatonComponent : MeleeWeaponComponent
{
public override string Name => "Stunbaton";
private float _paralyzeTime = 10f;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _paralyzeTime, "paralyzeTime", 10f);
}
public override void OnHitEntities(IEnumerable<IEntity> entities)
{
foreach (var entity in entities)
{
if(entity.TryGetComponent(out StunnableComponent stunnable))
stunnable.Paralyze(_paralyzeTime);
}
}
}
}

View File

@@ -0,0 +1,24 @@
- type: entity
name: Stun baton
parent: BaseItem
id: Stunbaton
components:
- type: Sprite
sprite: Objects/Melee/spear.rsi
state: spear
- type: Icon
sprite: Objects/Melee/spear.rsi
state: spear
- type: Stunbaton
range: 1.5
arcwidth: 0
arc: default
- type: Item
Size: 24
sprite: Objects/Melee/spear.rsi
prefix: inhand
- type: ItemCooldown