File size: 4,627 Bytes
ea562e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
Fakemeta function:
PHP Code:
EngFunc_TraceLine 
Description:
This function traces between 2 origins and gives us information about it.

The constants that we can use in flags:
PHP Code:
#define DONT_IGNORE_MONSTERS            0
#define IGNORE_MONSTERS                 1
#define IGNORE_MISSILE                  2
#define IGNORE_GLASS                    0x100 
These constants can be used together.
Ex: IGNORE_MISSILE | IGNORE_MONSTERS | IGNORE_GLASS - This makes the traceline ignore missiles, monsters (players) and glass.

Here is a drawing that will show you how it works!
PHP Code:
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, 0, tr) 
[IMG]http://img529.**************/img529/1863/traceline1.jpg[/IMG]

PHP Code:
engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, 0, tr) 
[IMG]http://img529.**************/img529/1415/traceline2.jpg[/IMG]

PHP Code:
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, 0, tr) 
[IMG]http://img529.**************/img529/5815/traceline3.jpg[/IMG]

PHP Code:
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, 0, tr) 
[IMG]http://img529.**************/img529/326/traceline4.jpg[/IMG]

Functions that come with the TraceLine pack:
PHP Code:
// Description: This creates a trace handle! 
// It is important to use because we don't want our plugins to mess with eachothers info!
new ptr = create_tr2() 
PHP Code:
// Description: This creates a trace handle! 
// It is important to use because we don't want our plugins to mess with each others info!
free_tr2(ptr) 
PHP Code:
// Description: Gets/Sets information from/in the trace_handle
[g|s]et_tr2(trace_handle, CONSTANT, number_if_needed!) 
CONSTANT Expresion has this posible values:
Code:
enum TraceResult
{
	TR_AllSolid,		// int
	TR_StartSolid,		// int
	TR_InOpen,		// int
	TR_InWater,		// int
	TR_flFraction,		// float
	TR_vecEndPos,		// float array[3]
	TR_flPlaneDist,		// float
	TR_vecPlaneNormal,	// float array[3]
	TR_pHit,		// int (edict_t*)
	TR_iHitgroup,		// int
};
The float and array values need the third argument! Example:

PHP Code:
    new allsolid = get_tr2(trace, TR_AllSolid)
    new startsolid = get_tr2(trace, TR_StartSolid)
    // TR_StartSolid is a boolean that says whether you were "inside" something 
    // (usually the world) when the trace started (point A)
    // TR_AllSolid tells you if you ever got out of the "inside" or not.
    
    new inopen = get_tr2(trace, TR_InOpen)
    // TR_InOpen means that the start point is in Open
    // That means in the world and not in an ent or something
    
    new hit = get_tr2(trace, TR_pHit)
    // What was hit by the traceline. It will either be a player index,
    // entity index, 0 (part of map), or -1 (didn't hit anything; 
    // doesn't happen with player tracelines).
    
    new hitgroup = get_tr2(trace, TR_iHitgroup)
    // If the traceline hit another player, returns will be HIT_HEAD,
    // HIT_CHEST, HIT_LEFTLEG... etc. If the traceline hit part of the
    // map, this returns HIT_GENERIC.
    
    new Float:fraction
    get_tr2(trace, TR_flFraction, fraction)
    // Returns a number between 0.0 and 1.0, indicating how far the
    // traceline traveled start to end before it hit something. Depending
    // on what conditions were passed to this traceline forward function,
    // it could either be a wall or another entity.
    
    new Float:end_origin[3]
    get_tr2(trace, TR_vecEndPos, end_origin)
    // The official end of the traceline. Not necesarily the same as the
    // second argument passed to this traceline forward function.
    
    new Float:normal[3]
    get_tr2(trace, TR_vecPlaneNormal, normal)
    // Returns a 1 unit long vector normal to the spot that it hit. Note
    // that "normal" has a special connotation here. It doesn't mean "regular." 
Example Stock:
PHP Code:
stock is_wall_between_points(Float:start[3], Float:end[3], ignore_ent)
{
    // Create the trace handle! It is best to create it!
    new ptr = create_tr2()
    
    // The main traceline function!
    // This function ignores GLASS, MISSILE and MONSTERS!
    // Here is an example of how you should combine all the flags!
    engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS | IGNORE_MONSTERS | IGNORE_MISSILE, ignore_ent, ptr)
    
    // We are interested in the fraction parameter
    new fraction
    get_tr2(ptr, TR_flFraction, fraction)
    
    // Free the trace handle (don't forget to do this!)
    free_tr2(ptr)
    
    // If = 1.0 then it didn't hit anything!
    return (fraction != 1.0)
}