Raised This Month: $ Target: $400
 0% 

Entity stuck


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 07-20-2011 , 05:48   Entity stuck
Reply With Quote #1

How to check if non-player entity stuck in the wall (or in the other solid entity) after the spawn?
__________________
Полный похуизм.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 07-20-2011 , 05:58   Re: Entity stuck
Reply With Quote #2

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?
__________________
Полный похуизм.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Reply


Thread Tools
Display Modes

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 00:49.


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