spears and mace (#66)

This commit is contained in:
Ed
2024-04-06 22:58:08 +03:00
committed by GitHub
parent d0b2666454
commit 9720dcffc5
19 changed files with 144 additions and 25 deletions

View File

@@ -19,5 +19,6 @@ public enum WeaponArcAnimation : byte
Thrust,
Slash,
//CrystallPunk Melee upgrade
CPSlashLight
CPSlash,
CPThrust
}

View File

@@ -14,8 +14,6 @@ public sealed partial class MeleeWeaponSystem
private const string SlashAnimationKey = "melee-slash";
private const string ThrustAnimationKey = "melee-thrust";
private const string CPSlashLightAnimationKey = "cp-melee-slash-light"; //CrystallPunk Melee upgrade
/// <summary>
/// Does all of the melee effects for a player that are predicted, i.e. character lunge and weapon animation.
/// </summary>
@@ -45,7 +43,6 @@ public sealed partial class MeleeWeaponSystem
}
var length = 1f; //CrystallPunk Melee upgrade
var scale = 1f; //CrystallPunk Melee upgrade
var offset = -1f; //CrystallPunk Melee upgrade
var spriteRotation = Angle.Zero;
@@ -62,12 +59,10 @@ public sealed partial class MeleeWeaponSystem
angle *= -1;
length = meleeWeaponComponent.CPAnimationLength; //CrystallPunk Melee upgrade
scale = meleeWeaponComponent.CPAnimationScale; //CrystallPunk Melee upgrade
offset = meleeWeaponComponent.CPAnimationOffset; //CrystallPunk Melee upgrade
}
sprite.NoRotation = true;
sprite.Rotation = localPos.ToWorldAngle();
sprite.Scale = new Vector2(scale); //CrystallPunk Melee upgrade
var distance = Math.Clamp(localPos.Length() / 2f, 0.2f, 1f);
var xform = _xformQuery.GetComponent(animationUid);
@@ -96,12 +91,17 @@ public sealed partial class MeleeWeaponSystem
_animation.Play(animationUid, GetFadeAnimation(sprite, 0f, 0.15f), FadeAnimationKey);
break;
//CrystallPunk MeleeUpgrade
case WeaponArcAnimation.CPSlashLight:
_animation.Play(animationUid, CPGetSlashLightAnimation(sprite, angle, spriteRotation, length, offset), CPSlashLightAnimationKey);
case WeaponArcAnimation.CPSlash:
_animation.Play(animationUid, CPGetSlashAnimation(sprite, angle, spriteRotation, length, offset), SlashAnimationKey);
TransformSystem.SetParent(animationUid, xform, user, userXform);
if (arcComponent.Fadeout)
_animation.Play(animationUid, GetFadeAnimation(sprite, length * 0.5f, length + 0.15f), FadeAnimationKey);
break;
case WeaponArcAnimation.CPThrust:
_animation.Play(animationUid, CPGetThrustAnimation(sprite, -offset, spriteRotation, length), ThrustAnimationKey);
TransformSystem.SetParent(animationUid, xform, user, userXform);
if (arcComponent.Fadeout)
_animation.Play(animationUid, GetFadeAnimation(sprite, 0f, 0.15f), FadeAnimationKey);
break;
//CrystallPunk MeleeUpgrade end
}
@@ -219,8 +219,8 @@ public sealed partial class MeleeWeaponSystem
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Vector2.Zero, 0f), //CrystallPunk MeleeUpgrade
new AnimationTrackProperty.KeyFrame(direction.Normalized() * 0.15f, length/2), //CrystallPunk MeleeUpgrade
new AnimationTrackProperty.KeyFrame(Vector2.Zero, length)
new AnimationTrackProperty.KeyFrame(direction.Normalized() * 0.15f, length*0.4f), //CrystallPunk MeleeUpgrade
new AnimationTrackProperty.KeyFrame(Vector2.Zero, length*0.8f) //CrystallPunk MeleeUpgrade
}
}
}
@@ -228,7 +228,7 @@ public sealed partial class MeleeWeaponSystem
}
//CrystallPunk MeleeUpgrade start
private Animation CPGetSlashLightAnimation(SpriteComponent sprite, Angle arc, Angle spriteRotation, float length, float offset = -1f)
private Animation CPGetSlashAnimation(SpriteComponent sprite, Angle arc, Angle spriteRotation, float length, float offset = -1f)
{
var startRotation = sprite.Rotation + (arc * 0.5f);
var endRotation = sprite.Rotation - (arc * 0.5f);
@@ -270,6 +270,34 @@ public sealed partial class MeleeWeaponSystem
}
};
}
private Animation CPGetThrustAnimation(SpriteComponent sprite, float distance, Angle spriteRotation, float length)
{
var startOffset = sprite.Rotation.RotateVec(new Vector2(0f, -distance / 5f));
var endOffset = sprite.Rotation.RotateVec(new Vector2(0f, -distance));
sprite.Rotation += spriteRotation;
return new Animation()
{
Length = TimeSpan.FromSeconds(length),
AnimationTracks =
{
new AnimationTrackComponentProperty()
{
ComponentType = typeof(SpriteComponent),
Property = nameof(SpriteComponent.Offset),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Vector2.Lerp(startOffset, endOffset, 0f), length * 0f),
new AnimationTrackProperty.KeyFrame(Vector2.Lerp(startOffset, endOffset, 1f), length * 0.5f),
new AnimationTrackProperty.KeyFrame(Vector2.Lerp(startOffset, endOffset, 0.9f), length * 0.8f),
}
},
}
};
}
//CrystallPunk MeleeUpgrade end
}

View File

@@ -125,12 +125,6 @@ public sealed partial class MeleeWeaponComponent : Component
[DataField]
public float CPAnimationLength = 0.5f;
/// <summary>
/// CrystallPunk Melee upgrade. Scale arc (for small knife ex.)
/// </summary>
[DataField]
public float CPAnimationScale = 1f;
/// <summary>
/// CrystallPunk Melee upgrade. how far away from the player the animation should be played.
/// </summary>

View File

@@ -1,7 +1,15 @@
- type: entity
id: CPWeaponArcSlashLight
id: CPWeaponArcSlash
parent: WeaponArcStatic
noSpawn: true
components:
- type: WeaponArcVisuals
animation: CPSlashLight
animation: CPSlash
- type: entity
id: CPWeaponArcThrust
parent: WeaponArcStatic
noSpawn: true
components:
- type: WeaponArcVisuals
animation: CPThrust

View File

@@ -19,7 +19,7 @@
- type: MeleeWeapon
attackRate: 1.8
wideAnimationRotation: 225
wideAnimation: CPWeaponArcSlashLight
wideAnimation: CPWeaponArcSlash
damage:
types:
Slash: 5

View File

@@ -19,7 +19,7 @@
attackRate: 1.4
range: 1.2
wideAnimationRotation: 225
wideAnimation: CPWeaponArcSlashLight
wideAnimation: CPWeaponArcSlash
damage:
types:
Slash: 10

View File

@@ -18,7 +18,7 @@
- type: MeleeWeapon
attackRate: 1.5
wideAnimationRotation: 225
wideAnimation: CPWeaponArcSlashLight
wideAnimation: CPWeaponArcSlash
cPAnimationLength: 0.18
damage:
types:

View File

@@ -0,0 +1,25 @@
- type: entity
id: CPBaseMace
parent:
- BaseItem
name: булава
description: Тяжелый кусок металла на длинной палке. Что может быть проще?
components:
- type: Item
size: Large
- type: Sprite
sprite: _CP14/Objects/Weapons/Melee/Mace/mace.rsi
layers:
- state: icon
- type: Sharp
- type: MeleeWeapon
attackRate: 0.7
wideAnimationRotation: 205
wideAnimation: CPWeaponArcSlash
damage:
types:
Blunt: 25
Piercing: 5
soundHit:
collection: MetalThud
cPAnimationLength: 0.25

View File

@@ -17,7 +17,7 @@
- type: MeleeWeapon
attackRate: 1.5
wideAnimationRotation: 225
wideAnimation: CPWeaponArcSlashLight
wideAnimation: CPWeaponArcSlash
cPAnimationLength: 0.18
damage:
types:

View File

@@ -0,0 +1,41 @@
- type: entity
id: CPBaseThrowableSpear
parent:
- BaseItem
- CPBaseWeaponChemical
- CPBaseWeaponThrowable
name: метательное копье
description: Оружие, исправно выполняющее свой долг еще со времен эпохи драконов.
components:
- type: Item
storedRotation: 0
size: Large
- type: Sprite
sprite: _CP14/Objects/Weapons/Melee/ThrowableSpear/throwableSpear.rsi
layers:
- state: icon
- type: Sharp
- type: MeleeWeapon
attackRate: 1
wideAnimationRotation: -115
wideAnimation: CPWeaponArcThrust
damage:
types:
Piercing: 24
soundHit:
collection: MetalThud
cPAnimationLength: 0.25
cPAnimationOffset: -1.3
- type: EmbeddableProjectile
offset: 0.15,0.15
removalTime: 1.5
- type: ThrowingAngle
angle: 245
- type: DamageOtherOnHit
damage:
types:
Piercing: 20
- type: DamageOnLand
damage:
types:
Piercing: 20

View File

@@ -21,7 +21,7 @@
- type: MeleeWeapon
attackRate: 0.5
wideAnimationRotation: 205
wideAnimation: CPWeaponArcSlashLight
wideAnimation: CPWeaponArcSlash
damage:
types:
Slash: 5

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

View File

@@ -0,0 +1,22 @@
{
"version": 1,
"license": "CC-BY-NC-SA-3.0",
"copyright": "Created by link (Discord) for CrystallPunk",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
}
]
}