allow attack boost to apply to self via attribute include-self="true"
This commit is contained in:
parent
cbdde66999
commit
db91ca6b9e
|
@ -36,6 +36,7 @@ AttackBoost::AttackBoost() {
|
||||||
targetType = abtFaction;
|
targetType = abtFaction;
|
||||||
unitParticleSystemTypeForSourceUnit = NULL;
|
unitParticleSystemTypeForSourceUnit = NULL;
|
||||||
unitParticleSystemTypeForAffectedUnit = NULL;
|
unitParticleSystemTypeForAffectedUnit = NULL;
|
||||||
|
includeSelf = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttackBoost::~AttackBoost() {
|
AttackBoost::~AttackBoost() {
|
||||||
|
@ -48,27 +49,16 @@ AttackBoost::~AttackBoost() {
|
||||||
|
|
||||||
bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
|
bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if(enabled == true && source != NULL && dest != NULL && source != dest) {
|
if(enabled == true &&
|
||||||
|
source != NULL && dest != NULL &&
|
||||||
|
(includeSelf == true || source != dest)) {
|
||||||
bool destUnitMightApply = false;
|
bool destUnitMightApply = false;
|
||||||
// All units are affected (including enemies)
|
if(source == dest && includeSelf == true) {
|
||||||
if(targetType == abtAll) {
|
destUnitMightApply = true;
|
||||||
destUnitMightApply = (boostUnitList.empty() == true);
|
|
||||||
|
|
||||||
// Specify which units are affected
|
|
||||||
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
|
|
||||||
const UnitType *ut = boostUnitList[i];
|
|
||||||
if(dest->getType()->getId() == ut->getId()) {
|
|
||||||
destUnitMightApply = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Only same faction units are affected
|
else {
|
||||||
else if(targetType == abtFaction) {
|
// All units are affected (including enemies)
|
||||||
//if(boostUnitList.empty() == true) {
|
if(targetType == abtAll) {
|
||||||
if(source->getFactionIndex() == dest->getFactionIndex()) {
|
|
||||||
//destUnitMightApply = true;
|
|
||||||
destUnitMightApply = (boostUnitList.empty() == true);
|
destUnitMightApply = (boostUnitList.empty() == true);
|
||||||
|
|
||||||
// Specify which units are affected
|
// Specify which units are affected
|
||||||
|
@ -81,15 +71,62 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//}
|
// Only same faction units are affected
|
||||||
}
|
else if(targetType == abtFaction) {
|
||||||
// Only ally units are affected
|
//if(boostUnitList.empty() == true) {
|
||||||
else if(targetType == abtAlly) {
|
if(source->getFactionIndex() == dest->getFactionIndex()) {
|
||||||
//if(boostUnitList.empty() == true) {
|
//destUnitMightApply = true;
|
||||||
if(source->isAlly(dest) == true) {
|
destUnitMightApply = (boostUnitList.empty() == true);
|
||||||
//destUnitMightApply = true;
|
|
||||||
destUnitMightApply = (boostUnitList.empty() == true);
|
|
||||||
|
|
||||||
|
// Specify which units are affected
|
||||||
|
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
|
||||||
|
const UnitType *ut = boostUnitList[i];
|
||||||
|
if(dest->getType()->getId() == ut->getId()) {
|
||||||
|
destUnitMightApply = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
// Only ally units are affected
|
||||||
|
else if(targetType == abtAlly) {
|
||||||
|
//if(boostUnitList.empty() == true) {
|
||||||
|
if(source->isAlly(dest) == true) {
|
||||||
|
//destUnitMightApply = true;
|
||||||
|
destUnitMightApply = (boostUnitList.empty() == true);
|
||||||
|
|
||||||
|
// Specify which units are affected
|
||||||
|
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
|
||||||
|
const UnitType *ut = boostUnitList[i];
|
||||||
|
if(dest->getType()->getId() == ut->getId()) {
|
||||||
|
destUnitMightApply = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
// Only foe units are affected
|
||||||
|
else if(targetType == abtFoe) {
|
||||||
|
//if(boostUnitList.empty() == true) {
|
||||||
|
if(source->isAlly(dest) == false) {
|
||||||
|
//destUnitMightApply = true;
|
||||||
|
destUnitMightApply = (boostUnitList.empty() == true);
|
||||||
|
|
||||||
|
// Specify which units are affected
|
||||||
|
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
|
||||||
|
const UnitType *ut = boostUnitList[i];
|
||||||
|
if(dest->getType()->getId() == ut->getId()) {
|
||||||
|
destUnitMightApply = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
else if(targetType == abtUnitTypes) {
|
||||||
// Specify which units are affected
|
// Specify which units are affected
|
||||||
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
|
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
|
||||||
const UnitType *ut = boostUnitList[i];
|
const UnitType *ut = boostUnitList[i];
|
||||||
|
@ -99,35 +136,6 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
}
|
|
||||||
// Only foe units are affected
|
|
||||||
else if(targetType == abtFoe) {
|
|
||||||
//if(boostUnitList.empty() == true) {
|
|
||||||
if(source->isAlly(dest) == false) {
|
|
||||||
//destUnitMightApply = true;
|
|
||||||
destUnitMightApply = (boostUnitList.empty() == true);
|
|
||||||
|
|
||||||
// Specify which units are affected
|
|
||||||
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
|
|
||||||
const UnitType *ut = boostUnitList[i];
|
|
||||||
if(dest->getType()->getId() == ut->getId()) {
|
|
||||||
destUnitMightApply = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
else if(targetType == abtUnitTypes) {
|
|
||||||
// Specify which units are affected
|
|
||||||
for(unsigned int i = 0; i < boostUnitList.size(); ++i) {
|
|
||||||
const UnitType *ut = boostUnitList[i];
|
|
||||||
if(dest->getType()->getId() == ut->getId()) {
|
|
||||||
destUnitMightApply = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(destUnitMightApply == true) {
|
if(destUnitMightApply == true) {
|
||||||
|
@ -268,10 +276,16 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
||||||
attackBoost.enabled = true;
|
attackBoost.enabled = true;
|
||||||
|
|
||||||
const XmlNode *attackBoostNode = sn->getChild("attack-boost");
|
const XmlNode *attackBoostNode = sn->getChild("attack-boost");
|
||||||
|
string targetType = attackBoostNode->getChild("target")->getAttribute("value")->getValue();
|
||||||
|
|
||||||
attackBoost.allowMultipleBoosts = attackBoostNode->getChild("allow-multiple-boosts")->getAttribute("value")->getBoolValue();
|
attackBoost.allowMultipleBoosts = attackBoostNode->getChild("allow-multiple-boosts")->getAttribute("value")->getBoolValue();
|
||||||
attackBoost.radius = attackBoostNode->getChild("radius")->getAttribute("value")->getIntValue();
|
attackBoost.radius = attackBoostNode->getChild("radius")->getAttribute("value")->getIntValue();
|
||||||
|
|
||||||
string targetType = attackBoostNode->getChild("target")->getAttribute("value")->getValue();
|
attackBoost.includeSelf = false;
|
||||||
|
if(attackBoostNode->getChild("target")->hasAttribute("include-self") == true) {
|
||||||
|
attackBoost.includeSelf = attackBoostNode->getChild("target")->getAttribute("include-self")->getBoolValue();
|
||||||
|
}
|
||||||
|
|
||||||
if(targetType == "ally") {
|
if(targetType == "ally") {
|
||||||
attackBoost.targetType = abtAlly;
|
attackBoost.targetType = abtAlly;
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,8 @@ public:
|
||||||
UnitParticleSystemType *unitParticleSystemTypeForSourceUnit;
|
UnitParticleSystemType *unitParticleSystemTypeForSourceUnit;
|
||||||
UnitParticleSystemType *unitParticleSystemTypeForAffectedUnit;
|
UnitParticleSystemType *unitParticleSystemTypeForAffectedUnit;
|
||||||
|
|
||||||
|
bool includeSelf;
|
||||||
|
|
||||||
bool isAffected(const Unit *source, const Unit *dest) const;
|
bool isAffected(const Unit *source, const Unit *dest) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,8 @@ public:
|
||||||
|
|
||||||
XmlAttribute *getAttribute(unsigned int i) const;
|
XmlAttribute *getAttribute(unsigned int i) const;
|
||||||
XmlAttribute *getAttribute(const string &name,bool mustExist=true) const;
|
XmlAttribute *getAttribute(const string &name,bool mustExist=true) const;
|
||||||
|
bool hasAttribute(const string &name) const;
|
||||||
|
|
||||||
XmlNode *getChild(unsigned int i) const;
|
XmlNode *getChild(unsigned int i) const;
|
||||||
XmlNode *getChild(const string &childName, unsigned int childIndex=0) const;
|
XmlNode *getChild(const string &childName, unsigned int childIndex=0) const;
|
||||||
vector<XmlNode *> getChildList(const string &childName) const;
|
vector<XmlNode *> getChildList(const string &childName) const;
|
||||||
|
|
|
@ -314,6 +314,17 @@ XmlAttribute *XmlNode::getAttribute(const string &name,bool mustExist) const {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool XmlNode::hasAttribute(const string &name) const {
|
||||||
|
bool result = false;
|
||||||
|
for(unsigned int i = 0; i < attributes.size(); ++i) {
|
||||||
|
if(attributes[i]->getName() == name) {
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
XmlNode *XmlNode::getChild(unsigned int i) const {
|
XmlNode *XmlNode::getChild(unsigned int i) const {
|
||||||
assert(!superNode);
|
assert(!superNode);
|
||||||
if(i >= children.size()) {
|
if(i >= children.size()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user