• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

SharpCraft, a managed replacement for Reinventing the Craft

Status
Not open for further replies.
Level 21
Joined
Aug 3, 2004
Messages
710
Background
Some of you might have heard about Reinventing the Craft. It's an old project I initially started in 2007 and worked extensively on for several years along with SFilip. Reinventing the Craft changed goals several times, but in the end, the idea was that we wanted to provide a stable API for extending Warcraft III with new natives and features. Sadly, due to limited coding experience and time, the project ended up collecting dust.

Since we stopped working on it, I've been contacted several times by people asking for the source, but I was reluctant to release because of the mess it was and all the experimental features it had. On top of that, it was nearly impossible to maintain if an update were released.

This got me to slowly work on a replacement. The new goal for the replacement was that it should be easier to use and it should prioritize maintainability in favor of features, and above all, it should be open source. Over the past few years I've worked on and off on project SharpCraft.

SharpCraft is written from scratch in C# and using EasyHook to inject into Warcraft III, I'm able to do what Reinventing the Craft did. Likewise as Reinventing the Craft only worked with Windows, so does SharpCraft. If enough interest is shown in the future, I might be able to look into how to make a version for Mac. For the time being, the whole project relies heavily on Windows APIs though.

I've finally reached a point where I feel confident in calling it usable and as such, I wanted to announce it.

Credits
  • MindWorX - for all initial development of SharpCraft
  • SFilip - for coding and research for our old project Reinventing the Craft.
  • PipeDream - for making Grimoire which have been used as reference and help on multiple occasions
  • xttocs - for making jAPI without which this probably wouldn't be possible

Changelog
Code:
v4.0.0.179
 * Fixes error with -loadfile paths.

v4.0.0.160
* Fixed error with passing zero arguments to the launcher.
* Added some path based error checking.
* Improved error handling when loading plugins.
* More stuff, check the commit log.

v4.0.0.152
* Made it possible to enable/disable auto-scroll in the DebuggerWindow.
* Made the DebuggerWindow more efficient with large amounts of text.
* Minor aesthetic changes to the DebuggerWindow.
* Removed faulty Mono.CSharp reference.

v4.0.0.145
* Updated EasyHook.
* Fixed bugs related to the EasyHook update.

v4.0.0.137
* Updated for 1.27a.

v4.0.0.136
* Added support for placing SharpCraft in a Warcraft III folder. It'll search the parent folder for war3.exe and use that if possible.
* Changed the plugin system a bit again. Sorry. <3

v3.0.1.135b
* Fixed .zip reading error.

v3.0.0.133
Everything is back to basics. SharpCraft now only has the core plugin functionality. All the advanced features will come as separate plugins.

v2.2.5.124b
* Expanded the managed JASS type wrappers.
* Implemented script-side events (issue #4)
* Implemented new method for calling natives with strings, resulting in more speed, since we're avoiding conversion.
* Implemented a better method for adding trigger actions.
* Implemented a few more Jass types.
* Minor improvement for the InternalNatives.JassStringHandleToString if check.
* Added missing DelegateAction type.
* Included commit number in the version number.
* Fixed a bug with returned JassStrings when calling natives directly.

v2.2.4
* Giant refactor. Too many changes to list them all.
* Added three new base classes for scripting.
* * FullPluginBase; // This class is for plugins that need full access, which means file writing and more.
* * SafePluginBase; // This class is for plugins that only need safe access.
* * MapScriptBase;  // This class is for internal war3map.cs scripts. It is similar to SafePluginBase.
* The sandbox milestone reached 100%, meaning more safety.
* Interplugin usage it possible through simple dependency.

v1.2.4a
* Fixed type return bug in CDestructable, CItem and CUnit.

v1.2.4
* Fixed a directory launcher issue.
* Fixed version reporting.
* Added several unmanaged classes to tinker with at your own risk.
* Improved launcher error reporting.

v1.2.3
* Refactored the API. It will be backwards compatible until v2.
* Added Input API for detecting keyboard and mouse input.
* Added Interface API for detecting FPS and writing messages.
* Added events for initializing systems that needs the JASS virtual machine ready.
* Improved on various Jass types.
* Improved on core functionality.

v1.1.3
* Improved the missing assembly loader.
* Added casting from Int32 to JassUnitId.
* Fixed WarcraftIII.IsMouseOverUI inverted return values.

v1.1.2
* Fixed issue with inferring return types of natives.

v1.1.1
* Fixed an issue with multiple plugins.
* Fixed an issue with loading Lidgren.Network.

v1.1.0
* Added Lidgren networking support.

v1.0.0
* First stable release

v0.1pre
* Initial prerelease


Tutorials
The tutorials assume a basic understanding of programming.
SharpCraft Development Environment (basic), shows how to setup Visual Studio and use SharpCraft.
SharpCraft Native Tutorial, shows how to add custom natives using the JassAPI plugin. This assumes you've followed the tutorial above.


SharpCraft binaries and source can be found on GitHub.
 

Attachments

  • SharpCraft.v4.0.0.160.zip
    302.9 KB · Views: 1,119
Last edited:
Level 21
Joined
Aug 3, 2004
Messages
710
Attached to this post are all the plugins that contain all the old features from v2 and below.

WarAPI is the core API that interacts with the game.
JassAPI(requires WarAPI) is the core API that allows you to add new natives and use JASS types.
InputAPI(requires WarAPI) is the core API that allows you to get advanced user input.
InterfaceAPI(requires WarAPI) is the core API that allows you to interact with the interface.

JassDebugger(requires WarAPI, JassAPI and InterfaceAPI) allows you to get debug information from JASS, like OpLimit, DivideByZero, etc, and what function caused the error.
Also gives Cheat callback features.
JASS:
// The following dumps the function code to a text file name "out.txt" in the "logs" folder in SharpCraft.
call Cheat("scdbg funcdump txt main out.txt")
// The following dumps the function code to a csv file name "out.csv" in the "logs" folder in SharpCraft.
call Cheat("scdbg funcdump csv main out.csv")

Lidgren.Network is a UDP powered network library.

Stopwatch is a basic Stopwatch toolset with the following self-explanatory natives
JASS:
native StopwatchGet takes nothing returns integer
native StopwatchFree takes integer return nothing
native StopwatchElapsedMilliseconds takes integer returns real
native StopwatchElapsedSeconds takes integer returns real
Also includes the source code to show a basic example of how to make plugins.
 

Attachments

  • MindWorX.SharpCraft.Lidgren.Network.zip
    56.5 KB · Views: 264
  • MindWorX.Modules.Stopwatch.zip
    2.8 KB · Views: 249
  • MindWorX.Modules.Stopwatch.src.zip
    4.2 KB · Views: 281
  • MindWorX.SharpCraft.Modules.InterfaceAPI.zip
    3.3 KB · Views: 239
  • MindWorX.SharpCraft.Modules.JassAPI.zip
    117.2 KB · Views: 288
  • MindWorX.SharpCraft.Modules.InputAPI.zip
    5.9 KB · Views: 273
  • MindWorX.SharpCraft.Modules.JassDebugger.zip
    8.5 KB · Views: 267
  • MindWorX.SharpCraft.Modules.WarAPI.zip
    16.6 KB · Views: 294
  • Modules.zip
    210.6 KB · Views: 299
Last edited:
We should make a lobby map that allows users to download maps online and stuff and go through games (maybe similar to the sc2 arcade). It should have a chatroom and people should be able to pick an avatar too.

The big thing ofc is dling maps. If we're going down full c#, they'll have to download the dll or w/e for the map + the map itself. Could also have automatic patching ^)^. On b.net, we could advertise sharpcraft. When they download the map, we tell them to start the map on their own and tell it what drive they want to put the installer on. From here, when they click the shell script, it will download the lobby map + SharpCraft to their computer. At this point, they just start wc3 through SharpCraft, go to single player, and run the lobby map =), then they are in.


Who wants to code this awesomness? Also, what server should host the lobby + provide the maps? I don't think that we'd get away with asking Ralle to do this, that's starting to ask too much, heh. Also, what server will host these maps? We'd have to have instanced maps and constant state maps (mmo vs like a fps).
 
Level 21
Joined
Aug 3, 2004
Messages
710
It can be. :p

Awesome. Perhaps this will have more potential now that it is on a stable patch (not stable in the sense of being bug-proof, but stable in the sense that Blizz won't patch it).

Thanks for the update!
Even if we get a patch, the settings.xml file comes with extensive instructions on relocating the addresses. One of the requirements of any core feature added is stability, so no adding random things found by pure luck. If it can't be documented, it won't get added. :)

We should make a lobby map that allows users to download maps online and stuff and go through games (maybe similar to the sc2 arcade). It should have a chatroom and people should be able to pick an avatar too.

The big thing ofc is dling maps. If we're going down full c#, they'll have to download the dll or w/e for the map + the map itself. Could also have automatic patching ^)^. On b.net, we could advertise sharpcraft. When they download the map, we tell them to start the map on their own and tell it what drive they want to put the installer on. From here, when they click the shell script, it will download the lobby map + SharpCraft to their computer. At this point, they just start wc3 through SharpCraft, go to single player, and run the lobby map =), then they are in.


Who wants to code this awesomness? Also, what server should host the lobby + provide the maps? I don't think that we'd get away with asking Ralle to do this, that's starting to ask too much, heh. Also, what server will host these maps? We'd have to have instanced maps and constant state maps (mmo vs like a fps).
SharpCraft will stay as a 3rd party library downloaded manually. What you're talking about will very likely result in a CnD from Blizzard. The current state of SharpCraft is harmless which means Blizzard wont interfere.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Cool, this here too!

Awesome. Perhaps this will have more potential now that it is on a stable patch (not stable in the sense of being bug-proof, but stable in the sense that Blizz won't patch it).
I hope they do. They tend to mess thing up and provide no information, that sucks.
 
It can be. :p


Even if we get a patch, the settings.xml file comes with extensive instructions on relocating the addresses. One of the requirements of any core feature added is stability, so no adding random things found by pure luck. If it can't be documented, it won't get added. :)


SharpCraft will stay as a 3rd party library downloaded manually. What you're talking about will very likely result in a CnD from Blizzard. The current state of SharpCraft is harmless which means Blizzard wont interfere.

I don't think that you'd get a CnD. Consider Garena.
 
Level 21
Joined
Aug 3, 2004
Messages
710
Is there a way to access/modify the unit or ability structs like in RtC?
Not right now, but it's easy to implement. The reason I haven't is because there's a lot of testing to do to make it even remotely stable.
I've added the WarcraftIII.IsMouseOverUI bug to the issue tracker.

Hmmm, I like this impolementation. Could we work together to make it integrated to JNGP 2.0.X?
I hope this gets impolemented in JNGP.
It's pretty straight forward to implement since SharpCraft.exe can be used just like you'd launch war3.exe. All parameters that are not SharpCraft specific gets passed along.

I don't think that you'd get a CnD. Consider Garena.
Well, in any case, it's beyond the scope of SharpCraft. How people go on to use SharpCraft is up to them. All this is is a modding API.
 
Level 21
Joined
Aug 3, 2004
Messages
710
New release!

Changelog
Code:
v1.2.3
 * Refactored the API. It will be backwards compatible until v2.
 * Added Input API for detecting keyboard and mouse input.
 * Added Interface API for detecting FPS and writing messages.
 * Added events for initializing systems that needs the JASS virtual machine ready.
 * Improved on various Jass types.
 * Improved on core functionality.
 
Level 5
Joined
Nov 10, 2009
Messages
85
Hey MindWorX, awesome mod you got here. is it able to work on a multiplayer level or do we need to wait for someting like Triggerhappy's WarCom to be released?
 
When I run it via command line:
Code:
cd "C:/Program Files/Warcraft III/Tools/jassnewgenpack206"
"SharpCraft/SharpCraft.exe" -game

It returns:
Code:
Sharpcraft by MindWorX
Version: 1.1.3.0 <debug>
Loading settings . . . settings.xml missing.

However, this will work:
Code:
cd "C:/Program Files/Warcraft III/Tools/jassnewgenpack206/SharpCraft"
"SharpCraft.exe" -game

Any way around that? btw, the console shows 1.1.3.0 even though I'm using 1.2.3.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
It's because of the work directory not including that file.
To solve it from the code-side, set the work directory to the one of the executable on run-time:
C#:
Directory.SetCurrentDirectory(System.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)));
 
Level 21
Joined
Aug 3, 2004
Messages
710
Hey MindWorX, awesome mod you got here. is it able to work on a multiplayer level or do we need to wait for someting like Triggerhappy's WarCom to be released?
This isn't doing any syncronization, so some things can cause desyncs.

When I run it via command line:
Code:
cd "C:/Program Files/Warcraft III/Tools/jassnewgenpack206"
"SharpCraft/SharpCraft.exe" -game

It returns:
Code:
Sharpcraft by MindWorX
Version: 1.1.3.0 <debug>
Loading settings . . . settings.xml missing.

However, this will work:
Code:
cd "C:/Program Files/Warcraft III/Tools/jassnewgenpack206/SharpCraft"
"SharpCraft.exe" -game
Any way around that? btw, the console shows 1.1.3.0 even though I'm using 1.2.3.
In the first, you're specifying a different work directory. Try placing settings.xml in "C:/Program Files/Warcraft III/Tools/jassnewgenpack206" and run the first command again.
I'll fix the version for next release.

I get this error when I try to run it:

Checking versions . . . System.IO.FileNotFoundException: C:\Programme\war3.exe
Sounds like your registry settings are borked up. You should look for a registry fixer.
 
Moving the settings.xml worked (although, I don't like having the SharpCraft files outside its folder :( )

I got this error:
attachment.php


Upon running it through this:
Lua:
function testmap(cmdline)
    start = string.find(cmdline, "-loadfile")
    loadfile = string.sub(cmdline, start)

    if sc_enabled.checked then
        cmdline = "SharpCraft\\SharpCraft.exe -game " .. loadfile
    end

    wehack.messagebox(cmdline)

    if wh_opengl.checked then
        cmdline = cmdline .. " -opengl"
    end
    if wh_window.checked then
        cmdline = cmdline .. " -window"
    end
    
    wehack.execprocess(cmdline)
end

The wehack.messagebox() command displayed:
Code:
SharpCraft\SharpCraft.exe -game -loadfile Maps\Test\WorldEditTestMap.w3x

And if you need the source on wehack.execprocess, click here. It started wc3 but it did not successfully hook. It just threw that error.
 

Attachments

  • Error.png
    Error.png
    48.2 KB · Views: 922

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
I just tested it. It worked but I think I am missing something.

1. how do I add a new native, the only way I noticed was to modify the example plugin and that is written c# (which I know a little of luckly) is that the only way?
2. you need to start the game with a custom launcer to make the custom native work isnt this a problem?
edit: calling a BJ doesnt seem to work either. I tried with BJDebugMsg("sads"); and it gave me error
 
Last edited:
I just tested it. It worked but I think I am missing something.

1. how do I add a new native, the only way I noticed was to modify the example plugin and that is written c# (which I know a little of luckly) is that the only way?
2. you need to start the game with a custom launcer to make the custom native work isnt this a problem?
edit: calling a BJ doesnt seem to work either. I tried with BJDebugMsg("sads"); and it gave me error

You gave no info or your code so we can't really help you.

Take a look at this page and look at the source of my plugins.

Also, you're not supposed to be able to hook BJ's (afaik).
 
Last edited:
@MindWorX:

Did you try what GhostWolf said?

It's because of the work directory not including that file.
To solve it from the code-side, set the work directory to the one of the executable on run-time:
C#:
Directory.SetCurrentDirectory(System.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)));

It would be very convenient if I could relegate it to one folder.
 
Is this based on JNGP 2.x? Hence the name 2.07

I'm still using 5d

Yeah. It is added to the 2.0.6 version (moyack's). I'll probably get moyack to do an official update in the next few days, but I first want to check out another resource that could be bundled as well.

If you just want to add it to your 5d version, just put the contents of Sharpcraft within your JNGP folder, inside a folder named "SharpCraft".

Then open wehack.lua, change the function testmap to this:
Lua:
function testmap(cmdline)
	
	start = string.find(cmdline, "-loadfile")
	loadfile = string.sub(cmdline, start)
    
	if sc_enabled.checked then
		cmdline = "SharpCraft\\SharpCraft.exe -game " .. loadfile
	end

	if wh_opengl.checked then
		cmdline = cmdline .. " -opengl"
	end
	if wh_window.checked then
		cmdline = cmdline .. " -window"
	end
    
	wehack.execprocess(cmdline)
end

And add this to the code somewhere (make sure it is outside of a function):
Lua:
--Sharpcraft Implementation

sharpcraft = wehack.addmenu("SharpCraft")
sc_enabled = TogMenuEntry:New( sharpcraft, "Enable SharpCraft", nil, false )

Then just open NewGen and the option to enable sharpcraft should be there.
 
Level 1
Joined
Sep 14, 2010
Messages
8
Doodads/prop limits.

Has there been something done about the doodad limit. As far as I know the World Editor only lets you place about 6k doodads, as well as trees/destructibles. I read that the map size is unlimited. Is this taking away those limits within the editor? Or is there already a way to get past these limits that I just dont know yet?

:eekani:
 
Has there been something done about the doodad limit. As far as I know the World Editor only lets you place about 6k doodads, as well as trees/destructibles. I read that the map size is unlimited. Is this taking away those limits within the editor? Or is there already a way to get past these limits that I just dont know yet?

:eekani:

Jass NewGen Pack should already allow you to get past that limit. You can download it here:
http://blizzardmodding.info/4263/the-jass-newgen-pack-jngp-2-0/
 
Level 21
Joined
Aug 3, 2004
Messages
710
Exception events that can be registered to triggers would be kinda cool. Could make debugging a whole lot easier even for non-SC maps.

I did consider adding some debugging functionality like that. Basically, if you declare a function like this:
JASS:
function SharpCraft_Exception takes nothing returns nothing
    // do your thing.
endfunction
That function would get called when an error happens. In time, I might be able to pass along what function failed as well.
 
Level 21
Joined
Aug 3, 2004
Messages
710
Another teaser for some upcoming features...

C#:
...
    var priest1 = JassUnit.Create(JassPlayer.FromIndex(0), (JassObjectId)"hmpr", 0, 0, 0).ToCUnit().AsUnsafe();
    var priest2 = JassUnit.Create(JassPlayer.FromIndex(0), (JassObjectId)"hmpr", 0, 0, 0).ToCUnit().AsUnsafe();
    var heal = new JassObjectId("Ahea");

    // We need to fetch ability from both units since they're unique to each unit.
    var ability1 = priest1->GetAbility(heal);
    var ability2 = priest2->GetAbility(heal);

    // We then make the data for each ability unique.
    ability1->MakeDataUnique();
    ability2->MakeDataUnique();

    // We can now set stats indedependantly for each unit.
    ability1->Data->Level[0].ManaCost = 1;
    ability1->Data->Level[0].SetDataA(10.00f);
    ability2->Data->Level[0].ManaCost = 2;
    ability2->Data->Level[0].SetDataA(20.00f);
...
 
Last edited:

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
Is it possible to create a JassCode variable in a plugin and use it in natives like TimerStart or TriggerAddAction? I want the callback go to the C# code again.


I would like to try building some kind of Jass-interpreter using SharpCraft. The interpreter would be able to reload the Jass-script without reloading the map, which would be really convenient when developing a map. Something like in this video, but for WarCraft III.
 
Level 21
Joined
Aug 3, 2004
Messages
710
Is it possible to create a JassCode variable in a plugin and use it in natives like TimerStart or TriggerAddAction? I want the callback go to the C# code again.
I've been looking at doing just this. I haven't been able to yet though, but I've added a CheatListener event in the latest uncommitted stuff, which means you can use Cheat to pass information to C#. From C#, you can even use GetTriggeringUnit and similar.

I would like to try building some kind of Jass-interpreter using SharpCraft. The interpreter would be able to reload the Jass-script without reloading the map, which would be really convenient when developing a map. Something like in this video, but for WarCraft III.
I've done some tests, and it's actually possible to replace the internal JASS Virtual Machine Code at run-time, to get new functionality. :)
 
  • Like
Reactions: peq

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
Last edited:
Level 1
Joined
Sep 14, 2010
Messages
8
I cannot start the Sharpcraft - Natives.w3x file either through the editor nor Warcraft directly. And I have the latest newgenpack. What could be the problem? Is there something else needed than just downloading it that ive missed?
 
I cannot start the Sharpcraft - Natives.w3x file either through the editor nor Warcraft directly. And I have the latest newgenpack. What could be the problem? Is there something else needed than just downloading it that ive missed?

Run Sharpcraft.game.exe -window.bat. If all goes well, then you should see a terminal window pop up (a black window with text). It should say some things, then "Done!" a few times, and then when wc3 opens, it'll do some more initialization. Then you just navigate to your map and test it.

If you want it to work with JNGP editor's test map function, see:
http://www.hiveworkshop.com/forums/2456081-post32.html
 
Level 21
Joined
Aug 3, 2004
Messages
710
The stuff PipeDream has found is all we have. :)

Is there a way to get the Player, who is pressing the key/mousebutton?
GetTriggerPlayer() didn't work for me
Input features are all local, so they have no concept of who triggered it.
 
Status
Not open for further replies.
Top