- it is now possible to explicitly specify which units should count towards victory conditions. In the unit's xml file add:
<?xml version="1.0" standalone="no"?> <unit> <parameters> <!-- valid values are true or false for this optional parameter --> <count-in-victory-conditions value="false"/> </parameters> </unit>
This commit is contained in:
parent
0120c5211a
commit
3b9f799d26
|
@ -3263,7 +3263,8 @@ void Game::checkWinnerStandard() {
|
||||||
std::map<int,int> teamsAlive;
|
std::map<int,int> teamsAlive;
|
||||||
for(int i = 0; i < world.getFactionCount(); ++i) {
|
for(int i = 0; i < world.getFactionCount(); ++i) {
|
||||||
if(i != world.getThisFactionIndex()) {
|
if(i != world.getThisFactionIndex()) {
|
||||||
if(hasBuilding(world.getFaction(i))) {
|
//if(hasBuilding(world.getFaction(i))) {
|
||||||
|
if(factionLostGame(world.getFaction(i)) == false) {
|
||||||
teamsAlive[world.getFaction(i)->getTeam()] = teamsAlive[world.getFaction(i)->getTeam()] + 1;
|
teamsAlive[world.getFaction(i)->getTeam()] = teamsAlive[world.getFaction(i)->getTeam()] + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3306,7 +3307,8 @@ void Game::checkWinnerStandard() {
|
||||||
else {
|
else {
|
||||||
//lose
|
//lose
|
||||||
bool lose= false;
|
bool lose= false;
|
||||||
if(hasBuilding(world.getThisFaction()) == false) {
|
//if(hasBuilding(world.getThisFaction()) == false) {
|
||||||
|
if(factionLostGame(world.getThisFaction()) == true) {
|
||||||
lose= true;
|
lose= true;
|
||||||
for(int i=0; i<world.getFactionCount(); ++i) {
|
for(int i=0; i<world.getFactionCount(); ++i) {
|
||||||
if(world.getFaction(i)->getPersonalityType() != fpt_Observer) {
|
if(world.getFaction(i)->getPersonalityType() != fpt_Observer) {
|
||||||
|
@ -3342,7 +3344,9 @@ void Game::checkWinnerStandard() {
|
||||||
for(int i = 0; i < world.getFactionCount(); ++i) {
|
for(int i = 0; i < world.getFactionCount(); ++i) {
|
||||||
if(i != world.getThisFactionIndex()) {
|
if(i != world.getThisFactionIndex()) {
|
||||||
if(world.getFaction(i)->getPersonalityType() != fpt_Observer) {
|
if(world.getFaction(i)->getPersonalityType() != fpt_Observer) {
|
||||||
if(hasBuilding(world.getFaction(i)) && world.getFaction(i)->isAlly(world.getThisFaction()) == false) {
|
//if(hasBuilding(world.getFaction(i)) &&
|
||||||
|
if(factionLostGame(world.getFaction(i)) == false &&
|
||||||
|
world.getFaction(i)->isAlly(world.getThisFaction()) == false) {
|
||||||
win= false;
|
win= false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3413,6 +3417,22 @@ void Game::checkWinnerScripted() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Game::factionLostGame(const Faction *faction) {
|
||||||
|
for(int i=0; i<faction->getUnitCount(); ++i) {
|
||||||
|
const UnitType *ut = faction->getUnit(i)->getType();
|
||||||
|
if(ut->getCountInVictoryConditions() == ucvcNotSet) {
|
||||||
|
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(ut->getCountInVictoryConditions() == ucvcTrue) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool Game::hasBuilding(const Faction *faction) {
|
bool Game::hasBuilding(const Faction *faction) {
|
||||||
for(int i=0; i<faction->getUnitCount(); ++i) {
|
for(int i=0; i<faction->getUnitCount(); ++i) {
|
||||||
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
||||||
|
|
|
@ -256,6 +256,7 @@ private:
|
||||||
void checkWinnerStandard();
|
void checkWinnerStandard();
|
||||||
void checkWinnerScripted();
|
void checkWinnerScripted();
|
||||||
bool hasBuilding(const Faction *faction);
|
bool hasBuilding(const Faction *faction);
|
||||||
|
bool factionLostGame(const Faction *faction);
|
||||||
void incSpeed();
|
void incSpeed();
|
||||||
void decSpeed();
|
void decSpeed();
|
||||||
int getUpdateLoops();
|
int getUpdateLoops();
|
||||||
|
|
|
@ -76,6 +76,7 @@ const char *UnitType::propertyNames[]= {"burnable", "rotated_climb"};
|
||||||
|
|
||||||
UnitType::UnitType() : ProducibleType() {
|
UnitType::UnitType() : ProducibleType() {
|
||||||
|
|
||||||
|
countInVictoryConditions = ucvcNotSet;
|
||||||
meetingPointImage = NULL;
|
meetingPointImage = NULL;
|
||||||
lightColor= Vec3f(0.f);
|
lightColor= Vec3f(0.f);
|
||||||
light= false;
|
light= false;
|
||||||
|
@ -173,6 +174,16 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
|
||||||
|
|
||||||
const XmlNode *parametersNode= unitNode->getChild("parameters");
|
const XmlNode *parametersNode= unitNode->getChild("parameters");
|
||||||
|
|
||||||
|
if(parametersNode->hasChild("count-in-victory-conditions") == true) {
|
||||||
|
bool countUnit = parametersNode->getChild("count-in-victory-conditions")->getAttribute("value")->getBoolValue();
|
||||||
|
if(countUnit == true) {
|
||||||
|
countInVictoryConditions = ucvcTrue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
countInVictoryConditions = ucvcFalse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//size
|
//size
|
||||||
//checkItemInVault(&(this->size),this->size);
|
//checkItemInVault(&(this->size),this->size);
|
||||||
size= parametersNode->getChild("size")->getAttribute("value")->getIntValue();
|
size= parametersNode->getChild("size")->getAttribute("value")->getIntValue();
|
||||||
|
@ -1053,6 +1064,8 @@ std::string UnitType::toString() const {
|
||||||
|
|
||||||
result += " meetingPoint = " + intToStr(meetingPoint);
|
result += " meetingPoint = " + intToStr(meetingPoint);
|
||||||
|
|
||||||
|
result += " countInVictoryConditions = " + intToStr(countInVictoryConditions);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,12 @@ enum UnitClass {
|
||||||
|
|
||||||
typedef vector<UnitParticleSystemType*> DamageParticleSystemTypes;
|
typedef vector<UnitParticleSystemType*> DamageParticleSystemTypes;
|
||||||
|
|
||||||
|
enum UnitCountsInVictoryConditions {
|
||||||
|
ucvcNotSet,
|
||||||
|
ucvcTrue,
|
||||||
|
ucvcFalse
|
||||||
|
};
|
||||||
|
|
||||||
class UnitType: public ProducibleType, public ValueCheckerVault {
|
class UnitType: public ProducibleType, public ValueCheckerVault {
|
||||||
public:
|
public:
|
||||||
enum Property {
|
enum Property {
|
||||||
|
@ -148,6 +154,8 @@ private:
|
||||||
const CommandType *firstCommandTypeOfClass[ccCount];
|
const CommandType *firstCommandTypeOfClass[ccCount];
|
||||||
const SkillType *firstSkillTypeOfClass[scCount];
|
const SkillType *firstSkillTypeOfClass[scCount];
|
||||||
|
|
||||||
|
UnitCountsInVictoryConditions countInVictoryConditions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//creation and loading
|
//creation and loading
|
||||||
UnitType();
|
UnitType();
|
||||||
|
@ -159,6 +167,7 @@ public:
|
||||||
|
|
||||||
virtual string getName(bool translatedValue=false) const;
|
virtual string getName(bool translatedValue=false) const;
|
||||||
|
|
||||||
|
UnitCountsInVictoryConditions getCountInVictoryConditions() const { return countInVictoryConditions; }
|
||||||
//get
|
//get
|
||||||
inline int getId() const {return id;}
|
inline int getId() const {return id;}
|
||||||
inline int getMaxHp() const {return maxHp;}
|
inline int getMaxHp() const {return maxHp;}
|
||||||
|
|
Loading…
Reference in New Issue