diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h
index 981fc13a..6ad52a95 100644
--- a/include/Game/Systems/PlayerMovementSystem.h
+++ b/include/Game/Systems/PlayerMovementSystem.h
@@ -46,4 +46,6 @@ private:
void updateMovementControllers(double dt);
void updateVelocity(EntityWrapper player, double dt);
+
+ void setAim(EntityWrapper root, std::string weaponNodeName, double time);
};
\ No newline at end of file
diff --git a/resources/Schema/Entities/AmmoShareEffectView.xml b/resources/Schema/Entities/AmmoShareEffectView.xml
new file mode 100644
index 00000000..651d1621
--- /dev/null
+++ b/resources/Schema/Entities/AmmoShareEffectView.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+ 1.2000000476837158
+
+
+
+
+ 1.2000000476837158
+ -1
+ 1.2000000476837158
+
+ true
+ true
+
+
+ 16.040000915527344
+ Models/Effects/JumpEffectHexagon.mesh
+
+ true
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/Schema/Entities/FriendlyAmmoHUD.xml b/resources/Schema/Entities/FriendlyAmmoHUD.xml
index 5ab1b754..57209829 100644
--- a/resources/Schema/Entities/FriendlyAmmoHUD.xml
+++ b/resources/Schema/Entities/FriendlyAmmoHUD.xml
@@ -16,7 +16,7 @@
-
+
@@ -33,11 +33,25 @@
88
Fonts/DroidSans.ttf,64
-
+
-
-
+
+
+
+
+
+
+
+
+
+ 88
+ Fonts/DroidSans.ttf,64
+
+
+
+
+
diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml
index 7a2010e6..4ca636da 100644
--- a/resources/Schema/Entities/PlayerAssaultBlue.xml
+++ b/resources/Schema/Entities/PlayerAssaultBlue.xml
@@ -15,7 +15,9 @@
-
+
+ 10
+
@@ -902,10 +904,10 @@
-
+
- DashLeftF
+ DashRightF
1.7999999523162842
false
@@ -914,10 +916,10 @@
-
+
- DashRightF
+ DashLeftF
1.7999999523162842
false
diff --git a/resources/Schema/Entities/WeaponSidearmAssaultBlueView.xml b/resources/Schema/Entities/WeaponSidearmAssaultBlueView.xml
index c3c06142..620d9416 100644
--- a/resources/Schema/Entities/WeaponSidearmAssaultBlueView.xml
+++ b/resources/Schema/Entities/WeaponSidearmAssaultBlueView.xml
@@ -190,11 +190,20 @@
Schema/Entities/FriendlyAmmoHUD.xml
-
+
+
+
+
+ Schema/Entities/AmmoShareEffectView.xml
+
+
+
+
+
diff --git a/resources/Schema/Entities/WeaponSidearmDefenderBlueView.xml b/resources/Schema/Entities/WeaponSidearmDefenderBlueView.xml
index 45f18c33..3ff8b0a2 100644
--- a/resources/Schema/Entities/WeaponSidearmDefenderBlueView.xml
+++ b/resources/Schema/Entities/WeaponSidearmDefenderBlueView.xml
@@ -48,116 +48,6 @@
-
-
-
- R_Arm_Weapon_Joint
-
-
- Models/Weapons/Blue/SecondaryWeaponBlue.mesh
-
-
-
-
-
-
-
-
-
-
- Schema/Entities/RayBlue.xml
-
-
-
-
-
-
-
-
-
-
- Schema/Entities/ReloadEffectView.xml
-
-
-
-
-
-
-
-
-
-
- R_Ammo_Joint
- true
-
-
-
-
-
-
-
-
-
-
-
- Models/Core/UnitQuad.mesh
-
- Textures/Core/UnitHexagon.png
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 38
- Fonts/DroidSans.ttf,64
-
-
-
-
- Sidearm
- Ammo
-
-
-
-
-
-
-
-
-
-
-
- 5
- Fonts/DroidSans.ttf,64
-
-
-
-
- Sidearm
- MagazineAmmo
-
-
-
-
-
-
-
-
-
-
-
@@ -190,6 +80,132 @@
+
+
+
+ R_Arm_Weapon_Joint
+
+
+ Models/Weapons/Blue/SecondaryWeaponBlue.mesh
+
+
+
+
+
+
+
+
+
+
+ Schema/Entities/Ray2Red.xml
+
+
+
+
+
+
+
+
+
+
+ Schema/Entities/WeaponSidearmReloadEffectView.xml
+
+
+
+
+
+
+
+
+
+
+ R_Ammo_Joint
+
+
+
+
+
+
+
+
+
+
+
+ Models/Core/UnitQuad.mesh
+
+ Textures/Core/UnitHexagon.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 16
+ Fonts/DroidSans.ttf,64
+
+
+
+
+ SidearmWeapon
+ MagazineAmmo
+
+
+
+
+
+
+
+
+
+
+
+ 8
+ Fonts/DroidSans.ttf,64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Schema/Entities/FriendlyAmmoHUD.xml
+
+
+
+
+
+
+
+
+
+
+ Schema/Entities/AmmoShareEffectView.xml
+
+
+
+
+
+
+
diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp
index cfe7356c..b86d4140 100644
--- a/src/Game/Systems/PlayerMovementSystem.cpp
+++ b/src/Game/Systems/PlayerMovementSystem.cpp
@@ -82,17 +82,15 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
// Limit camera pitch so we don't break our necks
cameraOrientation.x = glm::clamp(cameraOrientation.x, -glm::half_pi(), glm::half_pi());
+ float pitch = cameraOrientation.x;
+ double time = ((pitch + glm::half_pi()) / glm::pi());
+
// Set third person model aim pitch
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
if (playerModel.Valid()) {
- EntityWrapper aimPrimaryEntity = playerModel.FirstChildByName("Aim");
- if(aimPrimaryEntity.Valid()){
- if(aimPrimaryEntity.HasComponent("Animation")) {
- float pitch = cameraOrientation.x;
- double time = ((pitch + glm::half_pi()) / glm::pi());
- (double&)aimPrimaryEntity["Animation"]["Time"] = time;
- }
- }
+ setAim(playerModel, "SidearmWeapon", time);
+ setAim(playerModel, "AssaultWeapon", time);
+ setAim(playerModel, "DefenderWeapon", time);
}
}
@@ -308,6 +306,25 @@ void PlayerMovementSystem::updateVelocity(EntityWrapper player, double dt)
position += velocity * (float)dt;
}
+
+void PlayerMovementSystem::setAim(EntityWrapper root, std::string weaponNodeName, double time)
+{
+ if (root.Valid()) {
+ EntityWrapper blendTreeUpper = root.FirstChildByName("BlendTreeUpper");
+ if (blendTreeUpper.Valid()) {
+ EntityWrapper weapon = blendTreeUpper.FirstChildByName(weaponNodeName);
+ if(weapon.Valid()) {
+ EntityWrapper aim = weapon.FirstChildByName("Aim");
+ if (aim.Valid()) {
+ if (aim.HasComponent("Animation")) {
+ (double&)aim["Animation"]["Time"] = time;
+ }
+ }
+ }
+ }
+ }
+}
+
void PlayerMovementSystem::playerStep(double dt)
{
if (!m_LocalPlayer.Valid()) {
diff --git a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp
index cf611c44..f342f291 100644
--- a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp
+++ b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp
@@ -353,6 +353,9 @@ void DefenderWeaponBehaviour::spawnTracers(ComponentWrapper cWeapon, WeaponInfo&
glm::vec3 origin = Transform::AbsolutePosition(wi.Player.FirstChildByName("Camera"));
glm::vec3 direction = pelletRotation * glm::vec3(0, 0, -1);
float distance = traceRayDistance(origin, direction);
+
+ // Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos);
+
EntityWrapper ray = SpawnerSystem::Spawn(muzzle);
if (ray.Valid()) {
ComponentWrapper cTransform = ray["Transform"];
@@ -397,7 +400,7 @@ void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& w
float yRefFOV = glm::radians(59.f);
float yRef = glm::tan(yRefFOV) * nearClip;
float yRatio = yRef / (glm::tan(yFOV) * nearClip);
- float yMax = yRatio * (glm::tan(spreadAngle) * farClip);
+ float yMax = yRatio * (glm::tan(spreadAngle) * (farClip - nearClip)) * glm::pi(); // ????? Good enough????
LOG_DEBUG("Ratio: %f", yRatio);
LOG_DEBUG("fatClip: %f", farClip);
diff --git a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp
index 7ac802de..9c12bb2c 100644
--- a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp
+++ b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp
@@ -297,6 +297,8 @@ bool SidearmWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi
void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver)
{
+ bool gaveAmmo = false;
+
if (receiver.HasComponent("AssaultWeapon")) {
int magazineSize = receiver["AssaultWeapon"]["MagazineSize"];
int& magazineAmmo = receiver["AssaultWeapon"]["MagazineAmmo"];
@@ -306,8 +308,10 @@ void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi,
if(magazineAmmo < magazineSize) {
magazineAmmo += 1;
+ gaveAmmo = true;
} else if (ammo < maxAmmo) {
ammo += 1;
+ gaveAmmo = true;
}
} else if (receiver.HasComponent("DefenderWeapon")) {
int magazineSize = receiver["DefenderWeapon"]["MagazineSize"];
@@ -318,8 +322,20 @@ void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi,
if (magazineAmmo < magazineSize) {
magazineAmmo += 1;
+ gaveAmmo = true;
} else if (ammo < maxAmmo) {
ammo += 1;
+ gaveAmmo = true;
+ }
+ }
+
+
+ if(gaveAmmo) {
+ EntityWrapper effectSpawner = wi.FirstPersonEntity.FirstChildByName("AmmoShareEffectSpawner");
+ if(effectSpawner.Valid()) {
+ if (effectSpawner.HasComponent("Spawner")) {
+ SpawnerSystem::Spawn(effectSpawner, effectSpawner);
+ }
}
}
}
@@ -371,26 +387,38 @@ void SidearmWeaponBehaviour::CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi)
// If friendly fire, reduce damage to 0 (needed to make Boosts, Ammosharing work)
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) {
int magazineAmmo = 0;
+ int ammo = 0;
if (victim.HasComponent("AssaultWeapon")) {
magazineAmmo = (int)victim["AssaultWeapon"]["MagazineAmmo"];
+ ammo = (int)victim["AssaultWeapon"]["Ammo"];
} else if (victim.HasComponent("DefenderWeapon")) {
magazineAmmo = (int)victim["DefenderWeapon"]["MagazineAmmo"];
+ ammo = (int)victim["DefenderWeapon"]["Ammo"];
}
-
+
EntityWrapper friendlyAmmoHudSpawner = wi.FirstPersonPlayerModel.FirstChildByName("FriendlyAmmoAttachment");
- if(friendlyAmmoHudSpawner.Valid()) {
+ if (friendlyAmmoHudSpawner.Valid()) {
auto children = m_World->GetDirectChildren(friendlyAmmoHudSpawner.ID);
if (children.first == children.second) {
- EntityWrapper friendlyAmmoHud = SpawnerSystem::Spawn(friendlyAmmoHudSpawner, friendlyAmmoHudSpawner);
- if (friendlyAmmoHud.Valid()) {
- EntityWrapper textEntity = friendlyAmmoHud.FirstChildByName("MagazineAmmo");
- if (textEntity.Valid()) {
- if (textEntity.HasComponent("Text")) {
- (std::string&)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
+ if (friendlyAmmoHudSpawner.HasComponent("Spawner")) {
+ EntityWrapper friendlyAmmoHud = SpawnerSystem::Spawn(friendlyAmmoHudSpawner, friendlyAmmoHudSpawner);
+ if (friendlyAmmoHud.Valid()) {
+ EntityWrapper textEntity = friendlyAmmoHud.FirstChildByName("MagazineAmmo");
+ if (textEntity.Valid()) {
+ if (textEntity.HasComponent("Text")) {
+ (std::string&)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
+ }
+ }
+
+ EntityWrapper ammoTextEntity = friendlyAmmoHud.FirstChildByName("Ammo");
+ if (ammoTextEntity.Valid()) {
+ if (ammoTextEntity.HasComponent("Text")) {
+ (std::string&)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
+ }
}
}
}
@@ -401,8 +429,14 @@ void SidearmWeaponBehaviour::CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi)
(std::string&)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
}
}
+
+ EntityWrapper ammoTextEntity = friendlyAmmoHudSpawner.FirstChildByName("Ammo");
+ if (ammoTextEntity.Valid()) {
+ if (ammoTextEntity.HasComponent("Text")) {
+ (std::string&)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
+ }
+ }
}
-
}
}
}