Playing campaigns

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Ignatus
Elite
Posts: 492
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Playing campaigns

Postby Ignatus » Wed Sep 22, 2021 6:26 pm

I wish Freeciv could be played with a plot of a sequence of maps, like we see in Wesnoth campaigns. Surely, Wesnoth has been originally designed for it and Freeciv for a different things, but most of the basic tools for doing it (and with simultaneous multiplayer!) we do have, except one: the server can't change maps since the game is started. Since this is not going to be changed soon, maybe we could kludge it with some utility that mediates packets between the server and players, sets and stores campaign information (exchanged with the server via "lua cmd var1=value" commands and its stdout) and restarts server with a next scenario of the campaign without players' disconnect.

A scenario that comes into mind is the biblical conquest of Israel. Surely it's a controversal topic, but who does not like it may just not play it, and in it there is at least a Higher Will that justifies the genocidal plot of a typical Freeciv game. We can also try to reproduce key battles of historical wars without a single huge map that just troubles navigation most the time.

For plot elements in scenarios we likely need some other things Wesnoth has, notably quest-like dialogs and better AI regulation. For the latter, there could be easily done a server-side way to write order sequences for AI units by a script (rather than by go-to client command as it happens now) each turn before AI thinks how to manage it, so we could write our own AI in Lua that works, almost like Wesnoth RCA does in its campaigns.

Molo_Parko
Veteran
Posts: 65
Joined: Fri Jul 02, 2021 4:00 pm

Re: Playing campaigns

Postby Molo_Parko » Thu Sep 23, 2021 4:10 pm

A campaign of multiple scenarios which continue a storyline based on the outcome of each scenario is an interesting idea. There doesn't seem to be anything at all that would prevent a person from playing the first scenario, then progressing to the intended next scenario voluntarily by simply starting the prescribed "next" scenario. The key element isn't having the software automatically begin the next scenario, but rather it is the willingness of the (human) players to proceed to the next scenario in your specified order. If you create an interesting, enjoyable, or informative campaign set of scenarios, I'll play the scenarios through - and in your intended order. So why wait? How soon will I be able to play your campaign? :)

Conditional branching of the storyline would be fun - the outcome of scenario 1 could lead to either scenario 2a (after winning 1st scenario) or to scenario 2b (after losing first scenario), as an example. If you want to encourage people to play each successive scenario in the order you intend, you might try encrypting all scenario files except the first one, then use a Lua script within scenario 1 to supply the decryption password to either scenario 2a, or the password for scenario 2b depending on scenario 1's outcome, and so on.

Example scenario files attached. 8-)

Edit: And an updated PacCampaign Level 1 scenario. Pac is joined by several friends on the journey to find a good place to begin a new civilization. The first thing they see are warning signs about pirates! OH NO! Pac and his friends don't like the look of this land but need to pass through the area to continue the search for better land. Meanwhile, units from four other tribes are also in the area, and they've already run into pirates despite that it is only turn ZERO!!! Will Pac and friends make it to an exit before the pirates attack them too? Play "PacCampaign Level 1" to find out! :P

I think I added too many friends. It's not terribly challenging to get through so I'll probably reduce the number of Pac units from 11 down to hmm, maybe 3.

Image

Edit 2: Well, I ran into a few problems. First, somehow FreeCiv kept using different tribes than those specified in the scenario file. I had a "startposnation=FALSE" setting in the Scenario section of the sav file, so I changed that to True but that didn't solve it. Later, while looking at the loaded settings on the server after starting the scenario, I noticed that that setting wasn't even listed as an option, so I removed it from the file completely, no change at all in behavior though (EDIT: and I think that that particular setting only applies to map generation which is why it is not shown on the server after loading a pre-made map?) Next I checked the startpos setting in the Settings section of the sav file. It was set to default and what the heck does that mean, right? So I loaded the scenario and checked it on the server where I finally realized that that particular instance of startpos information only appears to apply to the map generator, not the pre-made scenario map. So I removed the setting from the sav file entirely. No change in behavior, still getting various random tribes instead of Vampires, Werewolves and so on. Soooo then I checked the startpos settings in the map section of the sav file and couldn't see anything wrong. I double-checked the x,y coordinates, they were ok - land tiles and not occupied or anything. I tried both TRUE and FALSE in the "exclude" (from what???) column but no change there either. So to make a long story end eventually, I knocked it down to aifill 1 player and only 1 startpos in the map section - and then created all the other tribes -after- gamestart via lua script in the scenario file -- which is working fine. Updated level 1 file v1.2 is attached. Oh and the barbarian horsemen kept slaughtering all the other tribes' units too quickly so I reduced Pac's friends but increased the units for the other tribes and created 1 city per each of them too.

Edit 3: The exact same thing happens with the British Isles scenario. It has 5 tribes configured with 5 start positions yet as I start the scenario, it shows 5 players as "random", then at turn zero the English are up against the South Koreans and whatnot. Weird.
Attachments
PacCampaign Level 1 v1.2.sav.zip
(9.06 KiB) Downloaded 15 times
PacCampaign Level 1 v1.1.sav.zip
(7.67 KiB) Downloaded 16 times
PacCampaign Level 1.sav.zip
(8.16 KiB) Downloaded 22 times
PacCampaign Level 2.sav.zip
(8.06 KiB) Downloaded 19 times
Last edited by Molo_Parko on Tue Sep 28, 2021 10:43 pm, edited 1 time in total.

Molo_Parko
Veteran
Posts: 65
Joined: Fri Jul 02, 2021 4:00 pm

Re: Playing campaigns

Postby Molo_Parko » Mon Sep 27, 2021 9:14 pm

Another day, another problem. This time not (apparently) bugs in the coding of the software, but rather software design elements which aren't helping with campaign scenario development at all. Specifically regarding barbarians. But first, the current idea for PacCampaign Level 1 is:

1] Pac and some friends undertake an adventure to find land suitable for building a new civilization

2] They have come to Scenario Level 1 territory, where the land is not pleasing, so they decide to move on.
---Main Quest: If any Pac tribe member makes it to an exit tile, then Victory, scenario Level 1 is over and a message directs the player to continue to Scenario Level 2.

3] Pac and friends start looking for an exit. They encounter signs warning about barbarians and pirates. They hear the sounds of battle to the north and head that direction to see what is going on.

4] Several local tribes in the area are under attack from barbarians. The barbarians destroy from 1 up to 3 of 4 cities. (The Vampire's city being destroyed and the Werewolf's city NOT being destroyed will both be used as plot elements later on another level. The UN is largely irrelevant (heh) and so are the Hackers but I think that both being destroyed will add to the "excitement" of campaign level 1.)

---Optional quest: Pac and friends stay to help fight the barbarians. If all pirates are killed and Pac's tribe is still alive, then a dialog window states that a local tribe member approaches to thank Pac and tells him a secret which will lead to a bonus on the Level 2 map.

5] After the barbarians are destroyed, Pac and friends resume their travels by finding and moving onto an exit tile. Victory, level over, on to Level 2. (At this time, it is also possible for the barbarians to eliminate the other tribes, then Pac eliminates the barbarians and a conquest victory occurs since no players are left but Pac.)

One possible problem is that it is -possible- for Pac to go to war with the local tribes. It would make the "grateful tribe member" who rewards Pac seem odd, but other than that it wouldn't change much except that Pac's tribe might fail as in "Game over, LOSER!" The player could try again by restarting Level 1.

The main problem I'm experiencing is with the barbarians. The ratio of barbarians to Pac's and local tribe units should be such that Pac can achieve victory, but not too easily. I first used "unleash.barbarians", then set a variable to their player number so that I can manually add more barbarian horsemen where and when needed. But using the "unleash" method results in seemingly random numbers of barbarian units appearing in random locations at random turn intervals, and that despite that the scenario has the barbarians setting at "HUTS_ONLY". Some times it's too many, sometimes too few. Sometimes there are also boats full of units which I'd rather avoid completely on Level 1 of the campaign. So I decided to "edit.create.player" the barbarian tribe instead of using "unleash". That worked and allowed me to place an exact number of pirates across specific tiles. BUT! The next issue was that while playing the level, Pac met the pirates and guess what they did? They issued a greeting message "At last I've found you! Now make it worth my while or be crushed!" or something to that effect. So I checked the Nations window/pane and sure enough, the "edit.create.player" method results in a barbarian tribe that is listed like a regular player in the Nations window (which I suspect is because the tribe does not have the ai.barb_type value set!) So I tried to set it to "Land" and GUESS WHAT? There doesn't seem to be any lua access to that setting at all.

So, I reverted to using the "unleash" method, to prevent any diplomacy between pirates and player tribes because that would be really weird if the local tribes allied with the pirates against Pac. Might be exciting though. :)

Now I'm trying to work out how best to ensure that the # of barbarian units is just the right amount, in just the right places for an exciting but not too difficult first level of the campaign. I'll get it worked-out soon even if I have to, every turn, run through the whole list of all barbarian units and kill some from certain areas, add more to other areas and so on.

Allowing lua access to set ai.barb_type to Land would have made things a whole lot easier. (Assuming that that would hide the tribe from the Nations window etc.) Or perhaps set the flag automatically when the tribe is "Barbarian"?

Or allowing setting a flag to prevent a given tribe from participating in diplomacy (so that they are always hostile and at war.) <---- Edit/Update: This appears to be exactly the case already with manually created barbarian tribes. Even after making contact with them, the Nations window/pane always shows "no contact" and thus diplomacy is impossible.

Or allowing a fully manual mode for "unleash.barbarians" in which the tribe is created, no units appear automatically, units can be created via scripting. Perhaps "if scenario setting "barbarians" is "HUTS_ONLY"" then only manual/lua script creation of units?


Image
EDIT: It just occurred to me that edit.create_player had a setting "better left as nil" that was not fully explained... I'll try it with "Land" and see what happens. :)

Edit 2: That's not it. The barbarians still show-up in the Nations window/pane like a regular tribe even when created with ai.barb_type set to Land.

Image
Image

Edit 3: Contactless Contact is the future!

Edit 4: I now think that diplomacy is -already- impossible with the barbarian tribe using edit.create_player. The greeting message they sent on first contact made me think that diplomacy would be possible, but the "no contact" despite having just made contact makes me think that the "no contact" -is- the method of preventing diplomacy with the barbarians... which makes the edit.create_player option more viable, but I'd still rather have the barbarian/pirate tribes not appear in the nation list because it seems like too much deviation from "standard" FreeCiv experience and might cause confusion for people who play either the campaign first, or FreeCiv generated games first, and then the other.
Last edited by Molo_Parko on Wed Sep 29, 2021 9:04 pm, edited 8 times in total.

cazfi
Elite
Posts: 2010
Joined: Tue Jan 29, 2013 6:54 pm

Re: Playing campaigns

Postby cazfi » Tue Sep 28, 2021 7:54 am

Molo_Parko wrote:Edit 3: The exact same thing happens with the British Isles scenario. It has 5 tribes configured with 5 start positions yet as I start the scenario, it shows 5 players as "random", then at turn zero the English are up against the South Koreans and whatnot. Weird.

I looked at that, and the problem seems to be that of those nations with startpos in the map only English are in the core nationset, so are not usable by default. When I add setting for using nationset "all" to the scenario file, I get English, Scottish, Irish etc on the map.

cazfi
Elite
Posts: 2010
Joined: Tue Jan 29, 2013 6:54 pm

Re: Playing campaigns

Postby cazfi » Tue Sep 28, 2021 8:05 am

Raised a ticket about the British isles problem: https://osdn.net/projects/freeciv/ticket/42939

Molo_Parko
Veteran
Posts: 65
Joined: Fri Jul 02, 2021 4:00 pm

Re: Playing campaigns

Postby Molo_Parko » Tue Sep 28, 2021 3:39 pm

Doh! and Thank you!

The PacCampaign Level 1 file has nationset="all" in lowercase, so I tried upper but still no change in behavior. For years I have been in the habit of duplicating existing .sav files, pasting in a new set of map data, change a couple of settings, and then start playing. It hadn't occurred to me that I might be accumulating various oddities within the files along the way -- perhaps because as far as I can recall, this is the first time that I've run into a scenario problem without a fairly obvious solution. It's also the first time I've tried to create a campaign so those two elements might be related somehow.

cazfi
Elite
Posts: 2010
Joined: Tue Jan 29, 2013 6:54 pm

Re: Playing campaigns

Postby cazfi » Tue Sep 28, 2021 4:17 pm

Molo_Parko wrote:nationset="all"

That's not the format to define server settings in a .sav. See patch for the british isles scenario in that ticket.

Molo_Parko
Veteran
Posts: 65
Joined: Fri Jul 02, 2021 4:00 pm

Re: Playing campaigns

Postby Molo_Parko » Tue Sep 28, 2021 4:25 pm

Yeah, I was just being lazy intending only to indicate the change from lowercase to uppercase. I meant "nationset","ALL","ALL" and I assume that that format is: label in lowercase, preferred setting 1st, fallback setting 2nd although I haven't actually looked at the source code because I worry that it would change my FreeCiv game-playing experience. I enjoy being surprised. :) I judge the quality of Freeciv games by the number of times I exclaim "Doh!" while playing because the game surprised me.

EDIT: Incidentally, I'd like to add the following to this discussion thread: I've played Wesnoth as well, every two to three years, and the primary reason that I'm not still playing Wesnoth -instead- of FreeCiv is that once one has completed their campaigns, Wesnoth becomes repetitive and B-O-R-I-N-G !!!! FreeCiv, on the other hand, is never the exact same game repeatedly.

I'd like the Pac campaign to retain that FreeCiv element of highly-variable gameplay experience and not "feel" too scripted/pre-determined.
Last edited by Molo_Parko on Wed Sep 29, 2021 8:19 pm, edited 1 time in total.

Molo_Parko
Veteran
Posts: 65
Joined: Fri Jul 02, 2021 4:00 pm

Re: Playing campaigns

Postby Molo_Parko » Tue Sep 28, 2021 9:40 pm

Image
^ Pac helped fight the barbarians, who were then eliminated, which completed Quest 2.

Image
^ Pac found the exit, completing Quest 1.


Ok, I think I've got it worked out for PacCampaign Level 1.

I've chosen the edit.create_player method for more control over the barbarians rather than "unleash.barbarians". This has two non-standard effects: (1) the barbarian tribe is listed in the Nations list but no diplomacy is possible, and (2) the barbarian tribe can actually be -eliminated- without more waves of barbarians showing-up later. #1 seems potentially confusing to human players, #2 happens to be perfect for Level 1 of the campaign.

I've played through the level several times with good outcomes:
1] Vampires tribe destroyed every time,
2] Werewolf tribe survives every time,
3] Pac found and fought barbarians every time,
4] Barbarians eliminated and Pac tribe still alive every time, which completes Quest 2,
5] Pac finds the exit every time which completes Quest 1.
6] The FreeCiv highly-variable gameplay element is still intact. It is still -possible- for Pac to lose in any of several ways, most notably if barbarians kill all the Pac units. It's also theoretically possible for Pac to capture a town from barbarians, if they manage to take a town from an "A.I." tribe without destroying it. Pac may also ally with any or all local tribes and could potentially stick around and assist an ally tribe in a war against the others. That would be a problem for the campaign storyline if Pac fights against the Werewolves, which raises the next issue...

Is it possible, with players created via edit.create_player, to add that player to Team 0 so that it is automatically Pac's ally?

Other than a couple of references to shared research, I found no hits for "team" at http://freeciv.fandom.com/wiki/Lua_reference_manual

PacCampaign Level 1 scenario file attached. Comments welcomed!

I will clean-up the lua script coding next.

Edit: It would be great to be able to set the player's team # at time of edit.create_player via lua script, otherwise I think that it won't be possible to add the created Werewolf team to team 0 since that player is only created after the game starts, there is no way to specify team # at time of creation, and even direct commands to the server like "/team Werewolf 0" won't work because "can't change teams after game is started." The -only- way I can see of having Werewolf tribe as a member of team 0 by default would be to save player data in the sav / scenario file itself, then manually change the team number in the file. I'll try that.

Edit 2: First problem with saving player data. After starting the original scenario, I went immediately to edit mode and saved as scenario with player data. Manually edited the sav file, disabled portions of lua code to create players since they are now saved in the file. Set Werewolf tribe to team 0 to be allied with Pac tribe. Loaded the scenario in the client to find that "Start" button is greyed out, "Take Mahmut" is available and the human playing the game could elect to be any of the pre-saved tribes which is not at all what I want in the campaign. Within the campaign, it would be highly problematic if the human player is not the tribe central to the storyline. Also, upon taking Mahmut, the game plays and starts on turn 0 but the initial message from lua script no longer displays, possibly because the game was saved -after- the "turn_started" signal, or more likely because if player data is in the file already, FreeCiv wouldn't generate the turn_started signal upon opening? Anyway, I think the inability to ensure that the human becomes the central character of the campaign storyline is more than enough reason to not have player data saved in the scenario and actually a pretty good reason by itself to set aifill to 1 and create other players via lua from within game.

Edit 3: Ahh! If saved as a saved game, not as a scenario then the human is automatically the correct player (0) and the initial pop-up message is shown. Also avoids the diplomacy message from the pirates because it occurred (this time) the moment I ran the scenario, right before saving.

Edit 4: Crap. Opening directly as player0 is dependent on the local system username saved in the sav file. That ain't gonna work out.

Edit 5: A cleaned-up version of the PacCampaign Level 1 v1.3 is also attached to this post.

Edit 6: Hmm, the /explain diplomacy output from freeciv-server isn't quite accurate where barbarian tribes are concerned.
/explain: Option: diplomacy - Ability to do diplomacy with other players
/explain: Description:
/explain: This setting controls the ability to do diplomacy with other players.
/explain: Status: fixed
/explain: Possible values:
/explain: - ALL: "Enabled for everyone"
/explain: - HUMAN: "Only allowed between human players"
/explain: - AI: "Only allowed between AI players"
/explain: - NOAI: "Only allowed when human involved"
/explain: - NOMIXED: "Only allowed between two humans, or two AI players"
/explain: - TEAM: "Restricted to teams"
/explain: - DISABLED: "Disabled for everyone"
/explain: Value: "Enabled for everyone" (ALL), Default: "Enabled for everyone" (ALL)
Attachments
PacCampaign Level 1 v1.3.sav.zip
(7.1 KiB) Downloaded 10 times
PacCampaign Level 1 v1.2.sav.zip
(9.85 KiB) Downloaded 12 times

Molo_Parko
Veteran
Posts: 65
Joined: Fri Jul 02, 2021 4:00 pm

Re: Playing campaigns

Postby Molo_Parko » Wed Sep 29, 2021 4:29 pm

In light of the possibility of accumulating in re-used sav files, settings which are either no longer meaningful, or are incorrect, I elected to go back through the sav file and remove settings (mostly from the "[settings]" section) which appear erroneous to the Campaign Level 1 scenario. I found and removed several that seemed to be irrelevant to the scenario given that it includes a map. Examples are settings such as: steepness, alltemperate, dispersion, flatpoles, huts, onsetbarbs, separatepoles, singlepole, specials, steepness, teamplacement, temperature, tinyisles, and wetness, all of which have been removed. Most of those were related to map generation which the scenario does not use, the others don't appear to have any bearing on the scenario due to the way tribe and unit creation are handled via lua. There are likely more which could be removed - I kept hem-hawing over "if the setting isn't in the file and the player has set non-default values will it affect the scenario gameplay" with some cases having clear answers and others not so much.

A slightly slimmed-down PacCampaign Level 1 scenario v1.4 is attached.
Attachments
PacCampaign Level 1 v1.4.sav.zip
(7.58 KiB) Downloaded 11 times
Last edited by Molo_Parko on Wed Sep 29, 2021 8:16 pm, edited 2 times in total.