void FactionManager::awardFactionStanding(CreatureObject* player, const String& factionName) { if (player == NULL) return; ManagedReference<PlayerObject*> ghost = player->getPlayerObject(); if (!factionMap.contains(factionName)) return; float lose = floor((float)75); //TODO: Find the equation for this. float gain = floor((float)lose / 2); //you gain half of what you lose Faction faction = factionMap.get(factionName); SortedVector<String>* enemies = faction.getEnemies(); SortedVector<String>* allies = faction.getAllies(); ghost->decreaseFactionStanding(factionName, lose); //Lose faction standing to allies of the creature. for (int i = 0; i < allies->size(); ++i) { String ally = allies->get(i); ghost->decreaseFactionStanding(ally, lose); } //Gain faction standing to enemies of the creature. for (int i = 0; i < enemies->size(); ++i) { String enemy = enemies->get(i); ghost->increaseFactionStanding(enemy, gain); } }
void MissionObjectiveImplementation::awardFactionPoints() { ManagedReference<MissionObject* > mission = this->mission.get(); int factionPointsRebel = mission->getRewardFactionPointsRebel(); int factionPointsImperial = mission->getRewardFactionPointsImperial(); if ((factionPointsRebel <= 0 && factionPointsImperial <= 0) || mission->getFaction() == MissionObject::FACTIONNEUTRAL) { return; } //Award faction points for faction delivery missions. ManagedReference<CreatureObject*> creatureOwner = getPlayerOwner(); if (creatureOwner != NULL) { ManagedReference<PlayerObject*> ghost = creatureOwner->getPlayerObject(); if (ghost != NULL) { Locker ghostLocker(creatureOwner); //Switch to get the correct order. switch (mission->getFaction()) { case MissionObject::FACTIONIMPERIAL: if (factionPointsImperial > 0) { ghost->increaseFactionStanding("imperial", factionPointsImperial); } if (factionPointsRebel < 0) { ghost->decreaseFactionStanding("rebel", -factionPointsRebel); } break; case MissionObject::FACTIONREBEL: if (factionPointsRebel > 0) { ghost->increaseFactionStanding("rebel", factionPointsRebel); } if (factionPointsImperial < 0) { ghost->decreaseFactionStanding("imperial", -factionPointsImperial); } break; } } } }
void FactionManager::awardPvpFactionPoints(TangibleObject* killer, CreatureObject* destructedObject) { if (killer->isPlayerCreature() && destructedObject->isPlayerCreature()) { CreatureObject* killerCreature = cast<CreatureObject*>(killer); ManagedReference<PlayerObject*> ghost = killerCreature->getPlayerObject(); ManagedReference<PlayerObject*> killedGhost = destructedObject->getPlayerObject(); if (killer->isRebel() && destructedObject->isImperial()) { ghost->increaseFactionStanding("rebel", 75); ghost->decreaseFactionStanding("imperial", 75); killedGhost->decreaseFactionStanding("imperial", 75); //TODO: find formulas } else if (killer->isImperial() && destructedObject->isRebel()) { ghost->increaseFactionStanding("imperial", 75); ghost->decreaseFactionStanding("rebel", 75); killedGhost->decreaseFactionStanding("rebel", 75); } } else if (destructedObject->isPlayerCreature()) { ManagedReference<PlayerObject*> ghost = destructedObject->getPlayerObject(); if (killer->getFaction() != destructedObject->getFaction()) { if (killer->isRebel() && destructedObject->isImperial()) { ghost->decreaseFactionStanding("imperial", 75); //TODO: find formulas } else if (killer->isImperial() && destructedObject->isRebel()) { ghost->decreaseFactionStanding("rebel", 75); } } } }