Local Code

From WarCraft3

< wc3
Jump to: navigation, search

Local code is a result of the way the warcraft 3 multiplayer engine is set up. Every player runs their own copy of the game, using the game host as a way of relaying orders back and forth between each person's copy of the map. Many functions, such as GetLocalPlayer and many camera functions take advantage of this, and allow mappers to run code on specific players' computers. However, if not done with caution, this can cause the game to be very unstable, and can result in De-synchronization in certain cases.

Contents

De-synchronization

A De-synchronization (or desync for short) is what happens when two players who are playing the same game have local code run that causes the two games to be different. There are many possible ways for this to happen, the most prominent being incorrect use of GetLocalPlayer. While there can be certain types of differences between local games, there are certain things that can't possibly happen.

Note that not all of these will always cause desyncs:

Gameplay Affecting Functions

Essentially, any function that changes the game (such as the move speed of a unit) will cause de-synchronization

Agent Creation/Removal

Since the creation or removal of an agent can cause huge differences in gameplay, it is strictly prohibited to create agents inside local code. Note that not all handles are of type agent, which means that pre-allocated handles such as texttags can be created inside local code. s are constant handles that cannot be created nor destroyed, so they are exceptions to the both rules.

String Initializing

Since strings are created in the memory, it will also cause a desync for any uninitialized string used in local code. This rule is rather inconsistent, and while it is possible for no problems to arise, it is recommended to follow this rule when writing local code.

Assign a New Random Seed

This one is rather straightforward. At initialization, every player has the same random seed. If this is changed for any one player, this will cause the entire game to differ for this player, and will cause de-synchronization.

TriggerSleepAction

Use of TriggerSleepAction inside local code will cause functions to be executed in a different order on one computer than another.

Personal tools