• 🏆 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!

Web Requests (HTTP) from your map (and more)

Status
Not open for further replies.
Download: th-ghost-v1.0.0-beta2.zip (demo map in maps folder)

Github: triggerhappy187/th-ghost

For a while now I have been working on a hostbot that allows maps to make HTTP requests from within JASS. This means it doesn't require any third party tools for the user, they simply need to join a map hosted by a hostbot which most people do already anyway. I have created a few vJass libraries that allow you to use the functionality with ease. You can make a request in one function call and get the response in a callback.

JASS:
private function OnReady takes nothing returns boolean
    local WebRequest req = GetTriggerWebRequest()

    call BJDebugMsg(GetTriggerWebResponse())

    call req.destroy()
        
    return false
endfunction

private function StartRequest takes nothing returns nothing
    call HttpGet("https://www.hiveworkshop.com/attachments/file-txt.293355/", Filter(function OnReady))
endfunction
I have been meaning to properly release this but I had been working on a feature that would allow you to monetize your map with an item mall as well as provide an API to store data onto a centralized server similar to how they are doing it in China. It's on hold for now so I decided I didn't want this to just sit in Github without anyone knowing about it. In it's current state you are fully able to create your own item mall if you want.

68747470733a2f2f692e696d6775722e636f6d2f513665414e52522e706e67


HTTP requests are just one feature. The underlying system is called W3HMC (Warcraft III Hostbot to Map Communication) or HMC. With this system you can send data from the hostbot to the map. Currently you can make web requests, get the current time or the time when the map started, and get a players realm. The way it basically works is by adding a fake player to the lobby. This fake player will then spoof chat message events (not seen by anyone) when the hostbot wants to send a string to the map.

For more information check out the github and wiki (very much a WIP).

I have created a special API that can allow people with no knowledge of JASS or servers to store data onto my server.

  • SaveGold
    • Events
      • Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
    • Conditions
    • Actions
      • Set goldvalue = ((Triggering player) Current gold)
      • Custom script: call SetServerValue(GetTriggerPlayer(), "gold", I2S(udg_goldvalue))
  • LoadGold
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: set udg_goldvalue = S2I(GetServerValueWithWait(Player(0), "gold"))
      • Player - Set Player 1 (Red) Current gold to goldvalue
You can use this functionality as-is without having to do anything, however if you want your own database for your map which isn't publicly shared like the demo's, you need to register here. Once registered you can created a database and update your MAP_ID in the ServerAPI library.

Download is at the top of the post with a demo map included.
 
What is the best way to test this during development? Host on BNet with that host bot and make sure you're getting valid responses?

After you make sure the demo map is working properly for you then you should be free to start writing code using the W3HMC libraries. I do all my tests on battle.net, but that requires multiple CD keys so if you can manage to test in LAN (I haven't tried) it would be easiest. In my opinion this should only be used to create optional features for your map and your map should not rely on it. This is why I added the functionality to check if the hostbot is running or not, in-game. If you enable the debug mode in the configuration file it should print what's going on in the console as well.

Anyway, this is drastic results. Do I need third party tools?

It requires no 3rd party tools for everyone playing your map but obviously a hostbot is a third party tool, so only the map developer will have to use 3rd party tools.
 
Level 7
Joined
Jun 5, 2018
Messages
180
Interesting, very interesting!
This work can be considered to be used in the Internet based map interaction by which the map enables an online network gaming mode. What is the difference between this work and ORPG?

By the way, I want to introduce another web based technique: Embedded Browser Framework. I think the development direction of the wc3 modding will be changed, if these two works combine.

Embedded browser framework (w4454962): plotting wc3 UI by drawing web pages can directly generate HTML directly with the HTML visual editor and write JavaScript front-end scripts to dynamically draw UI to interact with jass in a way to interact with C++.
 
So if I understand this correctly, I cannot make http requests unless I use the host bot?

Correct, which is why I suggest making it an optional feature to enhance your map.

Interesting, very interesting!
This work can be considered to be used in the Internet based map interaction by which the map enables an online network gaming mode. What is the difference between this work and ORPG?

By the way, I want to introduce another web based technique: Embedded Browser Framework. I think the development direction of the wc3 modding will be changed, if these two works combine.

Embedded browser framework (w4454962): plotting wc3 UI by drawing web pages can directly generate HTML directly with the HTML visual editor and write JavaScript front-end scripts to dynamically draw UI to interact with jass in a way to interact with C++.

That looks interesting but I assume it relies on client hacks and does not work on the newest patches.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
Why exactly does it need to be hosted by a bot?
As a rough guess it is due to the bot processing specific command packets and injecting response command packets that are processed by clients. The bot, which was acting as the coordination server, could be made into a portal to the outside world.

Reforged does not allow third party coordination servers and so this approach no longer works.
 
Status
Not open for further replies.
Top