Skip to content

Fix: Add more fire ports to China Bunkers to help prevent passengers from damaging it near uneven terrain #2133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 30, 2023

Conversation

commy2
Copy link
Collaborator

@commy2 commy2 commented Jul 21, 2023

This change adds 8 (16 for Infgen) additional fireports to China Bunkers. This prevents them from killing themselves on rough terrain in most situations if filled with more than 2 Tank Hunters.

shot_20230726_162556_2

shot_20230726_163014_5

This does not solve the bug with all GarrisonContain module using objects where shots emerge from 0,0,0 if attacked from certain angles. That can only be solved with engine changes.

@commy2 commy2 added Bug Something is not working right Major Severity: Minor < Major < Critical < Blocker Buff Makes a thing more powerful China Affects China faction labels Jul 21, 2023
@xezon xezon changed the title Add Better Default Fire Points To China Bunker Fix: Add proper fire ports to China Bunker that prevent passengers from damaging it near uneven terrain Jul 21, 2023
@xezon
Copy link
Contributor

xezon commented Jul 21, 2023

This is amazing fix.

@commy2

This comment was marked as outdated.

@commy2 commy2 marked this pull request as draft July 21, 2023 12:21
@ImTimK
Copy link
Collaborator

ImTimK commented Jul 21, 2023

would be an amazing fix when it all works properly

@xezon
Copy link
Contributor

xezon commented Jul 22, 2023

Unfortunately, they are stubborn. Needs more investigation to get it totally right.

What is the problem? On first image everything looked right.

@commy2
Copy link
Collaborator Author

commy2 commented Jul 23, 2023

What is the problem? On first image everything looked right.

Troops still use 0,0,0 if that is closer than any of the other unused firepoints. I think it may not be possible to prevent them from doing this, unless one adds enough firepoints closer to potential targets from all angles. Note that targets are at z=0 on even terrain, so 0,0,0 has a natural advantage too. I think we need to add enough fire points on the slits in the geometry. It is probably possible to do this for 5 guys, but probably impossible for Infgen Bunker when attacked from behind, unless many points sit (almost?) on top of each other.

@MTKing4
Copy link
Collaborator

MTKing4 commented Jul 23, 2023

Can't you just delete the default fireport at 0,0,0? And if hardcoded we do it with thyme?

@commy2
Copy link
Collaborator Author

commy2 commented Jul 23, 2023

It appears to be hard-coded with no work-around. Thyme. Ideally one could place some fallback firepoint that can be used by multiple troops. Maybe it is enough to just place enough points along the geometry. Will have to experiment more with it.

@xezon
Copy link
Contributor

xezon commented Jul 24, 2023

Then we need to put enough ports at the windows and door.

@xezon
Copy link
Contributor

xezon commented Jul 24, 2023

We can paint small windows in the door so that it also looks plausible to shoot from there.

@xezon
Copy link
Contributor

xezon commented Jul 24, 2023

I do wonder, is this also a problem with other bunker structures, such as Palace? Does it have enough ports in all directions to never shoot from center?

And why is this not a problem for vehicles? Would a Humvee not also shoot from íts center if does not have enough ports on either side?

@commy2
Copy link
Collaborator Author

commy2 commented Jul 24, 2023

I do wonder, is this also a problem with other bunker structures, such as Palace?

It is in 1.04 in certain animation states (e.g. on certain maps or after Fortified Structures). In patch, Palace has enough firepoints.

And why is this not a problem for vehicles? Would a Humvee not also shoot from íts center if does not have enough ports on either side?

Good question. Needs investigation. I know it is an issue with the GC Stealthgen Bus, which has a disguise ability similar to the Bomb Truck. If you disguise into certain models, e.g. Toxin Tractors, they will kill themselves due to the lack of non 0,0,0 firepoints on the models. (Could probably fix that too by giving that Bus a dummy model with extra firepoints.)

Maybe it has to do with TransportContain vs GarrisonContain.

@commy2
Copy link
Collaborator Author

commy2 commented Jul 24, 2023

Issue does not exist for Humvee:

shot_20230724_181340_14

Issue persists after changing the Bunker model to Humvee:

shot_20230724_181216_8

Issue does not exist when switching Bunker to TransportContain:

shot_20230724_183205_3

I conclude:

  • that GarrisonContain is the cause of this issue
  • the only way to solve it without Thyme is to add a sufficient number of firepoints to the models that cover all directions

@commy2
Copy link
Collaborator Author

commy2 commented Jul 24, 2023

The issue also exists for the civilian Bunker (e.g. 4 times on TD). If attacked from behind, the shots spawn at 0,0,0 and may collide with the terrain to hit the bunker.

@xezon
Copy link
Contributor

xezon commented Jul 25, 2023

The simplest fix from code side would be to allow reuse fire ports if there are not enough individual ones. This would mean that multiple units can shoot from the same port. There is a visual element to rocket ports on buildings. I think it shows a small barrel. Therefore individual positions are preferred, but reused ports would work too. I think we can do both fixes. Fix in Thyme for general coverage and fix in models where we find it.

@commy2
Copy link
Collaborator Author

commy2 commented Jul 26, 2023

I updated the OP.

The only feasible solution I see is to add sufficiently many additional firepoints. This seems to work pretty well from my testing. I used a script to space out the points evenly, because I'm a nerd with no augenmaß.

Yellow points are the original firepoints. Red are additions for vChina (top) and Infgen Bunkers (bottom).

script used
from itertools import islice, pairwise, starmap

import matplotlib.pyplot as plt
import numpy as np

fps = np.array([
    # x         y           z
    [ 3.928,     10.802,    7.697],
    [-8.217,      6.510,    7.697],
    [-8.331,     -6.190,    7.697],
    [ 3.469,    -10.168,    7.697]
])

def dist(A, B):
    return np.linalg.norm(A - B)

def angle(A, B):
    return np.rad2deg(np.arctan2(B[1] - A[1], B[0] - A[0]))

def fromto(A, B):
    diff = B - A
    return diff / dist(A, B)

def zrot(A, theta):
    theta = np.deg2rad(theta)
    vec = np.array([
        [np.cos(theta), -np.sin(theta), 0],
        [np.sin(theta),  np.cos(theta), 0],
        [0, 0, 1]
    ])
    return np.dot(vec, A)

def hpos(A, B):
    c = dist(A, B)
    h = c / 2 * np.tan(np.deg2rad(72/2))
    hdir = zrot(fromto(B, A), 90)
    hvec = h * hdir

    # edge A: FP1 + (FP2 - FP1) / 2 + hvec
    return A + (B - A) / 2 + hvec

FP1, FP2, FP3, FP4 = fps
A, B, C = starmap(hpos, pairwise(fps))
E = FP1 - (A - FP1)
D = FP4 - (C - FP4)

vcfps = [
    FP1 + (E - FP1) / 2,
    FP1 + (A - FP1) / 2,
    FP2 + (A - FP2) / 2,
    FP2 + (B - FP2) / 2,
    FP3 + (B - FP3) / 2,
    FP3 + (C - FP3) / 2,
    FP4 + (C - FP4) / 2,
    FP4 + (D - FP4) / 2,
]

igfps = [
    FP1 + (E - FP1) / 3,
    FP1 + (E - FP1) / 3 * 2,
    FP1 + (A - FP1) / 3,
    FP1 + (A - FP1) / 3 * 2,
    FP2 + (A - FP2) / 3,
    FP2 + (A - FP2) / 3 * 2,
    FP2 + (B - FP2) / 3,
    FP2 + (B - FP2) / 3 * 2,
    FP3 + (B - FP3) / 3,
    FP3 + (B - FP3) / 3 * 2,
    FP3 + (C - FP3) / 3,
    FP3 + (C - FP3) / 3 * 2,
    FP4 + (C - FP4) / 3,
    FP4 + (C - FP4) / 3 * 2,
    FP4 + (D - FP4) / 3,
    FP4 + (D - FP4) / 3 * 2,
]

plt.plot(*islice(zip(A, B, C, D, E, A), 2), alpha=0.5)
plt.scatter([0], [0], c="orange", marker="o")
plt.scatter(*zip(FP1, FP2, FP3, FP4), c="orange", marker="o")
plt.scatter(*zip(*vcfps), c="red", marker="o")
# plt.scatter(*zip(*igfps), c="red", marker="o")
plt.show()

@commy2 commy2 marked this pull request as ready for review July 26, 2023 15:02
@MTKing4
Copy link
Collaborator

MTKing4 commented Jul 26, 2023

Doesn't that mean when enemies approach from the door side they will still shoot from point 0,0,0?

@xezon
Copy link
Contributor

xezon commented Jul 26, 2023

I think we should allow them shooting from door too. Makes the setup much easier.

@commy2
Copy link
Collaborator Author

commy2 commented Jul 26, 2023

Doesn't that mean when enemies approach from the door side they will still shoot from point 0,0,0?

Didn't happen for me with vChina Bunker, but Infgen Bunker when full. Works on the front though, which is much better already.

I think we should allow them shooting from door too. Makes the setup much easier.

Yeah, but it makes no sense. Imo, instead GarrisonContain should work like TransportContain, where 0,0,0 is only used if no other free firepoint exists, instead of when 0,0,0 happens to be closer. It is an error in some algorithm most likely where 0,0,0 are the initial values - probably.

@xezon
Copy link
Contributor

xezon commented Jul 26, 2023

I will paint window in door. Then you can add fire ports there.

@commy2
Copy link
Collaborator Author

commy2 commented Jul 26, 2023

I don't think that is necessary or helpful. It has to be fixed in engine anyway, because its not feasible to go through all buildings like this.

This Bunker has 1 fireport in the backside, but you can fill so many guys inside that it starts damaging itself when firing backwards.

shot_20230726_205053_4

shot_20230726_205515_5

@xezon
Copy link
Contributor

xezon commented Jul 26, 2023

Too late. Windows painted. They are good for at least 4 ports. #2154

@commy2
Copy link
Collaborator Author

commy2 commented Jul 27, 2023

shot_20230727_114152_1

shot_20230727_114243_8

shot_20230727_114701_13

shot_20230727_114704_14

@xezon
Copy link
Contributor

xezon commented Jul 27, 2023

Nice work. Looks promising. I will test later.

@xezon
Copy link
Contributor

xezon commented Jul 27, 2023

2 missiles will emerge from below the 10 man bunker when shooting in this direction:

shot_20230727_184053_11

Adding more ports may become too cramped. We can accept current state and fix the rest in code.

@MTKing4
Copy link
Collaborator

MTKing4 commented Jul 27, 2023

I don't understand this comment, which two missiles? And how are we supposed to see which ones are emerging from below the bunker from a top down view? I don't see an issue in this picture.

@commy2
Copy link
Collaborator Author

commy2 commented Jul 28, 2023

And how are we supposed to see which ones are emerging from below the bunker from a top down view?

It's not the best view, but if you count the barrels, it's only 8 (2 are obscured at the center of the building). You can also see a faint trail in the middle.

@xezon xezon changed the title Fix: Add proper fire ports to China Bunker that prevent passengers from damaging it near uneven terrain Fix: Add more fire ports to China Bunkers to help prevent passengers from damaging it near uneven terrain Jul 28, 2023
@commy2 commy2 merged commit d88a4cd into main Jul 30, 2023
@commy2 commy2 deleted the fix-bunker-self-own branch July 30, 2023 14:57
@ItsWazzaP ItsWazzaP added the GameMismatchWith104 Affects game state towards original 1.04 label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Buff Makes a thing more powerful Bug Something is not working right China Affects China faction GameMismatchWith104 Affects game state towards original 1.04 Major Severity: Minor < Major < Critical < Blocker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants