|
Junior Member
|

09-21-2007
, 19:54
Creating truly solid entity
|
#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(PLUGIN, VERSION, AUTHOR) 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(id, EV_VEC_origin, playerOrigin)
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(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 = 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_SetSize, EntBlock, mins, 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_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
|
|