If this is your first visit, be sure to check out the FAQ by clicking the link above. You have to register before you can post.

If you have recently signed up, please make sure you log in so that your activity is registered. This is required for automatic promotions to work and to ensure your account is not deleted during the registration process.

Modding a game written in Pascal

Hi everyone!

I'm hoping to get some advice, a game I have been dying to mod is written in Pascal, most of the files are accessible for easy modding so that is a great start.

It's a strategy game, its the usual resource gathering/build an army setup, what makes it realistic is that each unit consumes food, if you run out of food you have a famine and the units start to die, so this is a really cool feature of the game. To add to the realism what I want to add to the game is also have supply wagons. What would happen would be that units health slowly decreases unless you have a supply wagon in a certain radius of your units and your units health will be increased to full/not decrease.

So what I need to do is code so that units health is always decreasing (at a certain rate) unless their is a supply wagon nearby, the supply wagon replenishes health. There is already a Priest unit in the game that heals units that are attacked in battle, so that side of things will be easy because I can just use the code from the Priest unit to replenish health, so really all I need to do is get units health to decrease, the rest would be easy. I have spoken to the devs and they said its something that can be done, I have this famine code which the game uses when food runs out and units start dying, I would love to understand the code so I can go from there:

The dev explained this to me:

look at current famine code:
scripts\units\unit.inc\nothing.inc

You should change it to be effective all the time (except supply unit`s nearby) and change it to draining unit hp, instead of killing it.

You may use famine code, and replace
_unit_SetTagStates(myHnd, gc_statetag_essential_death);
with code for decreasing current health (please, check TObj class declaration in dmscript.global, located in scripts\).
Also you'd have to set some kind of timer, to let the health decline slowly.
As for supply unit - you may add a check of it's availability (no need to use pope's code, just make a unique sid for this unit and check it, it'd be a slow solution though, i'd recommend putting a large timer to it), and in case it's near just inverse the health decreasement variable.
A viable alternative to sid would be adding another property to objprop class (classes.script in scripts\lib) and setting it false for all the units (initbase function in unit.script) except supply unit.

Hi!
I'm afraid that just seeing famine code won't be enough. Why? From what I can tell from this "famine" code game heavily relies on various variables which together form complex "Game State" information that is that used by "Game State Engine" to do most game logic. So I fear that in order to help you better I would have to study large part of this "Game State Engine".

Hi!
I'm afraid that just seeing famine code won't be enough. Why? From what I can tell from this "famine" code game heavily relies on various variables which together form complex "Game State" information that is that used by "Game State Engine" to do most game logic. So I fear that in order to help you better I would have to study large part of this "Game State Engine".

By the way which game are we talking about here?

Thanks you so much for the reply SilverWarior!

The game is called Cossacks 3, have you heard of it?

The dev said to make the units health drain, you should write your code in nothing.inc, next to famine check (use it as example). He said the famine code should get me started so use this as an example because essentially draining units health is similar to the famine code when food runs out units start to die. I attached the whole nothing.inc file to hopefully decipher it.

Wait! Cossacks 3 is made with Pascal?
I now know which game is the next in line for buying.
I spent many joyful times playing the first Cossacs game. So if this one is as fun as the first one was I will probably enjoy this one as well. And if it is so easily modable as you say this might be the first game for which I might try to make some mod of my own (need to play it first).

Any way I will take a closer look to see if I can lend you a helping hand. But I'm not making any promises.

Wait! Cossacks 3 is made with Pascal?
I now know which game is the next in line for buying.
I spent many joyful times playing the first Cossacs game. So if this one is as fun as the first one was I will probably enjoy this one as well. And if it is so easily modable as you say this might be the first game for which I might try to make some mod of my own (need to play it first).

Any way I will take a closer look to see if I can lend you a helping hand. But I'm not making any promises.

Yeh it sure is! It's really easy to mod because all the files are external and not part of the engine locked up so you can access and change almost anything, for example one of the players made a mod which you can zoom all the way out and get a birds eye view of the map so now you can control your formations a lot better. So glad you remember the first one! A lot of people playing Cossacks 3 are totally new to it all, if you get it you should come and play online, some of the multiplayer games are unbelievable, you really have to be smart with your formations and attack/defense tactics, I've played a few games that have gone for 3 hours, not even kidding you!

That's a good question, unless the game developer uses their own tools, a lot of game developers just code their own programming tools, unless they just recompile each time, I know the same developer did this with the original Cossacks game.

I just have to start learning Pascal, it seems like a fairly straight forward programming language, the simple stuff is anyway, I think what I am after is a lot more complex