Results 1 to 7 of 7

Thread: Modding a game written in Pascal

  1. #1

    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.
    The entire famine code looks like this:


    Code:
    [*] = ;         if gProfile.bFamine and (gPlayer[plInd].bfamine) and (bplayable) then
            [*] = ;         begin
            [*] = ;            if (gInterface.gamemode=gc_gamemode_game) or (gInterface.gamemode=gc_gamemode_spectator) then
            [*] = ;            begin
            [*] = ;               if (not TObjProp(pobjprop).bbuilding) and (not TObjProp(pobjprop).bnohungry) then
            [*] = ;               begin
            [*] = ;                  if (arg_obj.insideofuid<>0) and (gPlayer[plInd].difficulty>0) then // won't be here, cause unit insideofuid is unplayable
            [*] = ;                  begin
            [*] = ;                     // случай, если юнит сидит в шахте
            [*] = ;                     {var absorberHnd : Integer = GetGameObjectHandleByUniqueId(arg_obj.insideofuid);
            [*] = ;                     if (absorberHnd<>0) then
            [*] = ;                     begin
            [*] = ;                        var pobj2 : Pointer = _unit_GetTObj(absorberHnd);
            [*] = ;                        if (pobj2<>nil) then
            [*] = ;                        begin
            [*] = ;                           if (gObjProp[TObj(pobj2).cid][TObj(pobj2).id].usage=gc_obj_usage_mine) then
            [*] = ;                           begin
            [*] = ;                              var pObjInside : Pointer = _misc_GetObjectArgData(absorberHnd, gc_argunit_inside);
            [*] = ;                              var insidecount2 : Integer;
            [*] = ;                              if pObjInside <> nil then
            [*] = ;                              insidecount2 := TIntegerList(pObjInside).GetCount;
            [*] = ;
            [*] = ;                              if (insidecount2>0) and (_misc_RandomInt<(250/insidecount2)) then
            [*] = ;                              begin
            [*] = ;                                 _unit_SetTagStates(myHnd, gc_statetag_essential_death);
            [*] = ;                                 arg_obj.insideofuid := 0;
            [*] = ;                              end;
            [*] = ;                           end;
            [*] = ;                        end;
            [*] = ;                     end;}
            [*] = ;                  end
            [*] = ;                  else
            [*] = ;                  if (((gPlayer[plInd].difficulty>1) or (gbool_lan_isonlinecached)) and (_misc_RandomInt<50)) or ((gPlayer[plInd].difficulty=0) and (_misc_RandomInt<5)) or ((gPlayer[plInd].difficulty=1) and (_misc_RandomInt<12)) then
            [*] = ;                  _unit_SetTagStates(myHnd, gc_statetag_essential_death);
            [*] = ;               end;
            [*] = ;            end;
            [*] = ;         end;

  2. #2
    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?

  3. #3
    Quote Originally Posted by SilverWarior View Post
    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.
    Attached Files Attached Files

  4. #4
    Quote Originally Posted by PascalNewb View Post
    The game is called Cossacks 3, have you heard of 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.

  5. #5
    Quote Originally Posted by SilverWarior View Post
    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!

    I'd love to learn about Pascal and how you can work these things out!

  6. #6
    Interesting, what kind of script it is? Pascalscript (http://www.remobjects.com/ps.aspx) ?

  7. #7
    Quote Originally Posted by JC_ View Post
    Interesting, what kind of script it is? Pascalscript (http://www.remobjects.com/ps.aspx) ?

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •