• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Custom JASS Natives - (Requests & Submissions)

Status
Not open for further replies.
Thanks everyone, I'll be posting more updates soon including some features MindWorX just implemented into SharpCraft.

Also, I got the Http functions to support threading so there's no more lag when making requests :)

EDIT: Here's a basic example.

JASS:
    local string resp = null
    local Http req    = Http.create()
    set req.url       = "hiveworkshop.com"
    set req.reqMethod = "GET"
    
    call req.BeginRequest()

    loop
        exitwhen resp != null
        set resp = HttpPendingResponse(req)
        call TriggerSleepAction(0)
    endloop
    
    call req.destroy()
    
    call ClearTextMessages()
    call BJDebugMsg(resp)


JASS:
    struct Http
        
        string reqMethod = ""
        string url       = ""
        string cookies   = ""
        string values    = ""
        
        method BeginRequest takes nothing returns nothing
            call StartRequest(this.reqMethod, this.url, this.cookies, this.values, this)
        endmethod
        
        static method Post takes string url, string cookies, string values returns string
            return HttpRequest("POST", url, cookies, values)
        endmethod
        
        static method Get takes string url, string cookies returns string
            return HttpRequest("GET", url, cookies, "")
        endmethod
        
    endstruct
 

Attachments

  • thwchatt.png
    thwchatt.png
    949.7 KB · Views: 229
Last edited:
Update
  • BeginRequest and HttpPendingResponse added to the Http plugin. These will allow you to make requests in another thread so the game doesn't pause.
  • InterfaceAPI
    JASS:
    native FramesPerSecond    takes nothing returns real
    native EnableChatMessages takes boolean flag returns nothing
    native InterfaceMessage   takes string message, integer area, real duration returns nothing
    native PlayerChatMessage  takes integer pid, string message, integer whichGroup, real duration returns nothing
    PlayerChatMessage obviously forces a player to say something while InterfaceMessage creates a notification-type message around various areas of the screen. Check the attached screenshot.

All attachments in the main thread have been updated.

Extract-Play.zip - Download this if you're impatient and want to try the demo maps quickly
THW-Chatroom.w3x - Chatroom demo (unfinished)

EDIT Updated http plugin with a temporary crash fix.
 

Attachments

  • interface.png
    interface.png
    1.7 MB · Views: 158
Last edited:
Create natives that will effect object data (units, abilities, items, upgrades...):
- SetUnitName(int id, string s)
- SetUnitTooltip(int id, string s)
- SetAbilityTooltip(int id, int for_lvl, string s)
- SetAbilityTooltipExtended(int id, int for_lvl, string s)
...

or some for unit states
- SetUnitState(unit u, int state, int value)
where state can be: max hp,damage,damage type,armor,regeneration rate,...
 
I dont know if its possible.. But build in unit indexer please.

Yeah, it would be possible by overriding CreateUnit (making it slightly slower) however I think MindWorX could find a more elegant, internal solution.

Create natives that will effect object data (units, abilities, items, upgrades...):
- SetUnitName(int id, string s)
- SetUnitTooltip(int id, string s)
- SetAbilityTooltip(int id, int for_lvl, string s)
- SetAbilityTooltipExtended(int id, int for_lvl, string s)
...

or some for unit states
- SetUnitState(unit u, int state, int value)
where state can be: max hp,damage,damage type,armor,regeneration rate,...

These will be coming soon.

wait this is freakn cool
but how do u use it? where do i ahve to extract it to and etc? what files do i run

Extract it and run Sharpcraft.Game.exe -window with pause.bat

Check the SharpCraft thread.
 
Are you serious ?
I never tested this because I didn't need so but if it doesn't work so I agree with you that he can be cool to have such natives.
Why you even post something you didn't tested, why you think people work on such complex bonus systems and shits... Whatever...

I'm all into this if you allow us to edit object data using functions.
Oh boy, item generators for RPG maps are something we REALLY NEED.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
Why you even post something you didn't tested, why you think people work on such complex bonus systems and shits... Whatever...

I'm all into this if you allow us to edit object data using functions.
Oh boy, item generators for RPG maps are something we REALLY NEED.

Well apart from generating actual item objects, you can have item generators. You would just need to trigger all the effects. The downside would you would have a limited number of item names/models.
 
Well apart from generating actual item objects, you can have item generators. You would just need to trigger all the effects. The downside would you would have a limited number of item names/models.
Exactly what I do in my SotP project, still as you said item model, tooltip, icon look all the same.

Btw think about abilities as well. What if you could create spells like this, merging effects from 2 or more abilities or something.
 
Can you create natives that allow us to build custom UI based on U and V real coordinates on screen?

Like DGUI, just directly supported by the scripting language with no traffic and lag due to moving objects around in Multiplayer. As it's just a visual thing, it doesn't need to be syncronized except for click/keypress events on those UI elements (those have to be synced, naturally).

If you could do that (and the multiplayer support for SharpCraft is completed and bug free), I will port Gaias Retaliation ORPG over to using SharpCraft and require all people that want to play it to install SharpCraft. :)
 

MindWorX

Tool Moderator
Level 20
Joined
Aug 3, 2004
Messages
709
Can you create natives that allow us to build custom UI based on U and V real coordinates on screen?

Like DGUI, just directly supported by the scripting language with no traffic and lag due to moving objects around in Multiplayer. As it's just a visual thing, it doesn't need to be syncronized except for click/keypress events on those UI elements (those have to be synced, naturally).

If you could do that (and the multiplayer support for SharpCraft is completed and bug free), I will port Gaias Retaliation ORPG over to using SharpCraft and require all people that want to play it to install SharpCraft. :)
I've helped TriggerHappy with installing a DirectX EndScene hook, means overlaying a custom UI is relatively simple. The biggest hurdle is wrapping all the DirectX8 stuff in Warcraft III with C#. :)
 
Can you create natives that allow us to build custom UI based on U and V real coordinates on screen?

Like DGUI, just directly supported by the scripting language with no traffic and lag due to moving objects around in Multiplayer. As it's just a visual thing, it doesn't need to be syncronized except for click/keypress events on those UI elements (those have to be synced, naturally).

If you could do that (and the multiplayer support for SharpCraft is completed and bug free), I will port Gaias Retaliation ORPG over to using SharpCraft and require all people that want to play it to install SharpCraft. :)

Yea, custom UI is a goal. Luckily we found some EndScene hooking tutorial that uses Warcraft III directly and MindWorX should be implementing it into SharpCraft.

I'm going to be adding custom syncing natives for WarCom. This way if something isn't synced you can do it yourself, which will require a bit more work but it's worth it.

HTTP functions are already included so hypothetically you could store player data on a web server if you wanted.

SharpCraft apparently works over battle.net as well

Why you even post something you didn't tested, why you think people work on such complex bonus systems and shits... Whatever...

I'm all into this if you allow us to edit object data using functions.
Oh boy, item generators for RPG maps are something we REALLY NEED.

MindWorX has already got dynamic abilities working AFAIK, and items shouldn't be much different.
 
Last edited:
This is just awesome, it can really enhances maps in many ways.

Just a question (maybe unrelated to thread) :

JASS:
native HttpLastCookie      takes nothing returns string
native HttpPendingResponse takes integer id returns string
native HttpRequest         takes string method, string url, string cookies, string values returns string
native StartRequest        takes string method, string url, string cookies, string values, integer id returns nothing
How to use it actually? I see the example but I don't get the flow too well.
Mind if anyone explain what each function does?
 
Level 6
Joined
Jul 30, 2013
Messages
282
Currently ..
If you run a map with this system on vanilla war3 it will crash right..?

well. would it not be possible to.. tweak it so that it would not?
how?

in stead of new native MYFuncs..
we could hijack some existing native and use it as a hub..
so as say we have ..
JASS:
function HTTPGet takes string url returns string
    // call some native function that can fail harmlessly..  
    call SetPlayerName(Player(13), "HTTPGET="+url) //make request
    string data= GetPlayerName(Player(13))
    // restore player name..
    return data
endfunction

we just need retain binary compatibility for the interface..
and we canchange the implementation of the function so that it does sth useful for us.
 
Last edited:

MindWorX

Tool Moderator
Level 20
Joined
Aug 3, 2004
Messages
709
Waffle, the idea is interesting and I've been considering ways to do it. My idea was to utilize the Cheat native, and then some of the GetTrigger* natives to fetch results. We'd need to establish the best possible way of doing it and the most friendly natives to override.

EDIT:
Actually, we could just abuse the known limits, without compromising the existing functionality. Lets take your example. We could just override the "Player" native, and have it return a special value if we use a value above 15. This way we could just do something like ...
JASS:
call SetPlayerName(Player(100), "HTTPGET="+url)
... where "Player(100)" would be handled by the "http" mod.
 
Last edited:

MindWorX

Tool Moderator
Level 20
Joined
Aug 3, 2004
Messages
709
I truly think this is isn't that good and maybe we should keep using custom names to not confuse....
Anyway since we already have to implement Sharpcraft I don't see the point of using existing natives and get confused with enhanced coding :/

The idea with this is, you could have non-desyncing features in your map. Imagine having access to the Hive Chat while playing a map with friends. This way you could have stuff like GetPlayerName(Player(100)) return "SharpCraft" if SharpCraft is present, and then you can do stuff only possible if SharpCraft is present. This means you could player a map with people on Battle.Net where you could chat on THW at the same time.
 
Level 6
Joined
Jul 30, 2013
Messages
282
Hmm.. player function is not safe for some inputs..
I think is is an unchecked array access in the war3 code because Player(-1) crashes the game..

How about multiboard natives? we create some multiboard with special name and then we got a 2D array that we can use to make requests..
and later we just read the fields value to get the result.

as a bonus, the more we can pass as separate parameters the less we need to pollute the string table (and grind everything to a halt..)



ps. offtopic. the multiboard BJ-s are especially nasty, if anybody uses them .. i feel for ya..!
 
EDIT:
Actually, we could just abuse the known limits, without compromising the existing functionality. Lets take your example. We could just override the "Player" native, and have it return a special value if we use a value above 15. This way we could just do something like ...
JASS:
call SetPlayerName(Player(100), "HTTPGET="+url)
... where "Player(100)" would be handled by the "http" mod.

Probably not Player(#) because it will crash a regular user. GetTrigger...() might work, but I feel like it has a potential to conflict with standard triggers. Hashtables are an option (since they can take and remove most things). Idk, it is up to the native creator. IMO, you can use whichever natives you want (as long as it is noted in the documentation), and then you can just make wrapper functions, e.g.:
JASS:
function HttpRequest takes string s returns nothing
    call SetPlayerName(Player(0), s)
endfunction

That way, it'll work for everyone and it'll be easy to use.
 

MindWorX

Tool Moderator
Level 20
Joined
Aug 3, 2004
Messages
709
Yeah, I didn't consider that Player(100) might crash the game. The hashtable is a very valid possibility. We could just populate the hashtable with information on the C#/SharpCraft side and the Jass side could easily load from it. Basically something like
JASS:
    local hashtable ht = InitHashtable();
    SaveStr(ht, 0xFFFF, 0xFFFF, "SharpCraft")
    if(LoadBoolean(ht, 0xFFFF, 0xFFFF)) then
        // SharpCraft is available.
    endif
I'm sure I've missed something, but it's a valid way of doing things.
 
Level 6
Joined
Jul 30, 2013
Messages
282
#define sharpcraft wont work (or it wont be a true define) because you will only find out about it at runtime.

woudl it make a difference if we use multiboard or hashtable?

Is it hard to get at the different fields of a multiboard from withing c++?
if its not hard then i like multiboard just a tiny bit better because we could do stuff bit more elegantly wiht it..

say we can create a multiboard titled "HTTPGET: urlhost" and then set params in the fields..
(and then say run a callback when it is done.. and read answers from fields.... would it be possible to set callbacks..)


-----------------------------------
I think it really depends on what sort of events u want to work with.. complex web queries would do well if u have a lot of discrete fields..
but some stuff could work well with just 1 string..
-----------------------------------
 
I have a request:
JASS:
native StopWatchFrequency takes nothing returns integer
Should be easy because C# already offers this feature. I think it is important because miliseconds are not exact and the duration for ticks depends on the system.

Sure I'll probably do it tomorrow as well as update the rest of the plugins.
 
Level 6
Joined
Jul 30, 2013
Messages
282
can you make gamecache work in multiplayer? (i mean .. would you?)

and by "work" i mean as in singleplayer: persistent storage. cuz hacking with preload natives is so fiddly..
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
A game cache simulator could be done with a website page storing the information perhaps?

This is a good idea. A few years ago, I would have had tons of ideas.

I suppose you can't fix DestroyTrigger() nor provide a replacement that effectively destroys it? I was told Blizzard's native malfunctions, does not really destroy the trigger and causes crashes later in the game. KillSoundWhenDone() has also been rumored to not always work appropriately in the sense it may not destroy the sound object at all.
 

MindWorX

Tool Moderator
Level 20
Joined
Aug 3, 2004
Messages
709
A game cache simulator could be done with a website page storing the information perhaps?
This is an interesting idea. People could dump an xml file on dropbox and then load it into a hashtable or similar. This way you could externalize balancing, MotD's, etc.
I suppose you can't fix DestroyTrigger() nor provide a replacement that effectively destroys it? I was told Blizzard's native malfunctions, does not really destroy the trigger and causes crashes later in the game. KillSoundWhenDone() has also been rumored to not always work appropriately in the sense it may not destroy the sound object at all.
Fixing convoluted errors like that can be difficult. It's possible though, if there's a known workaround, to implement that so it's used every time automatically.
 
Cool. What about the DestroyTrigger() and KillSoundWhenDone() though? D=

DestroyTrigger() works with triggers with conditions just fine. But iirc, triggers with actions leave some data. This isn't much of a problem in JASS because we generally use conditions for both conditions and actions, e.g.:
JASS:
function Condition takes nothing returns boolean
    if GetSpellAbilityId() == 'A000' then
        // do actions here
    endif
    return false
endfunction
As for the crash, that is probably related to handle stack corruption, outlined here:
http://www.wc3c.net/showthread.php?p=999565#post999565
But it requires a particular sequence of things (destroying a trigger and then waiting twice). It is just something to avoid, but you don't normally use TriggerSleepAction in JASS anyway (and GUI users don't normally destroy triggers).

-----

As for KillSoundWhenDone(), yeah there is apparently an issue where the sound doesn't get destroyed if you are muted (because the sound never plays). This might be a problem if you periodically create a sound. Instead, you should just make one sound and use it over and over (where it is feasible). But a couple of excess sound handles won't do anything to your map. It would be cool if it was easily fixable, but I don't know if it is. :eek:
 
Status
Not open for further replies.
Top