aliens

Author Topic: Improved Single Battle Mode  (Read 6012 times)

Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Improved Single Battle Mode
« on: October 16, 2012, 07:50:52 pm »
This adds an improved single battle mode to OpenXcom trunk  (improving the "new battle" button in the menu UI). It tries to make getting an acceptable battle quickly, reducing the amount of fiddling needed to set options.

Changes include:
*Random selection of research completed: not all items are usable in all battles, e.g. can get battles where Plasma weapons are not usable if taken from dead aliens
*Random selection of alien equipment level: aliens are not always equipped to level 0, but instead 0-2 (so can get battles versus heavy plasma wielding aliens)
*No longer field only rookies: randomly promote + increase stats of some soldiers
*No longer provide 100 of each item
*Randomly setup the battle in UI (mission type, alien race, difficulty, darkness, craft, terrain) while still permitting choice if desired
*Currently, in addition to the "New Battle" button in the UI, adds a "New Random Battle" button

This patch works for me (tm) and could be cleaned up for commit if desired.

Offline Fenyő

  • Colonel
  • ****
  • Posts: 423
    • View Profile
Re: Improved Single Battle Mode
« Reply #1 on: October 18, 2012, 10:50:17 pm »
I thought the "New Battle" option is just for testing Battlescape. (to easily view development changes)

Offline pmprog

  • Commander
  • *****
  • Posts: 647
  • Contributor
    • View Profile
    • Polymath Programming
Re: Improved Single Battle Mode
« Reply #2 on: October 18, 2012, 11:11:22 pm »
Why would you not leave it as a cool game feature?  ;D

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: Improved Single Battle Mode
« Reply #3 on: October 18, 2012, 11:28:01 pm »
New Battle can be used by both developers and users, although "having everything enabled" is specially useful for developers.

I can see why a user would prefer a random set of options, but instead of having a lot of if's spread around the code, probably better to just put it all in a random() function in NewBattleState that you can call with a new Random button there. More organized that way, doesn't interfere with the existing developer functionality, and lets you keep re-randomizing without leaving the screen. :)

Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Improved Single Battle Mode
« Reply #4 on: October 20, 2012, 11:33:20 pm »
OK, I have been cleaning this patch up a bit, and have a question: how do I suppress the presence of unusable weapons?

I am attempting to filter out all weapons whose a) ammo is not researched and b) that are not themselves researched

   std::vector<std::string> items = rule->getItemsList();
   for (std::vector<std::string>::iterator i = items.begin(); i != items.end(); ++i)
   {
      RuleItem *rule = _game->getRuleset()->getItem(*i);
      if (!save->isResearched(rule->getRequirements()))
         continue;
      if (!save->isResearched(*i))
         continue;


The above seems to do this; but also to remove all original XCOM weaponry (e.g. basic rifle). Is there a good way to say "OK if XCOM original equipment?"

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: Improved Single Battle Mode
« Reply #5 on: October 21, 2012, 12:10:27 am »
You don't need this:

if (!save->isResearched(*i))
         continue;


If you wanna check for weapons without researched ammo, you can do this:

for (std::vector<std::string>::iterator j = rule->getCompatibleAmmo()->begin(); j != rule->getCompatibleAmmo()->end(); ++j)
{
      RuleItem *ammo = _game->getRuleset()->getItem(*i);
      ...

Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Improved Single Battle Mode
« Reply #6 on: October 21, 2012, 11:24:50 pm »
Random battle mode now a single button in the New Battle screen.

Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Improved Single Battle Mode
« Reply #7 on: November 07, 2012, 10:31:04 pm »
Now that 0.4.5 is out, any chance of getting this into the mainstream OpenXCom?

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: Improved Single Battle Mode
« Reply #8 on: November 08, 2012, 02:08:10 pm »
Sure, I'll add it in soon.

Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Improved Single Battle Mode
« Reply #9 on: November 08, 2012, 07:22:20 pm »
Great! Cheers for that.