Team Colours Mod

Talk about general things concerning Forged Alliance Forever.

Moderators: FtXCommando, Ze Dogfather

Team Colours Mod

Postby nine2 » 10 Sep 2014, 07:58

I've started work on a mod that sets the player colours according to which team they are on, but I'm having trouble with it.

Before:
Image
After:
Image

As you can see I'm using warm and cool colours to differentiate teams. Pretend you are the blue team and notice how much 'warm' air is above your base ... it's totally obvious, and that is the value of the mod right there. The mod is actually way more complicated then that because it has a whole colour wheel and it dynamically chooses the 'best' colours based off the teams ... so it can handle other game formats like a 2v4v1v1 pretty well (eg: two reddish, 4 greenish, a yellow, a purple).

So it's mostly working besides a few tweaks, but I don't think it's usable in the end. The trouble is it needs to be a Sim mod because it uses SetArmyColor which is a Sim function. The color change gets recorded into the replay as well. Because SetArmyColor is considered a cheat I set up a SimCallback which allowed me to use it with cheats disabled. I am not sure if that is the only way of doing it since I am new to modding. The SimCallback call is also recorded into the replay. So what that means is if you use my team colours mod, the other players need to as well, you will be forcing them to see the new colours, and the replay will be unwatchable by people without the mod, and they will be forced to see the new colours as well. All of which sucks. I wanted this to be a UI choice for the user, just like the normal 'allegiance' colours button that we have at the moment (it makes you blue, your enemies red your allies green etc.) The only solution to this I can think of is to have this as a lobby setting that the host can press to change everyone's colours before the game starts - although that might annoy people, it is certainly less bad than my current situation. I had thought I could look at how 'allegiance' colours is coded but that seems to be in C++ land.

Can anyone help me?

- is SimCallback the correct way to do 'cheats' without cheats enabled?
- is there any way to change army colours without going through this SetArmyColor?
- is there any way to make it so my simcallback and setarmycolor calls are not recorded into the replay?
- is there anything else I can do to get this to work?

Thanks!
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Team Colours Mod

Postby Aurion » 10 Sep 2014, 08:03

partytime wrote:I've started work on a mod that sets the player colours according to which team they are on, but I'm having trouble with it.

Before:
Image
After:
Image

As you can see I'm using warm and cool colours to differentiate teams. Pretend you are the blue team and notice how much 'warm' air is above your base ... it's totally obvious, and that is the value of the mod right there. The mod is actually way more complicated then that because it has a whole colour wheel and it dynamically chooses the 'best' colours based off the teams ... so it can handle other game formats like a 2v4v1v1 pretty well (eg: two reddish, 4 greenish, a yellow, a purple).

So it's mostly working besides a few tweaks, but I don't think it's usable in the end. The trouble is it needs to be a Sim mod because it uses SetArmyColor which is a Sim function. The color change gets recorded into the replay as well. Because SetArmyColor is considered a cheat I set up a SimCallback which allowed me to use it with cheats disabled. I am not sure if that is the only way of doing it since I am new to modding. The SimCallback call is also recorded into the replay. So what that means is if you use my team colours mod, the other players need to as well, you will be forcing them to see the new colours, and the replay will be unwatchable by people without the mod, and they will be forced to see the new colours as well. All of which sucks. I wanted this to be a UI choice for the user, just like the normal 'allegiance' colours button that we have at the moment (it makes you blue, your enemies red your allies green etc.) The only solution to this I can think of is to have this as a lobby setting that the host can press to change everyone's colours before the game starts - although that might annoy people, it is certainly less bad than my current situation. I had thought I could look at how 'allegiance' colours is coded but that seems to be in C++ land.

Can anyone help me?

- is SimCallback the correct way to do 'cheats' without cheats enabled?
- is there any way to change army colours without going through this SetArmyColor?
- is there any way to make it so my simcallback and setarmycolor calls are not recorded into the replay?
- is there anything else I can do to get this to work?

Thanks!


Isn't it possible to hook into the 'Show team colors' function and replace the team colors with a custom one in a UI mod? It seems not logical for me if that would be a SIM mod (but I have no idea about that). This mod would be quite nice, especially considering orange and brown where I have real troubles if they are on opposing teams (I use the advanced icons currently, which makes it harder to see the difference between some colors imo).
Aurion
Priest
 
Posts: 380
Joined: 25 Jul 2013, 20:03
Has liked: 12 times
Been liked: 15 times
FAF User Name: NuclearPudding

Re: Team Colours Mod

Postby nine2 » 10 Sep 2014, 08:33

Aurion wrote:Isn't it possible to hook into the 'Show team colors' function and replace the team colors with a custom one in a UI mod?.

That function strangely seems to be coded in c++, so, no.
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Team Colours Mod

Postby Sheeo » 10 Sep 2014, 09:37

partytime wrote:- is SimCallback the correct way to do 'cheats' without cheats enabled?


Making a simcallback enables anyone to call that function from the user side. This has the side effect of players being able to call that function whenever, thus changing their own army colour (Perhaps others, if neither that one or your function does validation).

partytime wrote:- is there any way to change army colours without going through this SetArmyColor?


Unlikely, but you should just use it from within the sim. Don't mod user side at all.

partytime wrote:- is there any way to make it so my simcallback and setarmycolor calls are not recorded into the replay?


How is it recorded into the replay?

partytime wrote:- is there anything else I can do to get this to work?Thanks!


Hook into the function BeginSession() in '/lua/simInit.lua'. Run your team-colour setting code after that function is done setting up teams and effect markers etc.
Support FAF on patreon: https://www.patreon.com/faf?ty=h

Peek at our continued development on github: https://github.com/FAForever
Sheeo
Councillor - Administrative
 
Posts: 1038
Joined: 17 Dec 2013, 18:57
Has liked: 109 times
Been liked: 233 times
FAF User Name: Sheeo

Re: Team Colours Mod

Postby nine2 » 10 Sep 2014, 13:18

Thanks for your time Sheeo.

I think the actual calls to SetArmyColor are somehow baked into the replay because when I watch the replay with a 2nd version of the mod with different colours, it still appears with the old colours. I think.

I understand how you're giving me a better way of putting this into the sim layer, but really what I want is for each player to individually (or not) set their view mode via their own ui. So you and I are both playing the same game but I see in teamColors mode and you see in normal mode, and I could turn teamColors mode off after a while. Ideally, you wouldn't even have to have the mod installed and I could still override how I see the game via a ui mod. I guess what I want is impossible, can you confirm?
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Team Colours Mod

Postby BushMaster » 12 Sep 2014, 07:09

Could you not just use the same method of changing colors as the color toggle that exists in game? granted it sets all your units to one color, all your allies to the same color, and all the enemy to the same color. at the very least i think it would be a place to look but ive never done an FA work soo ya...
User avatar
BushMaster
Avatar-of-War
 
Posts: 88
Joined: 28 Jun 2014, 07:35
Has liked: 3 times
Been liked: 12 times
FAF User Name: MooseFabricator

Re: Team Colours Mod

Postby Mr-Smith » 12 Sep 2014, 10:43

ya guess it should be possible to hook it directly into the lobby at all and integrate an option there as well.
If you can't beat us...
...join us.
Doge This, hover ACU: https://youtu.be/a67tvWmu31Y?list=LLW-T ... O4fQ&t=179
User avatar
Mr-Smith
Evaluator
 
Posts: 523
Joined: 27 Mar 2012, 19:15
Location: Austria
Has liked: 39 times
Been liked: 36 times
FAF User Name: Mr-Smith

Re: Team Colours Mod

Postby Sheeo » 12 Sep 2014, 15:36

partytime wrote:Thanks for your time Sheeo.

I think the actual calls to SetArmyColor are somehow baked into the replay because when I watch the replay with a 2nd version of the mod with different colours, it still appears with the old colours. I think.

I understand how you're giving me a better way of putting this into the sim layer, but really what I want is for each player to individually (or not) set their view mode via their own ui. So you and I are both playing the same game but I see in teamColors mode and you see in normal mode, and I could turn teamColors mode off after a while. Ideally, you wouldn't even have to have the mod installed and I could still override how I see the game via a ui mod. I guess what I want is impossible, can you confirm?


You're welcome :)

As a UI-mod only, with the current fa binary, it's most likely impossible. I haven't really checked myself, but if that function is engine-side then yes.

If you're up for the task, I have just made this repository public: https://github.com/Sheeo/FAShared

It contains code that hooks into the engine and allows us to modify the AllowedCommandSources list for armies, thus allowing coop-style play without having cheats enabled. Hooking into the function that sets colours for armies user-side should be possible.
Support FAF on patreon: https://www.patreon.com/faf?ty=h

Peek at our continued development on github: https://github.com/FAForever
Sheeo
Councillor - Administrative
 
Posts: 1038
Joined: 17 Dec 2013, 18:57
Has liked: 109 times
Been liked: 233 times
FAF User Name: Sheeo

Re: Team Colours Mod

Postby nine2 » 12 Sep 2014, 17:37

I'm totally not up for the task (I'm a lowly c# programmer).

I stared at it for half an hour ... so what, you are rewriting over the original FA binary with a few changes with assembler and c++ to patch in the changes you want? That's pretty awesome, and I could never do that, and I'm super impressed.

Even then it still doesn't entirely get me what I want, which is a user-specific setting .. if I did it that way I wouldn't need cheats activated but one player would be activating it for all, I am pretty sure, in which case I think I should just be trying to make a lobby option that the host can set to override custom colour choices - ie: do it in the pre-game setup somehow.
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Team Colours Mod

Postby Sheeo » 15 Sep 2014, 09:56

partytime wrote:I'm totally not up for the task (I'm a lowly c# programmer).

I stared at it for half an hour ... so what, you are rewriting over the original FA binary with a few changes with assembler and c++ to patch in the changes you want? That's pretty awesome, and I could never do that, and I'm super impressed.

Even then it still doesn't entirely get me what I want, which is a user-specific setting .. if I did it that way I wouldn't need cheats activated but one player would be activating it for all, I am pretty sure, in which case I think I should just be trying to make a lobby option that the host can set to override custom colour choices - ie: do it in the pre-game setup somehow.


Sorry for my slow replying. Need to setup notifications for threads I've posted to :)

That won't work, since the player-chosen colours are stored in the sim. So if each client has their own version it's a desync.
Support FAF on patreon: https://www.patreon.com/faf?ty=h

Peek at our continued development on github: https://github.com/FAForever
Sheeo
Councillor - Administrative
 
Posts: 1038
Joined: 17 Dec 2013, 18:57
Has liked: 109 times
Been liked: 233 times
FAF User Name: Sheeo

Next

Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest