OpenXcom Forum
Contributions => Programming => Topic started by: grrussel 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.
-
I thought the "New Battle" option is just for testing Battlescape. (to easily view development changes)
-
Why would you not leave it as a cool game feature? ;D
-
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. :)
-
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?"
-
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);
...
-
Random battle mode now a single button in the New Battle screen.
-
Now that 0.4.5 is out, any chance of getting this into the mainstream OpenXCom?
-
Sure, I'll add it in soon.
-
Great! Cheers for that.