H5画布+websocket实现csgo云雷达

nodejs (nodejs10.5.0 模块ws6.1.4)

//apt-get install -y nodejs
//apt-get install -y npm
//npm install -g n
//n 10.5.0
//npm init
//npm install ws@6.1.4
//node ws.js


var server = require('ws').Server;
var ws = new server({
    port:9998
});
var connNum = [];
ws.on("connection",function(socket){
    connNum.push(socket);
    console.log("连接了"+connNum.length);
    socket.on("message",function(msg){
        for (var i = 0; i < connNum.length; i++) {
            connNum[i].send(msg);
        }
    })
    socket.on("close",function(){
        connNum.splice(connNum.indexOf(this),1);
    })
})

html jquery-3.3.1


<!DOCTYPE html>
<html>
    <head>
          <title>Cloud Radar</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta charset="UTF-8">
        <script src="jquery-3.3.1.min.js">
        </script>
        <style type="text/css">
            body,div{margin: 0; padding: 0;} #myCanvas{margin:0;};
        </style>
    </head>
    <body>
        <div>
            <select id="myselect">
                <option style='display: none'>
                </option>
                <option value="dust2">
                    dust2
                </option>
                <option value="mirage">
                    mirage
                </option>
                <option value="info">
                    info
                </option>
                <option value="cache">
                    cache
                </option>
                <option value="overpass">
                    overpass
                </option>
                <option value="train">
                    train
                </option>
            </select>
            </br>
            <canvas id="myCanvas" width="816" height="816">
            </canvas>
            <img src="" id="img" style="display:none" />
        </div>
        <!-- <button onclick="flusha()">test</button> -->
        <div id="msg">
        </div>
    </body>
    <script type="text/javascript">
        var opt = $("#myselect").val();
        $(document).ready(function() {
              if($(window).width()>$(window).height()){
              $("#myCanvas").width($(window).height());  
              $("#myCanvas").height($(window).height());
            }else{
              $("#myCanvas").width($(window).width());  
              $("#myCanvas").height($(window).width());
            }
            
            $("#myselect").find("option:contains(" + getUrlParam() + ")").attr("selected", true);
            setmap();
        });  
        function getUrlParam() {
            var reg = new RegExp("(^|&)" + "map" + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null){
                  $("#msg").hide();
                  $("#myselect").hide();
                return unescape(r[2]);
            }else{
                return null;
            }
        }

        /*
                绘制图片
                图片预加载,获取图片文件
                onload中调用
                drawImage(img,x,y,w,h);绘制图片(图片,坐标x,坐标y,宽度,高度)
            */
        var can = document.getElementById("myCanvas");
        var cxt = can.getContext("2d");
        var imgs = new Image();
        $("#myselect").change(function() {
            setmap();
        });
        function setmap() {
            opt = $("#myselect").val();
            imgs.src = "map/" + opt + ".jpg";
            imgs.onload = drawImg; //图片加载完成再执行
        }
        function drawImg() {
            cxt.drawImage(imgs, 0, 0, can.width, can.height);
            cxt.fillStyle = "#FF0000";
            cxt.beginPath();
            cxt.arc(10, 28, 5, 22, Math.PI * 2, true);
            cxt.closePath();
            cxt.fill();
        }

        function getTemp_XY(X, Y) {
            var temp_xy = new Array();
            if (opt == "dust2") {
                temp_xy[0] = X / 15.8 + 74;
                temp_xy[1] = Y / 14.8 + 150;
            } else if (opt == "mirage") {
                temp_xy[0] = X / 13.3 + 202;
                temp_xy[1] = Y / 15.5 + 175;
            } else if (opt == "info") {
                temp_xy[0] = X / 16.5 + 51;
                temp_xy[1] = Y / 16.5 + 107;
            } else if (opt == "cache") {
                temp_xy[0] = X / 14 + 106;
                temp_xy[1] = Y / 19 + 98;
            } else if (opt == "overpass") {
                temp_xy[0] = X / 19 + 184;
                temp_xy[1] = Y / 15 + 268;
            } else if (opt == "train") {
                temp_xy[0] = X / 13.2 + 137;
                temp_xy[1] = Y / 14 + 126;
            }
            temp_xy[0] = temp_xy[0] * 3;
            temp_xy[1] = temp_xy[1] * 3;
            return temp_xy;
        }

        function flusha() {

            var json = eval('(' + json_ + ')');
            cxt.drawImage(imgs, 0, 0, can.width, can.height);
            var json_length=json.length;
            var metct = json[json_length-1].tct;
         
            cxt.fillStyle = "#00ec00";
            cxt.beginPath();
            var mos = parseFloat(json[json_length-1].mos);
            mos = mos / (180 / Math.PI);
            var temp_XY_I = getTemp_XY(parseFloat(json[json_length-1].datax), parseFloat(json[json_length-1].datay));
            cxt.arc(temp_XY_I[0], temp_XY_I[1], 35, -mos + Math.PI * 0.25, -mos + Math.PI / 2 + Math.PI * 0.25, false);
            cxt.lineTo(temp_XY_I[0], temp_XY_I[1]);
            cxt.fill();
            cxt.closePath();
            //cxt.fillStyle = 'rgba(192, 80, 77, 0.2)';
            //cxt.beginPath();
            //cxt.arc(temp_XY_I[0], temp_XY_I[1], 150, 0, Math.PI * 2, false);
            //cxt.lineTo(temp_XY_I[0], temp_XY_I[1]);
            //cxt.fill();
            //cxt.closePath();

            for (var i = 0; i < json_length-1; i++) {
                if (json[i].tct != metct) {
                    if (parseFloat(json[i].hp) > 0) {
                        if (json[i].dormant == "0") {
                            var mos = parseFloat(json[i].mos);
                            mos = mos / (180 / Math.PI);
                            cxt.fillStyle = "#FF0000";
                            cxt.beginPath();
                            var opt = $("#myselect").val();
                            var temp_XY_ = getTemp_XY(parseFloat(json[i].datax), parseFloat(json[i].datay));
                            cxt.moveTo(temp_XY_I[0], temp_XY_I[1]);
                            cxt.lineTo(temp_XY_[0], temp_XY_[1]);
                            cxt.strokeStyle = "#FF359A";
                            cxt.stroke();
                            cxt.arc(temp_XY_[0], temp_XY_[1], 35, -mos + Math.PI * 0.25, -mos + Math.PI / 2 + Math.PI * 0.25, false);
                            cxt.lineTo(temp_XY_[0], temp_XY_[1]);
                            cxt.fill();
                            cxt.closePath();
                        } else {
                            var mos = parseFloat(json[i].mos);
                            mos = mos / (180 / Math.PI);
                            cxt.fillStyle = "#FF0000";
                            cxt.beginPath();
                            var opt = $("#myselect").val();
                            var temp_XY_ = getTemp_XY(parseFloat(json[i].datax), parseFloat(json[i].datay));
                            cxt.moveTo(temp_XY_I[0], temp_XY_I[1]);
                            cxt.lineTo(temp_XY_[0], temp_XY_[1]);
                            cxt.strokeStyle = "#FFFFFF";
                            cxt.stroke();
                            cxt.fillStyle = '#FFFF6F';
                              cxt.font = "30px Arial";
                            cxt.fillText("?", temp_XY_[0], temp_XY_[1]);
                            cxt.fill();
                            cxt.closePath();
                        }
                    }
                }
            }

        }

        //flushcxt();
        /**
 0:未连接
1:连接成功,可通讯
2:正在关闭
3:连接已关闭或无法打开
*/

        //创建一个webSocket 实例
        var json_;
        var webSocket = new WebSocket("ws://47.95.8.94:9998");

        webSocket.onerror = function(event) {
            onError(event);
        };

        // 打开websocket
        webSocket.onopen = function(event) {
            onOpen(event);
        };

        //监听消息
        webSocket.onmessage = function(event) {
            onMessage(event);
        };

        webSocket.onclose = function(event) {
            onClose(event);
        }

        //关闭监听websocket
        function onError(event) {
            document.getElementById("msg").innerHTML = "<p>close</p>";
            console.log("error" + event.data);
        };

        function onOpen(event) {
            console.log("open:" + sockState());
            document.getElementById("msg").innerHTML = "<p>Connect to Service</p>";
        };
        function onMessage(event) {
            <!--json_ = decodeURIComponent(event.data);-->
            json_ = decodeURIComponent(event.data);
            //json_ ="{"+json_+"}"
            console.log(json_);
            flusha();
        };

        function onClose(event) {
            document.getElementById("msg").innerHTML = "<p>close</p>";
            console.log("close:" + sockState());
            webSocket.close();
        }

        function sockState() {
            var status = ['未连接', '连接成功,可通讯', '正在关闭', '连接已关闭或无法打开'];
            return status[webSocket.readyState];
        }

        function close(event) {
            webSocket.close();
        }
    </script>

</html>

不知名语言

.版本 2

.子程序 取敌人坐标数据, playerinfo
.参数 个数, 整数型, 可空
.局部变量 playerinfo, playerinfo
.局部变量 指针, 整数型
.局部变量 敌人坐标偏移, 整数型
.局部变量 阵营, 整数型


个数 = 个数 × 16
playerinfo.hp = 读内存整数型 (进程ID, 读内存整数型 (进程ID, 敌人基址 + 个数) + 十六到十 (py血量))  ' 血量
playerinfo.tct = 读内存整数型 (进程ID, 读内存整数型 (进程ID, 敌人基址 + 个数) + 十六到十 (py人物阵营))  ' 人物阵营
playerinfo.Dormant = 读内存整数型 (进程ID, 读内存整数型 (进程ID, 敌人基址 + 个数) + 十六到十 (py人物是否休眠))  ' 人物是否休眠
playerinfo.三维坐标型.x = 读内存小数型 (进程ID, 读内存整数型 (进程ID, 敌人基址 + 个数) + 十六到十 (py坐标x))
playerinfo.三维坐标型.y = 读内存小数型 (进程ID, 读内存整数型 (进程ID, 敌人基址 + 个数) + 十六到十 (py坐标y))
playerinfo.三维坐标型.z = 读内存小数型 (进程ID, 读内存整数型 (进程ID, 敌人基址 + 个数) + 十六到十 (py坐标z))
playerinfo.鼠标坐标.X = 读内存小数型 (进程ID, 读内存整数型 (进程ID, 敌人基址 + 个数) + 十六到十 (py鼠标x轴坐标))

返回 (playerinfo)
.版本 2

.子程序 取自己坐标数据, playerinfo
.局部变量 playerinfo, playerinfo

playerinfo.hp = 读内存整数型 (进程ID, 读内存整数型 (进程ID, 人物基址) + 十六到十 (py血量))  ' 血量
playerinfo.tct = 读内存整数型 (进程ID, 读内存整数型 (进程ID, 人物基址) + 十六到十 (py人物阵营))  ' 人物阵营
playerinfo.Dormant = 读内存整数型 (进程ID, 读内存整数型 (进程ID, 敌人基址) + 十六到十 (py人物是否休眠))  ' 人物是否休眠
playerinfo.三维坐标型.x = 读内存小数型 (进程ID, 读内存整数型 (进程ID, 人物基址) + 十六到十 (py坐标x))
playerinfo.三维坐标型.y = 读内存小数型 (进程ID, 读内存整数型 (进程ID, 人物基址) + 十六到十 (py坐标y))
playerinfo.三维坐标型.z = 读内存小数型 (进程ID, 读内存整数型 (进程ID, 人物基址) + 十六到十 (py坐标z))
playerinfo.鼠标坐标.X = 读内存小数型 (进程ID, 读内存整数型 (进程ID, 人物基址) + 十六到十 (py鼠标x轴坐标))  ' 鼠标x轴坐标
返回 (playerinfo)

.版本 2


人物基址 = 强力返回模块DLL地址 (“client_panorama.dll”, 进程ID) + 十六到十 (“CD2764”)  ' dwLocalPlayer
敌人基址 = 强力返回模块DLL地址 (“client_panorama.dll”, 进程ID) + 十六到十 (“4CE34DC”)  ' dwEntityList


py血量 = “100”  ' 血量
py人物阵营 = “f4”  ' 人物阵营
py人物是否休眠 = “ED”  ' 人物是否休眠
py坐标x = “A4”
py坐标y = “A0”
py坐标z = “A8”
py鼠标x轴坐标 = “130”  ' 鼠标x轴坐标
最后修改:2019 年 04 月 29 日 09 : 53 AM
如果觉得我的文章对你有用,请随意赞赏

发表评论