AttachmentUnit improvement - Selection and Flash#1992
Conversation
|
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. |
Metadorius
left a comment
There was a problem hiding this comment.
looking good, couple of thoughts though
also do all the children flash because of InheritStateEffects? maybe that should be excluded from state effects if it's an UI flash and be controlled by other tags, like InheritCommands to signify they will also be commanded when you give order to the parent unit?
src/Misc/Hooks.AI.cpp
Outdated
| { | ||
| auto pType = attachment->GetType(); | ||
| if (pType && pType->InheritStateEffects && !pType->PassSelection && attachment->Child) | ||
| { | ||
| int childFlashRemaining = attachment->Child->Flashing.DurationRemaining; | ||
|
|
||
| attachment->AI(); | ||
|
|
||
| if (childFlashRemaining > 0) | ||
| { | ||
| attachment->Child->Flash(childFlashRemaining); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| attachment->AI(); | ||
| } | ||
| } |
There was a problem hiding this comment.
I think this should be done by amending AttachmentClass::AI instead
There was a problem hiding this comment.
I originally planned to do that, but later found that directly modifying AttachmentClass::AI was somewhat difficult, so I went up and found the call point of AttachmentClass::AI to operate on it. If you have any good methods, feel free to edit it.
src/Ext/Techno/Hooks.Misc.cpp
Outdated
| if (pFinalTarget && pFinalTarget != pOriginal) | ||
| { | ||
| for (int i = 0; i < ObjectClass::CurrentObjects.Count; i++) | ||
| { | ||
| if (ObjectClass::CurrentObjects[i] == pOriginal) | ||
| { | ||
| int lastIndex = ObjectClass::CurrentObjects.Count - 1; | ||
| ObjectClass::CurrentObjects[i] = ObjectClass::CurrentObjects[lastIndex]; | ||
| ObjectClass::CurrentObjects.Count--; | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
Hmm, can't we take over the game's code before anything is actually selected and redirect it to as if we were clicking or selecting only the parent unit? Then we won't need that extra handling, supposedly.
There was a problem hiding this comment.
I made some attempts, but ultimately failed. Although it is not elegant, currently it indeed is such that clicking Child will directly redirect to Parent, but I think the query here cannot be ignored, although if possible, it would indeed be better to handle it earlier.
There was a problem hiding this comment.
Perhaps @TaranDahl or @NetsuNegi could help with this and the AI modification?
There was a problem hiding this comment.
if (pExt->ParentAttachment && PassSelection)
{
pExt->ParentAttachment->Parent->Select();
return RETN;
}
Isn't this okay?
There was a problem hiding this comment.
I'll replace the function in vtable
src/Ext/Techno/Hooks.Misc.cpp
Outdated
| bool parentAlreadySelected = false; | ||
| for (int i = 0; i < ObjectClass::CurrentObjects.Count; i++) | ||
| { | ||
| if (ObjectClass::CurrentObjects[i] == pFinalTarget) | ||
| { | ||
| parentAlreadySelected = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (!parentAlreadySelected) | ||
| { | ||
| ObjectClass::CurrentObjects.AddItem(pFinalTarget); | ||
| } |
Indeed, that was passed by |
Well, the whole point of all those customisation tags is to allow people to make different attachment types depending on what they need. |
|
I have greatly simplified the code and now replace the corresponding function in vtable. |
Metadorius
left a comment
There was a problem hiding this comment.
looks great now, I think it would be great to also handle hover effect if we're doing PassSelection, so if you hover on a child and the parent is going to be selected -- then the HP (or whatever other UI) should show up for the parent. not sure if this should be a separate tag though
|
When |
I thought of a scenario of children having individual health (can be targeted by enemies), but not able to be commanded. The use case kind of makes sense, and in this case there will be no way to see the health of the child unit. |
|
I hope that by default, the information of the child is displayed but the parent is selected, which is the current behavior.
|
|
I think the 4th combination you wrote is a niche scenario that won't be much useful, but the rest works. Regardless, I think this could be done outside of this PR, this is good as-is. |
f71219c
into
Phobos-developers:feature/techno-attachment
Fixed the abnormal SelectionFlash issue caused by synchronization states and added a flag to pass the selection target to the Parent Unit when a Child Unit is selected.
PassSelection=false, the Child Unit will be selected as usual, but unlike before, it can correctly reference SelectionFlash instead of being terminated after 1 frame.PassSelection=true, if a Child Unit is selected, it will search upward for the nearest Parent Unit within an AttachmentType wherePassSelection=false(or the final caller).Before (in the current latest version compiled three days ago):

Now :

In
rulesmd.ini:The line with a red cross mark indicates that the selection status of a Child Unit is not passed to the Parent Unit when the Child Unit is selected, due to

PassSelection=false.Selected State Transmission Relationship Diagram