Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
More Weapon slots + IFV business
#17
Not even with saved targets?
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
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.
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.
Reply


Messages In This Thread
More Weapon slots + IFV business - by DCoder - 18.10.2008, 19:48:00
RE: More Weapon slots + IFV business - by Guest - 19.10.2008, 15:19:53
RE: More Weapon slots + IFV business - by DCoder - 09.11.2008, 15:49:45
RE: More Weapon slots + IFV business - by mt. - 09.11.2008, 21:11:07
RE: More Weapon slots + IFV business - by DCoder - 10.11.2008, 07:29:15
RE: More Weapon slots + IFV business - by DCoder - 12.11.2008, 18:45:11
RE: More Weapon slots + IFV business - by DCoder - 12.11.2008, 20:56:04
RE: More Weapon slots + IFV business - by Renegade - 13.11.2008, 06:19:31



Users browsing this thread: 1 Guest(s)