-
Notifications
You must be signed in to change notification settings - Fork 231
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
Platoon movement #3134
Platoon movement #3134
Conversation
… new function that is used by this new approach.
hello, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lua doesnt require ; at the end of the line
It happens when you tell a platoon to move through scripting. For platoons moved by players this behavior does not happen because you either implicitly or explicitly orientate the platoon as a player. For example, using the following in a script:
This is the example map from the video: If you start the map, you should be able to observe the same behavior. Take note that the inner circles use the original behavior, the outer circles use the new behavior. When you open up the campaign, and start the first mission on normal you'll see that the Percivals that run around your base show the same behavior: on each way point they first orientate themselves south before they continue the patrol. Edit: I will remove all the semicolons. |
…sivePath' and 'IssuePatrolPath' to match the IssueFormMove, IssueFormAggressiveMove and IssueFormPatrol commands which are available globally and used internally
Renamed the functions slightly to match convention of other functions. Implemented the patrol and aggressive move. Another showcase: From the outer to the inner platoon:
The corresponding test map from the video: I am going to do a read through of the comments tomorrow, remove semicolons that I introduced again by habit and look for other quirky things. |
I cannot see anything to change or add further, suggestions are welcome. I've also checked whether functions such as CPlatoon:IsMoving(squad) and function CPlatoon:IsPatrolling(squad) correctly pick up that the platoon is moving / patrolling with the new approach. They do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice Work.
Do you want this only for mapscripts or do you also want to patch Skirmish AI ?
If you do so, have in mind there are not only GPG ans Sorian AI using this.
Swarm AI, RNGAI and my AI. (AI-Uveso) will be affected by this.
lua/platoon.lua
Outdated
-- check if we have a formation, IssueFormMove doesn't work if the formation argument is 'NoFormation'. | ||
if formation == 'NoFormation' then | ||
WARN('MovePathOrientedByPast: No platoon formation provided, defaulting to GrowthFormation.') | ||
formation = 'GrowthFormation' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't force a formation, there are some platoons that are meant to move without formation.
(they move faster without a formation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functions IssueFormMove, IssueFormAggressiveMove, etc, do not work without a formation. I can add an if statement at the bottom to use IssueMove instead of IssueFormMove when no formation is provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking into it, how do you retrieve the desired formation of a platoon? I see the following line throughout platoon.lua:
local formation = self.PlatoonData.UseFormation or 'NoFormation
But that appears to be always nil. Calling LOG(repr(self)), which is the platoon in this context, doesn't show me a lot of information either.
That is a good question, if I would make these changes more 'global' in that sense: where would I start doing this? I haven't looked a lot into the code surrounding the AI's. Edit: I just checked to be sure, platoons from AI's (of the base game from Steam) have the same issues. |
If you want to see whats inside a table, you can't simply use repr() because inside classes are too many sub tables. function DebugArray(Table)
for Index, Array in Table do
if type(Array) == 'thread' or type(Array) == 'userdata' then
LOG('Index['..Index..'] is type('..type(Array)..'). I won\'t print that!')
elseif type(Array) == 'table' then
LOG('Index['..Index..'] is type('..type(Array)..'). I won\'t print that!')
else
LOG('Index['..Index..'] is type('..type(Array)..'). "', repr(Array),'".')
end
end
end then call it with When we get this to work, then you don't need to implement this into the normal AI. |
With your function, it shows:
With the LOG(repr()) it shows:
Regardless of the information, the formation information is not in there. The platoons (of the video) are made with:
The formation is applied / given to a squad. Looking through the definitions of the platoon.lua and cplatoonlua files, I cannot seem to be able to retrieve a squad (and then, in turn, its formation). I did find: But that doesn't allow me to retrieve the formation. Given this information: my code doesn't look for squads of any kind - should I add that in? |
|
Writing the following:
Produces in the console:
The table is empty. That is why I was looking at C functions in the faf repository, perhaps the formation data is stored somewhere else. Looking into it further shows the function:
Given that the code from the repository attempts to use:
I started looking for where 'UseFormation' is defined, which is in the files:
These are 'Buildergroups', of which I am know they are related to platoons but unsure whether the data is being transferred to the platoon data table. If they are being transferred, then all the squads typically lose their original formation because they get overridden whenever this value is set. In the GPG editor you can also define, or at least view, the platoon data manually. I am not sure whether that is being used given that one drop down mentions that it is being generated dynamically. That being said, this would make the function worthless for map-related code unless you specifically define the platoon data on your platoon, to pass the formation. Which would be quite hidden. Therefore I propose the following:
If you manually define a formation, that formation is used. This is useful when the function is called through a map-based script. If that information is not provided, the typical place for a formation is checked. This is useful for AI-related calls. And if there is no formation there either, then no formation is used at all. Down below, the function IssueMove is called instead of IssueFormMove when no formation is provided. In the gpg-code the call for overriding the squad formations always follows after a manual formation is set. Should we do this here too, when we override the platoons formation as a whole? That being said:
|
…roposing a solution to the formation issue. Separated the generic code into because of the loss of generality after implementing the suggestions
@Uveso : I'd like to know what to add / change on the current code, or whether I can consider this to be done 😄 . |
Hey Garanas :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a newer test map available ?
I had to modify the old one to add the options table
lua/platoon.lua
Outdated
|
||
-- base orientation when the angle is 0 for the function IssueFormMove | ||
local base = Vector( 0, 0, 1 ) | ||
local direction = Utilities.GetDirectionVector(next, curr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those function are called in a loop, please make them local for better performance
local GetDirectionVector = Utilities.GetDirectionVector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Do you have an article as to why this is faster? I tried to find one myself, but wasn't able to
Link for the latest version of the map: Went through all the changes Uvseo recommended. I decided to remove the first / last parameter because those operations can also be done outside this function. Also removed the formation parameter to make it fit more with how platoon (AI) functions are called generally in the code. Added in some error handling. Should these be errors or warnings? I believe there is no stack trace with warnings. If no more changes are required, then this is the final version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The map is no longer available as download, if someone want to test this.
Overall everything is running.
Please change the functions to accept a formation override argument.
Also if possible, can you rebase the PR to the latest game version please ?
I'll do the changes again, I think its best if we sit down some day this week to finish it up with direct and quick communication! On the map: I'll upload it to my drive instead of WeTransfer. edit: This is the map: |
Yes sure, but its already finished. |
Add back in the copyright symbol
… new function that is used by this new approach.
…sivePath' and 'IssuePatrolPath' to match the IssueFormMove, IssueFormAggressiveMove and IssueFormPatrol commands which are available globally and used internally
…roposing a solution to the formation issue. Separated the generic code into because of the loss of generality after implementing the suggestions
… platoon-movement
Introducing an alternative approach to move platoons around. The current approach forces the platoon to orient to the south at the end of every move order. The new approach either aligns them to the line between the current and next node (...ByFuture) or between the current and past node (...ByPast).
To showcase, see the following video:
https://www.youtube.com/watch?v=e4LH9oaKwTQ
The video becomes especially interesting about 30 seconds in, when the platoons are moving to the north.
From the outer to the inner line:
Especially platoon:MovePathOrientedByPast(...) (2nd from the outer one) is promising: it appears to be very smooth and is able to keep up with one of the older approaches that has a lower total distance. They finish at the same time.
I intend to make similar functions for:
Waiting for feedback on the coding style, naming and / or the taken approach before I continue.