- Joined
- Oct 12, 2011
- Messages
- 3,449
1. INTRO
2. What is a Sharpcraft?
3. How to play multiplayer map with Sharpcraft?
Some times ago I asked about how to play sharpcraft (with new natives) in multiplayer (but I can't locate that post anymore) and someone (perhaps PurgeandFire) answered that we need to modify the common.j and inject the new natives in order to pass a quick checking before we enter a room. But I was too lazy to test this and chose to stop my project due to this problem, it was my fault seriously. But a moment ago, finally I got some motivations to actually do some researches how to play sharpcraft in multiplayer, and soon discovered that the method above works flawlessly. So here is the steps how I did it. Check it out!
2. What is a Sharpcraft?
I'm not the best guy to explain sharpcraft so you can go here instead to read some informations about it. In short, it's an awesome tools that allows us to do many cool things like creating our own native functions, etc. (etc. because I don't know anything else
). However, it requires some works to install it properly.
3. How to play multiplayer map with Sharpcraft?
A. Why it can't work without these steps?
Before you enter a room, Warcraft will run some kind of quick check to validate your Warcraft 3 or perhaps the map. If the map has unidentified scripts (like new natives), then you just can't enter the room because it will assume that your Warcraft version is incompatible with the target room. Thus we need to modify the function library (common.j) and manually write the declaration of our new functions by ourselves.
B. How to make it works?
4. Known BugsThe trick is to modify the common.j file without modifying war3.mpq:
- You need to have "Allow local files" enabled (tuts). Normally, one who has JNGP wouldn't have this problem since they can simply enable it under Extensions > Enable Local Files.
- Use a MPQ Extractor application (example). Open war3.mpq using that tool and go to Scripts > common.j then extract the file somewhere.
- Open the extracted common.j using notepad. Press CTRL+End (Windows) to go to the bottom part of the texts. Then you need to declare every new natives you use in your map. This is one example:
Code:...... native NetworkConnect takes string host, integer port returns nothing native IsNetworkConnected takes nothing returns boolean native NetworkUserCount takes nothing returns integer native NetworkPing takes nothing returns real native NetworkSyncUnit takes unit u returns nothing*/ native GetMouseX takes nothing returns real native GetMouseY takes nothing returns real native GetMouseTerrainX takes nothing returns real native GetMouseTerrainY takes nothing returns real native GetMouseUIX takes nothing returns real native GetMouseUIY takes nothing returns real native GetTriggerKey takes nothing returns integer native GetTriggerWheelDelta takes nothing returns integer native GetTriggerKeyString takes nothing returns string native IsMouseOverUI takes nothing returns boolean native IsKeyDown takes integer vkey returns boolean native TriggerRegisterAnyKeyEvent takes trigger whichTrigger, integer state returns nothing native TriggerRegisterAnyMouseEvent takes trigger whichTrigger, integer state returns nothing native TriggerRegisterKeyEvent takes trigger whichTrigger, integer vkey, integer state returns nothing native TriggerRegisterMouseEvent takes trigger whichTrigger, integer vkey, integer state returns nothing native TriggerRegisterMouseWheelEvent takes trigger whichTrigger returns nothing native StopWatchCreate takes nothing returns integer native StopWatchTicks takes integer id returns integer native StopWatchMark takes integer id returns integer native StopWatchDestroy takes integer id returns nothing native StringReplace takes string str, string old, string new returns string native StringReverse takes string str returns string native StringSplit takes string str, string sub, integer index returns string
- Now that you have it modified, close the notepad and go to your Wacraft 3 directory. Create a folder named "Scripts" and move the modified common.j to that folder.
- (Untested) You need to do all these steps to all of PCs that want to play in the room that uses sharpcraft. I don't know does the server need to do these as well or not.
- It's done. But if you still can't enter the room, retry to enter it twice or so and it's going to work.
Problem: Compile error when saving maps.
Solution: Rename the "Script" folder into something else. You just need to revert the name back to "Script" when you want to play a multiplayer map again using sharpcraft.
5. ClosingSolution: Rename the "Script" folder into something else. You just need to revert the name back to "Script" when you want to play a multiplayer map again using sharpcraft.
Hope this can be helpful. I also attached the example of modified common.j below. If you spot any mistake above, please report it in this thread. Thanks!
Attachments
Last edited: