OpenXcom Forum

Modding => Released Mods => XPiratez => Topic started by: Stoddard on August 17, 2016, 12:35:44 am

Title: 16B Patch
Post by: Stoddard on August 17, 2016, 12:35:44 am
While hammering away on my Geoscape AI project I got sick of being bitten in the ass with the 8-base limitation.

The AI in the current form just doesn't forgive any interception, and if the base responsible was in detection range of faction being intercepted, and if they have particularly bitter hangover at the moment (which they usually do), and they have enough forces at the ready, there goes your base. So bases became that much more disposable. Just hope the crackdown is detected so you can cheat and transfer all the stuff away (to be fixed, so that you won't be able to do that in a couple of clicks :) ). Also I'm experimenting with reducing detection range in favor of scan frequency. This obviously raises number of bases needed.

Long story short, here's a minimal patch extending max number of bases  to 16.

After you build 9th base, the 'NEW HIDEOUT' button is replaced by the second row of bases. To build more, click on an empty base slot.

The click works before that too.
(https://s3.postimg.org/xamwmzugz/image.png) (https://postimg.org/image/tr0yx6rr3/)12B (https://postimage.org/app.php)

I guess a ruleset setting is needed instead of hardcoded constants like 8 or 16.

I got lost in git right now, so here's the patch if anyone's interested:

diff --git a/src/Basescape/BasescapeState.cpp b/src/Basescape/BasescapeState.cpp
index 76738cd..3988e12 100644
--- a/src/Basescape/BasescapeState.cpp
+++ b/src/Basescape/BasescapeState.cpp
@@ -68,7 +68,13 @@ BasescapeState::BasescapeState(Base *base, Globe *globe) : _base(base), _globe(g
        https:// Create objects
        _txtFacility = new Text(192, 9, 0, 0);
        _view = new BaseView(192, 192, 0, 8);
+       if ( _game->getSavedGame()->getBases()->size() > MiniBaseView::ROW_BASES) {
+               _mini = new MiniBaseView(128, 32, 192, 38);
+       }
+       else
+       {
        _mini = new MiniBaseView(128, 16, 192, 41);
+       }
        _edtBase = new TextEdit(this, 127, 17, 193, 0);
        _txtLocation = new Text(126, 9, 194, 16);
        _txtFunds = new Text(126, 9, 194, 24);
@@ -203,8 +209,7 @@ void BasescapeState::init()
        }
 
        _txtFunds->setText(tr("STR_FUNDS").arg(Text::formatFunding(_game->getSavedGame()->getFunds())));
-
-       _btnNewBase->setVisible(_game->getSavedGame()->getBases()->size() < MiniBaseView::MAX_BASES);
+       _btnNewBase->setVisible(_game->getSavedGame()->getBases()->size() <= MiniBaseView::ROW_BASES);
 }
 
 /**
@@ -480,7 +485,7 @@ void BasescapeState::viewMouseOut(Action *)
  * Selects a new base to display.
  * @param action Pointer to an action.
  */
-void BasescapeState::miniLeftClick(Action *)
+void BasescapeState::miniLeftClick(Action *unused)
 {
        size_t base = _mini->getHoveredBase();
        if (base < _game->getSavedGame()->getBases()->size())
@@ -488,13 +493,17 @@ void BasescapeState::miniLeftClick(Action *)
                _base = _game->getSavedGame()->getBases()->at(base);
                init();
        }
+       else
+       {
+               btnNewBaseClick(unused);
+       }
 }
 
 /**
  * Opens a dialog to make the selected base your HQ.
  * @param action Pointer to an action.
  */
-void BasescapeState::miniRightClick(Action *)
+void BasescapeState::miniRightClick(Action *unused)
 {
        size_t baseIndex = _mini->getHoveredBase();
 @@ -510,6 +519,10 @@ void BasescapeState::miniRightClick(Action *)
                        _game->pushState(new ChangeHeadquartersState(_game->getSavedGame()->getBases()->at(baseIndex)));
                }
        }
+       else
+       {
+               btnNewBaseClick(unused);
+       }
 }
 
 /**
diff --git a/src/Basescape/MiniBaseView.cpp b/src/Basescape/MiniBaseView.cpp
index 0ab1e4a..973197b 100644
--- a/src/Basescape/MiniBaseView.cpp
+++ b/src/Basescape/MiniBaseView.cpp
@@ -94,18 +94,20 @@ void MiniBaseView::draw()
        Surface::draw();
        for (size_t i = 0; i < MAX_BASES; ++i)
        {
+               int cell_x = (i % ROW_BASES) * (MINI_SIZE + 2);
+               int cell_y = (i / ROW_BASES) * (MINI_SIZE + 2);
                https:// Draw base squares
                if (i == _base)
                {
                        SDL_Rect r;
-                       r.x = i * (MINI_SIZE + 2);
-                       r.y = 0;
+                       r.x = cell_x;
+                       r.y = cell_y;
                        r.w = MINI_SIZE + 2;
                        r.h = MINI_SIZE + 2;
                        drawRect(&r, 1);
                }
-               _texture->getFrame(41)->setX(i * (MINI_SIZE + 2));
-               _texture->getFrame(41)->setY(0);
+               _texture->getFrame(41)->setX(cell_x);
+               _texture->getFrame(41)->setY(cell_y);
                _texture->getFrame(41)->blit(this);
 
                https:// Draw facilities
@@ -121,8 +123,8 @@ void MiniBaseView::draw()
                                else
                                        color = _red;
 
-                               r.x = i * (MINI_SIZE + 2) + 2 + (*f)->getX() * 2;
-                               r.y = 2 + (*f)->getY() * 2;
+                               r.x = cell_x + 2 + (*f)->getX() * 2;
+                               r.y = cell_y + 2 + (*f)->getY() * 2;
                                r.w = (*f)->getRules()->getSize() * 2;
                                r.h = (*f)->getRules()->getSize() * 2;
                                drawRect(&r, color+3);
@@ -156,6 +158,7 @@ void MiniBaseView::draw()
 void MiniBaseView::mouseOver(Action *action, State *state)
 {
        _hoverBase = (int)floor(action->getRelativeXMouse() / ((MINI_SIZE + 2) * action->getXScale()));
+       _hoverBase += (int)floor(action->getRelativeYMouse() / ((MINI_SIZE + 2) * action->getYScale())) * ROW_BASES;
        InteractiveSurface::mouseOver(action, state);
 }
 
diff --git a/src/Basescape/MiniBaseView.h b/src/Basescape/MiniBaseView.h
index 9168634..0bef494 100644
--- a/src/Basescape/MiniBaseView.h
+++ b/src/Basescape/MiniBaseView.h
@@ -43,7 +43,8 @@ private:
        size_t _base, _hoverBase;
        Uint8 _red, _green;
 public:
-       static const size_t MAX_BASES = 8;
+       static const size_t MAX_BASES = 16;
+       static const size_t ROW_BASES = 8;
        https:/// Creates a new mini base view at the specified position and size.
        MiniBaseView(int width, int height, int x = 0, int y = 0);
        https:/// Cleans up the mini base view.



EDIT: yea, it doesn't show extra bases in Logs screen, I know
Title: Re: 16B Patch
Post by: Arthanor on August 17, 2016, 01:47:58 am
You might be interested to look into this then:
- https://github.com/fenyo1/OpenXcom/tree/InfiniteBaseSizes
- https://github.com/fenyo1/OpenXcom/tree/UnlimitedBases

Unlimited potential if you'd like more bases. And if your AI can take them out more reliably, maybe the feature won't appear as broken to the community as it did back when it was presented.
Title: Re: 16B Patch
Post by: Dioxine on August 17, 2016, 08:18:53 am
This won't fly without global limits on the number of buildings, or people (extendable by progressively more expensive command buildings?); 8 bases is much more than enough to build up more industry and soldier capacity than you'll ever need in this gameplay model. However, say, 4 large bases + 12 outposts (radar + sam sites? would be nice if SAMs could engage fly-bys, and required ammo) would be much more reasonable (and manageable).
Title: Re: 16B Patch
Post by: nrafield on August 17, 2016, 09:04:19 am
Usually in these situations I just build my bases so that living quarters are next to a hangar and can shoot a Chinese Dragon into it. Although, that may stop working so well once it's the Mercenaries who start visiting my bases and not the Spartans.
Title: Re: 16B Patch
Post by: Solarius Scorch on August 17, 2016, 11:05:38 am
Usually in these situations I just build my bases so that living quarters are next to a hangar and can shoot a Chinese Dragon into it. Although, that may stop working so well once it's the Mercenaries who start visiting my bases and not the Spartans.

The problem isn't with base layout, only that it is viable to build more and more bases and turn most of them into manufacturing plants, making exponentially more money. This needs some investment, but in the long run would kill the campaign, since you could afford everything, no limits.

Dioxine proposes a de facto differentiation between types of bases, so you could have standard ones (with a limit) and some other types, where you can't build industry (possibly limited). Which is a fine idea game-wise, but it would need a logical explanation of why you can't do some stuff there.
Title: Re: 16B Patch
Post by: Dioxine on August 17, 2016, 12:07:15 pm
Money is one problem, management is the other. You will invest in more soldiers, scientists and engineers, because that pays off, but at some point, the game would turn into micromanaging hell.
Third problem, related, is, the game model designed for 30-40 soldiers, will come apart if you have hundreds or thousands of soldiers, both mechanics- and lore- wise.
Perhaps enforcing staff limitations is the simplest way out (since radars and storage facilities do not require staff).
Title: Re: 16B Patch
Post by: nrafield on August 17, 2016, 03:38:47 pm
The problem isn't with base layout, only that it is viable to build more and more bases and turn most of them into manufacturing plants, making exponentially more money. This needs some investment, but in the long run would kill the campaign, since you could afford everything, no limits.

Dioxine proposes a de facto differentiation between types of bases, so you could have standard ones (with a limit) and some other types, where you can't build industry (possibly limited). Which is a fine idea game-wise, but it would need a logical explanation of why you can't do some stuff there.
Oh yeah, that as well. Not like spending money isn't a problem already because there are already tons of ways to make millions with ease. It's just going to be hell to keep track of 16 bases anyway, especially when the compulsory monthly Crackdown missions come along. Although by that time you'll probably be able to shoot ALL of them down...which is somewhat a problem by itself.
Title: Re: 16B Patch
Post by: Stoddard on August 17, 2016, 10:21:08 pm
I think the micromanagement hell is in itself quite effective a limitation. In my current campaign, 1 research/industry base, 2 industry bases, 3 raiding bases and 1 pure outpost (radar/hangar) and I already resorted to writing inventory management tools, and that's just 7 of them.

It's that limited detection ranges and hyperaggressive retaliations require more bases overall present, and some backups 'in the pipeline', being built to replace neighbours that will fall. Nice money sink too. More than 16 though, and it'd turn into micromanagement hell of its own.

I also don't actually hit 30-40 soldier threshold, so to speak. Detachments of ~20 soldiers sit on some of the bases, but 3-5 are usually wounded, another 5 or so in reserve, and the craft carries 8-10. So I might have 30 active, 30 inactive, plus about 30 training up, any more and micromanagement bites again (and also is not needed).

So in fact I don't feel that introducing some base type subdivision is worth it. Those who overbuild will be punished as it is.


EDIT:
My perception might be biased by the geoscape work, which certainly changes the gameplay model, and in many ways I don't yet know.
But trying the patch in regular piratez, I never even considered building anything but an outpost, hangar and hyperwave detector on the extra bases. It's just not worth the hassle.
Title: Re: 16B Patch
Post by: Stoddard on August 17, 2016, 10:33:24 pm
The overabundance of money is a separate concern, and if it kills the campaign, then it is already dead, and a dozen more bases won't make it deader. I feel it should be solved not by directly limiting industry, but the market for the produce.
Title: Re: 16B Patch
Post by: Star_Treasure on August 18, 2016, 07:20:51 am
As I mentioned before, the Guild and or the Church should raid bases that sell too much bootleg X-grog.
Title: Re: 16B Patch
Post by: Surrealistik on August 18, 2016, 08:35:50 am
As I mentioned before, the Guild and or the Church should raid bases that sell too much bootleg X-grog.

I'm not sure what purpose this would serve; is the intent narrative or gameplay related? In the case of the latter as an attempt to curb income from bootlegging, all this will practically do is further increase the player's wealth (if he has prepared any kind of adequate defense).
Title: Re: 16B Patch
Post by: Dioxine on August 18, 2016, 11:25:06 am
The overabundance of money is a separate concern, and if it kills the campaign, then it is already dead, and a dozen more bases won't make it deader. I feel it should be solved not by directly limiting industry, but the market for the produce.

You're right, direct limitation of industry is a bad solution. What I stressed was that the existing gameplay model breaks apart at some point; problems visible with 8 bases will be even more pronounced with 16. To handle this, some change of the model is needed. Solutions to these problems, as I see them:
- Administrative limitations. Limits on the number of personnel (exceedable only at a huge cost). This isn't a hard limit, and it's a natural limit: how many people can you command directly?
- Security limitations: More aggressive enemy, more enemy actions when your business gets too big (sabotage of various kinds, security problems).
- Market limitations: Some kind of market model, limiting the amount of goods you can sell monthly and/or changing prices.  Related: limits on how many people you can hire monthly.

You can't really keep adding new bases without adressing these problems IMO; moving from small organization simulator to a state simulator can't be done without adding statehood mechanics.
Title: Re: 16B Patch
Post by: Solarius Scorch on August 18, 2016, 12:36:53 pm
OK, I'll think about adding some/all of this to the Wishlist.
Title: Re: 16B Patch
Post by: Dioxine on August 18, 2016, 12:52:44 pm
Not sure we want that; do we really want OXCom to become a state simulator?
Title: Re: 16B Patch
Post by: Solarius Scorch on August 18, 2016, 12:56:10 pm
Not sure we want that; do we really want OXCom to become a state simulator?

I don't know, that's why I'll think :)
Title: Re: 16B Patch
Post by: Meridian on August 18, 2016, 05:15:06 pm
OK, I'll think about adding some/all of this to the Wishlist.

Wait a moment... the Wishlist can grow?  :o
Title: Re: 16B Patch
Post by: Solarius Scorch on August 18, 2016, 05:46:43 pm
Wait a moment... the Wishlist can grow?  :o

I'm afraid it's inevitable.

But it'll take a while for Dioxine and I to digest the whole recent meal. :)
Title: Re: 16B Patch
Post by: Starving Poet on August 18, 2016, 06:16:17 pm
You're right, direct limitation of industry is a bad solution. What I stressed was that the existing gameplay model breaks apart at some point; problems visible with 8 bases will be even more pronounced with 16. To handle this, some change of the model is needed. Solutions to these problems, as I see them:
- Administrative limitations. Limits on the number of personnel (exceedable only at a huge cost). This isn't a hard limit, and it's a natural limit: how many people can you command directly?
- Security limitations: More aggressive enemy, more enemy actions when your business gets too big (sabotage of various kinds, security problems).
- Market limitations: Some kind of market model, limiting the amount of goods you can sell monthly and/or changing prices.  Related: limits on how many people you can hire monthly.

You can't really keep adding new bases without adressing these problems IMO; moving from small organization simulator to a state simulator can't be done without adding statehood mechanics.

Taxes / bribe money - it takes a lot of money to grease a lot of palms - but instead of flat out cost increase - have an ever increasing cost at the end of the month that increases with your number of main bases.  It's been too long since I've done derivations to give you some good numbers, but something along the lines of first base free - second base means you lose 15% net income, next base would be 28%, etc.   

Small radar bases wouldn't incur this cost because they are too small to be noticed.
Title: Re: 16B Patch
Post by: Dioxine on August 18, 2016, 07:06:36 pm
That's one way to incur administrative costs I spoke of earlier.
It should be like, some quadratic function with argument x=(a+b)-2, a = number of bases, b = number of personnel (in some multiples, like 20?); this function could impart additional maintenance costs. So you can have 1 base with 20 personnel w/o any extra costs, but the costs start to rise after that. With 16 bases and 600 people, you'd have x=44. If, say, increase was 1.05^x (cumulative 5% per level), your maintenance would be, in this case, about 8.5x nominal. Okay maybe that's a bit too steep but you can see where this game is going :).

This is quite fun formula as you can keep strong force of soldiers and many bases, yet don't suffer much, since most of the manpower are always the workers. Eg.: 50 soldiers + 30 scientists + 80 workers = 150, with 16 bases that makes x=21, and the maint. cost increase 2.8x nominal.
Title: Re: 16B Patch
Post by: Surrealistik on August 18, 2016, 08:52:30 pm
Taxes/bribe money on secret bases?

Man, with all those Star God/Faction spies running around these Govts sure have some solid confidentiality protocols in place.

That said, what mad man needs 16 bases? The economy is already more than broken at 8 while having effectively global hyperwave coverage though I am pretty Runt heavy (240+ for every base other than HQ).
Title: Re: 16B Patch
Post by: Star_Treasure on August 18, 2016, 10:30:51 pm
I'm not sure what purpose this would serve; is the intent narrative or gameplay related? In the case of the latter as an attempt to curb income from bootlegging, all this will practically do is further increase the player's wealth (if he has prepared any kind of adequate defense).

Mostly narrative really.