empire mission 4

Bug #1705950 reported by hessenfarmer on 2017-07-23
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Wishlist
Unassigned

Bug Description

This ist to track the development for a empire 4 mission.

Basic storyline:
Lutious and his crew are returning to fremil. they find a complete economic mess, which they need to resolve first to be able to beat the babarians

Related branches

hessenfarmer (stephan-lutz) wrote :
hessenfarmer (stephan-lutz) wrote :

the uploaded file is how far I came.
What I need is some input what and how to screw up further and how to set up a road network that is a complete mess as well. For the roads we have to take into account, that the buildings are placed randomly.

GunChleoc (gunchleoc) wrote :

To screw things up further, you could remove the mill. It would also look more plausible to have the fisher on the coast, but in a spot where here are no fish.

For the roads:

1. Find a field that is buildable or has a flag on it
2. Check all directions or a random direction for an empty buildable field (no flag). If one is found, build a road.
3. Repeat for random length to extend the road, or until no empty field can be found.

hessenfarmer (stephan-lutz) wrote :

tried the whole evening to identify a field with a flag did not manage this. am frustrated for now

GunChleoc (gunchleoc) wrote :

Should be something like this:

   if field.immovable ~= nil and field.immovable.descr.type == "flag" then
      print("Found a flag!")
   end

GunChleoc (gunchleoc) wrote :

Found an error in the documentation, the function is called type_name, not type.

Changed in widelands:
importance: Undecided → Wishlist
tags: added: campaign empire
removed: whishlist
Changed in widelands:
assignee: nobody → hessenfarmer (stephan-lutz)
hessenfarmer (stephan-lutz) wrote :

Thanks for the hint:
I missed the last function ".type" cause the documentation is not so easy to understand for a newbie in programmin / scripting like me.
Anyhow I found a working solution this morning as well but will probably use the above mentioned code now. I already incorporated some more buildings with more or less severe bugs.
What would be helpful for the Story is a possibility to incorporate the screwed buildings into the build menu if this is possible without any Major code Change.

hessenfarmer (stephan-lutz) wrote :

ok did my very best to create a complete mess without creating any deadlocks.
Added the result as attachment. Did not playtest it yet. Perhaps would be better to do so against new Ai as well. comments are welcome

kaputtnik (franku) wrote :

Well, the economy is really a big mess... nearly all production buildings are placed wrong and have to be dismantled and erected at another place. Dismantling will bring some wares which are really needed to build up the basic buildings (woodcutter, stonemason).

I ran into a 'deadlock' of builders, because i dismantled and erected too many, and maybe wrong buildings :-) I would suggest to increase the amount of initial builders from 10 to 14 or so. Getting an overview over the wrong placed buildings and cleanup the roads is a big task and i think having some more builders would be fine. But this is just my first impression.

What i am wondering about are the Farms. They show always "No fields" and the working area shows something totally different. See attached screenshot. Normally a farm should work on every terrain, shouldn't it?

I have tried to kick out the farmer but then the game crashes (i think the crash is not related to your scenario):

widelands: ../src/economy/idleworkersupply.cc:89: virtual uint32_t Widelands::IdleWorkerSupply::nr_supplies(const Widelands::Game&, const Widelands::Request&) const: Zusicherung �req.get_type() != wwWORKER || worker_.owner().tribe().has_worker(req.get_index())� nicht erf�llt.

Don't know why the unknown characters suddenly appear.

kaputtnik (franku) wrote :

Forgot the screenshot :-D

hessenfarmer (stephan-lutz) wrote :

hi kaputtnik,
glad you found my sophisticated chaos. ;-)
The behaviour of the farm is purely intentional. I wanted to have a farm with a very low productivity so I exchanged the original farm against a negatively tuned clone. As the working area of the farm is defined by the farmer I had to clone the farmer as well (therefore I am not sure whether your crash hasn't been created by me;-)). So first I reduced the farmer's planting radius to 1 which results in the 2 filled circles while showing the working area. As this turned out to deliver 50% productivity I further screwed the farmer to only plant at big building lots so it is telling you "no fields" with full intention. I will try to set the radius to 2 again if this still gives me 0% productivity.
Further buildings that I modified are:
the well ( reduced productivity without ressource from 65% to 10%)
the lumberjack (reduced working area by around 60 %)
the forester (increased sleeping time a lot)
the mill (uses 2 wheat instead of 1)
the brewery (uses 3 water instead of one)
the training camp (stores only 1 weapon each and only 2 soldiers could be trained)

furthermore
all fish and water in the starting area has been removed from the map within starting_conditions.lua (I had to bypass the default amount of ressources to create real unefficiency).
The mines are intentionally placed over the wrong ressources.
No ressources at startup so you need to dismantle some buildings but you shouldn't dismantle all and every because some are still working fine.
the road network is created to be as stupid as it could be.

The idea is that amalea gives some advice what to do to get the economy working again. but I have to test my chaos first to find the right order of actions to advice for.
So I will look into the crash and test if there really is a deadlock regarding the builders. I think as soon as you got stuck you could free one worker and dismantle another building.

What I really could use would be a way to incorporate my "screwed up buildings into the build menu and modify it under the game (because I am thinking about a "recover the lost plans how to construct building "x" plans" objective using the artefacts.

Anyhow any quest that would fit into this story would be welcome. any other idea to further mess up the economy as well.

regards hessenfarmer

PS: Hint for farm and lumberjack they return the necessary tool when dismantled

kaputtnik (franku) wrote :

I played another test game... after 3 hrs game time i get my wood economy working :-D

Modifying the buildings is nice idea. The problem with this is the crash described in #9 and save games do not work to load:

Game data error
map objects: [../src/logic/map_objects/tribes/worker.cc:2717] loading worker: Unknown worker type "empire_farmer1"

Did not took a deeper look into this Game data error.

I am not sure if this plan:

> "recover the lost plans how to construct building "x" plans" objective using the artefacts.

will really fit. Just because in the previous scenario all buildings are working as they are usually do. After the empire scenario 3 is successfully played, there is no reason why the buildings suddenly not work as expected. Nevertheless i think this is a good idea :-)

GunChleoc (gunchleoc) on 2017-07-30
Changed in widelands:
status: New → Confirmed
GunChleoc (gunchleoc) wrote :

The problem here is that you can't just add new building and worker types in a scenario, the engine doesn't support it.

You will need to list all new entities used in data/tribes/empire.lua

This will make them appear in all normal games as well for now, but I could think of a design to allow custom entities if you really need them to get the scenario to work.

kaputtnik (franku) wrote :

Maybe an easier solution than add the screwed up buildings into the build menu is to forbid them to build? Don't know if this is possible to add a screwed up farm into the game and forbid to build a normal farm simultaneously.

But if this will work you could amalea saying something like: "The Farms do not work as usual, we have to find the manual for building farms that work correct." And the manual is one of the artifacts...

hessenfarmer (stephan-lutz) wrote :

hi everybody,
I wasn't aware of the problems with save games cause I did never try to load a savegame. This is really a serious problem to tell my story.
the possibility to modify the menu would have been just the cherry on the cake. (In fact I was thinking exactly about the same thing as kaputtnik described. Amalea would give the objective to find the plans or the manual and if found the "normal" building could be built.)

But the savegame problem really hit me. When I started to work on the scenario I tried to create a weak and weirded economy which is not really possible with the given buildings. (for example the well will produce water at 65 % when there is no water ressource at all. the farm will plant wheat even in the desert.) I will try to figure out a solution but the way to modify the buildings in the scenario was really appealing to me to get my story transported.

If we can fix this or at least identify a smart workaround then I think I can tell a really nice scenario story. If we need to identify why this mess exists and a lot of the economy is not working correctly well in every saga there is an evil governor or custodian (very often a younger brother or an unprivileged cousin). So I think we can give a nice explanation why the mess exists and it is our (and Lutius ) duty to resolve it.

so in short YES I think I really need custom entities to get this to work properly.

best regards hessenfarmer

GunChleoc (gunchleoc) wrote :

Do go ahead and introduce new building types. Making them not buildable should make them disappear from the menus. I can take care of that next week if you're having trouble, as well as looking into whether we need some C++ magic.

hessenfarmer (stephan-lutz) wrote :

Just to clarify the new or "screwed" buildings never appeared in any menu, because that was not possible. I just found a way to made them build in starting conditions of the scenario. So the problem is not that they appear in any menu. In contrary the possibility to have them in the building menu would have offered further possibilities in story telling but is not essential. We just need to find a way to either make the "cloned" buildings loadable from a savegame (which I would prefer) or a way to create similar effects (mainly 0% productivity) with the normal buildings and workers.
without solving this problem it just doesn't make sense to create more tuned buildings. I'll work on the second best solution next weekend although I would prefer the C# magic to enable solution 1.

regards hessenfarmer

hessenfarmer (stephan-lutz) wrote :

Ok I figured out a possible workaround but it is not half as elegant as my preferred solution. I could simply place some of the buildings without worker(s). They will not be automatically filled as there are not tools. Fulfilling Amalea's objectives will deliver the tools to get the economy running. But this is very monodimensional and will not deliver the possibility to just lower the productivity of buildings in different ways (sometimes mostly unnoticeable by the player but slowing down the economy a lot).
So I might create the scenario in this way, but still I don't feel happy with it.

What do you think?

GunChleoc (gunchleoc) wrote :

Not half as elegant does not sound good to me. I am back at my Linux machine now, so I can do some coding. How about you code it like you envisioned and let it crash, then point me to the problems, so I can then design something for you?

hessenfarmer (stephan-lutz) wrote :

Last night I suddenly had another idea. up to now I thougth that I need to include the buildings in my map folder. But as this is planned to be a scenario in the campaign I could simply add them to the init.lua in the tribes folder. Hopefully that will cure the crash and everything will be fine again. I will prepare a branch for that and test it. Just give me a couple of hours. I'll keep you informed. If everything will work as planned we don't even need to do C# magic. keep fingers crossed.

GunChleoc (gunchleoc) wrote :

Sounds like a plan. I'd like not to have them in the tribes when we're done, because that will mean that they will be always loaded, for all games. I can take care of that once we have a working scenario, because then whatever I come up with will be easier to test.

hessenfarmer (stephan-lutz) wrote :

ok I created a branch which is working.
had to include all of my buildings to Init.lua of the tribes.
commented out buildcost in most of them making them not buildable (I had to dig a lot in the code to find that out). But this is making them unable to dismantle as well. Which is not undesired in that case. These building had to be added to empire.lua as well.
for two of them I created them as enhancement including only the enhanced one in empire.lua (and only used the enhanced ones in the map). This led them to be dismanteable but not appearing in the menu.
I kicked out the custom workers cause I do not really need them as I found different ways to create my desird effect.
So scenario start point is working. Menu is clean in all games. Couldn't measure any increase in loading time due to the custom entities being part of the tribes data.
Linked the branch to this bug.
Best of all with this solution: I am motivated again to develop the storyline. Any testing and comments on how to start and how to continue the story would be very welcome.

GunChleoc (gunchleoc) wrote :

Great! I'll split off a branch to look at what I can do about the code design.

hessenfarmer (stephan-lutz) wrote :

Hi everybody,
just uploaded the first full Version of the Mission. It still could use some polish on the code and the language and the pics, and many things more. But it is playable. It does tell the story. And it is fun to play.

So now I need some feedback what could be improved and we need a way to get this into the game.

Have fun
hessenfarmer
PS: Shall we ask for testing in the forum now?

SirVer (sirver) wrote :

Is it sufficient to check out the Mission4 branch, build and run the game?

hessenfarmer (stephan-lutz) wrote :

it is even more simple. You just need the data dir and can use it with datadir option with any actual build. Personally I'm on bzr 8434 currently.

Have fun

kaputtnik (franku) wrote :

With Version bzr8458[trunk] i got a crash right after starting the mission:

widelands: ../src/ai/defaultai.cc:859: void DefaultAI::late_initialization(): Assertion `count_buildings_with_attribute(BuildingAttribute::kWell) == 1' failed.
Abgebrochen (Speicherabzug geschrieben)

hessenfarmer (stephan-lutz) wrote :

That is interesting. I had a quick look on the code and the Assertion should have failed in my build as well. However in the appveyor build of trunk 8434 I am currently using it isn't doing so. Perhaps this is a Windows specific "feature".

The reason why it is failing in your build and should fail according to the code is that I introduced 3 types of a well in my custom entities and that worked fine for the human Player. But then I introduced a third AI Player as empire and since then ever it should have failed. But as I said it doesn't in my Windows build.

Will dig into this deeper this evening

hessenfarmer (stephan-lutz) wrote :

If you or somenbody else would give it a try:
a possible solution might be to remove the Ai hints from the custom entitities buildings cause they are not designed for AI use

Asserts are only checked in debug builds. Appveyor builds are release mode. Tiber is the one to ask about this particular assert.

> Am 26.09.2017 um 09:28 schrieb hessenfarmer <email address hidden>:
>
> If you or somenbody else would give it a try:
> a possible solution might be to remove the Ai hints from the custom entitities buildings cause they are not designed for AI use
>
> --
> You received this bug notification because you are subscribed to
> widelands.
> https://bugs.launchpad.net/bugs/1705950
>
> Title:
> empire mission 4
>
> Status in widelands:
> Confirmed
>
> Bug description:
> This ist to track the development for a empire 4 mission.
>
> Basic storyline:
> Lutious and his crew are returning to fremil. they find a complete economic mess, which they need to resolve first to be able to beat the babarians
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/widelands/+bug/1705950/+subscriptions

Tino (tino79) wrote :

2017-09-26 10:27 GMT+02:00 SirVer <email address hidden>:

> Asserts are only checked in debug builds. Appveyor builds are release
> mode. Tiber is the one to ask about this particular assert.
>

Appveyor also does Debug builds. Each commit is built and packaged in 4
variants [x86|x64][Debug|Release].

hessenfarmer (stephan-lutz) wrote :

Ok,
that explains the thing so far. I couldn't have seen the Crash as I am on a release build.
As I would like to not install a debug build due to the limited Time I have I wopuld be happy if Kaputtnik could test to delete the AI hints in the custom entities Buildings ( They are in emp4.wmf/Scripting/custom entities) and see whethter the Crash happens again.
Otherwise I will download a debug build and test it this evening.

hessenfarmer (stephan-lutz) wrote :

Ok checked it.
In the last version I removed the AI Hints from the custom entities. Now this runs fine with the latest trunk debug build from appveyor (master 2507). Fixed a small bug at the very end. Now it should run fine.
Looking for feedback regarding texts, objectives, code and so on.
Especially welcome would be additional quests which fit into mthe story line.

regards hessenfarmer

hessenfarmer (stephan-lutz) wrote :

I will open a thread in the forum as well to get more feedback

Steven De Herdt (stdh) wrote :

A patch for immediately putting carriers on the roads and recruits in the barracks. Otherwise it takes a few minutes before all personnel is where they should be. I noticed though that they only appear after Lutius' first words. Also, they appear on the separate economies, the networks not connected with the headquarters. That could be a bit confusing...

Steven De Herdt (stdh) wrote :

There's a bug in the code that starts the 'conquer' objective if the enemy has been spotted. If that's not the case, 'enemy_seen' returns an empty table, but the if-block at line 307 is executed anyway. That happens with attached savegame after a few minutes.

kaputtnik (franku) wrote :

script for testing

Changed in widelands:
status: Confirmed → In Progress
GunChleoc (gunchleoc) wrote :

Test setup for the dynamic tribe loading bit.

kaputtnik (franku) wrote :

Played this branch with trunk (r8493), saved a game and after reloading the save game the game crashes immediately. Don't know if this is maybe related because playing the branch with current trunk...

Error and backtrace:

 3: Initializing in the basic economy mode, required buildings:
Sorry, cannot find building with id 2Fatal exception: [../src/ai/defaultai.cc:5493] Sorry, cannot find building with id 2
FATAL ERROR - game crashed. Attempting emergency save.
Game: Writing Preload Data ...
Thread 1 "widelands" received signal SIGSEGV, Segmentation fault.
0x0000555556433b7c in Widelands::GamePreloadPacket::write (this=0x7fffffffa830, fs=..., game=...) at ../src/game_io/game_preload_packet.cc:115
115 s.set_int("gametype", static_cast<int32_t>(game.game_controller()->get_game_type()));
(gdb) bt
#0 0x0000555556433b7c in Widelands::GamePreloadPacket::write (this=0x7fffffffa830, fs=..., game=...) at ../src/game_io/game_preload_packet.cc:115
#1 0x00005555564344f7 in Widelands::GameSaver::save (this=0x7fffffffa960) at ../src/game_io/game_saver.cc:51
#2 0x0000555556017a8f in SaveHandler::save_game (this=0x7fffffffb020, game=..., complete_filename="save/2017-11-21T20.22.39.wgf", error=0x7fffffffaa00)
    at ../src/logic/save_handler.cc:254
#3 0x0000555555e87934 in WLApplication::emergency_save (game=...) at ../src/wlapplication.cc:1385
#4 0x0000555555e86df4 in WLApplication::load_game (this=0x555556cff2d0) at ../src/wlapplication.cc:1289
#5 0x0000555555e85b14 in WLApplication::mainmenu_singleplayer (this=0x555556cff2d0) at ../src/wlapplication.cc:1116
#6 0x0000555555e85442 in WLApplication::mainmenu (this=0x555556cff2d0) at ../src/wlapplication.cc:1017
#7 0x0000555555e81c0b in WLApplication::run (this=0x555556cff2d0) at ../src/wlapplication.cc:438
#8 0x0000555555e7ffc7 in main (argc=2, argv=0x7fffffffe568) at ../src/main.cc:49

hessenfarmer (stephan-lutz) wrote :

could you please provide the savegame in question. Could you give me a short description of the status of the scenario at the time of saving. Especially the state of the objectives would be interesting.
Also the complete log could be helpful.
from the small snapshot this could,be related to the player 3 which is vesta and which is not having any buildings until a certain objective is triggered.

kaputtnik (franku) wrote :

Sorry, i do not know the actual state of objectives. What i did was to fulfill Vestas demand on 35 wheed and 15 wine (didn't conquered Vesta). I remember the objective to train soldiers was active.

Save game is attached.

hessenfarmer (stephan-lutz) wrote :

ok first check showed it is loading and running in rev 8478 which is my current version so it must have been something in between that. I will analyse this tonight

hessenfarmer (stephan-lutz) wrote :

tested it with actual trunk (r8495) can confirm the issue but I don't understand it. I suspect r8493 or r8480. will try to find out which Change broke the thing. As my Knowledge of C# is nearly not existing perhaps it would be good if GunChleoc or SIrVer could look at it after I have identified the correct revision

GunChleoc (gunchleoc) wrote :

The AI is trying to load the remaining basic buildings for the player. Seems like there is no building with ID 2 for some nebulous reason.

r8493 definitely introduced some changes, trying to fix another bug.

GunChleoc (gunchleoc) wrote :
kaputtnik (franku) wrote :

I see the bug is fixed... will make another test round...

GunChleoc (gunchleoc) on 2017-12-27
Changed in widelands:
status: In Progress → Fix Committed
milestone: none → build20-rc1
assignee: hessenfarmer (stephan-lutz) → nobody
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers