Skip to content

[Highly Customized] Building placing and deploying logic enhancement #1479

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

Open
wants to merge 68 commits into
base: develop
Choose a base branch
from

Conversation

CrimRecya
Copy link
Contributor

@CrimRecya CrimRecya commented Dec 28, 2024

  • In vanilla games, buildings are always cannot placing or deploying on the cells that other infantries or units on. Now this can be changed by setting ExpandBuildingPlace to true, when you try to place the building on these cells, it will check whether the occupiers can be scatter by yourself (include your own technos and allies non-player technos) and whether there are enough spaces to scatter. If can, it will record which building you are placing and show a preview to you and your allies, then start a timer to record this placement and order the occupiers to leave this building area. When the area is cleared, the building will be truly place down and the production queue will be restored to original state. But when the timer expires or an unexpected situation has occurred which make the building impossible be constructed here anymore, it will stop the action and play "cannot deploy here", then you should re-place or re-deploy the building in a valid space. Note that when the building has been recorded and is trying to place, unless the production queue has vanished (such as construction yard is no longer exist), it will continue to function normally until the conditions are not met.
  • AutoBuilding controls whether building can be automatically placed.
    • AutoBuilding.Gap controls the gap of automatically placed buildings.
  • LimboBuild controls whether building can be automatically placed like LimboDelivery.
    • LimboBuildID defines the numeric ID of the building placed by LimboBuild.
  • PlaceBuilding.OnLand controls building with Naval=yes will become which building when placed on land.
  • PlaceBuilding.OnWater controls building with Naval=no will become which building when placed on water.

In rulesmd.ini:

[General]
ExpandBuildingPlace=false   ; boolean

[SOMEBUILDING]              ; BuildingType
AutoBuilding=false          ; boolean
AutoBuilding.Gap=0          ; integer
LimboBuild=false            ; boolean
LimboBuildID=-1             ; integer
PlaceBuilding.OnLand=       ; BuildingType
PlaceBuilding.OnWater=      ; BuildingType
  • Now LaserFence can be customized by setting LaserFencePost.Fence on LaserFencePost=true buildings.
    • LaserFencePost.Fence defines which kind of laser fence can connect this kind of laser fence post. If they have different LaserFencePost.Fence, they will not be connected.

In rulesmd.ini:

[SOMEBUILDING]              ; BuildingType, `LaserFencePost=yes`
LaserFencePost.Fence=       ; BuildingType
  • Now technos have CanBeBuiltOn=true can simply removed when building is placed on them.

In rulesmd.ini:

[SOMETECHNO]         ; TechnoType
CanBeBuiltOn=false   ; boolean

Splits from #1335 .

Copy link

github-actions bot commented Dec 28, 2024

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@TaranDahl
Copy link
Contributor

我觉得AutoBuilding可能需要一个ingame的快捷键来决定是否整体地开启它。
I think AutoBuilding may need an in-game shortcut key to determine whether to turn it on globally.
一个具体的需求:在游戏初期我对于战争工厂的位置没有什么需求,所以自动放置它是好的;而在游戏后期我可能会修建前线阵地以确保生产出的单位能快速加入战斗,这时候我希望能手动决定它的位置。
A specific requirement: In the early stage of the game, I have no specific need for the location of the war factory, so it is good to place it automatically. In the later stage of the game, I may build a frontline position to ensure that the produced units can quickly join the battle. At this time, I hope to manually determine its location.

@brckhan88
Copy link

brckhan88 commented Jan 26, 2025

Hello,

I've been following this PR for a long time which allows AI to use its available foundation area efficiently, I even pull the relevant branch as it is updated and test it after rebuilding. First of all, I would like to thank you for all your efforts. I have observed a small bug with the flow of the 'ExtendedBuildingPlacing' tag on the AI side for a long time. If the AI fails to clean the space of the LimboBuilding it is placed within the time specified in the 'pHouseExt->CurrentBuildingTimer.Start()' statement in the function and cannot replace the real building instead, the AI permanently bypasses that building and never builds it again. Any other functions seem to be working flawlessly.

@CrimRecya
Copy link
Contributor Author

Hello,

I've been following this PR for a long time which allows AI to use its available foundation area efficiently, I even pull the relevant branch as it is updated and test it after rebuilding. First of all, I would like to thank you for all your efforts. I have observed a small bug with the flow of the 'ExtendedBuildingPlacing' tag on the AI side for a long time. If the AI fails to clean the space of the LimboBuilding it is placed within the time specified in the 'pHouseExt->CurrentBuildingTimer.Start()' statement in the function and cannot replace the real building instead, the AI permanently bypasses that building and never builds it again. Any other functions seem to be working flawlessly.

Thank you for your feedback. I will try to fix it later (but it will take some time as Chinese New Year is coming).

At present, I have also encountered a problem, which is that for buildings with areas such as 4x3 and 2x5, the automatically calculated FoundationOutside is incorrect, and it is needed to customize this parameter to evacuate units within the construction area correctly in some special situations. I'm not sure if it can be fixed afterwards. At least for now, if you encounter such problems, you can solve them by Foundation=Custom with customizing FoundationOutline.
efe0f72c3b483901eefe413d1c37b976
1dc92fffe478bf3111aa10e65e60736a

@CrimRecya
Copy link
Contributor Author

CrimRecya commented Jan 27, 2025

Hello,

I've been following this PR for a long time which allows AI to use its available foundation area efficiently, I even pull the relevant branch as it is updated and test it after rebuilding. First of all, I would like to thank you for all your efforts. I have observed a small bug with the flow of the 'ExtendedBuildingPlacing' tag on the AI side for a long time. If the AI fails to clean the space of the LimboBuilding it is placed within the time specified in the 'pHouseExt->CurrentBuildingTimer.Start()' statement in the function and cannot replace the real building instead, the AI permanently bypasses that building and never builds it again. Any other functions seem to be working flawlessly.

I checked the code, buildings with LimboBuild=true should actually be completely separate from the placement logic of ordinary buildings and should not enter into the placement waiting logic. In other words, regardless, it should have been successfully placed.
Can you provide a detailed description of how your problem was produced? Considering that my English is not very good, it would be very helpful if you could explain it in short sentences as much as possible. Thank you so much.

@CrimRecya CrimRecya added the On Hold Due to some reasons, it cannot be completed temporarily label Feb 20, 2025
@CrimRecya
Copy link
Contributor Author

Considering that ExpandBuildingPlace and AutoBuilding have already been separated and no longer related in previous updates, and these two functions themselves do not have much intersection, I believe that splitting these two functions will help with code review. Afterwards, AutoBuilding related functions will be removed from this PR and I will submit a new PR later specifically to provide these.

@CrimRecya CrimRecya added the Needs splitting The PR should be splitted into several separate standalone commits label Feb 20, 2025
@CrimRecya CrimRecya removed On Hold Due to some reasons, it cannot be completed temporarily Needs splitting The PR should be splitted into several separate standalone commits labels Feb 22, 2025
@Coronia Coronia added the ⚙️T2 T2 maintainer review is sufficient label Mar 19, 2025
CrimRecya added a commit that referenced this pull request Apr 11, 2025
Game removes deploying vehicles from map temporarily to check if there's
enough space to deploy into a building when displaying allow/disallow
deploy cursor. This can cause desyncs if there are certain types of
units around the deploying unit because the OccupationFlags may be
accidentally cleared, or the order of the objects linked list may be
scrambled.

About implementation:
This is a hook separated from #1479 .
This solution completely abandons the method of removing and then
adding, and solves the problem by directly excluding specific units.

Other related repairs:
Fix unit's self-destruct when using trigger 107 to teleport the MCV.
Fix reconnection error when moving MCV with Teleport locomotion.
Coronia pushed a commit that referenced this pull request Apr 12, 2025
Game removes deploying vehicles from map temporarily to check if there's
enough space to deploy into a building when displaying allow/disallow
deploy cursor. This can cause desyncs if there are certain types of
units around the deploying unit because the OccupationFlags may be
accidentally cleared, or the order of the objects linked list may be
scrambled.

About implementation:
This is a hook separated from #1479 .
This solution completely abandons the method of removing and then
adding, and solves the problem by directly excluding specific units.

Other related repairs:
Fix unit's self-destruct when using trigger 107 to teleport the MCV.
Fix reconnection error when moving MCV with Teleport locomotion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs testing ⚙️T2 T2 maintainer review is sufficient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants