Raised This Month: $ Target: $400
 0% 

Setting an entity's bounds box


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
beeker`
Junior Member
Join Date: Mar 2006
Old 03-22-2006 , 21:58   Setting an entity's bounds box
Reply With Quote #1

Hi everyone. With the help of VEN (a lot of help from VEN) and many others from this community, i'm very close to finishing a plugin that makes HE grenades in Counter-Strike shootable with any weapon. It works by creating a new breakable entity everytime a grenade has been thrown, and once it is created, it is set to follow the thrown grenade. If the entity is shot and destroyed, it tells the grenade it is following to detonate. It works very well, however, i do have a problem with the bounding box of the new entity.

When i use entity_set_size() with the mins at { -40.0, -40.0, -40.0 } and maxs at { 40.0, 40.0, 40.0 }, the grenade is almost impossible to shoot. But, when i set the entity's size to { -3.5, -3.5, -3.5 } and { 3.5, 3.5, 3.5 }, it works pretty consistently but not every time, even if i shoot the grenade directly in the center. How come, even if i shoot the nade directly, it will not explode half the time? If I set the entity's size to a large number, shouldn't i be able to shoot anywhere around the nade and break the entity? Any advice is appreciated! here's the code for creating the entity, i use the FM_SetModel forward:

Code:
public Set_Grenade_Box( entity, model[] ) {         if( get_cvar_num( "ToggleValue" ) == 0 )         return PLUGIN_HANDLED;     if( !( is_valid_ent( entity ) ) ) {               return FMRES_IGNORED;       }       if(entity_get_edict( entity, EV_ENT_owner ) && equal( model, g_sHE_Nade_Model ) ) {               new eNade = entity;                 new Float:fNadeOrigin[3];                 entity_get_vector( eNade, EV_VEC_origin, fNadeOrigin );           entity_set_int( eNade, EV_INT_solid, SOLID_TRIGGER)             new eBox = create_entity( "func_breakable" );             entity_set_origin( eBox, fNadeOrigin );               entity_set_float( eBox, EV_FL_takedamage, 1.0 );           entity_set_float( eBox, EV_FL_health, 5.0 );               entity_set_string( eBox, EV_SZ_classname, g_sBoxClass );           entity_set_model( eBox, g_sHE_Nade_Model );           //        entity_set_int( eBox, EV_INT_movetype, MOVETYPE_BOUNCE)         entity_set_int( eBox, EV_INT_solid, SOLID_BBOX)                 new Float:mins[3] = { -3.5, -3.5, -3.5 };           new Float:maxs[3] = { 3.5, 3.5, 3.5 };         entity_set_size( eBox, mins, maxs );                 //        new Float:mins[3] = { -20.5, -20.5, -20.5 };           //        new Float:maxs[3] = { 20.5, 20.5, 20.5 };         //    entity_set_size( eBox, mins, maxs );             entity_set_edict( eBox, EV_ENT_aiment, eNade );           entity_set_int( eBox, EV_INT_movetype, MOVETYPE_FOLLOW )           entity_set_int( eBox, EV_INT_sequence, 0 );         }       return FMRES_IGNORED;   }
beeker` is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-23-2006 , 11:33  
Reply With Quote #2

In case you want to get a good answer you should post the whole code.

Quote:
How come, even if i shoot the nade directly, it will not explode half the time?
Miss? Recoil? Follow problem? (use my last debug version to debug ents origin).

Quote:
If I set the entity's size to a large number, shouldn't i be able to shoot anywhere around the nade and break the entity?
That method should work fine, i used it while debugging.
VEN is offline
beeker`
Junior Member
Join Date: Mar 2006
Old 03-23-2006 , 12:05  
Reply With Quote #3

Hey VEN, how's it gion? Here's the whole code:

Code:
/* Plugin generated by AMXX-Studio */   #include <amxmodx>   #include <amxmisc>   #include <engine>   #include <fakemeta>   #define PLUGIN "New Plugin"   #define VERSION "1.0"   #define AUTHOR "Author"   new g_sHE_Nade_Model[] = "models/w_hegrenade.mdl";   new g_sBoxClass[] = "nade_box"; new Float:radius = 5.0; public plugin_init() {           register_plugin( "Shootable Grenades", "0.1", "beeker" );           register_forward( FM_SetModel, "Set_Grenade_Box" );       register_forward( FM_EmitSound, "forward_emit_sound" );         register_concmd( "amx_grenade", "NadeToggle", ADMIN_IMMUNITY, "<1 or 0> Toggle shootable grenades on or off" );     register_cvar( "ToggleValue", "1" );     }   public plugin_precache() {           precache_model( g_sHE_Nade_Model );         precache_sound("debris/bustglass1.wav");       precache_sound("debris/bustglass2.wav");       precache_sound("debris/bustglass3.wav");       precache_sound("debris/glass1.wav");       precache_sound("debris/glass2.wav");       precache_sound("debris/glass3.wav");       precache_sound("debris/glass4.wav");       } public NadeToggle( id, lvl, cid ) {         if( cmd_access( id, lvl, cid, 1 ) ) {                 if( get_cvar_num( "ToggleValue" ) == 1 ) {                     set_cvar_num( "ToggleValue", 0 );             console_print( id, "[AMXX] Shootable grenades disabled" );                         } else {                     set_cvar_num( "ToggleValue", 1 );             console_print( id, "[AMXX] Shootable grenades enabled" );                     }             }         return PLUGIN_HANDLED;     } public forward_emit_sound( eId ) {         if( get_cvar_num( "ToggleValue" ) == 0 )         return PLUGIN_HANDLED;     if( is_valid_ent( eId ) && ( entity_get_int( eId, EV_INT_effects) & EF_NODRAW ) ) {               new sClassname[9];             entity_get_string( eId, EV_SZ_classname, sClassname, 8 );               if( equal( sClassname, g_sBoxClass ) ) {                       new eCloseNade, Float:origin[3];                     entity_get_vector( eId, EV_VEC_origin, origin );             origin[0] += 1.0;                     while( ( eCloseNade = find_ent_in_sphere( eCloseNade, origin, radius ) ) != 0 ) {                             new sNadeClass[8];                 entity_get_string( eCloseNade, EV_SZ_classname, sNadeClass, 7 );                             if( is_valid_ent( eCloseNade ) && equal( sNadeClass, "grenade" ) ) {                                         remove_entity( eId );                     set_pdata_int( eCloseNade, 4, 127173264 );                                     }                         }                     return FMRES_SUPERCEDE;                   }               }       return FMRES_IGNORED;   }   public Set_Grenade_Box( entity, model[] ) {         if( get_cvar_num( "ToggleValue" ) == 0 )         return PLUGIN_HANDLED;     if( !( is_valid_ent( entity ) ) ) {               return FMRES_IGNORED;       }       if(entity_get_edict( entity, EV_ENT_owner ) && equal( model, g_sHE_Nade_Model ) ) {               new eNade = entity;                 new Float:fNadeOrigin[3];                 entity_get_vector( eNade, EV_VEC_origin, fNadeOrigin );           entity_set_int( eNade, EV_INT_solid, SOLID_TRIGGER)             new eBox = create_entity( "func_breakable" );             entity_set_origin( eBox, fNadeOrigin );               entity_set_float( eBox, EV_FL_takedamage, 1.0 );           entity_set_float( eBox, EV_FL_health, 5.0 );               entity_set_string( eBox, EV_SZ_classname, g_sBoxClass );           entity_set_model( eBox, g_sHE_Nade_Model );           //        entity_set_int( eBox, EV_INT_movetype, MOVETYPE_BOUNCE)         entity_set_int( eBox, EV_INT_solid, SOLID_BBOX)                 new Float:mins[3] = { -3.5, -3.5, -3.5 };           new Float:maxs[3] = { 3.5, 3.5, 3.5 };         entity_set_size( eBox, mins, maxs );                 //        new Float:mins[3] = { -20.5, -20.5, -20.5 };           //        new Float:maxs[3] = { 20.5, 20.5, 20.5 };         //    entity_set_size( eBox, mins, maxs );             entity_set_edict( eBox, EV_ENT_aiment, eNade );           entity_set_int( eBox, EV_INT_movetype, MOVETYPE_FOLLOW )           entity_set_int( eBox, EV_INT_sequence, 0 );         }       return FMRES_IGNORED;   }

For some reason, I tried using the debugged version you sent me, but the grenades will not explode no matter what. I had to use get_pdata_int and finally set_pdata_int for it to work.
beeker` is offline
beeker`
Junior Member
Join Date: Mar 2006
Old 03-23-2006 , 20:43  
Reply With Quote #4

bump
beeker` is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-24-2006 , 02:30  
Reply With Quote #5

Just debug it.
You know, i solved a lot of problems while working on the code. Why? Because of debug.
VEN is offline
beeker`
Junior Member
Join Date: Mar 2006
Old 03-26-2006 , 11:28  
Reply With Quote #6

VEN, i used the debug version you gave me, and the origin of the new entity and the origin of the grenade are exactly the same. I wanted to see exactly how the entity would follow the grenade, so i changed it's model to a bag. Instead of the grenade lying exactly in the middle of the bag, it's on the very bottom, and only the upper half of the grenade lies inside the bag. It's hard to explain, so i posted a screenshot.

( edit: sorry, had to change picture to .jpg )
Attached Images
File Type: jpg ka_roadwars_v200042.jpg (21.4 KB, 253 views)
beeker` is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-26-2006 , 12:39  
Reply With Quote #7

What is the entities mins and maxs?
VEN is offline
beeker`
Junior Member
Join Date: Mar 2006
Old 03-26-2006 , 12:54  
Reply With Quote #8

with the bag model, the mins are { -2.5, -2.5, -2.5 } and the maxs are { 2.5, 2.5, 2.5 }
beeker` is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-26-2006 , 13:07  
Reply With Quote #9

Hm, sorry to say, but actually this is "normal" - that's how entities follows (i.e. centers isn't coincides).
VEN is offline
beeker`
Junior Member
Join Date: Mar 2006
Old 03-26-2006 , 13:13  
Reply With Quote #10

well i don't know if this would be the correct way to go about it, or if it would cause a ton of lag, but would i be able to create a task, set it to every 0.1 seconds, and have it update the poisiton of the entity?
beeker` 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 16:36.


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