Raised This Month: $51 Target: $400
 12% 

Get player's hitboxes?


Post New Thread Reply   
 
Thread Tools Display Modes
FaTony
Veteran Member
Join Date: Aug 2008
Old 04-26-2010 , 13:00   Re: Get player's hitboxes?
Reply With Quote #31

Трейсит параллелепипед из точки А в точку Б и записывает результат туда, куда ты хочешь. Вот я его использовал для своих ботов чтобы узнать, можно ли пройти пешком:
PHP Code:
public bool:IsTargetVisible (const Float:coords1[3], const Float:coords2[3], const VisibilityFilter:filter, const startentindex, const endentindex)
{
    
decl Handle:ray;
    switch (
filter) {
        case 
FILTER_NODE_LINKING:{
            new 
Float:mins[]={-24.0, -24.00.0};
            new 
Float:maxs[]={24.024.060.0};
            
ray=TR_TraceHullFilterEx(coords1coords2minsmaxsMASK_PLAYERSOLIDFilterNodeLinking);
            if (
TR_DidHit(ray)) {
                
CloseHandle(ray);
                return 
false;
                }
            
CloseHandle(ray);
            return 
true;
            }
        case 
FILTER_BOT_NAVIGATION:{
            new 
Float:mins[]={-24.0, -24.00.0};
            new 
Float:maxs[]={24.024.060.0};
            
ray=TR_TraceHullFilterEx(coords1coords2minsmaxsMASK_PLAYERSOLIDFilterBotNavigationstartentindex);
            if (
TR_DidHit(ray)) {
                if (
TR_GetEntityIndex(ray)==endentindex) {
                    
CloseHandle(ray);
                    return 
true;
                    }
                
CloseHandle(ray);
                return 
false;
                }
            else {
                
CloseHandle(ray);
                return 
true;
                }
            }
        case 
FILTER_PLAYER_VISIBLE:{
            
ray=TR_TraceRayFilterEx(coords1coords2MASK_PLAYERSOLIDRayType_EndPointFilterPlayerVisiblestartentindex);
            if (
TR_GetEntityIndex(ray)==endentindex) {
                
CloseHandle(ray);
                return 
true;
                }
            
CloseHandle(ray);
            return 
false;
            }
        }
    return 
false;
}
public 
bool:FilterNodeLinking (entitymask)
{
    if(
entity <=32) { 
        return 
false
        }
    else {
        
decl String:entclass[64];
        
GetEdictClassname(entityentclass64);
        
decl enttype;
        if (!
GetTrieValue(NodeLinkPassTrieentclassenttype)) {
            return 
true;
            }
        else {
            return 
false;
            }
        }
}
public 
bool:FilterBotNavigation (entitymaskany:startent)
{
    if (
entity == startent) {
        return 
false
        }
    else {
        
decl String:entclass[64];
        
GetEdictClassname(entityentclass64);
        
decl enttype;
         if (!
GetTrieValue(BotNavigationVisTrieentclassenttype)) {
            return 
true;
            }
        else {
            switch (
enttype) {
                case 
PASS_ALWAYS:{return false;}
                case 
PASS_TEAM_ONLY:{
                    if ((
startent<33)&&(startent>0)) {
                        if (
PlayerTeam[startent]==Team:GetEntProp(entityProp_Send"m_iTeamNum")) {
                            return 
false;
                            }
                        else {
                            return 
true;
                            }
                        }
                    else {
                        return 
false;
                        }
                    }
                case 
PASS_TEAM_ONLY_NOT_SELF:{
                    if ((
startent<33)&&(startent>0)) {
                        if ((
PlayerTeam[startent]==Team:GetEntProp(entityProp_Send"m_iTeamNum"))&&(GetEntPropEnt(entityProp_Send"m_hBuilder")!=startent)) {
                            return 
false;
                            }
                        else {
                            return 
true;
                            }
                        }
                    else {
                        return 
false;
                        }
                    }
                }
            }
        }
    return 
true;
}
public 
bool:FilterPlayerVisible (entitymaskany:client)
{
    if (
entity == client) { 
        return 
false
        }
    else {
        
decl String:entclass[64];
        
GetEdictClassname(entityentclass64);
        
decl enttype;
        if (!
GetTrieValue(PlayerVisTrieentclassenttype)) {
            return 
true;
            }
        else {
            switch (
enttype) {
                case 
PASS_ALWAYS:{return false;}
                case 
PASS_TEAM_ONLY:{
                    if (
PlayerTeam[client]==Team:GetEntProp(entityProp_Send"m_iTeamNum")) {
                        return 
false;
                        }
                    else {
                        return 
true;
                        }
                    }
                }
            }
        }
    return 
true;
}
public 
Walkability:IsTargetWalkable (const Float:coords1[3], const Float:coords2[3], const Float:coords3, const bool:brush, const VisibilityFilter:filter, const startent, const endent)
{
    if (!
CheckForPit(coords1filterstartent)) {
        return 
PIT_START;
        }
    if (!
CheckForPit(coords2filterstartent)) {
        return 
PIT_END;
        }
    new 
numchecks=1;
    
decl Float:endcoords[3];
    
endcoords=coords2;
    if (
brush) {
        
numchecks=RoundToFloor(FloatAbs(coords3-coords2[2])/32.0);
        }
    for (new 
i=0;i<numchecks;i++) {
        if (
IsTargetVisible(coords1endcoordsfilterstartentendent)) {
            
decl Float:coords2D1[2];
            
decl Float:coords2D2[2];
            
decl Float:distance2D;
            
coords2D1[0]=coords1[0];
            
coords2D1[1]=coords1[1];
            
coords2D2[0]=endcoords[0];
            
coords2D2[1]=endcoords[1];
            
distance2D=GetDistance2D(coords2D1coords2D2);
            if (
distance2D>(FloatAbs(coords1[2]-endcoords[2]))) {
                if (
distance2D>49.0) {
                    new 
numrays=RoundToFloor(distance2D/49.0);
                    
decl Float:raystartcoords[3];
                    
decl Float:offset[3];
                    
offset[0]=49.0*Cosine(ArcTangent((endcoords[1]-coords1[1])/(endcoords[0]-coords1[0])));
                    if (
coords1[0]>endcoords[0]) {
                        
offset[0]=0.0-offset[0];
                        }
                    
raystartcoords[0]=coords1[0]+offset[0];
                    
offset[1]=SquareRoot(2401.0-Pow(offset[0], 2.0));
                    if (
coords1[1]>endcoords[1]) {
                        
offset[1]=0.0-offset[1];
                        }
                    
raystartcoords[1]=coords1[1]+offset[1];
                    
raystartcoords[2]=((raystartcoords[0]-coords1[0])*(endcoords[2]-coords1[2]))/(endcoords[0]-coords1[0])+coords1[2];
                    
offset[2]=raystartcoords[2]-coords1[2];
                    for (new 
j=1;j<=numrays;j++) {
                        if ((
brush)&&(IsPositionInBrush(raystartcoordsendent))) {
                            return 
WALKABLE;
                            }
                        if (!
CheckForPit(raystartcoordsfilterstartent)) {
                            return 
PIT_MIDDLE;
                            }
                        
raystartcoords[0]=raystartcoords[0]+offset[0];
                        
raystartcoords[1]=raystartcoords[1]+offset[1];
                        
raystartcoords[2]=raystartcoords[2]+offset[2];
                        }
                    return 
WALKABLE;
                    }
                else {
                    return 
WALKABLE;
                    }
                }
            }
        if (
brush) {
            
endcoords[2]=endcoords[2]+32.0;
            }
        }
    return 
WALL;
}
public 
bool:CheckForPit (const Float:coords[3], const VisibilityFilter:filter, const startent)
{
    
decl Float:coords2[3];
    
coords2[0]=coords[0];
    
coords2[1]=coords[1];
    
coords2[2]=-64000.0;
    
decl Handle:ray;
    new 
Float:mins[]={-24.0, -24.00.0};
    new 
Float:maxs[]={24.024.060.0};
    switch (
filter) {
        case 
FILTER_NODE_LINKING:{
            
ray=TR_TraceHullFilterEx(coordscoords2minsmaxsMASK_PLAYERSOLIDFilterNodeLinking);
            }
        case 
FILTER_BOT_NAVIGATION:{
            
ray=TR_TraceHullFilterEx(coordscoords2minsmaxsMASK_PLAYERSOLIDFilterBotNavigationstartent);
            }
        }
    
TR_GetEndPosition(coords2ray);
    
CloseHandle(ray);
    if ((
coords[2]-coords2[2])>50.0) {
        
//InformAdmin("Found pit");
        //InformAdmin("Start: %f %f %f", coords[0], coords[1], coords[2]);
        //InformAdmin("End: %f %f %f", coords2[0], coords2[1], coords2[2]);                    
        
return false;
        }
    return 
true;
}
public 
bool:GetBrushPosition (const entindexFloat:coords[6])
{
    
decl enttype;
    
decl String:entclass[64];
    
GetEdictClassname(entindexentclass64);
    if (
GetTrieValue(BrushTypesTrieentclassenttype)) {
        switch (
enttype) {
            case 
BRUSH_STATIC:{}
            case 
BRUSH_DYNAMIC:{}
            case 
BRUSH_PARSED:{
                
KvRewind(ftzmapkv);
                
KvJumpToKey(ftzmapkventclass);
                
decl String:entindexstring[8];
                
IntToString(entindexentindexstring8);
                
KvJumpToKey(ftzmapkventindexstring);
                
decl Float:mins[3];
                
decl Float:maxs[3];
                
KvGetVector(ftzmapkv"mins"mins);
                
KvGetVector(ftzmapkv"maxs"maxs);
                
coords[0]=mins[0];
                
coords[1]=mins[1];
                
coords[2]=mins[2];
                
coords[3]=maxs[0];
                
coords[4]=maxs[1];
                
coords[5]=maxs[2];
                return 
true;
                }
            }
        }
    return 
false;
}
public 
bool:IsPositionInBrush (const Float:coords[3], const entindex)
{
    
decl Float:brushcoords[6];
    if (!
GetBrushPosition(entindexbrushcoords)) {
        return 
false;
        }
    if ((
coords[0]>brushcoords[0])&&(coords[0]<brushcoords[3])&&(coords[1]>brushcoords[1])&&(coords[1]<brushcoords[4])&&(coords[2]>brushcoords[2])&&(coords[2]<brushcoords[5])) {
        return 
true;
        }
    return 
false;

FaTony is offline
Loco23ru
Junior Member
Join Date: Apr 2010
Location: Moscow, Russia
Old 04-26-2010 , 14:12   Re: Get player's hitboxes?
Reply With Quote #32

Не понял что делает вот эта строка:
GetTrieValue(PlayerVisTrie, entclass, enttype)

И еще интересует принцип видимости игрока, можешь в двух словах описать?
Буду благодарен тебе.
Loco23ru is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 04-27-2010 , 08:21   Re: Get player's hitboxes?
Reply With Quote #33

Trie - это массив, адресуемый по строкам. Смотри adt_trie в функциях. Видимость проверяется просто, трейсится луч между 2мя точками, если луч во что-то ударился, значит точки не видимы между собой.
FaTony is offline
Loco23ru
Junior Member
Join Date: Apr 2010
Location: Moscow, Russia
Old 04-27-2010 , 09:19   Re: Get player's hitboxes?
Reply With Quote #34

Quote:
Originally Posted by FaTony
Видимость проверяется просто, трейсится луч между 2мя точками, если луч во что-то ударился, значит точки не видимы между собой.
Просто если из одной точки не видно другую точку, это еще не значит что весь игрок не виден.
Ладно, спасибо за помощь Я решил написать плагин непосредственно для MM, а не для SM. Оттуда есть доступ к Source SDK.
Loco23ru is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode