first of all have a look at this picture to see what i'm talking about:
http://postimage.org/image/j96yas3wz/ .
as you all know phalanx formation is kinda crappy the way it is because of 2 factors:1) troops swich to their swords too quickly and 2) troops only use the soldiers from the first 2 rows to kill the enemy with their pikes. with this trick in this tutorial youll be able to get as much of a working phalanx as possible with both sword and pike.
RULES:
anything after ";*" is a comment by me about the changes to be made
anything after *** = not mandatory for implementing the pike configuration in the photo but still useful for overal balancing
step1) go to edu and start moding your pikemen as in this example
soldier Highland_Pikemen, 100, 0, 1.5;Highland_Pikemen ; *1 no space
attributes sea_faring, hide_forest, can_withdraw
;move_speed_mod 0.7
formation 0, 1.8, 2.8, 2.8, 4, square, phalanx ;*2 cant give negative values
stat_health 1, 0
stat_pri 8, 5, no, 0, 0, melee, melee_blade, piercing, spear, 25, 1.85 ;* this makes the unit stick
to its pike more than usual
;stat_pri_ex 0, 0, 0
stat_pri_attr , spear, long_pike
stat_sec 7, 2, no, 0, 0, melee, melee_blade, piercing, sword, 25, 0.15 ;*3
;stat_sec_ex 0, 0, 0
stat_sec_attr no
explanations: *1 the thing is that by adding the second time the skeleton after the ";" you make the units i mean individual units loose their own radius(haven't tryrd it for horses or other stuff ). my hunch was that the 0.8 iner unit spacing was made not by a hardcode but insted by the units individual radius that's why i could then pile the pikes up. it's really important NOT TO SPACE here: 1.5;Highland_Pikemen
*2 then set the formation to 0, 1.8, 2.8, 2.8, 4, the final "4" is the second breakthrough. as youll see adding the unit spacing to 0 will mean that instead of one unit in one place therell be 2 units in that exact same place(this why you said that there are 4 lines of pikes in the photo; i couldnt find a way to mode the number of rows of pikes lowered to anything but 2, so there are 2 lines of pikes over there but with the number of men that would have been otherwise into 4 rows ) anyway the drawback is that not pike units are less wide that's why i recomend to use them in another configuration: put 100 number of troops and lower the number of rows to 3 that should solve it.
* 3 the values 1.85 and 0.15 should not be changed to any othet value for example 100000 and -10000 because i THINK the game doesn't consider these values it there are lower than 0 and biger than 1
step 2) go to your descr_formations_ai.txt and delete inside the blocks that have pikemen the following 2 lines (you may have them or not its not mandatory to have them but in my case as i had the descr_formations_ai.txt from a mode so the respective lines were in it)
begin_block 5
max_units 6
unit_type spearmen infantry 1.0
unit_type heavy infantry 0.9
unit_type light infantry 0.8
unit_density close
min_unit_width 20
max_unit_width 20
block_formation line
block_relative_pos 4 0.0 -5.0
inter_unit_spacing 0.0
priority 1.0
end_block
explenation : ok, so now the pike(as well as all the other troop types present in this block) will have the number of rows set by default, meaning the one set in the edu above (4 or 3) for pikemen. THIS MAKES THE PIKEMEN FORMATION ABOVE HAVE THE DEFAULT NR OF ROWS WHICH I SET IN THE EXAMPLE ABOVE TO 4 . I SUGGEST TRYING IT TO 3.
*** in my opinion, its best to delete those 2 lines in all blocks in the descr_formations_ai.txt so that all troops switch to the number of rows set by default in the edu and then go to edu and set the default nr of rows to this configuration:
4 for cavalry with 24 nr of soldiers
6 for troops with 48 nr of soldiers
7 to troops with 60 nr of soldiers
4 or 3 to phalanx troops as long as they have 100 nr of soldiers
step3) now go to descr_projectile.txt and modify all the radius of all projectiles from 0 to 0.1 or greater, because the skeleton trick i've done at step 1 made the highland_pikemen's skeleton have no individual radius which makes all projectiled that haven't got a radius of their own to go right through them as if they were gosts).
projectile hand_gun_bullet
effect bullet_model_set
end_effect bullet_impact_ground_set
end_man_effect man_impact_tiny_set
end_package_effect bullet_impact_wall_set
end_shatter_effect bullet_impact_ground_set
end_shatter_man_effect man_impact_tiny_set
end_shatter_package_effect bullet_impact_wall_set
damage 0
radius 0 ; change this from 0 to 0.1
mass 0.05
accuracy_vs_units 0.04
min_angle -60
max_angle 70
velocity 40 65
display aimed
effect_only
great that's all there is to it. the crucial step of this turorial is adding the soldier's skeleton after the semicolons at step 1 just as it is shown there. this trick can be used for any other units in game (infantry, haven't tryed it for cavalry) this makes them pile up at the front rows and poke the enemy with their weapons it's really cool to watch and it would be good for some mod that uses a shield wall, besides it's use here for phalanx. i also think that adding the same trick to another melee unit (ex:dismounted_feudal_knights) will make them fight with all rows rather than just use its front row this combined with some formation moding may make for a more chaotic melee battle.
for halberd phalanx formatios: it's simple just add the janissary_heavy_inf skeleton to both the soldier and after the semicolon and the delete both the secondary weapon and the phalanx capability. the halberdiers will pile up in the first row and kick the enemy with all they've got it's really cool.
i hope this helps and i hope that this will be implemented in mods from now on although piling units in a small area needs a lot of computing power...
you may also try this configuration, courtoasy of Valiant Champion who has done the testing for it:
soldier Aventuros, 60, 0, 4;Aventuros ; the semicolon here has to be sticked to the last letter
attributes sea_faring, hide_forest, very_hardy, can_withdraw
formation 0.5, 1.2, 2.4, 2.4, 3, square, phalanx