一段代码

社区服务
高级搜索
猴岛论坛CSGO反恐精英CS作弊器交流讨论一段代码
发帖 回复
倒序阅读 最近浏览的帖子最近浏览的版块
1个回复

一段代码

楼层直达
3kb

ZxID:1275999

等级: 新兵
举报 只看楼主 使用道具 楼主   发表于: 2007-10-02 0
//==================================================
void VectorAngles (const float * forward, float * view)
{
      if(!forward[1]==0 && !forward[0]==0)
      {
      view[0] = (float)((atan2(forward[2],(sqrt(forward[0]*forward[0]+forward[1]*forward[1])))* 57.295779513082320876846364344191f));
      view[1] = (float)((atan2(forward[1],forward[0])* 57.295779513082320876846364344191f));
      view[2] = 0;
      }
}
int Visible(int ax)
{   
    int power = 2;

    float pWall[3];
        pWall[0] = me.pmEyePos[0], pWall[1] = me.pmEyePos[1], pWall[2] = me.pmEyePos[2];
   
    vec3_t vecEnd, up, right, forward, playerAngles;
        playerAngles[0] = 0, playerAngles[1] = vPlayers[ax].getEnt()->angles[1], playerAngles[2] = 0;

    pmtrace_t tr;
    cl_entity_s* ent = vPlayers[ax].getEnt();
        pmtrace_t pmtrace;
        pmtrace_t* tr2 = (pmtrace_t*) &pmtrace;
        gEngfuncs.pfnAngleVectors (playerAngles, forward, right, up);
        gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
        gEngfuncs.pEventAPI->EV_PlayerTrace( me.pmEyePos, vPlayers[ax].getEnt()->origin, PM_GLASS_IGNORE, me.ent->index, &tr );
        tr2->startsolid = true;
   
    forward[2] = -forward[2];

    while (power)
    {
        if( !tr2->startsolid ) power--;
       
        tr2 = gEngfuncs.PM_TraceLine( pWall, vPlayers[ax].getEnt()->origin, PM_TRACELINE_PHYSENTSONLY, 2, -1);
        if( tr2->fraction==1.0f)    return 1;
        if( tr2->allsolid )    return 0;

        switch (vPlayers[ax].getEnt()->curstate.gaitsequence)
        {
                default:
                    pWall[0] = tr2->endpos[0] + (vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - dR)) / (float)sqrt((vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - dR))*(vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - dR))+(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - dF))*(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - dF))+(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - dH))*(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - dH))) * 8.0f;
                    pWall[1] = tr2->endpos[1] + (vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - dF)) / (float)sqrt((vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - dR))*(vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - dR))+(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - dF))*(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - dF))+(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - dH))*(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - dH))) * 8.0f;
                    pWall[2] = tr2->endpos[2] + (vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - dH)) / (float)sqrt((vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - dR))*(vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - dR))+(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - dF))*(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - dF))+(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - dH))*(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - dH))) * 8.0f;
                    break;
                case 6:
                    pWall[0] = tr2->endpos[0] + (vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - jR)) / (float)sqrt((vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - jR))*(vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - jR))+(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - jF))*(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - jF))+(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - jH))*(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - jH))) * 8.0f;
                    pWall[1] = tr2->endpos[1] + (vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - jF)) / (float)sqrt((vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - jR))*(vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - jR))+(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - jF))*(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - jF))+(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - jH))*(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - jH))) * 8.0f;
                    pWall[2] = tr2->endpos[2] + (vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - jH)) / (float)sqrt((vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - jR))*(vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - jR))+(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - jF))*(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - jF))+(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - jH))*(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - jH))) * 8.0f;
                    break;
                case 0:
                    pWall[0] = tr2->endpos[0] + (vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - sR)) / (float)sqrt((vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - sR))*(vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - sR))+(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - sF))*(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - sF))+(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - sH))*(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - sH))) * 8.0f;
                    pWall[1] = tr2->endpos[1] + (vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - sF)) / (float)sqrt((vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - sR))*(vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - sR))+(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - sF))*(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - sF))+(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - sH))*(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - sH))) * 8.0f; 
                    pWall[2] = tr2->endpos[2] + (vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - sH)) / (float)sqrt((vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - sR))*(vPlayers[ax].getEnt()->origin[0] - (me.pmEyePos[0] - sR))+(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - sF))*(vPlayers[ax].getEnt()->origin[1] - (me.pmEyePos[1] - sF))+(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - sH))*(vPlayers[ax].getEnt()->origin[2] - (me.pmEyePos[2] - sH))) * 8.0f;
                    break;
        }
    }
    return 0;
}



void FindTarget()
{
    for (int ax=0;ax<vPlayers.size();ax++)
    if  ( vPlayers[ax].getPVS() && me.team != vPlayers[ax].team && Visible(ax) && target == -1)
        target = ax;
    }
}
void CalcViewAngles()
{

    vec3_t view,up,right,forward,playerAngles,EntViewOrg;
    playerAngles[0]=0;
    playerAngles[1]=vPlayers[target].getEnt()->angles[1];
    playerAngles[2]=0;
    gEngfuncs.pfnAngleVectors (playerAngles, forward, right, up);
    forward[2] = -forward[2];
    cl_entity_s* ent = vPlayers[target].getEnt();

    if(vPlayers[target].getPVS())
    {

    switch (vPlayers[target].getEnt()->curstate.gaitsequence) {
    default:
        view[0] = (vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - dR)) / (float)sqrt((vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - dR))*(vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - dR))+(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - dF))*(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - dF))+(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - dH))*(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - dH)));
        view[1] = (vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - dF)) / (float)sqrt((vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - dR))*(vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - dR))+(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - dF))*(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - dF))+(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - dH))*(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - dH))); 
        view[2] = (vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - dH)) / (float)sqrt((vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - dR))*(vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - dR))+(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - dF))*(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - dF))+(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - dH))*(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - dH)));
        break;
    case 6:
        view[0] = (vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - jR)) / (float)sqrt((vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - jR))*(vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - jR))+(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - jF))*(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - jF))+(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - jH))*(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - jH)));
        view[1] = (vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - jF)) / (float)sqrt((vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - jR))*(vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - jR))+(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - jF))*(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - jF))+(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - jH))*(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - jH))); 
        view[2] = (vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - jH)) / (float)sqrt((vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - jR))*(vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - jR))+(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - jF))*(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - jF))+(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - jH))*(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - jH)));
        break;
    case 0:
        view[0] = (vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - sR)) / (float)sqrt((vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - sR))*(vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - sR))+(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - sF))*(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - sF))+(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - sH))*(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - sH)));
        view[1] = (vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - sF)) / (float)sqrt((vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - sR))*(vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - sR))+(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - sF))*(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - sF))+(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - sH))*(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - sH))); 
        view[2] = (vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - sH)) / (float)sqrt((vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - sR))*(vPlayers[target].getEnt()->origin[0] - (me.pmEyePos[0] - sR))+(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - sF))*(vPlayers[target].getEnt()->origin[1] - (me.pmEyePos[1] - sF))+(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - sH))*(vPlayers[target].getEnt()->origin[2] - (me.pmEyePos[2] - sH)));
        break;
    }
}
//==================================================
☆┶兲鉂ぢ酷_h

ZxID:1271032

等级: 中校

举报 只看该作者 沙发   发表于: 2007-10-02 0
``````````什么意思
« 返回列表
发帖 回复