How to: Add buildable Blockhouses.

Discussion in 'Modding' started by A. Soldier, Oct 8, 2016.

  1. A. Soldier

    A. Soldier Active Member

    Hello, so a few days ago me and Kiergath managed to add buildable Blockhouses to the game, but just today I got arsed to make a guide on how we did it exactly.

    Today we will be looking at 3 required files and 1 optional file, for the rotation of the Blockhouses, credits to BombaRuLz for the help on this.

    First up is country.script, in the file add:

    Code:
    _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'misblg', 6, 0, ind, '', '', '');
             _country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'misblg2', 6, 1, ind, '', '', '');
    Under

    Code:
    //_country_AddFixedProduceWithAccessControl(country, fixedproduceind, member, 'eurcoa', 3, 0, ind, '', '', '');
    In the "// FIXED PRODUCE" section, you can just search for it to get to where you need to add the Blockhouse lines to.

    Picture: http://imgur.com/a/hmqFy

    After which we need to add them to the European and Eastern countries' respective editor sections.

    Put

    Code:
    if (not tur) and (not alg) then
          _country_AddMember(country, 'misblg', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
          _country_AddMember(country, 'misblg2', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
    Under

    Code:
    if (not tur) and (not alg) and (not ukr) then
          _country_AddMember(country, csid+'ba2', ind, True, gc_country_editorplace_category_buildings, 19, gc_ai_unit_ba18);
    You can just search for the above line in order to find where to put the Blockhouse lines, like with the "//FIXED PRODUCE" example I gave.

    Picture: http://imgur.com/a/CCcUz

    Just a few notes here, last time I checked Turkey and Algeria still had 1 of the blockhouses so I'm not 100% entirely sure what's the problem and why they have access to them, the line
    Code:
    if (not tur) and (not alg) then
    forbids them to have Blockhouses, since they're wooden based structures and both Turkey and Algeria don't generally have such structures so they're a bit out of place. But if you so wish, feel free to remove the specified line so everybody has access to them, and not just the European and Eastern Nations.

    Next up we'll be looking into our next file, unit.script.

    You can just search for "blg" in the file and copy-paste it from there, or, use my already done lines:

    Code:
    'misblg' : begin
                            SetObjBuildingBaseSettings(objprop, False, 500, gc_obj_usage_tower);
                            SetObjBuildingProperties(objprop, objbase, 10000, 4500, 300);
                            SetObjBasePrice(objbase, 0, 100, 100, 150, 0, 0);
                            SetObjBaseWeapon(objprop, objbase, 0, 85, 1, 400 {C1 Was 550}, 950, 550, 50000, gc_obj_weapon_kind_bullet, True);
                            objprop.weapon[0].weaponsid := 'SHOTBLOCKHOUSE';
                            objprop.weapon[0].cost[gc_resource_type_iron] := 2;
                            objprop.weapon[0].cost[gc_resource_type_coal] := 2;
                            objprop.weapon[0].fxshot := 'shotmusketpoint';
                            SetObjBaseMaterialCanKill(objprop, gc_obj_material_building, gc_obj_material_body, 0, 0, 0, 0);
                            objprop.searchradius := _misc_PixelsToTiles(1000);
                            objprop.vision := 3;
                            objprop.bshowdelay := True;
                            objprop.explradius := _misc_PixelsToTiles(1);
                      end;
                      'misblg2' : begin
                            SetObjBuildingBaseSettings(objprop, False, 500, gc_obj_usage_tower);
                            SetObjBuildingProperties(objprop, objbase, 10000, 4500, 300);
                            SetObjBasePrice(objbase, 0, 100, 100, 150, 0, 0);
                            SetObjBaseWeapon(objprop, objbase, 0, 85, 1, 400 {C1 Was 550}, 950, 550, 50000, gc_obj_weapon_kind_bullet, True);
                            objprop.weapon[0].weaponsid := 'SHOTBLOCKHOUSE';
                            objprop.weapon[0].cost[gc_resource_type_iron] := 2;
                            objprop.weapon[0].cost[gc_resource_type_coal] := 2;
                            objprop.weapon[0].fxshot := 'shotmusketpoint';
                            SetObjBaseMaterialCanKill(objprop, gc_obj_material_building, gc_obj_material_body, 0, 0, 0, 0);
                            objprop.searchradius := _misc_PixelsToTiles(1000);
                            objprop.vision := 3;
                            objprop.bshowdelay := True;
                            objprop.explradius := _misc_PixelsToTiles(1);
                      end;
    Just a note, that if you copy and paste the lines from the file you will need to separate them as I've done in order for them to work. Here I've put them under the Tower (tow) and above the Stone Wall (swa) as you can see in the picture below, in the common buildings section.

    Picture: http://imgur.com/a/DuHMb

    Last file, dmscript.global.

    This file is required to tell the game to increase the limit of units (and buildings) in each nation. Search for
    Code:
    gc_country_maxmembers
    and change the number from 64 to a bigger one, for example 128, double that. Keep that in mind when adding new units. Credits to Fimti for the idea on where to look at.

    Optional rotation files: go to \Steam\steamapps\common\Cossacks 3\data\objects\buildings

    And open up "misblg.prop" and "misblg2.prop".

    Go to
    Code:
     DefaultRollAngle
    and change misblg.prop from 45 to 0 and misblg2.prop from 135 to 90 to achieve a vertical and horizontal rotation, like shown in my picture: http://steamcommunity.com/sharedfiles/filedetails/?id=774799507

    and here: http://steamcommunity.com/sharedfiles/filedetails/?id=774799591

    So yes, the final product with all 3 files should be the above pictures.

    I'd link a download but atm my dropbox is cluttered as it is, plus it wouldn't be compatible with the community Mod Manager, you would have to replace your (modified) files and it's just generally better for people to learn to do these things by themselves to learn how to mod, yeah I know I'm an ass :p

    Cheers.
     
    Last edited: Oct 10, 2016
    BombaRuLz likes this.
  2. Alatristé

    Alatristé Member

    Oh thanks.
     
  3. Setakat

    Setakat Member

    Code:
    if (not tur) and (not alg) then
    begin
         _country_AddMember(country, 'misblg', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
          _country_AddMember(country, 'misblg2', ind, True, gc_country_editorplace_category_buildings, 15, gc_ai_unit_none);
    end;
    If statements only apply the condition to one line by default. If you want it to affect multiple lines, you need to embed the lines in question into a 'begin...end;' block.
     
  4. Gambler71

    Gambler71 New Member

    I am not sure why, but if I implement this modification, I cannot get Austria or France to build anything except MILL, MINE, and TOWN HALL. The error is that these 2 nations then need Required Upgrades of "misc|%com%". All other nations seem to be okay.

    The only difference I can see is in "unit.script". My code before editing:
    Code:
                      commonsid+'tow' : begin
                         SetObjBuildingBaseSettings(objprop, False, 500, gc_obj_usage_tower);
    ... SOME CODE CUT OUT ...
                      end;
    //BLOCKHOUSE code placed here works for all nations except Austria and France
                      commonsid+'swa', commonsid+'sga' : begin
                         SetObjBuildingBaseSettings(objprop, False, 1, gc_obj_usage_none);
    ... LOTS OF CODE CUT OUT ...
          else
          //if (mis) then
          begin
             if (bCheckBuilding) then
             begin
                var csid : String = 'mis';
                bCheckBuilding := False;
                case objprop.sid of
    //BLOCKHOUSE code placed here works for NO nation
                   'misblg', 'misblg2' : begin
                      SetObjBuildingBaseSettings(objprop, False, 500, gc_obj_usage_tower);
                      SetObjBuildingProperties(objprop, objbase, 10000, 4500, 300);
                      SetObjBasePrice(objbase, 0, 100, 100, 150, 0, 0);
                      SetObjBaseWeapon(objprop, objbase, 0, 85, 1, 400 {C1 Was 550}, 950, 550, 50000, gc_obj_weapon_kind_bullet, True);
                      objprop.weapon[0].weaponsid := 'SHOTBLOCKHOUSE';
                      objprop.weapon[0].cost[gc_resource_type_iron] := 2;
                      objprop.weapon[0].cost[gc_resource_type_coal] := 2;
                      objprop.weapon[0].fxshot := 'shotmusketpoint';
                      SetObjBaseMaterialCanKill(objprop, gc_obj_material_building, gc_obj_material_body, 0, 0, 0, 0);
                      objprop.searchradius := _misc_PixelsToTiles(1000);
                      objprop.vision := 3;
                      objprop.bshowdelay := True;
                      objprop.explradius := _misc_PixelsToTiles(1);
                   end;
                   'misyurt' : begin
                      SetObjBuildingBaseSettings(objprop, False, 0, gc_obj_usage_none);

    Here is my edited code:
    Code:
                      commonsid+'tow' : begin
                         SetObjBuildingBaseSettings(objprop, False, 500, gc_obj_usage_tower);
    ... SOME CODE CUT OUT ...
                      end;
    //BLOCKHOUSE start
                      'misblg' : begin
                        SetObjBuildingBaseSettings(objprop, False, 500, gc_obj_usage_tower);
                        SetObjBuildingProperties(objprop, objbase, 10000, 4500, 300);
                        SetObjBasePrice(objbase, 0, 100, 100, 150, 0, 0);
                        SetObjBaseWeapon(objprop, objbase, 0, 85, 1, 400 {C1 Was 550}, 950, 550, 50000, gc_obj_weapon_kind_bullet, True);
                        objprop.weapon[0].weaponsid := 'SHOTBLOCKHOUSE';
                        objprop.weapon[0].cost[gc_resource_type_iron] := 2;
                        objprop.weapon[0].cost[gc_resource_type_coal] := 2;
                        objprop.weapon[0].fxshot := 'shotmusketpoint';
                        SetObjBaseMaterialCanKill(objprop, gc_obj_material_building, gc_obj_material_body, 0, 0, 0, 0);
                        objprop.searchradius := _misc_PixelsToTiles(1000);
                        objprop.vision := 3;
                        objprop.bshowdelay := True;
                        objprop.explradius := _misc_PixelsToTiles(1);
                     end;
                     'misblg2' : begin
                        SetObjBuildingBaseSettings(objprop, False, 500, gc_obj_usage_tower);
                        SetObjBuildingProperties(objprop, objbase, 10000, 4500, 300);
                        SetObjBasePrice(objbase, 0, 100, 100, 150, 0, 0);
                        SetObjBaseWeapon(objprop, objbase, 0, 85, 1, 400 {C1 Was 550}, 950, 550, 50000, gc_obj_weapon_kind_bullet, True);
                        objprop.weapon[0].weaponsid := 'SHOTBLOCKHOUSE';
                        objprop.weapon[0].cost[gc_resource_type_iron] := 2;
                        objprop.weapon[0].cost[gc_resource_type_coal] := 2;
                        objprop.weapon[0].fxshot := 'shotmusketpoint';
                        SetObjBaseMaterialCanKill(objprop, gc_obj_material_building, gc_obj_material_body, 0, 0, 0, 0);
                        objprop.searchradius := _misc_PixelsToTiles(1000);
                        objprop.vision := 3;
                        objprop.bshowdelay := True;
                        objprop.explradius := _misc_PixelsToTiles(1);
                      end;
    //BLOCKHOUSE end
                      commonsid+'swa', commonsid+'sga' : begin
                         SetObjBuildingBaseSettings(objprop, False, 1, gc_obj_usage_none);
    ... LOTS OF CODE CUT OUT ...
          else
          //if (mis) then
          begin
             if (bCheckBuilding) then
             begin
                var csid : String = 'mis';
                bCheckBuilding := False;
                case objprop.sid of
    //BLOCKHOUSE  old data before it was implimented (start)
                   //'misblg', 'misblg2' : begin
                      //SetObjBuildingBaseSettings(objprop, False, 500, gc_obj_usage_tower);
                      //SetObjBuildingProperties(objprop, objbase, 10000, 4500, 300);
                      //SetObjBasePrice(objbase, 0, 100, 100, 150, 0, 0);
                      //SetObjBaseWeapon(objprop, objbase, 0, 85, 1, 400 {C1 Was 550}, 950, 550, 50000, gc_obj_weapon_kind_bullet, True);
                      //objprop.weapon[0].weaponsid := 'SHOTBLOCKHOUSE';
                      //objprop.weapon[0].cost[gc_resource_type_iron] := 2;
                      //objprop.weapon[0].cost[gc_resource_type_coal] := 2;
                      //objprop.weapon[0].fxshot := 'shotmusketpoint';
                      //SetObjBaseMaterialCanKill(objprop, gc_obj_material_building, gc_obj_material_body, 0, 0, 0, 0);
                      //objprop.searchradius := _misc_PixelsToTiles(1000);
                      //objprop.vision := 3;
                      //objprop.bshowdelay := True;
                      //objprop.explradius := _misc_PixelsToTiles(1);
                   //end;
    //BLOCKHOUSE  old data before it was implimented (end)
                   'misyurt' : begin
                      SetObjBuildingBaseSettings(objprop, False, 0, gc_obj_usage_none);

    I have tried many things, but I am unable to get it to work for Austria and France :(

    Love the code tho, so atm I am just playing other nations.

    I have attached the Unedited and Edited "unit.script" files incase anyone can make sense of this. I put .txt on the end of the file so that I could upload them.
     

    Attached Files:

  5. Gambler71

    Gambler71 New Member

    Also just discovered that I cannot save and reload a game properly, and that the AI teams do not do anything, the peasants just hide in the forests.

    To make sure it was not another mod, I uninstalled and re-installed the game, followed the steps again (no copying of my old code, only used your code), and the problem still exists sadly.
     
  6. A. Soldier

    A. Soldier Active Member

    I'm not entirely sure on what's causing it but what I've noticed is that it only happens in multiplayer after I've played a single session. So no idea what's wrong.

    Edit: I am only experimenting with whata works and what doesn't, Im not using it to cheat or troll, plus it has half the Tower's HP so it's easy to take it down with Artillery.
     
  7. A. Soldier

    A. Soldier Active Member

    Updated topic with the misc bug fix.

    Thanks to Fimti.
     
  8. Gambler71

    Gambler71 New Member

    Unfortunately if you change "gc_country_maxmembers = 64;" to "gc_country_maxmembers = 128;" in the "data\scripts\dmscript.global" file, you can no longer start campaign missions.

    Random and Editor worked ok, cannot test MP until weekend.

    I just finished a Random Map, and it was 100% fine. I like the blockhouses, nice defensive building. Thanks for everything you are doing, I appreciate it.
     
  9. A. Soldier

    A. Soldier Active Member

    You sure? I just went into a few MP games yesterday and everything was fine, well, except for my weird queue orders. Pretty much all of the units I queued from the Church, Stable, Artillery Depot and Diplomacy Center came out as the wrong units.

    Edit: Nvm misread, I'll try the campaign now and see what happens.
     
  10. Fimti

    Fimti New Member

    The shooting animation does not fit the blockhouse if I change the angle to 0' or 90' degrees.
    The animation coordinates are located in "data/game/var/objcustom.cfg" aaaand it would take to days adjust the coordinates to fit the new building angle o_O
    They must have had somekind of tool when placing the animations - hopefully we will get access to it some day.
     
  11. A. Soldier

    A. Soldier Active Member

    Yes, and the birth and exit point coordinates I took from the Austrian barracks also doesn't work sadly, I mean they just come out of thin air when I queue musketeers from the blockhouse.

    I also noticed that peasants come up out of the back of houses, and since they're all in separate files, it would take a hell of a lot of time to change all of them, well not a lot but I'm just too lazy to change all 12 house fies.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice