Assault boost check
This commit is contained in:
@@ -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