Апдейт ближнего боя (#37)

* Dagger update

* Light weapons

* HandheldAxe update

* Update handheldAxe.yml

* +sickle
+dart

* two handed update

* add Link LightHammer sprite

* pipi

* . Add Weapons prototypes

* fixes
This commit is contained in:
Ed
2024-04-05 20:19:33 +03:00
committed by GitHub
parent bdfb5a72b9
commit 492176a8c3
51 changed files with 489 additions and 66 deletions

View File

@@ -18,4 +18,6 @@ public enum WeaponArcAnimation : byte
None,
Thrust,
Slash,
//CrystallPunk Melee upgrade
CPSlashLight
}

View File

@@ -14,6 +14,8 @@ 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>
@@ -42,6 +44,10 @@ public sealed partial class MeleeWeaponSystem
return;
}
var length = 1f; //CrystallPunk Melee upgrade
var scale = 1f; //CrystallPunk Melee upgrade
var offset = -1f; //CrystallPunk Melee upgrade
var spriteRotation = Angle.Zero;
if (arcComponent.Animation != WeaponArcAnimation.None
&& TryComp(weapon, out MeleeWeaponComponent? meleeWeaponComponent))
@@ -54,9 +60,14 @@ public sealed partial class MeleeWeaponSystem
if (meleeWeaponComponent.SwingLeft)
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);
@@ -84,6 +95,15 @@ public sealed partial class MeleeWeaponSystem
if (arcComponent.Fadeout)
_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);
TransformSystem.SetParent(animationUid, xform, user, userXform);
if (arcComponent.Fadeout)
_animation.Play(animationUid, GetFadeAnimation(sprite, length * 0.5f, length + 0.15f), FadeAnimationKey);
break;
//CrystallPunk MeleeUpgrade end
}
}
@@ -184,7 +204,7 @@ public sealed partial class MeleeWeaponSystem
/// </summary>
private Animation GetLungeAnimation(Vector2 direction)
{
const float length = 0.1f;
const float length = 0.2f; // 0.1 original, CrystallPunk update
return new Animation
{
@@ -198,11 +218,58 @@ public sealed partial class MeleeWeaponSystem
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(direction.Normalized() * 0.15f, 0f),
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)
}
}
}
};
}
//CrystallPunk MeleeUpgrade start
private Animation CPGetSlashLightAnimation(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);
var startRotationOffset = startRotation.RotateVec(new Vector2(0f, offset));
var endRotationOffset = endRotation.RotateVec(new Vector2(0f, offset));
startRotation += spriteRotation;
endRotation += spriteRotation;
sprite.NoRotation = true;
return new Animation()
{
Length = TimeSpan.FromSeconds(length + 0.05f),
AnimationTracks =
{
new AnimationTrackComponentProperty()
{
ComponentType = typeof(SpriteComponent),
Property = nameof(SpriteComponent.Rotation),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Angle.Lerp(startRotation,endRotation,0.0f), length * 0.0f),
new AnimationTrackProperty.KeyFrame(Angle.Lerp(startRotation,endRotation,1.0f), length * 0.6f),
new AnimationTrackProperty.KeyFrame(Angle.Lerp(startRotation,endRotation,0.8f), length * 1.0f),
}
},
new AnimationTrackComponentProperty()
{
ComponentType = typeof(SpriteComponent),
Property = nameof(SpriteComponent.Offset),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Vector2.Lerp(startRotationOffset,endRotationOffset,0.0f), length * 0.0f),
new AnimationTrackProperty.KeyFrame(Vector2.Lerp(startRotationOffset,endRotationOffset,1.0f), length * 0.6f),
new AnimationTrackProperty.KeyFrame(Vector2.Lerp(startRotationOffset,endRotationOffset,0.8f), length * 1.0f),
}
},
}
};
}
//CrystallPunk MeleeUpgrade end
}

View File

@@ -114,11 +114,29 @@ public sealed partial class MeleeWeaponComponent : Component
public bool SwingLeft;
/// <summary>
/// CrystallPunk Melee improvment. Allows each attack to take turns being either left or right
/// CrystallPunk Melee upgrade. Allows each attack to take turns being either left or right
/// </summary>
[DataField]
public bool CPSwingBeverage = true;
/// <summary>
/// CrystallPunk Melee upgrade. Modifier of wide attack animation speed
/// </summary>
[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>
[DataField]
public float CPAnimationOffset = -1f;
// Sounds
/// <summary>

View File

@@ -385,6 +385,11 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
var ev = new AttemptMeleeEvent();
RaiseLocalEvent(weaponUid, ref ev);
//CrystallPun melee improvment
if (weapon.CPSwingBeverage)
weapon.SwingLeft = !weapon.SwingLeft;
//CrystallPun melee improvment end
if (ev.Cancelled)
{
if (ev.Message != null)
@@ -428,11 +433,6 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
var attackEv = new MeleeAttackEvent(weaponUid);
RaiseLocalEvent(user, ref attackEv);
//CrystallPun melee improvment
if (weapon.CPSwingBeverage)
weapon.SwingLeft = !weapon.SwingLeft;
//CrystallPun melee improvment end
weapon.Attacking = true;
return true;
}

View File

@@ -0,0 +1,7 @@
- type: entity
id: CPWeaponArcSlashLight
parent: WeaponArcStatic
noSpawn: true
components:
- type: WeaponArcVisuals
animation: CPSlashLight

View File

@@ -1,57 +1,62 @@
# Simple melee weapons
# Battle Staff
# Mace
# Stick
# Dagger
# Spear
# Light Hammer
# Throwing spear
# Hand axe
# Sickle
# Military melee weapons
# Halberd
# Battle pick
# Warhammer
# Battle axe
# Glaive
- type: entity
id: CPBaseWeaponChemical
abstract: true
components:
- type: SolutionContainerManager
solutions:
melee:
maxVol: 4
- type: MeleeChemicalInjector
solution: melee
- type: RefillableSolution
solution: melee
- type: InjectableSolution
solution: melee
- type: SolutionInjectOnEmbed
transferAmount: 2
solution: melee
- type: SolutionTransfer
maxTransferAmount: 2
- type: entity
name: двуручный меч
id: CPBaseWeaponThrowable
abstract: true
parent: BaseItem
id: CPBaseTwoHandedSword
description: Мощное оружие, требующее огромной силы и умения для эффективного использования.
components:
- type: Sharp
- type: MeleeWeapon
attackRate: 0.75
components:
- type: DamageOtherOnHit
damage:
types:
Slash: 10
Structural: 5
soundHit:
collection: MetalThud
- type: Wieldable
- type: IncreaseDamageOnWield
Piercing: 10
- type: DamageOnLand
damage:
types:
Slash: 30
Structural: 5
- type: Item
size: Ginormous
Piercing: 10
- type: Fixtures
fixtures:
fix1:
shape: !type:PolygonShape
vertices:
- -0.40,-0.30
- -0.30,-0.40
- 0.40,0.30
- 0.30,0.40
density: 10
mask:
- ItemMask
restitution: 0.3
friction: 0.2
- type: entity
id: CPBaseWeaponLight
abstract: true
components:
- type: MeleeWeapon
resetOnHandSelected: false
- type: entity
id: CPBaseWeaponShort
abstract: true
components:
- type: MeleeWeapon
range: 1.0 # 1.5 standart
cPAnimationOffset: -0.75
# Long spear
# Long sword
# Whip
# Short sword
# Hammer
# Morgenstern
# Pika
# Rapier
# Axe
# Scimitar
# Trident
# Chain

View File

@@ -0,0 +1,34 @@
- type: entity
name: кинжал
parent:
- BaseItem
- CPBaseWeaponChemical
- CPBaseWeaponThrowable
- CPBaseWeaponLight
- CPBaseWeaponShort
id: CPBaseDagger
description: Небольшое острое лезвие, сгодится и для ближнего боя, и как метательное оружие.
components:
- type: Item
storedRotation: -45
- type: Sprite
sprite: CrystallPunk/Objects/Weapons/Melee/Dagger/dagger.rsi
layers:
- state: icon
- type: Sharp
- type: MeleeWeapon
attackRate: 1.8
wideAnimationRotation: 225
wideAnimation: CPWeaponArcSlashLight
damage:
types:
Slash: 5
Piercing: 5
soundHit:
collection: MetalThud
cPAnimationLength: 0.15
- type: EmbeddableProjectile
offset: 0.15,0.15
removalTime: 1
- type: ThrowingAngle
angle: 225

View File

@@ -0,0 +1,42 @@
- type: entity
name: ручной топор
parent:
- BaseItem
- CPBaseWeaponChemical
- CPBaseWeaponThrowable
- CPBaseWeaponLight
id: CPBaseHandheldAxe
description: Небольшой, надежный топорик.
components:
- type: Item
size: Normal
- type: Sprite
sprite: CrystallPunk/Objects/Weapons/Melee/HandheldAxe/handheldAxe.rsi
layers:
- state: icon
- type: Sharp
- type: MeleeWeapon
attackRate: 1.4
range: 1.2
wideAnimationRotation: 225
wideAnimation: CPWeaponArcSlashLight
damage:
types:
Slash: 10
Piercing: 5
soundHit:
collection: MetalThud
cPAnimationLength: 0.25
- type: EmbeddableProjectile
offset: 0.15,0.15
removalTime: 1.5
- type: DamageOtherOnHit
damage:
types:
Slash: 5
Piercing: 5
- type: DamageOnLand
damage:
types:
Slash: 5
Piercing: 5

View File

@@ -0,0 +1,35 @@
- type: entity
name: легкий молот
parent:
- BaseItem
- CPBaseWeaponChemical
- CPBaseWeaponThrowable
- CPBaseWeaponLight
- CPBaseWeaponShort
id: CPBaseLightHammer
description: Небольшое молоток. Хорош как для плотнических работ, так и для проламывания черепов.
components:
- type: Item
storedRotation: -45
- type: Sprite
sprite: CrystallPunk/Objects/Weapons/Melee/LightHammer/lightHammer.rsi
layers:
- state: icon
- type: MeleeWeapon
attackRate: 1.5
wideAnimationRotation: 225
wideAnimation: CPWeaponArcSlashLight
cPAnimationLength: 0.18
damage:
types:
Blunt: 10
soundHit:
collection: MetalThud
- type: DamageOtherOnHit
damage:
types:
Blunt: 10
- type: DamageOnLand
damage:
types:
Blunt: 10

View File

@@ -0,0 +1,27 @@
- type: entity
name: серп
parent:
- BaseItem
- CPBaseWeaponChemical
- CPBaseWeaponLight
- CPBaseWeaponShort
id: CPBaseSickle
description: Изначально разработанное как оружие против травы, серп внезапно показал себя хорош и в более кровавой жатве.
components:
- type: Item
storedRotation: -45
- type: Sprite
sprite: CrystallPunk/Objects/Weapons/Melee/Sickle/sickle.rsi
layers:
- state: icon
- type: MeleeWeapon
attackRate: 1.5
wideAnimationRotation: 225
wideAnimation: CPWeaponArcSlashLight
cPAnimationLength: 0.18
damage:
types:
Slash: 8
Piercing: 4
soundHit:
collection: MetalThud

View File

@@ -1,17 +1,45 @@
- type: entity
name: цвайхендер
parent: CPBaseTwoHandedSword
id: CPZweichender
name: двуручный меч #ToDo - сделать базовый двуручник
parent:
- BaseItem
- CPBaseWeaponChemical
id: CPBaseTwoHandedSword
description: Мощное оружие, требующее огромной силы и умения для эффективного использования.
components:
- type: MeleeWeapon
wideAnimationRotation: 225
- type: Sprite
sprite: CrystallPunk/Objects/Weapons/Melee/zweichhender.rsi
sprite: CrystallPunk/Objects/Weapons/Melee/TwoHandedSword/twoHandedSword.rsi
state: icon
- type: Clothing
sprite: CrystallPunk/Objects/Weapons/Melee/zweichhender.rsi
sprite: CrystallPunk/Objects/Weapons/Melee/TwoHandedSword/twoHandedSword.rsi
quickEquip: false
slots:
- back
#TODO двуручный хват требует перчаток чтобы не получать урона самому
- type: Icon
sprite: CrystallPunk/Objects/Weapons/Melee/TwoHandedSword/twoHandedSword32.rsi
state: icon
- type: Sharp
- type: MeleeWeapon
attackRate: 0.5
wideAnimationRotation: 205
wideAnimation: CPWeaponArcSlashLight
damage:
types:
Slash: 5
Blunt: 3
Structural: 5
soundHit:
collection: MetalThud
cPAnimationLength: 0.8
- type: Wieldable
- type: IncreaseDamageOnWield
damage:
types:
Slash: 20
Blunt: 10
Structural: 5
- type: Item
size: Ginormous
- type: ClothingSpeedModifier
walkModifier: 0.9
sprintModifier: 0.8
- type: HeldSpeedModifier

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 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
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 841 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,34 @@
{
"version": 1,
"license": "CC-BY-NC-SA-3.0",
"copyright": "Created by TheShuEd (Github) for CrystallPunk",
"size": {
"x": 48,
"y": 48
},
"states": [
{
"name": "icon"
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
},
{
"name": "wielded-inhand-left",
"directions": 4
},
{
"name": "wielded-inhand-right",
"directions": 4
},
{
"name": "equipped-BACKPACK",
"directions": 4
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

View File

@@ -0,0 +1,14 @@
{
"version": 1,
"license": "CC-BY-NC-SA-3.0",
"copyright": "Created by TheShuEd (Github) for CrystallPunk",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B