-AI can't command non-commandable units anymore
-Removed non-selectable
This commit is contained in:
parent
72828c39a3
commit
850a9a7dc0
|
@ -531,7 +531,7 @@ bool Ai::findAbleUnit(int *unitIndex, CommandClass ability, bool idleOnly){
|
||||||
*unitIndex= -1;
|
*unitIndex= -1;
|
||||||
for(int i=0; i<aiInterface->getMyUnitCount(); ++i){
|
for(int i=0; i<aiInterface->getMyUnitCount(); ++i){
|
||||||
const Unit *unit= aiInterface->getMyUnit(i);
|
const Unit *unit= aiInterface->getMyUnit(i);
|
||||||
if(unit->getType()->hasCommandClass(ability)){
|
if(unit->getType()->isCommandable() && unit->getType()->hasCommandClass(ability)){
|
||||||
if(!idleOnly || !unit->anyCommand() || unit->getCurrCommand()->getCommandType()->getClass()==ccStop){
|
if(!idleOnly || !unit->anyCommand() || unit->getCurrCommand()->getCommandType()->getClass()==ccStop){
|
||||||
units.push_back(i);
|
units.push_back(i);
|
||||||
}
|
}
|
||||||
|
@ -553,55 +553,57 @@ vector<int> Ai::findUnitsHarvestingResourceType(const ResourceType *rt) {
|
||||||
Map *map= aiInterface->getMap();
|
Map *map= aiInterface->getMap();
|
||||||
for(int i = 0; i < aiInterface->getMyUnitCount(); ++i) {
|
for(int i = 0; i < aiInterface->getMyUnitCount(); ++i) {
|
||||||
const Unit *unit= aiInterface->getMyUnit(i);
|
const Unit *unit= aiInterface->getMyUnit(i);
|
||||||
if(unit->getType()->hasCommandClass(ccHarvest)) {
|
if(unit->getType()->isCommandable()) {
|
||||||
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == ccHarvest) {
|
if(unit->getType()->hasCommandClass(ccHarvest)) {
|
||||||
Command *command= unit->getCurrCommand();
|
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == ccHarvest) {
|
||||||
const HarvestCommandType *hct= dynamic_cast<const HarvestCommandType*>(command->getCommandType());
|
Command *command= unit->getCurrCommand();
|
||||||
if(hct != NULL) {
|
const HarvestCommandType *hct= dynamic_cast<const HarvestCommandType*>(command->getCommandType());
|
||||||
const Vec2i unitTargetPos = unit->getTargetPos();
|
if(hct != NULL) {
|
||||||
SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unitTargetPos));
|
const Vec2i unitTargetPos = unit->getTargetPos();
|
||||||
Resource *r= sc->getResource();
|
SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unitTargetPos));
|
||||||
if (r != NULL && r->getType() == rt) {
|
Resource *r= sc->getResource();
|
||||||
units.push_back(i);
|
if (r != NULL && r->getType() == rt) {
|
||||||
}
|
units.push_back(i);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(unit->getType()->hasCommandClass(ccProduce)) {
|
|
||||||
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == ccProduce) {
|
|
||||||
Command *command= unit->getCurrCommand();
|
|
||||||
const ProduceCommandType *pct= dynamic_cast<const ProduceCommandType*>(command->getCommandType());
|
|
||||||
if(pct != NULL) {
|
|
||||||
const UnitType *ut = pct->getProducedUnit();
|
|
||||||
if(ut != NULL) {
|
|
||||||
const Resource *r = ut->getCost(rt);
|
|
||||||
if(r != NULL) {
|
|
||||||
if (r != NULL && r->getAmount() < 0) {
|
|
||||||
units.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if(unit->getType()->hasCommandClass(ccProduce)) {
|
||||||
else if(unit->getType()->hasCommandClass(ccBuild)) {
|
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == ccProduce) {
|
||||||
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == ccBuild) {
|
Command *command= unit->getCurrCommand();
|
||||||
Command *command= unit->getCurrCommand();
|
const ProduceCommandType *pct= dynamic_cast<const ProduceCommandType*>(command->getCommandType());
|
||||||
const BuildCommandType *bct= dynamic_cast<const BuildCommandType*>(command->getCommandType());
|
if(pct != NULL) {
|
||||||
if(bct != NULL) {
|
const UnitType *ut = pct->getProducedUnit();
|
||||||
for(int j = 0; j < bct->getBuildingCount(); ++j) {
|
|
||||||
const UnitType *ut = bct->getBuilding(j);
|
|
||||||
if(ut != NULL) {
|
if(ut != NULL) {
|
||||||
const Resource *r = ut->getCost(rt);
|
const Resource *r = ut->getCost(rt);
|
||||||
if(r != NULL) {
|
if(r != NULL) {
|
||||||
if (r != NULL && r->getAmount() < 0) {
|
if (r != NULL && r->getAmount() < 0) {
|
||||||
units.push_back(i);
|
units.push_back(i);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if(unit->getType()->hasCommandClass(ccBuild)) {
|
||||||
|
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == ccBuild) {
|
||||||
|
Command *command= unit->getCurrCommand();
|
||||||
|
const BuildCommandType *bct= dynamic_cast<const BuildCommandType*>(command->getCommandType());
|
||||||
|
if(bct != NULL) {
|
||||||
|
for(int j = 0; j < bct->getBuildingCount(); ++j) {
|
||||||
|
const UnitType *ut = bct->getBuilding(j);
|
||||||
|
if(ut != NULL) {
|
||||||
|
const Resource *r = ut->getCost(rt);
|
||||||
|
if(r != NULL) {
|
||||||
|
if (r != NULL && r->getAmount() < 0) {
|
||||||
|
units.push_back(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -614,7 +616,7 @@ vector<int> Ai::findUnitsDoingCommand(CommandClass currentCommand) {
|
||||||
|
|
||||||
for(int i = 0; i < aiInterface->getMyUnitCount(); ++i) {
|
for(int i = 0; i < aiInterface->getMyUnitCount(); ++i) {
|
||||||
const Unit *unit= aiInterface->getMyUnit(i);
|
const Unit *unit= aiInterface->getMyUnit(i);
|
||||||
if(unit->getType()->hasCommandClass(currentCommand)) {
|
if(unit->getType()->isCommandable() && unit->getType()->hasCommandClass(currentCommand)) {
|
||||||
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == currentCommand) {
|
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == currentCommand) {
|
||||||
units.push_back(i);
|
units.push_back(i);
|
||||||
}
|
}
|
||||||
|
@ -630,7 +632,7 @@ bool Ai::findAbleUnit(int *unitIndex, CommandClass ability, CommandClass current
|
||||||
*unitIndex= -1;
|
*unitIndex= -1;
|
||||||
for(int i=0; i<aiInterface->getMyUnitCount(); ++i){
|
for(int i=0; i<aiInterface->getMyUnitCount(); ++i){
|
||||||
const Unit *unit= aiInterface->getMyUnit(i);
|
const Unit *unit= aiInterface->getMyUnit(i);
|
||||||
if(unit->getType()->hasCommandClass(ability)){
|
if(unit->getType()->isCommandable() && unit->getType()->hasCommandClass(ability)){
|
||||||
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass()==currentCommand){
|
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass()==currentCommand){
|
||||||
units.push_back(i);
|
units.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,12 +71,7 @@ bool Selection::select(Unit *unit) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if selectable
|
//check if commandable
|
||||||
if(unit->getType()->isSelectable() == false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if selectable
|
|
||||||
if(unit->getType()->isCommandable() == false && isEmpty() == false) {
|
if(unit->getType()->isCommandable() == false && isEmpty() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,6 @@ UnitType::UnitType() : ProducibleType() {
|
||||||
lightColor= Vec3f(0.f);
|
lightColor= Vec3f(0.f);
|
||||||
light= false;
|
light= false;
|
||||||
multiSelect= false;
|
multiSelect= false;
|
||||||
selectable= true;
|
|
||||||
commandable= true;
|
commandable= true;
|
||||||
armorType= NULL;
|
armorType= NULL;
|
||||||
rotatedBuildPos=0;
|
rotatedBuildPos=0;
|
||||||
|
@ -335,10 +334,6 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
|
||||||
//multi selection
|
//multi selection
|
||||||
multiSelect= parametersNode->getChild("multi-selection")->getAttribute("value")->getBoolValue();
|
multiSelect= parametersNode->getChild("multi-selection")->getAttribute("value")->getBoolValue();
|
||||||
|
|
||||||
//selectable
|
|
||||||
if(parametersNode->hasChild("selectable")){
|
|
||||||
selectable= parametersNode->getChild("selectable")->getAttribute("value")->getBoolValue();
|
|
||||||
}
|
|
||||||
//commandable
|
//commandable
|
||||||
if(parametersNode->hasChild("commandable")){
|
if(parametersNode->hasChild("commandable")){
|
||||||
commandable= parametersNode->getChild("commandable")->getAttribute("value")->getBoolValue();
|
commandable= parametersNode->getChild("commandable")->getAttribute("value")->getBoolValue();
|
||||||
|
@ -1250,7 +1245,6 @@ std::string UnitType::toString() const {
|
||||||
result += " light = " + intToStr(light);
|
result += " light = " + intToStr(light);
|
||||||
result += " lightColor = " + lightColor.getString();
|
result += " lightColor = " + lightColor.getString();
|
||||||
result += " multiSelect = " + intToStr(multiSelect);
|
result += " multiSelect = " + intToStr(multiSelect);
|
||||||
result += " selectable = " + intToStr(selectable);
|
|
||||||
result += " commandable = " + intToStr(commandable);
|
result += " commandable = " + intToStr(commandable);
|
||||||
result += " sight = " + intToStr(sight);
|
result += " sight = " + intToStr(sight);
|
||||||
result += " size = " + intToStr(size);
|
result += " size = " + intToStr(size);
|
||||||
|
|
|
@ -171,7 +171,6 @@ private:
|
||||||
bool light;
|
bool light;
|
||||||
Vec3f lightColor;
|
Vec3f lightColor;
|
||||||
bool multiSelect;
|
bool multiSelect;
|
||||||
bool selectable;
|
|
||||||
bool commandable;
|
bool commandable;
|
||||||
int sight;
|
int sight;
|
||||||
int size; //size in cells
|
int size; //size in cells
|
||||||
|
@ -257,7 +256,6 @@ public:
|
||||||
inline bool getRotationAllowed() const {return rotationAllowed;}
|
inline bool getRotationAllowed() const {return rotationAllowed;}
|
||||||
inline Vec3f getLightColor() const {return lightColor;}
|
inline Vec3f getLightColor() const {return lightColor;}
|
||||||
inline bool getMultiSelect() const {return multiSelect;}
|
inline bool getMultiSelect() const {return multiSelect;}
|
||||||
inline bool isSelectable() const {return selectable;}
|
|
||||||
inline bool isCommandable() const {return commandable;}
|
inline bool isCommandable() const {return commandable;}
|
||||||
inline int getSight() const {return sight;}
|
inline int getSight() const {return sight;}
|
||||||
inline int getSize() const {return size;}
|
inline int getSize() const {return size;}
|
||||||
|
|
Loading…
Reference in New Issue