HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

HCL code vjass -> jass

02-03-2010, 03:39 AM#1
Gorman
is it possible to "translate" the HCL code into normal jass instead of vjass?
02-03-2010, 04:02 AM#2
thelifelessone
What is HCL?
02-03-2010, 04:16 AM#3
Ammorth
http://www.wc3c.net/showthread.php?t=106854

Compile it with vJass and then modify variables and some of the functions so they work in Jass. Thats how I created the Jass version of Multibars.
02-03-2010, 05:13 AM#4
Gorman
A friend tried to translate it to JASS but it didnt work, here is the code that came out of the translation attempt

code

Code:
///////////////////////////////////////////
/// 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:
    
    //Requires you to create 1 global variable:
    //Name: HCL__command    Type: string
    
    function HCL_GetCommandString takes nothing returns string
        return udg_HCL__command
    endfunction
    
    function InitTrig_HCL 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
        set udg_HCL__command = ""
        

        //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 udg_HCL__command = udg_HCL__command + SubString(chars , v , v + 1)
            endif
            set i = i + 1
        endloop
    endfunction

//library HCL ends



Doesnt work :3

Any help appreciated n_n
02-03-2010, 06:35 AM#5
Ammorth
Assuming Strilanc doesn't have a problem, I will wip something up.

Here you go. If any issues arise, I will take this down immediately.

Collapse JASS:
// !! THIS IS NOT AN OFFICAL COPY OF HCL !!
//
// This is an unoffical port of HCL by Strilanc, to Jass.
// This is ported from v1.01
// The official HCL library can be found here:
// [url]http://www.wc3c.net/showthread.php?t=106854[/url]
//
// !! THIS IS NOT AN OFFICAL COPY OF HCL !!


///////////////////////////////////////////
/// 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.
///////////////////////////////////////////

// Setup:  1) Copy this script to the custom script section of your map.
//         2) Create a string variable called HCL_command with initial value "" (empty string)
//         3) Create a trigger on Map Initialization that has the following action:
//            Custom Script:  call HCL_init()
//         4) You can now get the string either through the HCL_command variable created
//            or through HCL_GetCommandString()
    
    function HCL_GetCommandString takes nothing returns string
        return udg_HCL_command
    endfunction
    
    function HCL_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 udg_HCL_command = udg_HCL_command + SubString(chars, v, v + 1)
            endif
            set i=i + 1
        endloop
    endfunction
    
// !! THIS IS NOT AN OFFICAL COPY OF HCL !!
//
// This is an unoffical port of HCL by Strilanc, to Jass.
// This is ported from v1.01
// The official HCL library can be found here:
// [url]http://www.wc3c.net/showthread.php?t=106854[/url]
//
// !! THIS IS NOT AN OFFICAL COPY OF HCL !!
02-03-2010, 07:00 AM#6
DioD
there is no reason to post anything from vjass zinc or cjass to jass.

if you want to inject code into protected map it much more better to compile and inject compiled code.
02-04-2010, 04:42 AM#7
Gorman
Thanks a lot Ammorth! Very helpful

Quote:
Originally Posted by DioD
there is no reason to post anything from vjass zinc or cjass to jass.

if you want to inject code into protected map it much more better to compile and inject compiled code.
Well that is neither here nor there, just because you prefer to work in vjass, zinc or cjass (and a lot of people do), doesnt mean everyone does.
I'm not sure how you thought this comment would be helpful...
02-04-2010, 01:43 PM#8
Anitarf
Quote:
Originally Posted by Gorman
Well that is neither here nor there, just because you prefer to work in vjass, zinc or cjass (and a lot of people do), doesnt mean everyone does.
You can easily call vJass functions from regular JASS so this is irrelevant. HCL being written in vJass is not preventing you from writing your own code in JASS.
02-04-2010, 04:51 PM#9
Gorman
Ah... just pull this discussion past its lifetime, who cares if the issue is resolved ey?

Well if I am not mistaken then to use vJass for the HCL then I would have to implement it etc using JNPG right?
Which is something I don't use. (for various reasons)

inb4 you flame me.
02-04-2010, 09:33 PM#10
Deaod
Let me phrase it this way: If you think you can only use vJass through JNGP, youre mistaken. If its a problem that you have with JassHelper, then i could understand it, but JassHelper (thus vJass and ZINC) can be used without JNGP (via imports). It can even be used on a Mac or a PC running a Linux distro with WINE.