Unit Collisions

Discussion in 'Modding' started by Ftoomsh, Nov 30, 2019.

  1. Ftoomsh

    Ftoomsh Well-Known Member

    I am trying to understand unit collisions.

    If one experiments with the in-game editor with streaming units from a barracks to a point, one notes that the units behave as if they have some significant collision radius. They randomly push each (the pushed unit slides not walks) and then they also randomly take a little walk and spread. Units in formation behave relative to each other as if they have both a set formation spacing and some aspect of a collision radius (for others in the same formation only). However, when another formation is stacked on that formation the units behave as if they have a much smaller collision radius with respect to units in formations other than their own. That is quite strange. Even stranger, when melee (cold steel) units go on attack, they act is they have no unit radius (or unit box) at all. It's as if the code has logic somewhere (which I am trying to find) which says in effect "when on attack ignore collision". The crowding of melee units on attack is ridiculous. They can turn into an absurdly compressed blob. The code logic appears not to be applying collision boxes or collision radiuses at that stage of a melee.

    The miscext2.script has some interesting code to do with collisions.

    // _misc_SetUseCollision
    procedure _misc_SetUseCollision(val: boolean);
    var pind: integer;
    for pind:=0 to gc_MaxPlayerCount-1 do begin
    var gind: integer;
    var phnd: integer=GetPlayerHandleByIndex(pind);
    for gind:=0 to GetPlayerGameObjectsCountByHandle(phnd)-1 do begin
    var ghnd: integer=GetGameObjectHandleByIndex(gind, phnd);
    if _unit_IsUnit(ghnd) then begin
    if gbool_use_collision then begin
    SetGameObjectCollidedStateNameByHandle(ghnd, '_misc_Collided');
    SetGameObjectUncollidedStateNameByHandle(ghnd, ''); // leave empty
    SetGameObjectRuleCollidedExecFrByHandle(ghnd, 4, 35.0, False); // no collide event with friendly
    SetGameObjectRuleCollidedExecEnByHandle(ghnd, 2, 90.0, False); // collide event with enemy in front for 90 fov
    SetGameObjectRuleCollidedExecNlByHandle(ghnd, 4, 35.0, False); // no collide event with neutral
    end else begin
    SetGameObjectCollidedStateNameByHandle(ghnd, '');
    SetGameObjectUncollidedStateNameByHandle(ghnd, '');
    SetGameObjectRuleCollidedExecFrByHandle(ghnd, 4, 90.0, False); // no collide event with friendly
    SetGameObjectRuleCollidedExecEnByHandle(ghnd, 4, 90.0, False); // no collide event with enemy
    SetGameObjectRuleCollidedExecNlByHandle(ghnd, 4, 90.0, False); // no collide event with neutral

    The SetGameObjectRuleCollidedExec.... functions are interesting though I can find nowhere else where they are defined in scripts. How can script code call an undefined function? What clue am I overlooking here?

    The code seems to be saying that the procedure will implement no collide events with friendly (as per comment) even if bool_use_collision = True. This is if the comments are even correct.

    Can anyone shed light on this code and moveable unit collisions in general?
    Loner likes this.
  2. Loner

    Loner Well-Known Member

    Start a conversation with Awar, I'm sure he will be able to help.
  3. Ftoomsh

    Ftoomsh Well-Known Member

    Yes, I have had a conversation with Awar and he has helped. The interesting thing I have found after more investigation is that unit blobbing is not as bad as I thought it was. Due to the fact that I get a lot of client lag, playing from Australia on the other side of the world, I see things on my PC screen display that are only displayed because of glitches caused by client lag. This led me to over-estimate the blobbing problem. A combination of using no-fire-through-friendlies in OCMOD4 and employing artillery strongly discourages a player from blobbing and formation stacking: although I would say formation stacking might still be something of an issue. However, artillery and envelopment / encirclement are the best ways to counter formation stacking in OCMOD4. I think a formation stacker would come out worst against a good opponent. I will test this in the editor. If the tests come out showing that the formation stacker comes off second best then I will lay this issue to rest and leave unit "elbow room" the same. Infantry lines don't take all that much damage from a salvo of artillery (unless the cannon enfilade the infantry), whereas stacked formations take higher casulaties. Infantry envelopment should put more fire-power into the stack too. But as I say I will test it.


    I tested 3 x 120 man 18th C musket line formations stacked against 3 x 120 man 18th C musket line formations in linear concentric and converging attack. The separate lines in linear concentric and converging attack had 121 infantry left after the battle. Even allowing for random head-shot variations and an error of +60 to -60 troops (a very large allowance) this translates into an almost certain victory by 60 to 180 troops for the linear tactics player. Very bad odds for the stacking player. By its firing model alone, OCMOD4 renders blobbing and stacking a seriously losing tactic.
    Last edited: Jan 4, 2020
    Awar and Loner like this.
  4. Ftoomsh

    Ftoomsh Well-Known Member

    Awar, I am interested to know how you added a different attack command for State vs Country. When the player attacks an enemy formation with his formation, his formation keeps it shape on attack rather than compressing like in vanilla. How is that coded? What are the key files and changes? It is associated with a different "attack in formation" icon.
  5. Awar

    Awar Well-Known Member

    attack command is replaced with movement command, with an attack animation.
  6. Loner

    Loner Well-Known Member

    How is this implemented.
  7. Awar

    Awar Well-Known Member

    That was a long time ago. I don't remember much anymore

  8. Loner

    Loner Well-Known Member

    Thank you Awar.
  9. Ftoomsh

    Ftoomsh Well-Known Member

    Loner, with that hint I would compare state vs country onmousedown.inc to vanilla onmousedown.inc and see what has been changed relative to the command. I would also search for all instances of gbool_gui_goinattackmode in the S v C code. I've checked S v C in the in-game editor to make sure that pikes (for example) can still bunch to attack wooden fences. They can so that's fine.

    I am still considering whether to add this command change to my OCMOD4. Bunching effects on combat outcomes are complex and important, especially in a no-upgrades mod. Cold steel gains a lot of power from bunching. I've found a lot of the balancing in my mod is knife-edge. Change a parameter by a few points and the outcomes are vastly different. In an actual game, change the amount of bunching by micro-ing an attack point and the outcome can be vastly different. Again in an actual game, even change the angle of attack and the outcome can be much different. Adding this command would remove a micro-ing tactic. At first, I thought it might be a good idea. It certainly looks better on screen. Bunching looks ugly and unrealistic. However, from a combat point of view, bunching of cold steel is a very useful tactic. It depends on the whole mod and what effects you are trying to achieve. I'm going to hold off on using this command for now. My ideas have changed a bit on this point.

    My block on shooting through friendly units has changed the whole dynamic of the game. A column of 18th C muskets withstands a cavalry charge much better than a line though not as well as a square on stand ground. With the column it is the bunching of so many bayonets in a small space which assists them to withstand the cavalry quite a bit better. However, a column's fire power is much reduced. An infantry line of muskets defeats an infantry column of muskets. Then again, though I haven't tested it yet, I imagine that a line which is too thin and extended (say all 3 rank formations and a very long line) would be vulnerable to a heavy central attack from columns. Bust the center and then wheel your formations each way and role up the lines from the center.

    I've already experimented with an en echelon attack on one wing. It works beautifully. Again, you can turn your formations and roll up the line. I will post soon on how to test an en echelon attack in the in-game editor. The en echelon attack works well in OCMOD 4 and it would also work well in State vs Country Plus, for sure.

    This is just with infantry. Add in cavalry maneuvers and charges as well and it all gets quite complex.

    As you can see, my ideas are still evolving on this issue.
    Last edited: Jan 10, 2020
    Loner likes this.
  10. Loner

    Loner Well-Known Member

    Thanks for this Ftoomsh, I'll look into it.
  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