C/C++ 学习日记4:反恐精英(单机)的敌我阵营遍历器 源码

此处省去过程,直接上代码

#include "GameCheater.h"// 自己写个封装函数库,供自己调用
#include <stdio.h>
#include <stdlib.h>

// 人物属性结构体
struct Character{
    long float blood;  //  血
    long float x, y , z ;  //  三维坐标
    long float AC;  //  护甲
};

// 遍历敌我阵营所有人的偏移  同时遍历出他们的坐标。返回偏移数组
DWORD* EnemyAddress(HANDLE PID)
{
    DWORD ePass = 0x1B250000;  // amxmodx_mm.dll 模块地址
    DWORD ePasser = 0x97000;  //  偏移
    DWORD Add; // 计算地址
    DWORD AddPress;  // 返回地址
    DWORD AddPress2[30];
    Character my;
    int i=0;

    while (ePasser <= 0x99FFF) {
        Add = ePass + ePasser;

        ReadProcessMemory(PID, LPVOID(Add), &AddPress, sizeof(DWORD),NULL);
        ReadProcessMemory(PID, LPVOID(AddPress + 0x7c), &AddPress, sizeof(DWORD), NULL);
        ReadProcessMemory(PID, LPVOID(AddPress + 0x04), &AddPress, sizeof(DWORD), NULL);

        my.x = nc_dxsx(PID, LPVOID(AddPress + 0x8));
        my.y = nc_dxsx(PID, LPVOID(AddPress + 0xC));
        my.z = nc_dxsx(PID, LPVOID(AddPress + 0x10));
        my.blood = nc_dxsx(PID, LPVOID(AddPress + 0x160));
        my.AC = nc_dxsx(PID, LPVOID(AddPress + 0x160 + 0x5C));

        if (my.blood == 100) {
            AddPress2[ i ] = ePasser;
            printf("Ace提示    报告Boss,已找到地址:%X\n", AddPress2[i]);
            i += 1;
        }
        ePasser += 0x01;
    }
    return AddPress2;
}

int main()
{
    HANDLE PID;

    PID=GetProcessID2(_T("hl.exe"));// 封装函数库里的

    EnemyAddress(PID);

    system("pause");
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以回答你的问题。以下是一个使用 switch 语句实现猜拳游戏的 C++ 代码: ```c++ #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int playerChoice; int computerChoice; // 生成随机数种子 srand(time(0)); // 让玩家输入选择(1:石头,2:剪刀,3:布) cout << "请出拳(1:石头,2:剪刀,3:布):" << endl; cin >> playerChoice; // 生成计算机的选择(1-石头,2-剪刀,3-布) computerChoice = rand() % 3 + 1; // 根据玩家和计算机的选择确定胜负 switch (playerChoice) { case 1: // 玩家出石头 if (computerChoice == 1) { cout << "平局!" << endl; } else if (computerChoice == 2) { cout << "你赢了!" << endl; } else { cout << "你输了!" << endl; } break; case 2: // 玩家出剪刀 if (computerChoice == 1) { cout << "你输了!" << endl; } else if (computerChoice == 2) { cout << "平局!" << endl; } else { cout << "你赢了!" << endl; } break; case 3: // 玩家出布 if (computerChoice == 1) { cout << "你赢了!" << endl; } else if (computerChoice == 2) { cout << "你输了!" << endl; } else { cout << "平局!" << endl; } break; default: cout << "选择无效!" << endl; break; } return 0; } ``` 这段代码首先让玩家输入选择(1:石头,2:剪刀,3:布),然后生成计算机的选择。接着使用 switch 语句判断玩家和计算机的选择,输出对应的胜负结果。注意,这里使用了 srand 函数来生成随机数种子,以保证每次运行程序生成的随机数不同。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值