Assault boost check
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Entity name="FriendlyBoostHUD" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Scale X="1.5" Y="1.5" Z="1"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
|
||||
<Children>
|
||||
<Entity name="BoostHUDBackground">
|
||||
<Components>
|
||||
<c:Sprite>
|
||||
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||
<GlowMap></GlowMap>
|
||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||
<Color A="0.588235319" B="0" G="0" R="0"/>
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="-0.00300000003"/>
|
||||
<Scale X="0.0599999987" Y="0.0599999987" Z="0.0599999987"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="BoostIcons">
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="-1.47358617e-06" Y="-0.0191892758" Z="4.05375999e-07"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="AssaultBoost">
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="0.0120000001" Y="0.00899999961" Z="-8.43336147e-06"/>
|
||||
<Scale X="0.0199999996" Y="0.0199999996" Z="0.0199999996"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Active">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>\1</Content>
|
||||
<Resource>Fonts/Hind-Edited.otf,64</Resource>
|
||||
<Color A="1" B="1.37254906" G="0.392156869" R="0"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.0149999997"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Inactive">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>\1</Content>
|
||||
<Resource>Fonts/Hind-Edited.otf,64</Resource>
|
||||
<Color A="1" B="0.0784313753" G="0.0784313753" R="0.0784313753"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="-8.43336147e-06"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="DefenderBoost">
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="-0.0120000001" Y="0.00900000054" Z="-8.43336147e-06"/>
|
||||
<Scale X="0.0199999996" Y="0.0199999996" Z="0.0199999996"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Active">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>\2</Content>
|
||||
<Resource>Fonts/Hind-Edited.otf,64</Resource>
|
||||
<Color A="1" B="1.37254906" G="0.392156869" R="0"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Inactive">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>\2</Content>
|
||||
<Resource>Fonts/Hind-Edited.otf,64</Resource>
|
||||
<Color A="1" B="0.0784313753" G="0.0784313753" R="0.0784313753"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="-8.43336147e-06"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="SniperBoost">
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.0310000014" Z="-1.21438188e-05"/>
|
||||
<Scale X="0.0199999996" Y="0.0199999996" Z="0.0199999996"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Active">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>\3</Content>
|
||||
<Resource>Fonts/Hind-Edited.otf,64</Resource>
|
||||
<Color A="1" B="1.37254906" G="0.392156869" R="0"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Inactive">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>\3</Content>
|
||||
<Resource>Fonts/Hind-Edited.otf,64</Resource>
|
||||
<Color A="1" B="0.0784313753" G="0.0784313753" R="0.0784313753"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="-8.43336147e-06"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
@@ -216,7 +216,7 @@
|
||||
<Entity name="FriendlyBoostAttachment">
|
||||
<Components>
|
||||
<c:Spawner>
|
||||
<EntityFile>Schema/Entities/FriendlyAmmoHUD.xml</EntityFile>
|
||||
<EntityFile>Schema/Entities/FriendlyBoostBlueHUD.xml</EntityFile>
|
||||
</c:Spawner>
|
||||
<c:Transform>
|
||||
<Position X="-0.000110394583" Y="-0.0891034827" Z="6.07890324e-05"/>
|
||||
|
||||
@@ -8,21 +8,18 @@ BoostSystem::BoostSystem(SystemParams params)
|
||||
|
||||
bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||
{
|
||||
if (e.Victim.ID == e.Inflictor.ID) {
|
||||
if (!IsServer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!e.Victim.Valid() || !LocalPlayer.Valid()) {
|
||||
if (e.Victim == e.Inflictor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
|
||||
if (!e.Victim.Valid() || !e.Inflictor.Valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!e.Inflictor.Valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//if its not friendly fire, return
|
||||
if ((int)m_World->GetComponent(e.Inflictor.ID, "Team")["Team"] != (int)m_World->GetComponent(e.Victim.ID, "Team")["Team"]) {
|
||||
@@ -86,7 +83,7 @@ void BoostSystem::giveAmmo(EntityWrapper giver, EntityWrapper receiver)
|
||||
int maxAmmo = receiver["AssaultWeapon"]["MaxAmmo"];
|
||||
Field<int> ammo = receiver["AssaultWeapon"]["Ammo"];
|
||||
|
||||
int givenAmmo = 3;
|
||||
int givenAmmo = 20;
|
||||
|
||||
magazineAmmo = glm::clamp(magazineAmmo + givenAmmo, 0, magazineSize);
|
||||
if (magazineAmmo > prevMagazineAmmo) {
|
||||
@@ -102,7 +99,7 @@ void BoostSystem::giveAmmo(EntityWrapper giver, EntityWrapper receiver)
|
||||
int maxAmmo = receiver["DefenderWeapon"]["MaxAmmo"];
|
||||
Field<int> ammo = receiver["DefenderWeapon"]["Ammo"];
|
||||
|
||||
int givenAmmo = 1;
|
||||
int givenAmmo = 3;
|
||||
|
||||
magazineAmmo = glm::clamp(magazineAmmo + givenAmmo, 0, magazineSize);
|
||||
if (magazineAmmo > prevMagazineAmmo) {
|
||||
|
||||
@@ -10,6 +10,7 @@ void AssaultWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWra
|
||||
|
||||
void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt)
|
||||
{
|
||||
CheckBoost(cWeapon, wi);
|
||||
// Start reloading automatically if at 0 mag ammo
|
||||
Field<int> magAmmo = cWeapon["MagazineAmmo"];
|
||||
if (m_ConfigAutoReload && magAmmo <= 0) {
|
||||
@@ -407,52 +408,106 @@ void AssaultWeaponBehaviour::CheckBoost(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"]) {
|
||||
|
||||
|
||||
EntityWrapper friendlyBoostHudSpawner = wi.FirstPersonPlayerModel.FirstChildByName("FriendlyBoostAttachment");
|
||||
if (friendlyBoostHudSpawner.Valid()) {
|
||||
|
||||
EntityWrapper assaultBoost = victim.FirstChildByName("BoostAssault");
|
||||
EntityWrapper defenderBoost = victim.FirstChildByName("BoostDefender");
|
||||
EntityWrapper sniperBoost = victim.FirstChildByName("BoostSniper");
|
||||
|
||||
auto children = m_World->GetDirectChildren(friendlyBoostHudSpawner.ID);
|
||||
|
||||
if (children.first == children.second) {
|
||||
if (friendlyBoostHudSpawner.HasComponent("Spawner")) {
|
||||
EntityWrapper friendlyAmmoHud = SpawnerSystem::Spawn(friendlyBoostHudSpawner, friendlyBoostHudSpawner);
|
||||
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 friendlyBoostHud = SpawnerSystem::Spawn(friendlyBoostHudSpawner, friendlyBoostHudSpawner);
|
||||
if (friendlyBoostHud.Valid()) {
|
||||
EntityWrapper assaultBoostEntity = friendlyBoostHud.FirstChildByName("AssaultBoost");
|
||||
if (assaultBoostEntity.Valid()) {
|
||||
EntityWrapper active = assaultBoostEntity.FirstChildByName("Active");
|
||||
if (active.HasComponent("Text")) {
|
||||
if (assaultBoost.Valid()) {
|
||||
(Field<bool>)active["Text"]["Visible"] = true;
|
||||
} else {
|
||||
(Field<bool>)active["Text"]["Visible"] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EntityWrapper ammoTextEntity = friendlyAmmoHud.FirstChildByName("Ammo");
|
||||
if (ammoTextEntity.Valid()) {
|
||||
if (ammoTextEntity.HasComponent("Text")) {
|
||||
// (std::string&)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
|
||||
EntityWrapper defenderBoostEntity = friendlyBoostHud.FirstChildByName("DefenderBoost");
|
||||
if (defenderBoostEntity.Valid()) {
|
||||
EntityWrapper active = defenderBoostEntity.FirstChildByName("Active");
|
||||
if (active.HasComponent("Text")) {
|
||||
if (defenderBoost.Valid()) {
|
||||
(Field<bool>)active["Text"]["Visible"] = true;
|
||||
} else {
|
||||
(Field<bool>)active["Text"]["Visible"] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EntityWrapper sniperBoostEntity = friendlyBoostHud.FirstChildByName("SniperBoost");
|
||||
if (sniperBoostEntity.Valid()) {
|
||||
EntityWrapper active = sniperBoostEntity.FirstChildByName("Active");
|
||||
if (active.HasComponent("Text")) {
|
||||
if (sniperBoost.Valid()) {
|
||||
(Field<bool>)active["Text"]["Visible"] = true;
|
||||
} else {
|
||||
(Field<bool>)active["Text"]["Visible"] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
EntityWrapper textEntity = friendlyBoostHudSpawner.FirstChildByName("MagazineAmmo");
|
||||
if (textEntity.Valid()) {
|
||||
if (textEntity.HasComponent("Text")) {
|
||||
// (std::string&)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
|
||||
EntityWrapper friendlyBoostHud = friendlyBoostHudSpawner.FirstChildByName("FriendlyBoostHUD");
|
||||
if (friendlyBoostHud.Valid()) {
|
||||
EntityWrapper assaultBoostEntity = friendlyBoostHud.FirstChildByName("AssaultBoost");
|
||||
if (assaultBoostEntity.Valid()) {
|
||||
EntityWrapper active = assaultBoostEntity.FirstChildByName("Active");
|
||||
if (active.HasComponent("Text")) {
|
||||
if (assaultBoost.Valid()) {
|
||||
(Field<bool>)active["Text"]["Visible"] = true;
|
||||
} else {
|
||||
(Field<bool>)active["Text"]["Visible"] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EntityWrapper ammoTextEntity = friendlyBoostHudSpawner.FirstChildByName("Ammo");
|
||||
if (ammoTextEntity.Valid()) {
|
||||
if (ammoTextEntity.HasComponent("Text")) {
|
||||
// (std::string&)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
|
||||
EntityWrapper defenderBoostEntity = friendlyBoostHud.FirstChildByName("DefenderBoost");
|
||||
if (defenderBoostEntity.Valid()) {
|
||||
EntityWrapper active = defenderBoostEntity.FirstChildByName("Active");
|
||||
if (active.HasComponent("Text")) {
|
||||
if (defenderBoost.Valid()) {
|
||||
(Field<bool>)active["Text"]["Visible"] = true;
|
||||
} else {
|
||||
(Field<bool>)active["Text"]["Visible"] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EntityWrapper sniperBoostEntity = friendlyBoostHud.FirstChildByName("SniperBoost");
|
||||
if (sniperBoostEntity.Valid()) {
|
||||
EntityWrapper active = sniperBoostEntity.FirstChildByName("Active");
|
||||
if (active.HasComponent("Text")) {
|
||||
if (sniperBoost.Valid()) {
|
||||
(Field<bool>)active["Text"]["Visible"] = true;
|
||||
} else {
|
||||
(Field<bool>)active["Text"]["Visible"] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AssaultWeaponBehaviour::RemoveBoostCheckHUD(WeaponInfo& wi)
|
||||
{
|
||||
|
||||
EntityWrapper friendlyBoostHudSpawner = wi.FirstPersonPlayerModel.FirstChildByName("FriendlyBoostAttachment");
|
||||
if (friendlyBoostHudSpawner.Valid()) {
|
||||
friendlyBoostHudSpawner.DeleteChildren();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user