void TangibleObjectImplementation::sendPvpStatusTo(CreatureObject* player) {
	uint32 newPvpStatusBitmask = pvpStatusBitmask;

	if (!(newPvpStatusBitmask & CreatureFlag::ATTACKABLE)) {
		if (isAttackableBy(player))
			newPvpStatusBitmask |= CreatureFlag::ATTACKABLE;
	} else if (!isAttackableBy(player))
		newPvpStatusBitmask -= CreatureFlag::ATTACKABLE;

	if (!(newPvpStatusBitmask & CreatureFlag::AGGRESSIVE)) {
		if (isAggressiveTo(player))
			newPvpStatusBitmask |= CreatureFlag::AGGRESSIVE;
	} else if (!isAggressiveTo(player))
		newPvpStatusBitmask -= CreatureFlag::AGGRESSIVE;

	if (newPvpStatusBitmask & CreatureFlag::TEF) {
		if (player != asTangibleObject())
			newPvpStatusBitmask -= CreatureFlag::TEF;
	}

	BaseMessage* pvp = new UpdatePVPStatusMessage(asTangibleObject(), newPvpStatusBitmask);
	player->sendMessage(pvp);
}
bool InstallationObjectImplementation::isAttackableBy(CreatureObject* object) {
	if (!(getPvpStatusBitmask() & CreatureFlag::ATTACKABLE)) {
		return false;
	}

	unsigned int thisFaction = getFaction();
	unsigned int otherFaction = object->getFaction();

	if (otherFaction != 0 && thisFaction != 0) {
		if (otherFaction == thisFaction) {
			return false;
		}

	}

	if (object->isPet()) {
		ManagedReference<CreatureObject*> owner = object->getLinkedCreature().get();

		if (owner == NULL)
			return false;

		return isAttackableBy(owner);

	} else if (object->isPlayerCreature()) {
		ManagedReference<PlayerObject*> ghost = object->getPlayerObject();
		if (ghost == NULL) {
			return false;
		}

		if (thisFaction != 0) {
			if (ghost->getFactionStatus() == 0) {
				return false;
			}

			if ((getPvpStatusBitmask() & CreatureFlag::OVERT) && ghost->getFactionStatus() != FactionStatus::OVERT) {
				return false;
			}
		}
	}

	return true;
}