AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   EngineX Functions (https://forums.alliedmods.net/showthread.php?t=135841)

ot_207 08-20-2010 07:12

EngineX Functions
 
2 Attachment(s)
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(destmsg_typeFloat:origin[3]={0.0,0.0,0.0},player=0);
native emessage_fbegin(destmsg_typeFloat: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_MONSTERSignore_ent 0Float:mulconst 1.0);

// The same as is_visible but checks origin not an entity
native is_visible_origin(entityFloat: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(entityFloat: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(ident)
{
    new 
Float:origin[3];
    
entity_get_vector(entEV_VEC_originorigin);
    return 
in_front(idorigin);
}

// 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(idEV_VEC_originstart);
    
entity_get_vector(idEV_VEC_view_ofsend);
    
    
// We get the start origin! It is the player eyes!
    
xs_vec_add(endstartstart);

    
// We  get the direction where the player is aiming (here we have angles! Not a directional vector!)
    
entity_get_vector(idEV_VEC_v_angleangles);
    
// 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(anglesANGLEVECTOR_FORWARDangles);
    
    
// 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(angles10000.0angles);

    
// We obtain the end origin, which is the place where the player is aiming
    
xs_vec_add(startanglesend);
    
    
// 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(idstartendangles);
    
    
// 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(startenddif);
    
xs_vec_sub(startanglesdif2);
    
    
// We compare the lengths, here is like comparing TR_flFraction with 1.0
    
if (xs_vec_len(dif) == xs_vec_len(dif2))
    {
        
client_print(idprint_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(pHitstartendtexturecharsmax(texture))
    {
        
// to see the type values check my tut about EngFunc_TraceTexture!
        
new type dllfunc(DLLFunc_PM_FindTextureTypetexture);
        
client_print(idprint_chat"Texture name: %s, Texture type: %c"texturetype);
        return 
type;
    }
    else
    {
        
client_print(idprint_chat"Texture name: %s, Texture type: No Texture"texture);
        return 
0;
    }
    
    
    return 
0;


Border plane stock example!
PHP Code:

stock is_player_border_visible(idtarget)
{
    new 
Float:mins[3], Float:maxs[3], Float:start[3], Float:end[3];
    
entity_get_vector(idEV_VEC_originstart);
    
entity_get_vector(idEV_VEC_view_ofsend);
    
    
// We obtain, the eyes of the player (the place where the trace starts)
    
xs_vec_add(startendstart);
    
    
// We obtain the end origin, this origin will be used to center the plane!
    
entity_get_vector(targetEV_VEC_originend);
    
    
entity_get_vector(targetEV_VEC_minsmins);
    
entity_get_vector(targetEV_VEC_maxsmaxs);
    
    if (
is_borderplane_visible(startendminsmaxsIGNORE_MONSTERS IGNORE_GLASS01.0))
        return 
1;
    
    if (
is_borderplane_visible(startendminsmaxsIGNORE_MONSTERS IGNORE_GLASS00.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.

xPaw 08-20-2010 07:25

Re: EngineX Functions
 
Good job! I will find an use for it

ot_207 08-20-2010 07:44

Re: EngineX Functions
 
Quote:

Originally Posted by xPaw (Post 1276577)
Good job! I will find an use for it

I will post some examples with every function so that the people will use them correctly.

ConnorMcLeod 08-20-2010 11:19

Re: EngineX Functions
 
I guess is_visible_origin is same as Ham_FVecVisible.

Arkshine 08-20-2010 11:32

Re: EngineX Functions
 
Yes, exactly the same.

Alucard^ 08-20-2010 11:44

Re: EngineX Functions
 
Nice one OT =o... you help a lot to amxx comunity.

ot_207 08-20-2010 12:53

Re: EngineX Functions
 
Quote:

Originally Posted by ConnorMcLeod (Post 1276826)
I guess is_visible_origin is same as Ham_FVecVisible.

Yes. But it does not crash the server :P.

@Alucard.
Thanks!

ConnorMcLeod 08-20-2010 14:01

Re: EngineX Functions
 
Quote:

Originally Posted by ot_207 (Post 1276921)
Yes. But it does not crash the server :P.

Ah... may be wrong index in .ini file


Will you write some native on request ?

ot_207 08-20-2010 16:09

Re: EngineX Functions
 
Quote:

Originally Posted by ConnorMcLeod (Post 1276979)
Will you write some native on request ?

Yes, but only with 2 conditions:
1. I must find it useful.
2. You must post examples with it.

Other than that, I just need joropito to compile it for linux.
Post what you wish.

wrecked_ 08-20-2010 21:24

Re: EngineX Functions
 
Awesome job, ot!


All times are GMT -4. The time now is 21:45.

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