Tweaking
This commit is contained in:
@@ -31,7 +31,6 @@ private:
|
||||
|
||||
// Weapon functions
|
||||
void fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi);
|
||||
//void dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage);
|
||||
bool canFire(ComponentWrapper cWeapon, WeaponInfo& wi);
|
||||
bool dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi);
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ private:
|
||||
bool dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi);
|
||||
// void giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver);
|
||||
|
||||
void spawnTracer(ComponentWrapper cWeapon, WeaponInfo& wi);
|
||||
|
||||
void CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi);
|
||||
void RemoveFrindlyAmmoHUD(WeaponInfo& wi);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Entity name="RayBlue" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:Lifetime>
|
||||
<Lifetime>0.5</Lifetime>
|
||||
</c:Lifetime>
|
||||
<c:Transform>
|
||||
<Scale X="0" Y="1" Z="1"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Sprite>
|
||||
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||
<GlowMap></GlowMap>
|
||||
<DiffuseTexture>Textures/Effects/NewRay3.png</DiffuseTexture>
|
||||
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
|
||||
<KeepRatioX>true</KeepRatioX>
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="-0.5"/>
|
||||
<Orientation X="0" Y="-1.57099998" Z="0"/>
|
||||
<Scale X="1" Y="0.0710000023" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Sprite>
|
||||
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||
<GlowMap></GlowMap>
|
||||
<DiffuseTexture>Textures/Effects/NewRay3.png</DiffuseTexture>
|
||||
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
|
||||
<KeepRatioX>true</KeepRatioX>
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="-0.5"/>
|
||||
<Orientation X="0" Y="4.71218538" Z="3.14199996"/>
|
||||
<Scale X="1" Y="0.0710000023" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
@@ -13,9 +13,13 @@
|
||||
</c:Team>
|
||||
<c:Collidable/>
|
||||
<c:DefenderWeapon>
|
||||
<BaseDamage>120</BaseDamage>
|
||||
<MagazineAmmo>8</MagazineAmmo>
|
||||
<SpreadAngle>5</SpreadAngle>
|
||||
</c:DefenderWeapon>
|
||||
<c:SidearmWeapon/>
|
||||
<c:SidearmWeapon>
|
||||
<BaseDamage>10</BaseDamage>
|
||||
</c:SidearmWeapon>
|
||||
<c:Health>
|
||||
<Health>150</Health>
|
||||
<MaxHealth>150</MaxHealth>
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
<Entity name="WeaponMuzzle">
|
||||
<Components>
|
||||
<c:Spawner>
|
||||
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
|
||||
<EntityFile>Schema/Entities/DefenderRayBlue.xml</EntityFile>
|
||||
</c:Spawner>
|
||||
<c:Transform>
|
||||
<Position X="0.0145629933" Y="0.0680000037" Z="-0.306000024"/>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<Entity name="WeaponMuzzle">
|
||||
<Components>
|
||||
<c:Spawner>
|
||||
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
|
||||
<EntityFile>Schema/Entities/DefenderRayBlue.xml</EntityFile>
|
||||
</c:Spawner>
|
||||
<c:Transform>
|
||||
<Position X="0.000284185546" Y="0.0318552479" Z="-0.193328083"/>
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
<Entity name="WeaponMuzzle">
|
||||
<Components>
|
||||
<c:Spawner>
|
||||
<EntityFile>Schema/Entities/Ray2Red.xml</EntityFile>
|
||||
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
|
||||
</c:Spawner>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.105000004" Z="-0.256000012"/>
|
||||
|
||||
@@ -373,27 +373,28 @@ void DefenderWeaponBehaviour::spawnTracers(ComponentWrapper cWeapon, WeaponInfo&
|
||||
|
||||
float distance;
|
||||
glm::vec3 hitPosition;
|
||||
Collision::EntityFirstHitByRay(Ray(cameraPosition, direction), m_CollisionOctree, distance, hitPosition);
|
||||
if (Collision::EntityFirstHitByRay(Ray(cameraPosition, direction), m_CollisionOctree, distance, hitPosition) != boost::none) { // don't spawn ray if you "miss the world"
|
||||
|
||||
EntityWrapper ray = SpawnerSystem::Spawn(muzzle);
|
||||
if (ray.Valid()) {
|
||||
ComponentWrapper cTransform = ray["Transform"];
|
||||
glm::vec3& rayOrigin = cTransform["Position"];
|
||||
glm::vec3& rayOrientation = cTransform["Orientation"];
|
||||
glm::vec3& rayScale = cTransform["Scale"];
|
||||
EntityWrapper ray = SpawnerSystem::Spawn(muzzle);
|
||||
if (ray.Valid()) {
|
||||
ComponentWrapper cTransform = ray["Transform"];
|
||||
glm::vec3& rayOrigin = cTransform["Position"];
|
||||
glm::vec3& rayOrientation = cTransform["Orientation"];
|
||||
glm::vec3& rayScale = cTransform["Scale"];
|
||||
|
||||
glm::vec3 muzzlePosition = Transform::AbsolutePosition(muzzle);
|
||||
glm::quat muzzleOrientation = Transform::AbsoluteOrientation(muzzle);
|
||||
|
||||
rayOrigin = muzzlePosition;
|
||||
glm::vec3 muzzlePosition = Transform::AbsolutePosition(muzzle);
|
||||
glm::quat muzzleOrientation = Transform::AbsoluteOrientation(muzzle);
|
||||
|
||||
glm::vec3 muzzleToHit = hitPosition - muzzlePosition;
|
||||
glm::vec3 lookVector = glm::normalize(-muzzleToHit);
|
||||
float pitch = std::asin(-lookVector.y);
|
||||
float yaw = std::atan2(lookVector.x, lookVector.z);
|
||||
glm::quat orientation = glm::quat(glm::vec3(pitch, yaw, 0));
|
||||
rayOrientation = glm::eulerAngles(orientation);
|
||||
rayScale.z = glm::length(muzzleToHit);
|
||||
rayOrigin = muzzlePosition;
|
||||
|
||||
glm::vec3 muzzleToHit = hitPosition - muzzlePosition;
|
||||
glm::vec3 lookVector = glm::normalize(-muzzleToHit);
|
||||
float pitch = std::asin(-lookVector.y);
|
||||
float yaw = std::atan2(lookVector.x, lookVector.z);
|
||||
glm::quat orientation = glm::quat(glm::vec3(pitch, yaw, 0));
|
||||
rayOrientation = glm::eulerAngles(orientation);
|
||||
rayScale.z = glm::length(muzzleToHit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -448,8 +449,8 @@ void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& w
|
||||
}
|
||||
|
||||
// Temp hit decal
|
||||
EntityWrapper hit = ResourceManager::Load<EntityFile>("Schema/Entities/HitTest.xml")->MergeInto(m_World);
|
||||
hit["Transform"]["Position"] = pick.Position;
|
||||
// EntityWrapper hit = ResourceManager::Load<EntityFile>("Schema/Entities/HitTest.xml")->MergeInto(m_World);
|
||||
// hit["Transform"]["Position"] = pick.Position;
|
||||
|
||||
// Don't let us shoot ourselves in the foot somehow
|
||||
if (victim == LocalPlayer) {
|
||||
@@ -471,7 +472,7 @@ void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& w
|
||||
}
|
||||
|
||||
damageSum[victim] += pelletDamage;
|
||||
((glm::vec3&)hit["Model"]["Color"]).b = 1.f;
|
||||
// ((glm::vec3&)hit["Model"]["Color"]).b = 1.f;
|
||||
}
|
||||
|
||||
// Deal damage!
|
||||
|
||||
@@ -321,6 +321,8 @@ bool SidearmWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
}
|
||||
}
|
||||
|
||||
spawnTracer(cWeapon, wi);
|
||||
|
||||
// Deal damage!
|
||||
Events::PlayerDamage ePlayerDamage;
|
||||
ePlayerDamage.Inflictor = wi.Player;
|
||||
@@ -330,6 +332,49 @@ bool SidearmWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi
|
||||
|
||||
return damage > 0;
|
||||
}
|
||||
|
||||
void SidearmWeaponBehaviour::spawnTracer(ComponentWrapper cWeapon, WeaponInfo& wi)
|
||||
{
|
||||
EntityWrapper muzzle = getRelevantWeaponEntity(wi).FirstChildByName("WeaponMuzzle");
|
||||
if (!muzzle.Valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityWrapper camera = wi.Player.FirstChildByName("Camera");
|
||||
if (!camera.Valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
glm::vec3 cameraPosition = Transform::AbsolutePosition(camera);
|
||||
glm::vec3 direction = glm::vec3(0, 0, -1);
|
||||
|
||||
float distance;
|
||||
glm::vec3 hitPosition;
|
||||
Collision::EntityFirstHitByRay(Ray(cameraPosition, direction), m_CollisionOctree, distance, hitPosition);
|
||||
|
||||
EntityWrapper ray = SpawnerSystem::Spawn(muzzle);
|
||||
if (ray.Valid()) {
|
||||
ComponentWrapper cTransform = ray["Transform"];
|
||||
glm::vec3& rayOrigin = cTransform["Position"];
|
||||
glm::vec3& rayOrientation = cTransform["Orientation"];
|
||||
glm::vec3& rayScale = cTransform["Scale"];
|
||||
|
||||
glm::vec3 muzzlePosition = Transform::AbsolutePosition(muzzle);
|
||||
glm::quat muzzleOrientation = Transform::AbsoluteOrientation(muzzle);
|
||||
|
||||
rayOrigin = muzzlePosition;
|
||||
|
||||
glm::vec3 muzzleToHit = hitPosition - muzzlePosition;
|
||||
glm::vec3 lookVector = glm::normalize(-muzzleToHit);
|
||||
float pitch = std::asin(-lookVector.y);
|
||||
float yaw = std::atan2(lookVector.x, lookVector.z);
|
||||
glm::quat orientation = glm::quat(glm::vec3(pitch, yaw, 0));
|
||||
rayOrientation = glm::eulerAngles(orientation);
|
||||
rayScale.z = glm::length(muzzleToHit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver)
|
||||
|
||||
Reference in New Issue
Block a user