Raised This Month: $ Target: $400
 0% 

Creating truly solid entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
summodder
Junior Member
Join Date: Sep 2007
Old 09-21-2007 , 19:54   Creating truly solid entity
Reply With Quote #1

I've had a lot of trouble trying to create a solid entity. I've repetitively tried using code from other topics but my entity just won't be solid (shoot at/can't walk through). Here's the code I'm at now:

EDIT: This is the full code of the plugin. I've redundantly declared the entity a solid but it was just to confirm I was using it.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <engine>
#include <fakemeta>

#define PLUGIN "Build Block"
#define VERSION "1.0"
#define AUTHOR "z"

#define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor,%1)

#define ZMIN Float:{-32.000000 ,-32.000000 ,-32.000000}
#define ZMAX Float:{ 32.000000 , 32.000000 , 32.000000}

new Float:nblocksize[3] = {-16.0,-16.0,-16.0}
new 
Float:pblocksize[3] = {16.0,16.0,16.0}

new const 
CON_BLOCK 4000

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say showorigin","showorigin")
}

public 
plugin_precache() {
    
    
precache_model("models/pac_cube.mdl"//from building block by emp
    
precache_sound("debris/bustmetal1.wav");
    
precache_sound("debris/bustmetal2.wav");
    
precache_sound("debris/metal1.wav");
    
precache_sound("debris/metal2.wav");
    
precache_sound("debris/metal3.wav");
    
precache_model("models/metalplategibs.mdl");
}

public 
showorigin(id) {

    new 
Float:playerOrigin[3]
    
entity_get_vector(idEV_VEC_originplayerOrigin)

    static 
Float:mins[3], Float:maxs[3];
    
    
mins ZMIN;
    
    
maxs ZMAX;
    
    
//this part from sentry guns by jhhg
    
      
new Float:vNewOrigin[3]
    new 
Float:vTraceDirection[3]
    new 
Float:vTraceEnd[3]
    new 
Float:vTraceResult[3]
    
velocity_by_aim(id50vTraceDirection// get a velocity in the directino player is aiming, with a multiplier of 64...
    
vTraceEnd[0] = vTraceDirection[0] + playerOrigin[0// find the new max end position
    
vTraceEnd[1] = vTraceDirection[1] + playerOrigin[1]
    
vTraceEnd[2] = vTraceDirection[2] + playerOrigin[2]
    
trace_line(idplayerOriginvTraceEndvTraceResult// trace, something can be in the way, use hitpoint from vTraceResult as new origin, if nothing's in the way it should be same as vTraceEnd
    
vNewOrigin[0] = vTraceResult[0]// just copy the new result position to new origin
    
vNewOrigin[1] = vTraceResult[1]// just copy the new result position to new origin
    
vNewOrigin[2] = playerOrigin[2// always build in the same height as player.
    /*
    new EntBlock = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString, "func_breakable"))
    
    
    engfunc(EngFunc_SetOrigin,EntBlock,vNewOrigin)
    set_pev(EntBlock,pev_angles,vNewOrigin)
    
    set_pev(EntBlock,pev_owner,id)
    set_pev(EntBlock,pev_classname,"func_cube")
    set_pev(EntBlock,pev_takedamage,DAMAGE_YES)
    
    engfunc(EngFunc_SetModel,EntBlock,"models/pac_cube.mdl")
    engfunc(EngFunc_SetSize,EntBlock,nblocksize,pblocksize)
    set_pev(EntBlock,pev_health,250.0)
    set_pev(EntBlock,pev_solid,SOLID_BBOX)
    
    DispatchSpawn(EntBlock)
    
    */
    
new EntBlock create_entity("func_breakable")
    
entity_set_int(EntBlock,EV_INT_solid,SOLID_BBOX)
    
DispatchKeyValue(EntBlock,"material","2")
    
DispatchKeyValue(EntBlock,"health","30")
    
set_pev(EntBlock,pev_solid,SOLID_BBOX)
    
DispatchSpawn(EntBlock)
    
set_pev(EntBlock,pev_solid,SOLID_BBOX)
    
entity_set_string(EntBlock,EV_SZ_classname,"func_cube")
    
entity_set_vector(EntBlock,EV_VEC_mins,Float:{-32.0,-32.0,-32.0})
    
entity_set_vector(EntBlock,EV_VEC_maxs,Float:{32.0,32.0,32.0})
    
entity_set_size(EntBlock,Float:{-32.0,-32.0,-32.0},Float:{32.0,32.0,32.0})
    
    
engfunc(EngFunc_SetSizeEntBlockminsmaxs)
    
    
entity_set_model(EntBlock,"models/pac_cube.mdl")
    
entity_set_int(EntBlockEV_INT_movetype,MOVETYPE_NONE)
    
entity_set_int(EntBlock,EV_INT_solid,SOLID_BBOX)
    
set_pev(EntBlock,pev_solid,SOLID_BBOX)
    
entity_set_origin(EntBlock,vNewOrigin)
    
//entity_set_edict(EntBlock,EV_ENT_owner,id)
    
    //fm_drop_to_floor(EntBlock)
    
    
entity_set_int(EntBlock,EV_INT_solid,SOLID_BBOX)    
    return 
PLUGIN_HANDLED;

i've also tried

PHP Code:
    new EntBlock engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString"info_target"))
    
    
    
engfunc(EngFunc_SetOrigin,EntBlock,zorigin)
    
set_pev(EntBlock,pev_angles,zorigin)
    
    
set_pev(EntBlock,pev_owner,id)
    
set_pev(EntBlock,pev_classname,"func_cube")
    
engfunc(EngFunc_SetModel,EntBlock,"models/pac_cube.mdl")
    
engfunc(EngFunc_SetSize,EntBlock,nblocksize,pblocksize)
    
set_pev(EntBlock,pev_health,250.0)
    
set_pev(EntBlock,pev_solid,SOLID_TRIGGER
Both have failed so far and i'm not sure whats wrong. The model appears in the right spot but there is nothing blocking me near the model. If anyone could help me it'd be appreciated. I started with engine but since that wouldn't work i switched to fakemeta which still didn't work, still only getting the model to appear with no blockage.

I'm probably missing/doing something stupid, but I can't seem to figure out what it is that's wrong. Any help is appreciated.

Last edited by summodder; 09-22-2007 at 15:29. Reason: Changing code
summodder is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 09-21-2007 , 21:46   Re: Creating truly solid entity
Reply With Quote #2

Check out this plugin for good example code. That's what I did when I wanted to create a solid entity and it worked great:

http://forums.alliedmods.net/showthread.php?t=52927
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
summodder
Junior Member
Join Date: Sep 2007
Old 09-22-2007 , 00:13   Re: Creating truly solid entity
Reply With Quote #3

The problem appears to be with the entity size or solid state. I can break my boxes but i'm unable to shoot or be blocked by them I've revised some of my code and got this:
Quote:
new Float:playerOrigin[3]
entity_get_vector(id, EV_VEC_origin, playerOrigin)

new Float:mins[3], Float:maxs[3]

mins[0] = zminz[0]
mins[1] = zminz[1]
mins[2] = zminz[2]

maxs[0] = zmaxz[0]
maxs[1] = zmaxz[1]
maxs[2] = zmaxz[2]

//this part from sentry guns by jhhg

new Float:vNewOrigin[3]
new Float:vTraceDirection[3]
new Float:vTraceEnd[3]
new Float:vTraceResult[3]
velocity_by_aim(id, 50, vTraceDirection) // get a velocity in the directino player is aiming, with a multiplier of 64...
vTraceEnd[0] = vTraceDirection[0] + playerOrigin[0] // find the new max end position
vTraceEnd[1] = vTraceDirection[1] + playerOrigin[1]
vTraceEnd[2] = vTraceDirection[2] + playerOrigin[2]
trace_line(id, playerOrigin, vTraceEnd, vTraceResult) // trace, something can be in the way, use hitpoint from vTraceResult as new origin, if nothing's in the way it should be same as vTraceEnd
vNewOrigin[0] = vTraceResult[0]// just copy the new result position to new origin
vNewOrigin[1] = vTraceResult[1]// just copy the new result position to new origin
vNewOrigin[2] = playerOrigin[2] // always build in the same height as player.

new EntBlock = create_entity("func_breakable")

DispatchKeyValue(EntBlock,"material","2")
DispatchKeyValue(EntBlock,"health","30")

DispatchSpawn(EntBlock)

entity_set_string(EntBlock,EV_SZ_classname,"f unc_cube")
entity_set_size(EntBlock,mins,maxs)

engfunc(EngFunc_SetSize, EntBlock, mins, maxs);
set_pev(EntBlock, pev_mins, mins);
set_pev(EntBlock, pev_maxs, maxs );
set_pev(EntBlock, pev_absmin, mins);
set_pev(EntBlock, pev_absmax, maxs );

entity_set_model(EntBlock,"models/pac_cube.mdl")
entity_set_int(EntBlock, EV_INT_movetype,MOVETYPE_NONE)
entity_set_int(EntBlock,EV_INT_solid,SOLID_BS P)
entity_set_origin(EntBlock,vNewOrigin)
entity_set_edict(EntBlock,EV_ENT_owner,id)
summodder is offline
AlMod
Member
Join Date: Nov 2006
Old 09-22-2007 , 04:59   Re: Creating truly solid entity
Reply With Quote #4

if using engine set this
entity_set_int(EntBlock,EV_INT_solid,SOLID_BB OX)

for future there are solid constants (already defined)
PHP Code:
#define    SOLID_NOT        0        /* no interaction with other objects */
#define    SOLID_TRIGGER        1        /* touch on edge, but not blocking */
#define    SOLID_BBOX        2        /* touch on edge, block */
#define    SOLID_SLIDEBOX        3        /* touch on edge, but not an onground */
#define    SOLID_BSP        4        /* bsp clip, touch on edge, block */ 

Last edited by AlMod; 09-22-2007 at 05:02.
AlMod is offline
summodder
Junior Member
Join Date: Sep 2007
Old 09-22-2007 , 15:16   Re: Creating truly solid entity
Reply With Quote #5

I've declared the entity as a solid plenty of times and i've tried all the different solid forms. doesn't seem to work. it might be the sizes but its pretty well defined at Float:{-32.0,-32.0,-32.0},Float:{32.0,32.0,32.0} for mins and maxes
summodder is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 09-22-2007 , 18:54   Re: Creating truly solid entity
Reply With Quote #6

Like I said, try copying and pasting the entity information form pallets with bags and changing the specifics from there to locate your error. Have you tried that?
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
summodder
Junior Member
Join Date: Sep 2007
Old 09-22-2007 , 22:17   Re: Creating truly solid entity
Reply With Quote #7

I'm trying but it was a lot of stuff that is unrelated.
summodder is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 09-22-2007 , 22:50   Re: Creating truly solid entity
Reply With Quote #8

Yeah, but if you actually read the code, rather than just look at it as someone banging their head on a keyboard and outputting a bunch of random characters, you'll see an amazingly concise and to the point function that perfectly pronounces the point of my suggestion;

Code:
public place_palletwbags(id) {         if( palletscout == get_pcvar_num(maxpallets) )     {         client_print(id,print_chat,"You can't place more than %d pallets with bags",get_pcvar_num(maxpallets));         return PLUGIN_HANDLED;     }         // create a new entity     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_wall"));             // set a name to the entity     set_pev(ent,pev_classname,"amxx_pallets");         // set model            engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]);         // register a new var. for origin     static Float:xorigin[3];     get_user_hitpoint(id,xorigin);             // check if user is aiming at the air     if(engfunc(EngFunc_PointContents,xorigin) == CONTENTS_SKY)     {         client_print(id,print_chat,"[AMXX] You can't place a pallet with bags on the air");         return PLUGIN_HANDLED;     }             // set sizes     static Float:p_mins[3], Float:p_maxs[3];     p_mins = PALLET_MINS;     p_maxs = PALLET_MAXS;     engfunc(EngFunc_SetSize, ent, p_mins, p_maxs);     set_pev(ent, pev_mins, p_mins);     set_pev(ent, pev_maxs, p_maxs );     set_pev(ent, pev_absmin, p_mins);     set_pev(ent, pev_absmax, p_maxs );         // set the rock of origin where is user placed     engfunc(EngFunc_SetOrigin, ent, xorigin);             // make the rock solid     set_pev(ent,pev_solid,SOLID_BBOX); // touch on edge, block         // set the movetype     set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff         // now the damage stuff, to set to take it or no     // if you set the cvar "pallets_wbags_health" 0, you can't destroy a pallet with bags     // else, if you want to make it destroyable, just set the health > 0 and will be     // destroyable.     new Float:p_cvar_health = get_pcvar_float(phealth);     switch(p_cvar_health)     {         case 0.0 :         {             set_pev(ent,pev_takedamage,DAMAGE_NO);         }                 default :         {             set_pev(ent,pev_health,p_cvar_health);             set_pev(ent,pev_takedamage,DAMAGE_YES);         }     }                     static Float:rvec[3];     pev(id,pev_v_angle,rvec);         rvec[0] = 0.0;         set_pev(ent,pev_angles,rvec);         // drop entity to floor     fm_drop_to_floor(ent);         // num ..     palletscout++;         // confirm message     client_print(id,print_chat,"[AMXX] You placed a Pallet with Bags !");         return PLUGIN_HANDLED; }

Now, that works. Use that and alter the simple stuff like the model, for example. Bit by bit, until you find out where you went wrong.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
summodder
Junior Member
Join Date: Sep 2007
Old 09-23-2007 , 00:10   Re: Creating truly solid entity
Reply With Quote #9

I know it works, but I'm going to mainly using engine and not fakemeta, which pellets is using. I'm looking for a way to make the engine one work first. I've already gotten it to work now in both and it had to do with the order of setting the size of the entity.
summodder is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 09-23-2007 , 09:28   Re: Creating truly solid entity
Reply With Quote #10

I am done with you.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
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 16:14.


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