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);
    begin
    gbool_use_collision:=val;
    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
    end;
    end;
    end;
    end;
    end;

    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 Active Member

    Start a conversation with Awar, I'm sure he will be able to help.
     
  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