Found a (normally impossible) way to control CommandButton availability differently between human players. It is normally impossible because the CommandButton scripts have no "for player X" insert field, so if both players are the same faction, both players will be able to build X even if only one of them has fulfilled the prerequisites. And if you cheat your way around this using LocalPlayer by removing or adding command-buttons for only one LocalPlayer, the game will be thrown off-sync and eventually mismatch, making this impossible even with all the tricks above.
But wait! There still is a way to fix that behaviour:
With this script you can only build neutrone shells if you own an InternetCenter, the script is fully in sync and will not cause a mismatch. Note the different slot numbers. Basically, the command button is made off-limits instead of being removed.
Take a look at the slot numbers in these scripts:
(active, run every frame, don't deactivate upon success)
*** IF ***
Player '<Local Player>' has Less Than 1 unit or structure of type 'Nuke_ChinaInternetCenter'
*** THEN ***
[???] Command button: 'Command_UpgradeChinaNeutronShells' is removed from all objects of type 'Nuke_ChinaNuclearMissileLauncher'.
[???] Command button: 'Command_UpgradeChinaNeutronShells' is added to all objects of type 'Nuke_ChinaNuclearMissileLauncher' in slot number 16 (1-12).
*** ELSE ***
Command button: 'Command_UpgradeChinaNeutronShells' is removed from all objects of type 'Nuke_ChinaNuclearMissileLauncher'.
Command button: 'Command_UpgradeChinaNeutronShells' is added to all objects of type 'Nuke_ChinaNuclearMissileLauncher' in slot number 6 (1-12).
Limitation: The imaginary slots (16 in the example above) may only be the slots 15, 16, 17 and 18. Slots higher than that will still cause a mismatch! So you are limited to 4 command buttons per faction per building.
Explanation why this works:
So player0 owns an InternetCenter.
player1 doesn't.
For player0 the upgrade is in slot 6.
For player1 the upgrade is in slot 16, which means that, for player1 only, it is technically there, but off-limits and not clickable or keyboard-shortcut-able, but the machine of player1 still accepts the fact that somehow player0 clicked the upgrade (because, technically, the command button
is there, the game doesn't understand it's off-limits). AI behaviour not tested.
This allows you to fully and completely customize the entire building and unit tech-tree of maps without .ini file! Things like "you need 5 propaganda centers and exactly 57 dozers to build a nuke are now easily do-able with this. And the best thing, you only need one script for all 8 player slots!
One tiny detail to keep in mind:
There, however, is one tiny glitch:
In order to update command button positions, the object needs to be re-selected. That means: If one player has the requirements to "see" the command button, and, while having the object selected, loses the requirements, the command button will still be there and click-able until the object is re-selected. It is the same the other way around, the button is not there until the object was re-selected.
If you, absolutely positively, need to fix that tiny bug, this would be the way to force-deselect everything, but will require some more work to check if the condition changed:
*** IF ***
[prerequities changed]
*** THEN ***
Disable mouse and keyboard input.
Enable mouse and keyboard input.
Edited by user
7 years ago |
Reason: Not specified