From ed2016d060d428f6d8d54665c7e1ca66a87059ad Mon Sep 17 00:00:00 2001 From: Treeku Date: Sat, 4 Jan 2014 20:54:55 +0000 Subject: [PATCH] Target's Pvp Status Calculation --- src/services/gcw/FactionService.java | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/services/gcw/FactionService.java b/src/services/gcw/FactionService.java index 0406f2e5..9a2dfd42 100644 --- a/src/services/gcw/FactionService.java +++ b/src/services/gcw/FactionService.java @@ -36,8 +36,12 @@ import protocol.swg.FactionResponseMessage; import resources.common.FileUtilities; import resources.common.Opcodes; +import resources.datatables.FactionStatus; +import resources.datatables.Options; +import resources.datatables.PvpStatus; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleObject; import engine.clientdata.StfTable; import engine.clients.Client; @@ -183,6 +187,52 @@ public class FactionService implements INetworkDispatch { return false; } + /* + * Calculates the target's pvp bitmask based on the person's + * faction standing and the enemy's options bitmask. + * + * This shouldn't be what we "set" the bitmask to, just + * what we use when calculating how to treat a target + * and when we send it. + * + * This should be used instead of getPvPBitmask where possible, but + * should not be used in setPvPBitmask. + */ + public int calculatePvpStatus(CreatureObject player, TangibleObject target) { + PlayerObject ghost = (PlayerObject) player.getSlottedObject("ghost"); + + int pvpBitmask = target.getPvPBitmask(); + + if (target.getSlottedObject("ghost") != null) { + pvpBitmask |= PvpStatus.Player; + + if (player.getFactionStatus() == FactionStatus.SpecialForces && + ((CreatureObject) target).getFactionStatus() == FactionStatus.SpecialForces) { + pvpBitmask |= (PvpStatus.Attackable | PvpStatus.Aggressive); + } + + return pvpBitmask; + } + + if (target.getOption(Options.ATTACKABLE)) { + pvpBitmask |= PvpStatus.Attackable; + } + + if (target.getOption(Options.AGGRESSIVE)) { + pvpBitmask |= PvpStatus.Aggressive; + } else { + Integer factionStanding = ghost.getFactionStandingMap().get(target.getFaction()); + + if (factionStanding != null) { + if (((TangibleObject) target).getOption(Options.ATTACKABLE) && factionStanding < 0) { + pvpBitmask |= PvpStatus.Aggressive; + } + } + } + + return pvpBitmask; + } + public Map getFactionMap() { return factionMap; }