Staredit Network > Forums > Modding Assistance > Topic: Set player selection (in multiplayer)
Set player selection (in multiplayer)
May 7 2018, 6:39 pm
By: Biophysicist  

May 7 2018, 6:39 pm Biophysicist Post #1



("What the heck, why did this asshole come back," I hear you saying. Shhhhhhhh.)

In GPTP, I'd like to create a
Code
void select(CPlayer*, CPlayer**)
which causes the indicated player to select the indicated units (and deselect all other units). This would need to function properly in multiplayer; it would be great if it would also work in singleplayer, but that's less of a priority. Maybe I'm just blind, but I don't see anything that obviously causes units to be selected. Some of the functions in selection.cpp look promising, but I can't figure out how they determine which player selects the new units...

If that isn't possible (yet), workarounds are also welcome. The intended use case is specifically for a button, if that helps.



None.

May 7 2018, 7:36 pm Neiv Post #2



I think that calling the function applyNewSelect_Sub_6FA00 which is in hooks/interface/selection.cpp should do all that you are asking for: Select units, play sounds and send network commands to keep things in sync.

In general none those functions take a player id since they operate on the local player's selection - network commands that change other players' selections don't even exist.



None.

May 8 2018, 9:28 pm UndeadStar Post #3



For a button, I guess you would "borrow" one of the RECV functions in hooks/recv_commands/, so that you can use the corresponding button behavior as a base, making a "if" condition to check if the unit calling the function is the one you want, then use the code in hooks/interface/selection.cpp as a reference to see how to create a new selection.

edit: sorry, wrong idea, I just realized that this could lead to modifying selection for all players :><:

Post has been edited 1 time(s), last time on May 8 2018, 9:35 pm by UndeadStar.




May 9 2018, 12:01 am Biophysicist Post #4



Quote from Neiv
I think that calling the function applyNewSelect_Sub_6FA00 which is in hooks/interface/selection.cpp should do all that you are asking for: Select units, play sounds and send network commands to keep things in sync.

In general none those functions take a player id since they operate on the local player's selection - network commands that change other players' selections don't even exist.

I'll give it a shot!



None.

May 10 2018, 1:19 pm UndeadStar Post #5



I just added select_larva hooks in Version 4.026 of GPTP.
I hope it can help.




May 10 2018, 4:11 pm KYSXD Post #6



Quote from UndeadStar
I just added select_larva hooks in Version 4.026 of GPTP.
I hope it can help.

Cool!




May 12 2018, 1:53 pm Biophysicist Post #7



If I'm reading this correctly, more or less any "click this to select foo" could be implemented by looking at activePortraitUnit to determine the proper behavior. That's really cool!!

One last question, if that's alright? It looks like that hook only gets run on the client where the button was actually pushed, so clientSelectionGroup and friends should be safe to use there. Is that correct, or am I mistaken and it'd desync?



Sorry for the dumb questions, haha ;^; It's just, desyncs are obviously hard to test with only one computer...



None.

May 13 2018, 9:54 pm UndeadStar Post #8



Quote from Biophysicist
If I'm reading this correctly, more or less any "click this to select foo" could be implemented by looking at activePortraitUnit to determine the proper behavior. That's really cool!!

One last question, if that's alright? It looks like that hook only gets run on the client where the button was actually pushed, so clientSelectionGroup and friends should be safe to use there. Is that correct, or am I mistaken and it'd desync?



Sorry for the dumb questions, haha ;^; It's just, desyncs are obviously hard to test with only one computer...
It may desync.
As mentioned in the comments of the hook, while it's not appearing directly on the hook, there's a command that is queued and sent to all players.
I think there's an array somewhere that is something like allSelections[8 (nb of players)][SELECTION_ARRAY_LENGTH] storing the selections for all players, and would be the target of that broadcast.
I don't know how the game set in sync the selections at that point.

edit:
Select Larva hooks had issues that got fixed in Version 4.027

Post has been edited 2 time(s), last time on Jun 8 2018, 12:37 pm by UndeadStar.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[06:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[06:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[06:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
[06:49 pm]
Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
[06:48 pm]
Vrael -- On this Topic, I could definitely use some Introductions.
[06:48 pm]
Vrael -- Perhaps that utilizes cutting-edge technology and eco-friendly cleaning products?
[06:47 pm]
Vrael -- Do you know anyone with a deep understanding of the unique characteristics of your carpets, ensuring they receive the specialized care they deserve?
[06:45 pm]
NudeRaider -- Vrael
Vrael shouted: I've also recently becoming interested in Carpet Cleaning, but I'd like to find someone with a reputation for unparalleled quality and attention to detail.
beats me, but I'd make sure to pick the epitome of excellence and nothing less.
[06:41 pm]
Vrael -- It seems like I may need Introductions to multiple companies for the Topics that I care deeply about, even as early as Today, 6:03 am.
[06:38 pm]
Vrael -- I need a go-to solution and someone who understands that Carpets are more than just decorative elements in my home.
Please log in to shout.


Members Online: Roy, RIVE