AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Entity stuck (https://forums.alliedmods.net/showthread.php?t=162539)

Flipper_SPb 07-20-2011 05:48

Entity stuck
 
How to check if non-player entity stuck in the wall (or in the other solid entity) after the spawn?

Flipper_SPb 07-20-2011 05:58

Re: Entity stuck
 
I found:


PHP Code:

bool:isBlockStuck(ent)
{
    
//first make sure the entity is valid
    
if (is_valid_ent(ent))
    {
        new 
content;
        new 
Float:vOrigin[3];
        new 
Float:vPoint[3];
        new 
Float:fSizeMin[3];
        new 
Float:fSizeMax[3];
        
        
//get the size of the block being grabbed
        
entity_get_vector(entEV_VEC_minsfSizeMin);
        
entity_get_vector(entEV_VEC_maxsfSizeMax);
        
        
//get the origin of the block
        
entity_get_vector(entEV_VEC_originvOrigin);
        
        
//decrease the size values of the block
        
fSizeMin[0] += 1.0;
        
fSizeMax[0] -= 1.0;
        
fSizeMin[1] += 1.0;
        
fSizeMax[1] -= 1.0
        
fSizeMin[2] += 1.0;
        
fSizeMax[2] -= 1.0;
        
        
//get the contents of the centre of all 6 faces of the block
        
for (new 014; ++i)
        {
            
//start by setting the point to the origin of the block (the middle)
            
vPoint vOrigin;
            
            
//set the values depending on the loop number
            
switch (i)
            {
                
//corners
                
case 0: { vPoint[0] += fSizeMax[0]; vPoint[1] += fSizeMax[1]; vPoint[2] += fSizeMax[2]; }
                case 
1: { vPoint[0] += fSizeMin[0]; vPoint[1] += fSizeMax[1]; vPoint[2] += fSizeMax[2]; }
                case 
2: { vPoint[0] += fSizeMax[0]; vPoint[1] += fSizeMin[1]; vPoint[2] += fSizeMax[2]; }
                case 
3: { vPoint[0] += fSizeMin[0]; vPoint[1] += fSizeMin[1]; vPoint[2] += fSizeMax[2]; }
                case 
4: { vPoint[0] += fSizeMax[0]; vPoint[1] += fSizeMax[1]; vPoint[2] += fSizeMin[2]; }
                case 
5: { vPoint[0] += fSizeMin[0]; vPoint[1] += fSizeMax[1]; vPoint[2] += fSizeMin[2]; }
                case 
6: { vPoint[0] += fSizeMax[0]; vPoint[1] += fSizeMin[1]; vPoint[2] += fSizeMin[2]; }
                case 
7: { vPoint[0] += fSizeMin[0]; vPoint[1] += fSizeMin[1]; vPoint[2] += fSizeMin[2]; }
                
                
//centre of faces
                
case 8: { vPoint[0] += fSizeMax[0]; }
                case 
9: { vPoint[0] += fSizeMin[0]; }
                case 
10: { vPoint[1] += fSizeMax[1]; }
                case 
11: { vPoint[1] += fSizeMin[1]; }
                case 
12: { vPoint[2] += fSizeMax[2]; }
                case 
13: { vPoint[2] += fSizeMin[2]; }
            }
            
            
//get the contents of the point on the block
            
content point_contents(vPoint);
            
            
//if the point is out in the open
            
if (content == CONTENTS_EMPTY || content == 0)
            {
                
//block is not stuck
                
return false;
            }
        }
    }
    else
    {
        
//entity is invalid but don't say its stuck
        
return false;
    }
    
    
//block is stuck
    
return true;


This from Block Maker plugin.

Can I use this code? Or it can be done easier?


All times are GMT -4. The time now is 00:49.

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