Help With Coding

Can you help improve your favourite game? Hardcore C mages, talented artists, and players with any level of experience are welcome!
Eusebio Ptolomeu
Posts: 20
Joined: Sat Oct 07, 2017 1:51 am

Help With Coding

Postby Eusebio Ptolomeu » Sun Jul 07, 2019 3:13 pm

I need some help with some tweakings I trying to make in the game code; I'm pretty new on these things, so this might be very trivial questions.

I've said once that I would like to implement the concept of revolting cities in the game: basically speaking, when the player or AI don't pay attention for it's cities and let them sink into revolt, the city automatically secedes from the nation, and create a new nation (aka, a new "player") on it's own. This is basically what happens in the event of a civil war, already implemented by the game: when a civil war happens, half of your cities becomes another entirely new nation. The idea here is pretty much the same thing, only it's not as dramatic (it would be only the revolting city), but it's a little more likely to happen (you don't need to lose your capital for this to happen, you just need to let a city be unhappy). I could also try to link this with the "corruption" setting, given that it takes into account the distance from the capital, so more distant cities would be more likely to revolt, think about these distant cities as being colonies.Although I know this might create some odd results when your government is communism, which sets the same amount of corruption for every city. Anyaway, the reason I'm telling this is just to see if it is possible at all to implement these changes, as I said, I'm pretty new to the concept of coding, so my idea might not even be possible at all (I already tried to do some modding in Rise of Nations just to realize, n the middle of the road, my ideas were unfeasible to begin with :lol: )
Now, supposing this idea might work, I would probably need to check the code for events like a civil war, or even a barbarian hut becoming a civilization (in the end, what I'm looking for is the "command" that triggers the game to create a new nation/player mid-game). Once I have this command, I would basically apply it for unhappy cities, except for the capital (leave it to the more dramatic civil war) so it creates a new nation centered around this city (keeping all of it's buildings, units supported, a proportional share of the player's treasure, all of the player's technology, and of course set it to antagonize the player). I've been looking for this commands troughout all of the files, but I can't see exactly where it is defined. I know the civil war setting appears in certain files in the "commom" folder ("events.c" for example), but it seems that in these files, it just tells the computer to apply the civil war setting; where exactly it is explained what the civil war setting does (i.e., take half the number of cities, alocate it for a entirely new player, halve the treasure)?

Ignatus
Elite
Posts: 360
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Help With Coding

Postby Ignatus » Sun Jul 07, 2019 5:00 pm

You should obtain some point-and-click coding environment to know where things are rooted (I use mostly Geany myself, Eclipse is also good but it's simpler). The code that actually changes the in-game state is mostly in the server/ folder. What you need is split_player() from server/plrhand.c + transfer_city() from server/citytools.c, the civil_war() is also in plrhand.c.

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

Re: Help With Coding

Postby cazfi » Sun Jul 07, 2019 6:51 pm