wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Samples
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 07-20-2009, 03:45 AM   #1
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default HCL - HostBot Command Library

Suppose you have a map league, where bots host your map and keep track of stats. But the map has modes and you want to force a particular mode in league games (eg. random pick or hard difficulty) without having a separate league version of the map. There is no good way to do this, so you use HCL to pass a short mode in.

This library allows the bot to communicate with your map by encoding characters into players' handicaps (idea by Varlock). Warcraft 3 normally only allows 6 possible handicaps, but bots can specify 256 different values. By encoding the original handicap inside the larger handicap, and only performing the encoding just before the map starts, players don't even realize their handicap was temporarily mutilated.

There is a limit of 1 character per player (empty slots don't count, but computers do), and the characters are limited to the set "abcdefghijklmnopqrstuvwxyz0123456789 -=,.". So don't expect someone to be entering long strings this way. Make the automated modes as short as they need to be. To read the mode entered by the bot, just call HCL_GetCommandString(). If it returns the empty string, there was no mode entered.

It's probably a good idea to include this in popular maps, even if they don't use it. If a bot tries to enter modes on a map without this library, the player handicaps will be absolutely ruined.

History
Hidden information:

v1.01
- Fixed a potential rounding issue when reading the handicap
- Fixed a floating point precision issue when assigning the handicap


Collapse JASS:
///////////////////////////////////////////
/// HostBot Command Library
/// Last Modified: September 14, 2009
/// Authors: Strilanc, 
/// v1.01
///////////////////////////////////////////
/// Reads a command string transparently encoded into player handicaps by hostbots.
/// Allows at most one character from "abcdefghijklmnopqrstuvwxyz0123456789 -=,." per player.
/// Empty slots don't count towards the player count, but computers do.
///////////////////////////////////////////
library HCL initializer init
    globals
        private string command = ""
    endglobals
    
    public function GetCommandString takes nothing returns string
        return command
    endfunction
    
    private function init takes nothing returns nothing
        local integer i
        local integer j
        local integer h
        local integer v
        local string chars = "abcdefghijklmnopqrstuvwxyz0123456789 -=,."
        local integer array map
        local boolean array blocked

        //precompute mapping [have to avoid invalid and normal handicaps]
        set blocked[0] = true
        set blocked[50] = true
        set blocked[60] = true
        set blocked[70] = true
        set blocked[80] = true
        set blocked[90] = true
        set blocked[100] = true
        set i = 0
        set j = 0
        loop
            if blocked[j] then
                set j = j + 1
            endif
            exitwhen j >= 256
            set map[j] = i
            set i = i + 1
            set j = j + 1
        endloop
        
        //Extract command string from player handicaps
        set i = 0
        loop
            exitwhen i >= 12
            set h = R2I(100*GetPlayerHandicap(Player(i)) + 0.5)
            if not blocked[h] then
                set h = map[h]
                set v = h/6
                set h = h-v*6
                call SetPlayerHandicap(Player(i), 0.5 + h/10.0)
                set command = command + SubString(chars, v, v+1)
            endif
            set i = i + 1
        endloop
    endfunction
endlibrary
Attached Images
File Type: png HCL.png (7.2 KB, 1099 views)
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 10-13-2009 at 02:44 PM.
Strilanc is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 09-04-2009, 11:47 AM   #2
Hans_Maulwurf
root bloody root
 
Hans_Maulwurf's Avatar
 
Join Date: Mar 2007
Posts: 117

Hans_Maulwurf will become famous soon enough (52)Hans_Maulwurf will become famous soon enough (52)

Send a message via ICQ to Hans_Maulwurf
Default

Why isn't this approved yet? Every map with different modes should support this. The next Dota version will be the first famous map to do so.
__________________

Suit up! Tonight is gonna be legen... wait for it... DARY!
Hans_Maulwurf is offline   Reply With Quote
Old 09-04-2009, 02:24 PM   #3
darkwulfv
Alpha Male of Wc3c
 
darkwulfv's Avatar


Official Map Reviewer
 
Join Date: Mar 2006
Posts: 3,646

Submissions (6)

darkwulfv is just really nice (270)darkwulfv is just really nice (270)

Send a message via AIM to darkwulfv
Default

Probably because a lot of people have no way to truly test it, eg: No bot, map doesn't have modes, etc.

Also, what if a mode is something like -emardaelbaejgfadoobedooda? (DotA, anyone?), but only one character per player? How does that work then? (Do you use multiple players to piece the string together?
__________________
The Spell Request Thread
Quote:
Originally Posted by Joe-Black-5
a dota like map but with unique stuff
(There was no map attached, and that was all the thread said.)
Spells I've Made

Darkwulfv's Lightning Grapple || Tritanis' Lazy Bolt


Last edited by darkwulfv : 09-04-2009 at 02:26 PM.
darkwulfv is offline   Reply With Quote
Old 09-04-2009, 04:16 PM   #4
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

It means that if your game is only going to have two players players, you can only enter an extremely small mode (2 characters). Dota will be able to put in 10 in standard games. The limitations are there because this is the only way we've managed to get any input into the game from the bot without introducing fake players or technically desyncing someone.

The shortness means you probably shouldn't just use the same long commands as inside your map. In power towers I abbreviated every command into a character and use that (there's also a way to see and use them in game instead of normal commands). eg. --nm is -noob -lastman. The HCL string doesn't even need the --.
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 09-04-2009 at 04:17 PM.
Strilanc is offline   Reply With Quote
Old 09-05-2009, 03:40 AM   #5
nichts
User
 
Join Date: Nov 2006
Posts: 40

nichts has little to show at this moment (4)

Default

well after all you don't have to use codes that make "sense" ingame (e.g. you can just give any possible gamemode combination a number encode it into that charset and pass it to the map this way there would be a limit of a wooping 41^12 (22 563 490 300 366 184 000) (for 12 players) possible gamemode combinations)

i don't think anybody will ever realy use that much (well bill gates said that too - so whatever) but for just passing gamemodes 2 players should be more than enough (41^2 => 1 681 diffrent settings)
nichts is offline   Reply With Quote
Old 09-05-2009, 01:54 PM   #6
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,375

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

This doesn't really have any usefulness on its own. It requires a bot to be useful. Therefore I think it should probably be in with the bot's thread in the tools section, maybe, rather than the scripts section? I'm not sure.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 09-05-2009, 07:42 PM   #7
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Quote:
Originally Posted by nichts
well after all you don't have to use codes that make "sense" ingame (e.g. you can just give any possible gamemode combination a number encode it into that charset and pass it to the map this way there would be a limit of a wooping 41^12 (22 563 490 300 366 184 000) (for 12 players) possible gamemode combinations)

i don't think anybody will ever realy use that much (well bill gates said that too - so whatever) but for just passing gamemodes 2 players should be more than enough (41^2 => 1 681 diffrent settings)

That sounds like a lot, except that the possible number of mode combinations is also huge. Plus there is inefficiency due to usability requirements. The player has to specify the mode, because the bot doesn't know how the map interprets modes. If you just number the possibles modes, you end up with crazy commands like " f-e=,," that players can't remember.

Quote:
Originally Posted by Captain Griffen
This doesn't really have any usefulness on its own. It requires a bot to be useful. Therefore I think it should probably be in with the bot's thread in the tools section, maybe, rather than the scripts section? I'm not sure.

Chances are one of your players uses a hosting bot. It doesn't belong in my bot's thread because this system is not specific to my bot. GHost uses it.
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 09-05-2009 at 07:44 PM.
Strilanc is offline   Reply With Quote
Old 09-13-2009, 11:42 AM   #8
TKF
User
 
TKF's Avatar
 
Join Date: Dec 2006
Posts: 384

TKF is on a distinguished road (10)

Default

Battle Tanks does also support this system now.
__________________
Retired
TKF is offline   Reply With Quote
Old 09-15-2009, 02:20 AM   #9
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

v1.01
- Fixed a potential rounding issue when reading the handicap
- Fixed a floating point precision issue when assigning the handicap
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 10-12-2009, 09:04 PM   #10
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Whatever. This isn't a script in the sense that it can just be shoved into a map's code and have it be happy. Because it can be used by many different bots, though, it can't just go in your bot's page.

I do see it as being useful, though. I am going to approve this as a Sample, because of how much an oddball it is and that it doesn't really fit anywhere else.

EDIT:
Do me a favor and attach a screenshot or something of the BNet lobby or something, since this will be in Samples. I'll approve it when you do so.
__________________

Last edited by Rising_Dusk : 10-12-2009 at 09:06 PM.
Rising_Dusk is offline   Reply With Quote
Old 10-13-2009, 08:32 AM   #11
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Am I the only one who thinks this is kind of useless? There already is a banlist, and I highly doubt this is a good idea at all.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 10-13-2009, 02:43 PM   #12
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Quote:
Originally Posted by Anachron
Am I the only one who thinks this is kind of useless? There already is a banlist, and I highly doubt this is a good idea at all.

I'm having a hard time formulating a reply to your question. I can't figure out what you must think this system does, or what you must think banlist does.

Quote:
Originally Posted by Rising_Dusk
EDIT:
Do me a favor and attach a screenshot or something of the BNet lobby or something, since this will be in Samples. I'll approve it when you do so.

I'll attach an icon.
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 10-13-2009, 02:55 PM   #13
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Quote:
This library allows the bot to communicate with your map by encoding characters into players' handicaps (idea by Varlock). Warcraft 3 normally only allows 6 possible handicaps, but bots can specify 256 different values. By encoding the original handicap inside the larger handicap, and only performing the encoding just before the map starts, players don't even realize their handicap was temporarily mutilated.
I guess this is what you meant, and I highly doubt someone needs this,.. as most don't have bots.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 10-13-2009, 03:01 PM   #14
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

You'd be surprised at how extensive a segment of the community uses GHost or other bots adhering to this standard.

Approved.
__________________
Rising_Dusk is offline   Reply With Quote
Old 10-13-2009, 03:12 PM   #15
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Hmm,.. Seems like that. Never found out whats so good at having stuff like GHost,.. but it seems like its used nowadays.

I guess I will have to check it out, so I am getting to know what this really does.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 06:43 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services