13.11.2008, 06:19:31
Not even with saved targets?
Like, assume a Mammoth Tank with cannon and missiles.
Three targets, tank_1, tank_2 and aircraft.
Absolutely pseudo code and totally oblivious of the actual game code (so there's no point criticizing the actual code), just to illustrate the idea - basically just pick a target for each weapon, store them all in a list/array/vector/whatever, then run through them - if that target can currently be attacked with any weapon, attack it, if not, go to the next target and try that. Ideally, the target selection would be smart to pick targets for the different weapons - so in this example, the Mammoth would pick tank_1 and aircraft, fire at tank_1, fire at aircraft while it can't fire at tank_1, and ignore tank_2 until tank_1 was destroyed.
Not sure if that's possible, just throwing out an idea. It would, of course, also have to account for the whole target-following logic.
Like, assume a Mammoth Tank with cannon and missiles.
Three targets, tank_1, tank_2 and aircraft.
Code:
vector<targets> tempTargets;
while(!this->guardArea->getNumTargets()) {
if(tempTargets.empty() || tempTargets.size() < this->getGunNumber())
while((tempTargets.size() < this->getGunNumber()) && (this->guardArea->getNumTargets() > tempTargets.size()))
tempTargets.push_back(this->pickTarget());
for(int i = 0; i <= tempTargets.size(); i++)
if(this->canCurrentlyAttack(tempTargets.at(i))) // if there is currently a gun available that can attack that target,
if(this->attack(tempTargets.at(i))) tempTargets.erase(i); //... attack it // attack attacks, returns true if the target was destroyed
}
tempTargets.clear(); // to clear targets if not all were destroyed, but they are not in the guard area anymore
Not sure if that's possible, just throwing out an idea. It would, of course, also have to account for the whole target-following logic.
Forum Rules
(01.06.2011, 05:43:25)kenosis Wrote: Oh damn don't be disgraced again!
(25.06.2011, 20:42:59)Nighthawk Wrote: The proverbial bearded omni-bug may be dead, but the containment campaign is still being waged in the desert.