new switches "count-unit-death-in-stats", "count-unit-production-in-stats" and "count-unit-kill-in-stats" for unit.xml ( allows better "resource" production for example )
This commit is contained in:
parent
bb44cfdb7b
commit
d8ba2443cf
|
@ -111,20 +111,28 @@ void Stats::setVictorious(int playerIndex){
|
|||
playerStats[playerIndex].victory= true;
|
||||
}
|
||||
|
||||
void Stats::kill(int killerFactionIndex, int killedFactionIndex, bool isEnemy) {
|
||||
playerStats[killerFactionIndex].kills++;
|
||||
playerStats[killedFactionIndex].deaths++;
|
||||
if(isEnemy == true) {
|
||||
void Stats::kill(int killerFactionIndex, int killedFactionIndex, bool isEnemy, bool isDeathCounted, bool isKillCounted) {
|
||||
if(isKillCounted == true){
|
||||
playerStats[killerFactionIndex].kills++;
|
||||
}
|
||||
if(isDeathCounted == true){
|
||||
playerStats[killedFactionIndex].deaths++;
|
||||
}
|
||||
if(isEnemy == true && isKillCounted == true) {
|
||||
playerStats[killerFactionIndex].enemykills++;
|
||||
}
|
||||
}
|
||||
|
||||
void Stats::die(int diedFactionIndex){
|
||||
playerStats[diedFactionIndex].deaths++;
|
||||
void Stats::die(int diedFactionIndex, bool isDeathCounted){
|
||||
if(isDeathCounted == true){
|
||||
playerStats[diedFactionIndex].deaths++;
|
||||
}
|
||||
}
|
||||
|
||||
void Stats::produce(int producerFactionIndex){
|
||||
playerStats[producerFactionIndex].unitsProduced++;
|
||||
void Stats::produce(int producerFactionIndex, bool isProductionCounted){
|
||||
if(isProductionCounted == true){
|
||||
playerStats[producerFactionIndex].unitsProduced++;
|
||||
}
|
||||
}
|
||||
|
||||
void Stats::harvest(int harvesterFactionIndex, int amount){
|
||||
|
|
|
@ -124,9 +124,9 @@ public:
|
|||
void setResourceMultiplier(int playerIndex, float resourceMultiplier) {playerStats[playerIndex].resourceMultiplier= resourceMultiplier;}
|
||||
void setTeam(int playerIndex, int teamIndex) {playerStats[playerIndex].teamIndex= teamIndex;}
|
||||
void setVictorious(int playerIndex);
|
||||
void kill(int killerFactionIndex, int killedFactionIndex, bool isEnemy);
|
||||
void die(int diedFactionIndex);
|
||||
void produce(int producerFactionIndex);
|
||||
void kill(int killerFactionIndex, int killedFactionIndex, bool isEnemy, bool isDeathCounted, bool isKillCounted);
|
||||
void die(int diedFactionIndex, bool isDeathCounted);
|
||||
void produce(int producerFactionIndex, bool isProductionCounted);
|
||||
void harvest(int harvesterFactionIndex, int amount);
|
||||
void setPlayerName(int playerIndex, string value) {playerStats[playerIndex].playerName = value; }
|
||||
void setPlayerColor(int playerIndex, Vec3f value) {playerStats[playerIndex].playerColor = value; }
|
||||
|
|
|
@ -928,7 +928,7 @@ void Faction::applyCostsOnInterval(const ResourceType *rtApply) {
|
|||
bool decHpResult = unit->decHp(unit->getType()->getMaxHp() / 3);
|
||||
if(decHpResult) {
|
||||
unit->setCauseOfDeath(ucodStarvedResource);
|
||||
world->getStats()->die(unit->getFactionIndex());
|
||||
world->getStats()->die(unit->getFactionIndex(),unit->getType()->getCountUnitDeathInStats());
|
||||
scriptManager->onUnitDied(unit);
|
||||
}
|
||||
StaticSound *sound= unit->getType()->getFirstStOfClass(scDie)->getSound();
|
||||
|
|
|
@ -2145,7 +2145,7 @@ bool Unit::applyAttackBoost(const AttackBoost *boost, const Unit *source) {
|
|||
|
||||
this->setLastAttackerUnitId(source->getId());
|
||||
this->setCauseOfDeath(ucodAttackBoost);
|
||||
Unit::game->getWorld()->getStats()->die(getFactionIndex());
|
||||
Unit::game->getWorld()->getStats()->die(getFactionIndex(),getType()->getCountUnitDeathInStats());
|
||||
game->getScriptManager()->onUnitDied(this);
|
||||
|
||||
StaticSound *sound= this->getType()->getFirstStOfClass(scDie)->getSound();
|
||||
|
@ -2224,7 +2224,7 @@ void Unit::deapplyAttackBoost(const AttackBoost *boost, const Unit *source) {
|
|||
this->setLastAttackerUnitId(source->getId());
|
||||
this->setCauseOfDeath(ucodAttackBoost);
|
||||
|
||||
Unit::game->getWorld()->getStats()->die(getFactionIndex());
|
||||
Unit::game->getWorld()->getStats()->die(getFactionIndex(),getType()->getCountUnitDeathInStats());
|
||||
game->getScriptManager()->onUnitDied(this);
|
||||
|
||||
StaticSound *sound= this->getType()->getFirstStOfClass(scDie)->getSound();
|
||||
|
@ -2288,7 +2288,7 @@ void Unit::tick() {
|
|||
if(decHpResult) {
|
||||
this->setCauseOfDeath(ucodStarvedRegeneration);
|
||||
|
||||
Unit::game->getWorld()->getStats()->die(getFactionIndex());
|
||||
Unit::game->getWorld()->getStats()->die(getFactionIndex(),getType()->getCountUnitDeathInStats());
|
||||
game->getScriptManager()->onUnitDied(this);
|
||||
}
|
||||
StaticSound *sound= this->getType()->getFirstStOfClass(scDie)->getSound();
|
||||
|
@ -2322,7 +2322,7 @@ void Unit::tick() {
|
|||
if(decHpResult) {
|
||||
this->setCauseOfDeath(ucodStarvedRegeneration);
|
||||
|
||||
Unit::game->getWorld()->getStats()->die(getFactionIndex());
|
||||
Unit::game->getWorld()->getStats()->die(getFactionIndex(),getType()->getCountUnitDeathInStats());
|
||||
game->getScriptManager()->onUnitDied(this);
|
||||
}
|
||||
StaticSound *sound= this->getType()->getFirstStOfClass(scDie)->getSound();
|
||||
|
|
|
@ -502,6 +502,28 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
|
|||
loadedFileList[meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,meetingPointNode->getAttribute("image-path")->getRestrictedValue()));
|
||||
}
|
||||
|
||||
//countUnitDeathInStats
|
||||
if(parametersNode->hasChild("count-unit-death-in-stats")){
|
||||
const XmlNode *countUnitDeathInStatsNode= parametersNode->getChild("count-unit-death-in-stats");
|
||||
countUnitDeathInStats= countUnitDeathInStatsNode->getAttribute("value")->getBoolValue();
|
||||
} else {
|
||||
countUnitDeathInStats=true;
|
||||
}
|
||||
//countUnitProductionInStats
|
||||
if(parametersNode->hasChild("count-unit-production-in-stats")){
|
||||
const XmlNode *countUnitProductionInStatsNode= parametersNode->getChild("count-unit-production-in-stats");
|
||||
countUnitProductionInStats= countUnitProductionInStatsNode->getAttribute("value")->getBoolValue();
|
||||
} else {
|
||||
countUnitProductionInStats=true;
|
||||
}
|
||||
//countUnitKillInStats
|
||||
if(parametersNode->hasChild("count-unit-kill-in-stats")){
|
||||
const XmlNode *countUnitKillInStatsNode= parametersNode->getChild("count-unit-kill-in-stats");
|
||||
countUnitKillInStats= countUnitKillInStatsNode->getAttribute("value")->getBoolValue();
|
||||
} else {
|
||||
countUnitKillInStats=true;
|
||||
}
|
||||
|
||||
//selection sounds
|
||||
const XmlNode *selectionSoundNode= parametersNode->getChild("selection-sounds");
|
||||
if(selectionSoundNode->getAttribute("enabled")->getBoolValue()){
|
||||
|
|
|
@ -133,6 +133,11 @@ private:
|
|||
bool meetingPoint;
|
||||
Texture2D *meetingPointImage;
|
||||
|
||||
// for dummy units and units used as shots and so on ....
|
||||
bool countUnitDeathInStats;
|
||||
bool countUnitProductionInStats;
|
||||
bool countUnitKillInStats;
|
||||
|
||||
//OPTIMIZATION: store first command type and skill type of each class
|
||||
const CommandType *firstCommandTypeOfClass[ccCount];
|
||||
const SkillType *firstSkillTypeOfClass[scCount];
|
||||
|
@ -176,6 +181,10 @@ public:
|
|||
const Resource *getStoredResource(int i) const {return &storedResources[i];}
|
||||
bool getCellMapCell(int x, int y, CardinalDir facing) const;
|
||||
bool getMeetingPoint() const {return meetingPoint;}
|
||||
bool getCountUnitDeathInStats() const {return countUnitDeathInStats;}
|
||||
bool getCountUnitProductionInStats() const {return countUnitProductionInStats;}
|
||||
bool getCountUnitKillInStats() const {return countUnitKillInStats;}
|
||||
|
||||
bool isMobile() const {return (firstSkillTypeOfClass[scMove] != NULL);}
|
||||
Texture2D *getMeetingPointImage() const {return meetingPointImage;}
|
||||
StaticSound *getSelectionSound() const {return selectionSounds.getRandSound();}
|
||||
|
|
|
@ -247,7 +247,7 @@ void UnitUpdater::updateUnit(Unit *unit) {
|
|||
else {
|
||||
spawned->create();
|
||||
spawned->born(ct);
|
||||
world->getStats()->produce(unit->getFactionIndex());
|
||||
world->getStats()->produce(unit->getFactionIndex(),spawned->getType()->getCountUnitProductionInStats());
|
||||
const CommandType *ct= spawned->computeCommandType(command->getPos(),command->getUnit());
|
||||
if(ct != NULL){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -1813,7 +1813,7 @@ void UnitUpdater::updateProduce(Unit *unit, int frameIndex) {
|
|||
else{
|
||||
produced->create();
|
||||
produced->born(ct);
|
||||
world->getStats()->produce(unit->getFactionIndex());
|
||||
world->getStats()->produce(unit->getFactionIndex(),produced->getType()->getCountUnitProductionInStats());
|
||||
const CommandType *ct= produced->computeCommandType(unit->getMeetingPos());
|
||||
if(ct!=NULL){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -2062,7 +2062,7 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
|
|||
|
||||
//damage the unit
|
||||
if(attacked->decHp(static_cast<int>(damage))) {
|
||||
world->getStats()->kill(attacker->getFactionIndex(), attacked->getFactionIndex(), attacker->getTeam() != attacked->getTeam());
|
||||
world->getStats()->kill(attacker->getFactionIndex(), attacked->getFactionIndex(), attacker->getTeam() != attacked->getTeam(),attacked->getType()->getCountUnitDeathInStats(),attacked->getType()->getCountUnitKillInStats());
|
||||
attacker->incKills(attacked->getTeam());
|
||||
|
||||
switch(this->game->getGameSettings()->getPathFinderType()) {
|
||||
|
|
Loading…
Reference in New Issue