AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get proper model size for creating accurate bounding box (https://forums.alliedmods.net/showthread.php?t=237778)

Kia 03-29-2014 10:30

Get proper model size for creating accurate bounding box
 
Hello everybody,

I want to place a model at the map and want it to take damage and execute a function when it's health under a fixed amount.
My problem is, players can go through the model and the model / entity does not take damage.
So my question is, how do I get the proper size of the model to make a accurate box?

My current code :

PHP Code:

new Floatmins[3] = {-12.0, -12.00.0 // Not accurate
new Floatmaxs[3] = { 12.012.075.0 }  // Not accurate

entity_set_model(iEntCORE_MODEL)
entity_set_origin(iEntg_flTCoreOrigin); 
                
entity_set_float(iEntEV_FL_takedamage1.0); 
entity_set_float(iEntEV_FL_health2000.0); 
        
entity_set_size(iEntminsmaxs); // Not accurate
entity_set_int(iEntEV_INT_solidSOLID_BBOX); // does not do anything? 


ironskillz1 03-29-2014 10:48

Re: Get proper model size for creating accurate bounding box
 
Maybe you can fix it by looking at the blockmakers codes.

Kia 03-29-2014 11:00

Re: Get proper model size for creating accurate bounding box
 
Quote:

Originally Posted by ironskillz1 (Post 2117465)
Maybe you can fix it by looking at the blockmakers codes.

afaik, it has fixed boxes since it is a cube-shaped model. My model isn't.

jimaway 03-29-2014 11:57

Re: Get proper model size for creating accurate bounding box
 
you can only make cube shaped solids

Kia 03-29-2014 12:23

Re: Get proper model size for creating accurate bounding box
 
Well okay, but how do I get the size of my model?

Arkshine 03-29-2014 12:23

Re: Get proper model size for creating accurate bounding box
 
Try GetModelBoundingBox or GetModelCollisionBox. (1.8.3, .inc : https://hg.alliedmods.net/amxmodx-ce...emeta.inc#l548)

Kia 03-29-2014 12:57

Re: Get proper model size for creating accurate bounding box
 
Quote:

Originally Posted by Arkshine (Post 2117501)
Try GetModelBoundingBox or GetModelCollisionBox. (1.8.3, .inc : https://hg.alliedmods.net/amxmodx-ce...emeta.inc#l548)

Thanks, I will try that.

EDIT : Does not work, I can still run through it. Maybe it is a issue with the model?

PHP Code:

while((iEnt find_ent_by_class(iEntENTITY_TERROR_CORE))) 
            {
                
g_iTCoreEnt iEnt
                
                entity_set_model
(g_iTCoreEntCORE_MODEL)
                
entity_set_origin(g_iTCoreEntg_flTCoreOrigin); 
                
                
entity_set_float(g_iTCoreEntEV_FL_takedamage1.0); 
                
entity_set_float(g_iTCoreEntEV_FL_health2000.0); 
                
                
GetModelCollisionBox(g_iTCoreEntminsmaxs// GetModelBoundingBox did not work too.
                
entity_set_size(g_iTCoreEntminsmaxs); 
                
entity_set_int(g_iTCoreEntEV_INT_solidSOLID_BBOX); 
                
                
drop_to_floor(g_iTCoreEnt)
                
ClCMD_sm(id)
            } 

PHP Code:

if(GetModelBoundingBox(g_iTCoreEntminsmaxsModel_DefaultSize))
                    
client_print(idprint_console"%i %i %i - %i %i %i"mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2]) 

Returns : 0 0 0 - 0 0 0

Kia 04-27-2014 12:58

Re: Get proper model size for creating accurate bounding box
 
Bump.

klippy 04-27-2014 13:18

Re: Get proper model size for creating accurate bounding box
 
PHP Code:

"%i %i %i - %i %i %i" 

Aren't mins and maxs supposed to be floats?
Or maybe try
PHP Code:

native SetModelCollisionBox(entity); 

Code:

/**
* Sets entity size to the models collision box.
*
* @param entity        The entity index to set the value on.
*
* @return              1 on success, 0 on faillure.
*
* @error              Invalid entity.
*                      Invalid model pointer.
*/

I believe that is also in 1.8.3.
And for moderators: it should be "failure", not "faillure" in @return line.

Arkshine 04-27-2014 14:18

Re: Get proper model size for creating accurate bounding box
 
native GetModelBoundingBox(entity, Float:mins[3], Float:maxs[3], sequence = Model_DefaultSize);

I see well Float:.

@KliPPy, thanks for the typo.


All times are GMT -4. The time now is 06:03.

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