Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
|
08-20-2010
, 07:12
EngineX Functions
|
#1
|
I have made a modified engine module for my block wallhack plugin and made some functions that can be useful for other users!
Message functions:
PHP Code:
// Message functions, read message.inc (the same but more faster than fakemeta)
native message_fbegin(dest, msg_type, Float:origin[3]={0.0,0.0,0.0},player=0);
native emessage_fbegin(dest, msg_type, Float:origin[3]={0.0,0.0,0.0},player=0);
// Message functions, read message.inc (the same but more faster than fakemeta)
native ewrite_fcoord(Float:coord);
native write_fcoord(Float:coord);
native write_fangle(Float:angle);
native ewrite_fangle(Float:angle);
These work exactly like the normal ones but I made them use the normal types of values.
Advanced functions:
PHP Code:
// Function checks 4 points on a plane made on an entity based on its bounding box (it is like 4 trace lines made to 4 different points calculated by the bounding box!)
// Returns 1 if one point from the borderplane is visible.
// Paramaters:
// startorigin - start point (this is the point where the trace starts!)
// endorigin - end origin, from this origin the plane will be created in right,left,up and down
// mins and maxs - are the bounding box of the target entity, use customs if you like
// ignore - ignore property (see trace line tutorial)
// ignore_ent - ignore entity
// mulconst - this is a multiplication constant, normally the plane has the size of the cube that surronds the entity. If this constant for example 0.5 then the plane is 1/2 times smaller
native is_borderplane_visible(Float:startorigin[3], Float:endorigin[3], Float:mins[3], Float:maxs[3], ignore = DONT_IGNORE_MONSTERS, ignore_ent = 0, Float:mulconst = 1.0);
// The same as is_visible but checks origin not an entity
native is_visible_origin(entity, Float:origin[3]);
// Returns 1 if origin is in front of the entity, 0 if not
native in_front(entity, const Float:origin[3]);
// The same as fakemeta trace texture but works better, it is more efficient, and it also does not crash the server
// Return 1 when we have a valid texture, 0 when not.
native trace_texture(entity, Float:v1[3], Float:v2[3], texture[], len);
Examples:
PHP Code:
// This will check if an entity is in front of our player/other ent (it can work with any ents!)
stock is_ent_in_front(id, ent)
{
new Float:origin[3];
entity_get_vector(ent, EV_VEC_origin, origin);
return in_front(id, origin);
}
// This will print the texture and the texture type to the player that sees a view ent! (does not work with players)
stock trace_viewent_texture(id)
{
new Float:start[3], Float:end[3], Float:angles[3];
entity_get_vector(id, EV_VEC_origin, start);
entity_get_vector(id, EV_VEC_view_ofs, end);
// We get the start origin! It is the player eyes!
xs_vec_add(end, start, start);
// We get the direction where the player is aiming (here we have angles! Not a directional vector!)
entity_get_vector(id, EV_VEC_v_angle, angles);
// We transform the angle vector in a directional vector, we choose FORWARD because we want to trace in front of the player! (Where he is aiming)
angle_vector(angles, ANGLEVECTOR_FORWARD, angles);
// We make the vector very big! Because the vector that we obtained after transforming is too small to have any results!
xs_vec_mul_scalar(angles, 10000.0, angles);
// We obtain the end origin, which is the place where the player is aiming
xs_vec_add(start, angles, end);
// Get the entity that we hit!
// Here we loose the angles but it is not a problem! We use it as an end
new pHit = trace_line(id, start, end, angles);
// Here we substract the vectors to obtain the difference between them (if they are equal our trace hasn't hit anything)
new Float:dif[3], Float:dif2[3];
xs_vec_sub(start, end, dif);
xs_vec_sub(start, angles, dif2);
// We compare the lengths, here is like comparing TR_flFraction with 1.0
if (xs_vec_len(dif) == xs_vec_len(dif2))
{
client_print(id, print_chat, "No Entity Has been hit!");
return 0;
}
// Apply entity correction, because pHit is -1 when the traceline hits the worldspawn!
if (pHit < 0)
pHit = 0;
new texture[64];
// If trace_texture returns 1 we have a valid texture!!!
if (trace_texture(pHit, start, end, texture, charsmax(texture))
{
// to see the type values check my tut about EngFunc_TraceTexture!
new type = dllfunc(DLLFunc_PM_FindTextureType, texture);
client_print(id, print_chat, "Texture name: %s, Texture type: %c", texture, type);
return type;
}
else
{
client_print(id, print_chat, "Texture name: %s, Texture type: No Texture", texture);
return 0;
}
return 0;
}
Border plane stock example!
PHP Code:
stock is_player_border_visible(id, target)
{
new Float:mins[3], Float:maxs[3], Float:start[3], Float:end[3];
entity_get_vector(id, EV_VEC_origin, start);
entity_get_vector(id, EV_VEC_view_ofs, end);
// We obtain, the eyes of the player (the place where the trace starts)
xs_vec_add(start, end, start);
// We obtain the end origin, this origin will be used to center the plane!
entity_get_vector(target, EV_VEC_origin, end);
entity_get_vector(target, EV_VEC_mins, mins);
entity_get_vector(target, EV_VEC_maxs, maxs);
if (is_borderplane_visible(start, end, mins, maxs, IGNORE_MONSTERS | IGNORE_GLASS, 0, 1.0))
return 1;
if (is_borderplane_visible(start, end, mins, maxs, IGNORE_MONSTERS | IGNORE_GLASS, 0, 0.5))
return 1;
return 0;
}
Graphical example of how is_borderplane_visible works!
[IMG]http://img228.**************/img228/1525/counterstrikeconditionzu.jpg[/IMG]
The red dots are the ones that are checked in the first if the orange ones are the ones that are checked in the second one.
__________________
Last edited by ot_207; 09-06-2010 at 05:42.
|
|