Results 1 to 8 of 8

Thread: What have you been up to?

  1. #1
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts

    What have you been up to?

    Anybody still modding for CoD2?
    set logfile 2

  2. #2
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 Posts
    Yes. 0123456789
    sudo apt-get rekt

  3. #3
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    +1 987654321

  4. #4
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    Zombies? Jumping?
    set logfile 2

  5. #5
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 Posts
    DeathRun...
    sudo apt-get rekt

  6. The Following User Says Thank You to voron00 For This Useful Post:

    guiismiti (23rd March 2017)

  7. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,725
    Thanks
    17
    Thanked 1,080 Times in 682 Posts
    codjumper modding.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  8. The Following User Says Thank You to IzNoGoD For This Useful Post:

    guiismiti (23rd March 2017)

  9. #7
    Private Lonsofore's Avatar
    Join Date
    Oct 2016
    Posts
    86
    Thanks
    82
    Thanked 38 Times in 25 Posts
    tdm, dm, ctf, hq, htf on the one server
    Last edited by Lonsofore; 21st March 2017 at 01:44.

  10. The Following User Says Thank You to Lonsofore For This Useful Post:

    guiismiti (23rd March 2017)

  11. #8
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,014
    Thanks
    2,110
    Thanked 1,086 Times in 753 Posts
    In the last days I've reimplemented the CoDScript style "threads" (coroutines) inside JavaScript/Duktape. As test engine I use ET:Legacy, because that's like CoD 0.5, lol.

    In the grand scheme, I wanna reimplement CoDScript as a whole and add JavaScript even on the client side, so it's possible to script the clients as server admin at runtime. And since ET has Quake3 heritage, the Quake Virtual Machine is available aswell... endless possibilities, I feel like in the beginning days of CoD2 scripting.

    All the JavaScript code I've put together in last days, it's the basemod "algorithm" to move brushes:

    PHP Code:
    // MIT License, have fun

    function sprintf() {
        var 
    ret "";
        var 
    param 1// maps to first %
        
    var msg arguments[0];
        for (var 
    i=0i<msg.lengthi++) {
            if (
    msg[i] == "%") {
                
    // %% will be printed as normal %
                
    if (msg[i+1] == "%") {
                    
    ret += "%";
                    
    i++;
                } else
                    
    ret += arguments[param++];
            } else {
                
    ret += msg[i];
            }
        }
        return 
    ret;
    }

    function 
    printf() {
        var 
    ret "";
        var 
    param 1// maps to first %
        
    var msg arguments[0];
        for (var 
    i=0i<msg.lengthi++) {
            if (
    msg[i] == "%") {
                
    // %% will be printed as normal %
                
    if (msg[i+1] == "%") {
                    
    ret += "%";
                    
    i++;
                } else
                    
    ret += arguments[param++];
            } else {
                
    ret += msg[i];
            }
        }
        
    log(ret);
        return 
    ret.length;
    }

    function require(
    filename) {
        var 
    content file_get_contentsfilename );
        try {
            eval.
    bindget_global() )(content);
        } catch (
    e) {
            
    printf("require(%): error %\n"filenamee.stack);
        }
    }


    if (
    typeof date_start == "undefined")
        
    date_start Date.now();
    // time since loading this file for first time
    function now() {
        return 
    Date.now() - date_start;
    }

    print = function() {
        for (var 
    i=0i<arguments.lengthi++) {
            
    log(arguments[i]);
        }
    }

    function 
    var_dump(ret) {
        switch (
    typeof ret) {
            case 
    "number": {
                print(
    "ret = "ret";");
                break;
            }
            case 
    "string": {
                print(
    "ret = \""ret"\";");
                break;
            }
            case 
    "function": {
                
    // print infos like byte codes or length of byte codes
                
    print("Function: "ret);
                break;
            }
            case 
    "boolean": {
                print(
    "ret = "ret";");
                break;
            }
            case 
    "object": {
                if (
    ret.constructor.name == "Array") {
                    
                    print(
    "ret = [\n");
                    for (var 
    i=0i<ret.lengthi++) {
                        if (
    typeof ret[i] == "object")
                            
    printf("\t%: % {...},\n"iret[i].constructor.name);
                        else
                            
    printf("\t%: %,\n"iret[i]);
                    }
                    print(
    "];\n");
                }
                
                
    // An array still can have properties, so print them aswell:
                
    {
                    
    printf("% {\n"ret.constructor.name);
                    for (var 
    i in ret) {
                        if (
    typeof ret[i] == "object")
                            
    printf("\t%: % {...},\n"iret[i].constructor.name);
                        else
                            
    printf("\t%: %,\n"iret[i]);
                    }
                    print(
    "};\n");
                }
                break;
            }
            case 
    "undefined": {
                
    // print infos like byte codes or length of byte codes
                
    print("undefined;");
                break;
            }
            default:
                print(
    "Unhandled type: "typeof ret);
        }
        
    }

    handle_input = function(code, global) {
        try {
            var 
    ret = eval.bind(global)(code); 
            
            
    log("> ");
            
    var_dump(ret);
            
    log("\n");
            
        } catch (
    e) {
            print(
    "handle_input> error: "e.stack"\n");
        }
        
        
    //repl_settext("asdddd");
    }


    //global = get_global();
    //printf("Global: %", global);
    //var_dump(global);

    consolecommand = function() {
        var 
    args getargs();
        var 
    cmdline "";
        for (var 
    i=1i<args.lengthi++)
            
    cmdline += args[i] + " ";
        
    //printf("cmdline: %\n", cmdline);
        
    handle_input(cmdlineget_global());
    }

    //function ThreadState()
    function wait(time)         { Duktape.Thread.yield( ["wait",            time 1000] ); }
    function 
    waittillframeend() { Duktape.Thread.yield( ["waittillframeend"            ] ); }
    function 
    waittill(what)     { Duktape.Thread.yield( ["waittill",        what       ] ); }
    if (
    typeof level == "undefined") {
        
    level = {};
        
    level.time 0;
    }

    function 
    Entity(id) {
      
    this.id id;
      
    this.threads = [];
      
    this.thread = function(func) {
        var 
    self this;
        return function() {
          var 
    = new Duktape.Thread(function(args) {
            
    func.bind(self)(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
            
    //func.apply(self, arguments) // waiting for: https://github.com/svaarala/duktape/issues/1420
          
    });
          
    t.nextrun level.time;
          
    t.parameters arguments;
          
    self.threads.push(t)
        }
      }

      
    this.runframe = function() {
        
    // iterate backwards over it, so we can delete finished threads instantly via ID
        
    for (var i=this.threads.length-1i>=0i--) {
          var 
    thread this.threads[i];

          var 
    state Duktape.info(thread);
          
    //printf("entid=% threadid=% state=%,%\n", this.id, i, state[0], state[1]);

          
    if (thread.nextrun level.time) {
            
    //printf("entid=% threadid=%> No run yet: nextrun in %\n", this.id, i, thread.nextrun - level.time)
            
    continue;
          }
          try {
            var 
    whatnow Duktape.Thread.resume(threadthread.parameters);

            var 
    state Duktape.info(thread);
            
    //printf("AFTER RESUME: entid=% threadid=% state=%,%\n", this.id, i, state[0], state[1]);

            
    switch (whatnow[0]) {
              case 
    "wait"thread.nextrun += whatnow[1];  break;
            }
            
    //printf("whatnow: %\n", whatnow);
          
    } catch (e) {
            
    this.threads.splice(i1); // delete thread from array
            //printf("Entity::runframe> Finished Thread id=% entityid=% level.time=%\n", i, this.id, level.time);

          
    }
        }
      }
      
      
    this.useButtonPressed    = function()       { return entity_usebuttonpressed   (this.id);                                  }
      
    this.sprintButtonPressed = function()       { return entity_sprintbuttonpressed(this.id);                                  }
      
    this.attackButtonPressed = function()       { return entity_attackbuttonpressed(this.id);                                  }
      
    this.getEye              = function()       { return entity_get_eye            (this.id);                                  }
      
    this.getOrigin           = function()       { return entity_get_origin         (this.id);                                  }
      
    this.setOrigin           = function(origin) { return entity_set_origin         (this.idorigin[0], origin[1], origin[2]); }
      
    this.getForward          = function()       { return entity_get_forward        (this.id);                                  }
      
    this.getClassname        = function()       { return entity_get_classname      (this.id);                                  }
    }

    function 
    vec3_new() {
        return new 
    Float32Array(3);
    }
    function 
    vec3_scale(vecscalaroutput) {
        
    output[0] = vec[0] * scalar;
        
    output[1] = vec[1] * scalar;
        
    output[2] = vec[2] * scalar;
    }
    function 
    vec3_copy(from_to) {
        
    to[0] = from_[0];
        
    to[1] = from_[1];
        
    to[2] = from_[2];
    }
    function 
    vec3_add(abc) {
        
    c[0] = a[0] + b[0];
        
    c[1] = a[1] + b[1];
        
    c[2] = a[2] + b[2];
    }
    function 
    vec3_sub(abret) {
      
    ret[0] = a[0] - b[0];
      
    ret[1] = a[1] - b[1];
      
    ret[2] = a[2] - b[2];
    }
    function 
    vec3_length(a) {
      return 
    Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
    }
    function 
    vec3_distance(ab) {
      var 
    delta vec3_new();
      
    vec3_sub(badelta);
      return 
    vec3_length(delta);
    }

    function 
    bullettrace(fromtohit_playersentity_to_ignore) {
        var 
    tmp trace(from[0], from[1], from[2], to[0], to[1], to[2], entity_to_ignore.id);
        return {
            
    positiontmp.endpos,
            
    fractiontmp.fraction,
            
    entity: new Entity(tmp.entityNum)
        }
    }

    doshit = function(abc) {
        try {
        
    wait(0.10);
        
    printf("Second print, id=%\n"this.id);
        
    printf("THIS THIS this is %\n"this.id)
        
    wait(0.15);
        
        
        var 
    nadeid spawngrenade();
        var 
    nade = new Entity(nadeid);
        
        var 
    brush_distance 1024;
        var 
    brush_selected 0;
        var 
    grenade_oldpos vec3_new();
        var 
    brush_oldpos vec3_new();
        var 
    brush_moving undefined;
        while (
    1) {
            
    //printf("this.id====%\n", this.id);
            
            
    if ( ! this.attackButtonPressed()) {
                
    brush_selected 0;            
            }
            
            if (
    brush_selected) {
                var 
    change 15;
                if (
    brush_distance 150change 20;
                if (
    brush_distance 300change 40;
                if (
    brush_distance 600change 60;
                if (
    this.sprintButtonPressed()) brush_distance += change;
                if (
    this.useButtonPressed()   ) brush_distance -= change;
                
                var 
    pos this.getEye();
                var 
    forward this.getForward();
                var 
    newnadepos vec3_new();
                
                
                
                
    vec3_copy(posnewnadepos);
                
    vec3_scale(forwardbrush_distanceforward);
                
    vec3_add(newnadeposforwardnewnadepos);
                
                
    nade.setOrigin(newnadepos);
                
                
                var 
    delta_grenade vec3_new();
                
    // a - b = c
                
    vec3_sub(newnadeposgrenade_oldposdelta_grenade);

                var 
    finalpos vec3_new();
                
    vec3_add(brush_oldposdelta_grenadefinalpos);

                
                
    brush_moving.setOrigin(finalpos);
                if (
    1) {
                    
    //moveto(brush_moving, finalpos, 150);
                
    }
                
            } else if (
    this.attackButtonPressed()) {
                
                var 
    pos this.getEye();
                var 
    forward this.getForward();
                
                var 
    newpos vec3_new();
                
                
                
                
    vec3_copy(posnewpos);
                
    vec3_scale(forward1024forward); // scale forward by 1024
                
    vec3_add(newposforwardnewpos);
                
                
                var 
    tmp bullettrace(posnewpos"useless"nade);
                
                
                if (
    tmp["fraction"] != 0) {
                    
                
                    
    //var_dump(pos);
                    
    printf("classname: %\n"tmp["entity"].getClassname());
                    
    //nade.setOrigin(tmp["position"]);
                    
                    
    if (tmp["entity"].getClassname() == "func_plat") {
                        
    brush_selected 1;
                        
    brush_distance vec3_distance(postmp["position"]);
                        
    vec3_copy(tmp["position"], grenade_oldpos);
                        
    vec3_copy(tmp["entity"].getOrigin(), brush_oldpos);
                        
    brush_moving tmp["entity"];
                    }
                    
                    
    //printf("asd: % asd[0]=%\n", asd, asd[0]);
                
    }
            }
            
            
    wait(0.05);
        }
        } catch (
    e) {
            
    printf("Error: % %\n"ee.stack);
            
        }
    }

    function 
    callback_runframe(levelTime) {
        
    runframe();
        
    }

    function 
    runframe() {
      for (var 
    i=0i</*entities.length*/1024i++) {
        if (
    entities[i] != undefined)
          
    entities[i].runframe()
      }
      
    level.time += 50;
    }

    //e1 = new Entity(1)
    //e2 = new Entity(2)
    //e3 = new Entity(3)
    //entities = [e1, e2, e3]
    //
    //e1.thread(doshit)
    //e2.thread(doshit)
    ////Duktape.info(e1.threads[1])
    ////Duktape.Thread.current()
    //runframe()
    //runframe()
    //runframe()
    //runframe()
    //runframe()
    //runframe()
    //runframe()
    //runframe()
    //runframe()
    //runframe()



    if (typeof entities == "undefined")
        
    entities = Array(1024);

    function 
    callback_clientconnected(clientNum) {
        
        
    entities[clientNum] = new Entity(clientNum);
        var 
    ent entities[clientNum];
        
        
    ent.thread(doshit)(1,22,333);
        
        
    printf("Client connected: %\n"clientNum);
    }



    print(
    "lib.js loaded\n"); 
    Pretty awesome how powerful Duktape/JavaScript is. Comparing this JavaScript Entity class to CoDScript:

    PHP Code:
        ent.thread(doshit)(1,22,333); // js
        
    ent thread doshit (1,22,333); // codscript 
    And best of all, it's all open source and highly extendable/hackable.
    timescale 0.01

  12. The Following 2 Users Say Thank You to kung foo man For This Useful Post:

    guiismiti (23rd March 2017),kubislav23 (22nd March 2017)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •