Warning: Long post incoming, explaining the most advanced Scripting Technique in existence of ZH.
This is a summary how multiplayer-syncing in Generals works and about the hard-to-understand way <Local Player> behaves.
Also this post will teach you how to use this new knowledge to your advantage in order to create far more powerful multiplayer maps. You will learn how to individually show different briefings and different timers to different players and how to individually move the camera to a different spot for each or any player at the same time. And you will learn what can absolutely not be done separately for each player.
What most people know: In Singleplayer Mission Maps (no start positions) and in singleplayer compstomp maps you can use <Local Player> to transfer stuff to the human player without any trouble.
But if you use <Local Player> in Multiplayer while another human player is present, the map will trigger a mismatch and the match will force-end (Like this:
Mismatch Picture).
But why is that?
The explanation is simple.
As a reminder:
player0 is the player in the first lobby slot.
player1 is the player in the second lobby slot, etc.
But <Local Player> is the human player sitting in front of the computer the code is being executed on. And that's why this will cause trouble in multiplayer maps when more than one human player is present.
Example to make it easier to understand:You are playing online 1vs1 against a human player. In your map you have a script:
Code:*** IF ***
True.
*** THEN ***
Unit 'Bulldozer' is transferred to the command of Player '<Local Player>'
The game will mismatch.
Both players will individually see that the "Bulldozer" was transfered to them. Theoretically the "Bulldozer" is now being owned by two human players at the same time, with both players having full control over it. But the game engine does not support that. There may only be one owner. And the game does not know whos game-data is valid and who is the rightful owner of the unit. Thus the match mismatches.
This is also being abused by assheads online to force-end a match they are losing. Of course they do not use a script, as they can't modify the map on-the-go. So instead they use a game-trainer/cheat-engine. For example they use a cheap cheat tool that increases their money. And their money does increase. But only on their computer. Again, the online-engine does not know who to trust and force-ends the game with a mismatch warning. But don't worry, Gentool blocks people from starting their game if they have a trainer installed, otherwise I wouldn't be teaching you how to mismatch your game :D
Now you know why the game mismatches. But how could you possibly use that to an advantage in order to make better maps?
The answer is actually quite simple: Not all script actions will trigger that Mismatch Warning! And that changes everything, because some of these actions you will absolutely love to use in a local-player-dependant way and I will teach you how and why.
Example:
We have a 4-human-players-multiplayer-mission-map with 5 start positions. The first 4 lobby slots are for 4 human players. The last lobby slot is for a computer player (same as in many AOD maps), let's say teamSkirmishGLA.
Every Human-Player has a different thing to do in the map. Human-Player 1 must kill a dozer. Human-Player 2 must kill some tanks. Human-Player 3 must snipe some people and Human-Player 4 must prevent the others from doing any of that.
How do you explain that ingame? You would need 4 different briefings, explaining the mission to one player after the other sequentially. Every player will learn about their mission... but also they will learn about 3 missions that they aren't supposed to do by themselves, reducing the amount of valuable information to a mere 25% and also making the intro very confusing. It also greatly reduces the re-playability of the map, because all players will know exactly what each player's job is and the map will round-about always be the same for everybody. That's not good (at times).
Let's see how to script it in a way that a mission is only explained to the player that is supposed to do that exact mission.
First we will need a support-script to spawn and transfer four support units, one for each human player (use units that will not attack each other or spawn the units at different waypoints):
Code:
*** IF ***
True.
*** THEN ***
Spawn Unit 'player0unit' of type 'ChinaCommandCenter' on Team 'teamSkirmishGLA' at waypoint Waypoint 'some place far off the map'
Spawn Unit 'player1unit' of type 'ChinaCommandCenter' on Team 'teamSkirmishGLA' at waypoint Waypoint 'some place far off the map'
Spawn Unit 'player2unit' of type 'ChinaCommandCenter' on Team 'teamSkirmishGLA' at waypoint Waypoint 'some place far off the map'
Spawn Unit 'player3unit' of type 'ChinaCommandCenter' on Team 'teamSkirmishGLA' at waypoint Waypoint 'some place far off the map'
[???] Unit 'player0unit' is transferred to the command of Player 'player0'
[???] Unit 'player1unit' is transferred to the command of Player 'player1'
[???] Unit 'player2unit' is transferred to the command of Player 'player2'
[???] Unit 'player3unit' is transferred to the command of Player 'player3'
Now come the trigger scripts that differ between the four Human Players:
Code:
*** IF ***
Unit 'player0unit' is owned by Player '<Local Player>'
*** THEN ***
Show military briefing String: 'Hi, your mission is to kill the Dozer.' for 5000 milliseconds.
Code:
*** IF ***
Unit 'player1unit' is owned by Player '<Local Player>'
*** THEN ***
Show military briefing String: 'Hi, your mission is to kill the Tanks.' for 5000 milliseconds.
Code:
*** IF ***
Unit 'player2unit' is owned by Player '<Local Player>'
*** THEN ***
Show military briefing String: 'Hi, your mission is to snipe the people.' for 5000 milliseconds.
Code:
*** IF ***
Unit 'player3unit' is owned by Player '<Local Player>'
*** THEN ***
Show military briefing String: 'Hi, your mission is to defend the Dozer, the Tanks and the People.' for 5000 milliseconds.
Yes, it is that simple.
Depending on which lobby slot you are in, you will only see one of these four briefings.
This can also be combined with any other ***IF*** condition (a timer/counter, a trigger area etc.).
The only thing you absolutely positively need to make sure when using this method:Do NEVER run an Action that will actually trigger a mismatch warning that force-ends the match. For example, you will never be able to share Ownership of a unit between multiple players, even with this method! You can only do cosmetic/visual things with these local-player-dependant scripts!
Things that do not cause a mismatch when made Local-Player-Dependant- Display of Counter / Timer (ONLY
DISPLAY!!!))
- Display of military Briefings
- Movement of Camera
- (
untested) Radar Events
- (
untested) Highlighting of Units
Things that will definitely mismatch a game if made Local-Player-Dependant:- "Play Sound 'XYZ'" (for some weird reason. So you can !!!!NOT!!!! play sound effects via scripts in individualized intros). Instead do this:
http://www.cnclabs.com/f...tiplayer.aspx#post148375- Movement of any unit
- Cashflow
- Triggering any other script that contains any of these actions (logically)
- (
untested) mere ownership of a unit (without the unit being used or moved in any other way, probably not a good idea!!)
Generally speaking:
Always keep local-player-dependant scripts and non-local-player-dependant scripts STRICTLY seperated. If you mix them up your map will be very unstable and bugs will be hard to find.
That is all for now.
If anything is too confusing or hard to understand, please feel free to ask.
Edited by user Tuesday, February 5, 2019 7:50:24 AM(UTC)
| Reason: Not specified