Snippet Hostbot Command Library (HCL) support

Nat4ku

New Member
Reaction score
0
Hostbot Command Library
or HCL

Introduction

Hostbot Command Library is a system on hostbots, that allow the bot to interract directly with the map triggers during the load time.
HCL can be used to set game modes, without having to enter them when game starts, it's usefull if you want to autohost a game with a particular game mode.

So bot owner just have to define HCL in the lobby or to put a variable into the map configuration file ["map_defaulthcl = <something>" in your map config file.]

In facts, to interract with the map, the HCL system changes the players handicap, before the game starts and restore default handicap once the map finished loading.
The problem is if you use HCL on a map that dont have any trigger to read the HCL code and restore default handicap, the healthpoints of players will be changed.

I found only one tutorial about HCL there but it requieres a tool : NewGen editor and that tool do not works for me.
So i have just edited Strilanc vJass trigger to make it works directly in worldedit, like this, everyone can use it easely, without any requierements.

Code
Okay first open worldeditor, go to triggers
triggereditor.png
, create a new trigger and rename it "ReadHCL".
Select it, go to edit and convert it into custom text.
Then add that code :
JASS:
function Trig_ReadHCL_Actions takes nothing returns nothing

 // This is allowed characters in the HCL code
    set udg_chars = &quot;abcdefghijklmnopqrstuvwxyz0123456789 -=,.&quot;
 // There, handicap values that u can choose in warcraft 3 lobby are blocked
    set udg_blocked[0] = true
    set udg_blocked[50] = true
    set udg_blocked[60] = true
    set udg_blocked[70] = true
    set udg_blocked[80] = true
    set udg_blocked[90] = true
    set udg_blocked[100] = true
    set udg_i = 0
    set udg_j = 0
    loop
      if udg_blocked[udg_j] then
        set udg_j = udg_j + 1
      endif
      exitwhen udg_j &gt;= 256
      set udg_map[udg_j] = udg_i
      set udg_i = udg_i + 1
      set udg_j = udg_j + 1
    endloop
    
    //There we extract the HCL string and he is stored into the variable &quot;command&quot;
    set udg_i = 0
    loop
      exitwhen udg_i &gt;= 12
      set udg_h = R2I(100*GetPlayerHandicap(Player(udg_i)))
      if not udg_blocked[udg_h] then
        set udg_h = udg_map[udg_h]
        set udg_v = udg_h/6
        set udg_h = udg_h-udg_v*6
        call SetPlayerHandicap(Player(udg_i), udg_h*0.11 + 0.55)
        set udg_command = udg_command + SubString(udg_chars, udg_v, udg_v + 1)
      endif
      set udg_i = udg_i + 1
    endloop
endfunction

// Map initialisation event
function InitTrig_ReadHCL takes nothing returns nothing
    set gg_trg_ReadHCL = CreateTrigger(  )
    call TriggerAddAction( gg_trg_ReadHCL, function Trig_ReadHCL_Actions )
endfunction


Ok now all that you need is to make variables, go to variables editor :
variableseditor.png
and add the following variables :
- <name> <type> <array>
- blocked boolean 256
- chars string
- command string
- h integer
- i integer
- j integer
- map integer 256
- v integer

All those variables are without initial value.

Ok just make a guy trigger and make him read the variable "command" to get the HCL string and to do whatever you want with it.

Just a little thing : in lobby 1 player = 1 HCL string (computers count also 1 string), anyway if you put too long HCL ghost will warn you with the following message : "The HCL command string is too long. Use 'force' to start anyway"

Credits
- Strilanc for the original HCL trigger,
- GhostOne readme.txt, "The HCL (HostBot Command Library) Standard" section

I added a test map, just host it with a hostbot, get in and add a computer (or !fakeplayer) and put a HCL, type -hcl to show it ingame.

View attachment HCL support.w3x
 

Hatebreeder

So many apples
Reaction score
381
All that math inbetween makes no sence to me, hence the large array sizes. Would you mind explaining?

Besides, I'm not sure if hostbots or bots in general are permitted here, or "support" for those.
Anyways, this library or Snipplet or w/e this is, enables bot commands in-game?

Also, this code is just copy + paste. But instead of the use of local variables, you used globals. Since it's not your own code, is it even aprovable?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top