Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
text
Languages:
Russian
Size:
10K - 100K
Tags:
code
License:
RichieBurundi
commited on
Upload 29 files
Browse files- EngFunc_AlertMessage.txt +20 -0
- EngFunc_AnimationAutomove.txt +25 -0
- EngFunc_CheckVisibility.txt +72 -0
- EngFunc_DecalIndex.txt +18 -0
- EngFunc_FindClientInPVS.txt +46 -0
- EngFunc_FindEntityInSphere.txt +25 -0
- EngFunc_GetBonePosition.txt +219 -0
- EngFunc_MessageBegin.txt +36 -0
- EngFunc_ModelFrames.txt +14 -0
- EngFunc_ModelIndex.txt +17 -0
- EngFunc_MoveToOrigin.txt +26 -0
- EngFunc_NumberOfEntities.txt +16 -0
- EngFunc_PointContents.txt +34 -0
- EngFunc_PrecacheModel.txt +19 -0
- EngFunc_PrecacheSound.txt +18 -0
- EngFunc_SetModel.txt +19 -0
- EngFunc_SetOrigin.txt +20 -0
- EngFunc_SetSize.txt +20 -0
- EngFunc_TraceLine Explanation.txt +121 -0
- EngFunc_TraceLine.txt +120 -0
- EngFunc_TraceModel.txt +21 -0
- EngFunc_TraceToss.txt +27 -0
- TraceModel usage simple example..txt +154 -0
- Traceline Tutorial.txt +247 -0
EngFunc_AlertMessage.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
Code:
|
3 |
+
EngFunc_AlertMessage
|
4 |
+
|
5 |
+
Description :
|
6 |
+
Prints an alert message.
|
7 |
+
|
8 |
+
|
9 |
+
Usage:
|
10 |
+
Code:
|
11 |
+
engfunc(EngFunc_AlertMessage, AlertType, const Message)
|
12 |
+
|
13 |
+
|
14 |
+
AlertType can be:
|
15 |
+
at_notice -
|
16 |
+
at_console - same as at_notice, but forces a ConPrintf, not a message box, prints output to server console, but only if 'developer' is 1.
|
17 |
+
at_aiconsole - same as at_console, but only shown if 'developer' is 2.
|
18 |
+
at_warning -
|
19 |
+
at_error -
|
20 |
+
at_logged - prints output to server logs and console.
|
EngFunc_AnimationAutomove.txt
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
Code:
|
3 |
+
EngFunc_AnimationAutomove
|
4 |
+
|
5 |
+
Description :
|
6 |
+
Plays the selected animation on entity
|
7 |
+
|
8 |
+
|
9 |
+
Usage :
|
10 |
+
Code:
|
11 |
+
entity_set_float(iEnt, EV_FL_framerate, fFrameRate);
|
12 |
+
entity_set_int(iEnt, EV_INT_sequence, iSequence);
|
13 |
+
engfunc(EngFunc_AnimationAutomove, iEnt, fTime);
|
14 |
+
|
15 |
+
Parameters
|
16 |
+
fFrameRate = Frame rate of desired animation.
|
17 |
+
iSequence = Sequence to play.
|
18 |
+
iEnt = Source entity.
|
19 |
+
fTime = It seems to not affect the animation. Maybe for internal use.
|
20 |
+
|
21 |
+
First you have to select the sequence and the desired frame rate. Then you can start the animation.
|
22 |
+
It will run in an endless loop.
|
23 |
+
|
24 |
+
It seems to work only on non-player entities
|
25 |
+
__________________
|
EngFunc_CheckVisibility.txt
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function:
|
2 |
+
PHP Code:
|
3 |
+
EngFunc_CheckVisibility
|
4 |
+
Description:
|
5 |
+
This function is used to check if an entity is in your PVS.
|
6 |
+
It can be used on all entities except worldspawn!
|
7 |
+
Here I will show you how to use is, since this function has a paramater that must be obtained in a special way!
|
8 |
+
|
9 |
+
What is PVS?
|
10 |
+
PVS means potentially visible set, this means that the entities that we have in this list can be seen.
|
11 |
+
PVS does not hold just the entities that we see!
|
12 |
+
By knowing this we can get to the conclusion that PVS has the role of limiting data transfer for better internet connection/lower amount of data transfer!
|
13 |
+
|
14 |
+
So in small words I want to say something like this:
|
15 |
+
Code:
|
16 |
+
Entity that is in PVS => Can be seen => Data Transfer about that entity
|
17 |
+
Entity that it is not in PVS => Can not be seen => No data transfer => Save bandwidth
|
18 |
+
How does it work?
|
19 |
+
Well let's say that every room of the map is a cube.
|
20 |
+
We find ourselves in a room and that also means that we are in the cube of that room.
|
21 |
+
We can see the entities in the next rooms because the cubes of that room touch with the cube of the room we are in.
|
22 |
+
|
23 |
+
How do I use this function?
|
24 |
+
Well this function has a parameter that must be obtained in a special way. That is the "pset" parameter.
|
25 |
+
Here is how you obtain that parameter.
|
26 |
+
Note: The parameter is player only, that means that if you get pset for example for a player that has the id "1". When you use this function on an entity it will check whether that entity is in PVS of the Player id "1".
|
27 |
+
|
28 |
+
Example Usage:
|
29 |
+
PHP Code:
|
30 |
+
new g_cl_pset[33]
|
31 |
+
|
32 |
+
public plugin_init(id)
|
33 |
+
{
|
34 |
+
register_forward(FM_AddToFullPack, "pfw_atfp", 1)
|
35 |
+
}
|
36 |
+
|
37 |
+
public pfw_atfp(es, e, ent, host, flags, player, set)
|
38 |
+
{
|
39 |
+
g_cl_pset[host] = set
|
40 |
+
|
41 |
+
return FMRES_IGNORED
|
42 |
+
}
|
43 |
+
|
44 |
+
stock is_ent_in_player_pvs(id, entity)
|
45 |
+
{
|
46 |
+
return engfunc(EngFunc_CheckVisibility, entity, g_cl_pset[id])
|
47 |
+
}
|
48 |
+
|
49 |
+
stock get_pvs_players(id, players[32], num, flags[], team[])
|
50 |
+
{
|
51 |
+
if (!is_user_connected(id))
|
52 |
+
return 0
|
53 |
+
|
54 |
+
get_players(players, num, flags, team)
|
55 |
+
|
56 |
+
for (new i=0;i<num;i++)
|
57 |
+
{
|
58 |
+
if (!is_ent_in_player_pvs(id, players[i]))
|
59 |
+
{
|
60 |
+
num--;
|
61 |
+
|
62 |
+
for (new j=i;j<num;j++)
|
63 |
+
{
|
64 |
+
players[j] = players[j+1]
|
65 |
+
}
|
66 |
+
|
67 |
+
i--
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
return 1
|
72 |
+
}
|
EngFunc_DecalIndex.txt
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
|
3 |
+
Quote:
|
4 |
+
EngFunc_DecalIndex
|
5 |
+
|
6 |
+
Description :
|
7 |
+
|
8 |
+
Returns an unique index of the decal name provided.
|
9 |
+
|
10 |
+
A decal index is used for example in some TE_* messages. ( TE_PLAYERDECAL, TE_DECAL, etc.. See message_const.inc file ).
|
11 |
+
All the available decals are stored in the decals.wad file. ( Located at your mod root )
|
12 |
+
As side-note a plugin Decals/Models Lister is available to see a list of decals/models index/name. ( Only CS and HL )
|
13 |
+
|
14 |
+
Usage :
|
15 |
+
|
16 |
+
Code:
|
17 |
+
DecalIndex = engfunc( EngFunc_DecalIndex, "{bigshot1" );
|
18 |
+
__________________
|
EngFunc_FindClientInPVS.txt
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function:
|
2 |
+
PHP Code:
|
3 |
+
EngFunc_EntitiesInPVS
|
4 |
+
Description:
|
5 |
+
This function checks entities that are in the PVS of an entity.
|
6 |
+
It can be used on all entities except worldspawn!
|
7 |
+
|
8 |
+
What is PVS?
|
9 |
+
PVS means potentially visible set, this means that the entities that we have in this list can be seen.
|
10 |
+
PVS does not hold just the entities that we see!
|
11 |
+
By knowing this we can get to the conclusion that PVS has the role of limiting data transfer for better internet connection/lower amount of data transfer!
|
12 |
+
|
13 |
+
So in small words I want to say something like this:
|
14 |
+
Code:
|
15 |
+
Entity that is in PVS => Can be seen => Data Transfer about that entity
|
16 |
+
Entity that it is not in PVS => Can not be seen => No data transfer => Save bandwidth
|
17 |
+
How does it work?
|
18 |
+
Well let's say that every room of the map is a cube.
|
19 |
+
We find ourselves in a room and that also means that we are in the cube of that room.
|
20 |
+
We can see the entities in the next rooms because the cubes of that room touch with the cube of the room we are in.
|
21 |
+
|
22 |
+
How do I use this function?
|
23 |
+
Well this function doesn't work like EngFunc_FindEntityInSphere so the HL engine has another method of providing the information.
|
24 |
+
At first this function returns a start entity and after that we can find the next entity using pev_chain/EV_ENT_chain. And so on, untill pev_chain is NULL.
|
25 |
+
|
26 |
+
Example Usage:
|
27 |
+
PHP Code:
|
28 |
+
public whatisonPVS(id)
|
29 |
+
{
|
30 |
+
static next, chain
|
31 |
+
static class[32]
|
32 |
+
|
33 |
+
next = engfunc(EngFunc_EntitiesInPVS, id)
|
34 |
+
while(next)
|
35 |
+
{
|
36 |
+
pev(next, pev_classname, class, charsmax(class))
|
37 |
+
chain = pev(next, pev_chain)
|
38 |
+
|
39 |
+
server_print("Found entity in player (%i) PVS: ent(%i) class(%s)", id, next, class)
|
40 |
+
|
41 |
+
if(!chain)
|
42 |
+
break
|
43 |
+
|
44 |
+
next = chain
|
45 |
+
}
|
46 |
+
}
|
EngFunc_FindEntityInSphere.txt
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function:
|
2 |
+
PHP Code:
|
3 |
+
EngFunc_FindEntityInSphere
|
4 |
+
Description:
|
5 |
+
Find entities within a radius. The function returnes the next entity id after the start entity!
|
6 |
+
|
7 |
+
This is a drawing to show how this function works:
|
8 |
+
[IMG]http://img265.**************/img265/2395/screenshot053.png[/IMG]
|
9 |
+
|
10 |
+
|
11 |
+
If we use
|
12 |
+
PHP Code:
|
13 |
+
engfunc(EngFunc_FindEntityInSphere, -1, origin, radius)
|
14 |
+
The function in the situation above will return 1!
|
15 |
+
PHP Code:
|
16 |
+
engfunc(EngFunc_FindEntityInSphere, 20, origin, radius)
|
17 |
+
The function in the situation above will return 30!
|
18 |
+
PHP Code:
|
19 |
+
engfunc(EngFunc_FindEntityInSphere, 100, origin, radius)
|
20 |
+
The function in the situation above will return 0, meaning that it didn't find an entity with an id grater than 100!
|
21 |
+
|
22 |
+
|
23 |
+
Usage:
|
24 |
+
PHP Code:
|
25 |
+
engfunc(EngFunc_FindEntityInSphere, ent_to_start, origin, radius)
|
EngFunc_GetBonePosition.txt
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function:
|
2 |
+
PHP Code:
|
3 |
+
EngFunc_GetBonePosition
|
4 |
+
Description:
|
5 |
+
The function allows to get the bone positions of an entity. This is best used on getting specific player origin points.
|
6 |
+
|
7 |
+
These are the bones that a player has.
|
8 |
+
|
9 |
+
Code:
|
10 |
+
Bone 1 Name: "Bip01"
|
11 |
+
|
12 |
+
Bone 2 Name: "Bip01 Pelvis"
|
13 |
+
|
14 |
+
Bone 3 Name: "Bip01 Spine"
|
15 |
+
|
16 |
+
Bone 4 Name: "Bip01 Spine1"
|
17 |
+
|
18 |
+
Bone 5 Name: "Bip01 Spine2"
|
19 |
+
|
20 |
+
Bone 6 Name: "Bip01 Spine3"
|
21 |
+
|
22 |
+
Bone 7 Name: "Bip01 Neck"
|
23 |
+
|
24 |
+
Bone 8 Name: "Bip01 Head"
|
25 |
+
|
26 |
+
Bone 9 Name: "Bone01"
|
27 |
+
|
28 |
+
Bone 10 Name: "Bip01 L Clavicle"
|
29 |
+
|
30 |
+
Bone 11 Name: "Bip01 L UpperArm"
|
31 |
+
|
32 |
+
Bone 12 Name: "Bip01 L Forearm"
|
33 |
+
|
34 |
+
Bone 13 Name: "Bip01 L Hand"
|
35 |
+
|
36 |
+
Bone 14 Name: "Bip01 L Finger0"
|
37 |
+
|
38 |
+
Bone 15 Name: "Bip01 L Finger01"
|
39 |
+
|
40 |
+
Bone 16 Name: "Bip01 L Finger1"
|
41 |
+
|
42 |
+
Bone 17 Name: "Bip01 L Finger11"
|
43 |
+
|
44 |
+
Bone 18 Name: "-- L knuckle"
|
45 |
+
|
46 |
+
Bone 19 Name: "-- L Forearm twist"
|
47 |
+
|
48 |
+
Bone 20 Name: "-- L wrist"
|
49 |
+
|
50 |
+
Bone 21 Name: "-- L Elbow"
|
51 |
+
|
52 |
+
Bone 22 Name: "-- L bicep twist"
|
53 |
+
|
54 |
+
Bone 23 Name: "-- L shoulder outside"
|
55 |
+
|
56 |
+
Bone 24 Name: "-- L Shoulder inside"
|
57 |
+
|
58 |
+
Bone 25 Name: "Bip01 R Clavicle"
|
59 |
+
|
60 |
+
Bone 26 Name: "Bip01 R UpperArm"
|
61 |
+
|
62 |
+
Bone 27 Name: "Bip01 R Forearm"
|
63 |
+
|
64 |
+
Bone 28 Name: "Bip01 R Hand"
|
65 |
+
|
66 |
+
Bone 29 Name: "Bip01 R Finger0"
|
67 |
+
|
68 |
+
Bone 30 Name: "Bip01 R Finger01"
|
69 |
+
|
70 |
+
Bone 31 Name: "Bip01 R Finger1"
|
71 |
+
|
72 |
+
Bone 32 Name: "Bip01 R Finger11"
|
73 |
+
|
74 |
+
Bone 33 Name: "-- R knuckle"
|
75 |
+
|
76 |
+
Bone 34 Name: "-- R wrist"
|
77 |
+
|
78 |
+
Bone 35 Name: "-- R forearm twist"
|
79 |
+
|
80 |
+
Bone 36 Name: "-- R Elbow"
|
81 |
+
|
82 |
+
Bone 37 Name: "-- R bicep twist"
|
83 |
+
|
84 |
+
Bone 38 Name: "-- R Shoulder inside"
|
85 |
+
|
86 |
+
Bone 39 Name: "-- R shoulder outside"
|
87 |
+
|
88 |
+
Bone 40 Name: "-- Neck smooth"
|
89 |
+
|
90 |
+
Bone 41 Name: "-- R Butt"
|
91 |
+
|
92 |
+
Bone 42 Name: "-- L butt"
|
93 |
+
|
94 |
+
Bone 43 Name: "Bip01 L Thigh"
|
95 |
+
|
96 |
+
Bone 44 Name: "Bip01 L Calf"
|
97 |
+
|
98 |
+
Bone 45 Name: "Bip01 L Foot"
|
99 |
+
|
100 |
+
Bone 46 Name: "Bip01 L Toe0"
|
101 |
+
|
102 |
+
Bone 47 Name: "-- L ankle"
|
103 |
+
|
104 |
+
Bone 48 Name: "-- L Knee"
|
105 |
+
|
106 |
+
Bone 49 Name: "Bip01 R Thigh"
|
107 |
+
|
108 |
+
Bone 50 Name: "Bip01 R Calf"
|
109 |
+
|
110 |
+
Bone 51 Name: "Bip01 R Foot"
|
111 |
+
|
112 |
+
Bone 52 Name: "Bip01 R Toe0"
|
113 |
+
|
114 |
+
Bone 53 Name: "-- R Ankle"
|
115 |
+
|
116 |
+
Bone 54 Name: "-- R Knee"
|
117 |
+
|
118 |
+
Bone 55 Name: "Bomb"
|
119 |
+
This image shows the locations of the bones, they are marked through blue points. The red point is the player origin.
|
120 |
+
|
121 |
+
[IMG]http://img507.**************/img507/7762/playerskeleton.jpg[/IMG]
|
122 |
+
|
123 |
+
|
124 |
+
Usage:
|
125 |
+
PHP Code:
|
126 |
+
// ENTITY is the player entity id
|
127 |
+
// BONE_NUMBER you have to choose from the list above
|
128 |
+
// bone_origin[3] is the vector where we save the bone origin
|
129 |
+
// bone_angles[3] the vector that holds the angles of the bone.
|
130 |
+
engfunc(EngFunc_GetBonePosition, ENTITY, BONE_NUMBER, Float:bone_origin[3], Float:bone_angles[3])
|
131 |
+
Useful Stocks:
|
132 |
+
These stocks are made for CS/CZ you need to port them to other mods.
|
133 |
+
|
134 |
+
This gets the hitgroup of the bone.
|
135 |
+
PHP Code:
|
136 |
+
#define BONE_HIT_HEAD 8
|
137 |
+
#define BONE_HIT_CHEST 6
|
138 |
+
#define BONE_HIT_STOMACH 4
|
139 |
+
#define BONE_HIT_LEFTARM 24
|
140 |
+
#define BONE_HIT_RIGHTARM 39
|
141 |
+
#define BONE_HIT_LEFTLEG 48
|
142 |
+
#define BONE_HIT_RIGHTLEG 54
|
143 |
+
#define HEAD_NECK 40
|
144 |
+
#define BONE_L_BUTT 41
|
145 |
+
#define BONE_R_BUTT 42
|
146 |
+
|
147 |
+
stock get_bone_hitgroup(number)
|
148 |
+
{
|
149 |
+
switch (number)
|
150 |
+
{
|
151 |
+
case HEAD_NECK:
|
152 |
+
{
|
153 |
+
return HIT_HEAD
|
154 |
+
}
|
155 |
+
case BONE_L_BUTT:
|
156 |
+
{
|
157 |
+
return HIT_LEFTLEG
|
158 |
+
}
|
159 |
+
case BONE_R_BUTT:
|
160 |
+
{
|
161 |
+
return HIT_RIGHTLEG
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
if (1 <= number <= BONE_HIT_STOMACH)
|
166 |
+
return HIT_STOMACH
|
167 |
+
|
168 |
+
if (BONE_HIT_STOMACH < number <= BONE_HIT_CHEST)
|
169 |
+
return HIT_CHEST
|
170 |
+
|
171 |
+
if (BONE_HIT_CHEST < number <= BONE_HIT_HEAD)
|
172 |
+
return HIT_HEAD
|
173 |
+
|
174 |
+
if (BONE_HIT_HEAD < number <= BONE_HIT_LEFTARM)
|
175 |
+
return HIT_LEFTARM
|
176 |
+
|
177 |
+
if (BONE_HIT_LEFTARM < number <= BONE_HIT_RIGHTARM)
|
178 |
+
return HIT_RIGHTARM
|
179 |
+
|
180 |
+
if (BONE_HIT_RIGHTARM < number <= BONE_HIT_LEFTLEG)
|
181 |
+
return HIT_LEFTLEG
|
182 |
+
|
183 |
+
if (BONE_HIT_LEFTLEG < number <= BONE_HIT_RIGHTLEG)
|
184 |
+
return HIT_RIGHTLEG
|
185 |
+
|
186 |
+
return HIT_GENERIC
|
187 |
+
}
|
188 |
+
This gets the closest bone to the gunshot [Use this in FM_TraceLine and Ham_TraceAttack
|
189 |
+
PHP Code:
|
190 |
+
#define DISTANCE_CLEAR_HIT 2.0
|
191 |
+
|
192 |
+
stock find_closest_bone_to_gunshot(victim, Float:endtrace[3])
|
193 |
+
{
|
194 |
+
new Float:angles[3], Float:origin[3], Float:dist = 9999999.99, Float:curorigin[3], bone_nr
|
195 |
+
for (new i=1;i<=54;i++)
|
196 |
+
{
|
197 |
+
// Get the bone position
|
198 |
+
engfunc(EngFunc_GetBonePosition, victim, i, curorigin, angles)
|
199 |
+
// Calculate the distance vector
|
200 |
+
xs_vec_sub(curorigin, endtrace, angles)
|
201 |
+
|
202 |
+
// If this is smaller than the last small distance remember the value!
|
203 |
+
if (xs_vec_len(angles) <= dist)
|
204 |
+
{
|
205 |
+
origin = curorigin
|
206 |
+
dist = xs_vec_len(angles)
|
207 |
+
bone_nr = i
|
208 |
+
}
|
209 |
+
|
210 |
+
// If distance is smaller than CLEARHIT! Break (We accept the last value!)
|
211 |
+
if (dist <= DISTANCE_CLEAR_HIT)
|
212 |
+
{
|
213 |
+
break
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
// Return the bone
|
218 |
+
return bone_nr
|
219 |
+
}
|
EngFunc_MessageBegin.txt
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta Function:
|
2 |
+
|
3 |
+
EngFunc_MessageBegin
|
4 |
+
|
5 |
+
Description:
|
6 |
+
|
7 |
+
This function is used to generate client messages.
|
8 |
+
|
9 |
+
Usage:
|
10 |
+
|
11 |
+
engfunc(EngFunc_MessageBegin,dest,msg_type,or igin[3]={0,0,0},player=0)
|
12 |
+
|
13 |
+
PHP Code:
|
14 |
+
static Float:origin[3] // Origin should be a Float
|
15 |
+
pev(id, pev_origin, origin) // Get user origin
|
16 |
+
engfunc(EngFunc_MessageBegin,MSG_BROADCAST,SVC_TEMPENTITY,origin,0) // Create message
|
17 |
+
PHP Code:
|
18 |
+
//With MSG_ONE_UNRELIABLE
|
19 |
+
engfunc(EngFunc_MessageBegin,MSG_ONE_UNRELIABLE,SVC_TEMPENTITY,_,id) // Create message
|
20 |
+
PHP Code:
|
21 |
+
//With MSG_ALL
|
22 |
+
engfunc(EngFunc_MessageBegin,MSG_ONE_UNRELIABLE,SVC_TEMPENTITY,_,id) // Create message
|
23 |
+
dest can be :
|
24 |
+
|
25 |
+
Code:
|
26 |
+
#define MSG_BROADCAST 0 // Unreliable to all, There is not id
|
27 |
+
#define MSG_ONE 1 // Reliable to one (msg_entity)
|
28 |
+
#define MSG_ALL 2 // Reliable to all, There is not origin
|
29 |
+
#define MSG_INIT 3 // Write to the init string
|
30 |
+
#define MSG_PVS 4 // Ents in PVS of org
|
31 |
+
#define MSG_PAS 5 // Ents in PAS of org
|
32 |
+
#define MSG_PVS_R 6 // Reliable to PVS
|
33 |
+
#define MSG_PAS_R 7 // Reliable to PAS
|
34 |
+
#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram (could be dropped), There is not origin
|
35 |
+
#define MSG_SPEC 9 // Sends to all spectator proxies
|
36 |
+
Before calling another EngFunc_MessageBegin you must call message_end()
|
EngFunc_ModelFrames.txt
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
|
3 |
+
Quote:
|
4 |
+
EngFunc_ModelFrames
|
5 |
+
|
6 |
+
Description :
|
7 |
+
|
8 |
+
Returns the frames number of a model.
|
9 |
+
|
10 |
+
Usage :
|
11 |
+
|
12 |
+
Code:
|
13 |
+
ModelFrames = engfunc( EngFunc_ModelFrames, ModelIndex );
|
14 |
+
ModelIndex = The model index. Value you can get from precache_model() or EngFunc_ModelIndex.
|
EngFunc_ModelIndex.txt
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
|
3 |
+
Quote:
|
4 |
+
EngFunc_ModelIndex
|
5 |
+
|
6 |
+
Description :
|
7 |
+
|
8 |
+
Returns an unique index of the model name provided.
|
9 |
+
It's actually the same number that precache_model() returns.
|
10 |
+
|
11 |
+
A model index is used for example in some TE_* messages. ( TE_LIGHTNING, TE_GLOWSPRITE, etc.. See message_const.inc file ).
|
12 |
+
The model index of an entity is stored in pev_modelindex.
|
13 |
+
|
14 |
+
Usage :
|
15 |
+
|
16 |
+
Code:
|
17 |
+
ModelIndex = engfunc( EngFunc_ModelIndex, "models/MyModel.mdl" );
|
EngFunc_MoveToOrigin.txt
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
Code:
|
3 |
+
EngFunc_MoveToOrigin
|
4 |
+
|
5 |
+
Description :
|
6 |
+
Moves an entity a defined distance toward a coordinate.
|
7 |
+
|
8 |
+
If the distance between Entity and Destination is less than the required distance, the entity will pass over that point.
|
9 |
+
Usage :
|
10 |
+
Code:
|
11 |
+
engfunc(EngFunc_MoveToOrigin, iEnt, Float:Destination[3], Float:Distance, iMoveType);
|
12 |
+
|
13 |
+
Parameters
|
14 |
+
iEnt = Entity index
|
15 |
+
Destination[3] = A Coordinate toward which the entity moves
|
16 |
+
Distance = The distance to move the entity
|
17 |
+
iMoveType = This is the MOVE_* option used for monsters and players to change the behaviour of the movement
|
18 |
+
Code:
|
19 |
+
#define MOVE_NORMAL 0 // normal move in the direction monster is facing
|
20 |
+
#define MOVE_STRAFE 1 // moves in direction specified, no matter which way monster is facing
|
21 |
+
#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck.
|
22 |
+
#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal
|
23 |
+
Caveats :
|
24 |
+
iEnt must be on ground
|
25 |
+
If there's an object closer than Distance that iEnt could collide then the movement is not done
|
26 |
+
If there's a ramp, it works like an object and the movement is not done
|
EngFunc_NumberOfEntities.txt
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
Code:
|
3 |
+
EngFunc_NumberOfEntities
|
4 |
+
|
5 |
+
Description :
|
6 |
+
Returns the number of entities in the world.
|
7 |
+
|
8 |
+
|
9 |
+
Usage :
|
10 |
+
Code:
|
11 |
+
ents = engfunc(EngFunc_NumberOfEntities);
|
12 |
+
|
13 |
+
Engine Replacement :
|
14 |
+
http://www.amxmodx.org/funcwiki.php?go=func&id=356
|
15 |
+
Code:
|
16 |
+
ents = entity_count();
|
EngFunc_PointContents.txt
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function:
|
2 |
+
PHP Code:
|
3 |
+
EngFunc_PointContents
|
4 |
+
Description:
|
5 |
+
This function checks an origin and gives us information of its whearabouts.
|
6 |
+
|
7 |
+
The constants that this function returns are these:
|
8 |
+
Code:
|
9 |
+
#define CONTENTS_EMPTY -1
|
10 |
+
#define CONTENTS_SOLID -2
|
11 |
+
#define CONTENTS_WATER -3
|
12 |
+
#define CONTENTS_SLIME -4
|
13 |
+
#define CONTENTS_LAVA -5
|
14 |
+
#define CONTENTS_SKY -6
|
15 |
+
#define CONTENTS_ORIGIN -7 // Removed at csg time
|
16 |
+
#define CONTENTS_CLIP -8 // Changed to contents_solid
|
17 |
+
#define CONTENTS_CURRENT_0 -9
|
18 |
+
#define CONTENTS_CURRENT_90 -10
|
19 |
+
#define CONTENTS_CURRENT_180 -11
|
20 |
+
#define CONTENTS_CURRENT_270 -12
|
21 |
+
#define CONTENTS_CURRENT_UP -13
|
22 |
+
#define CONTENTS_CURRENT_DOWN -14
|
23 |
+
#define CONTENTS_TRANSLUCENT -15
|
24 |
+
#define CONTENTS_LADDER -16
|
25 |
+
#define CONTENT_FLYFIELD -17
|
26 |
+
#define CONTENT_GRAVITY_FLYFIELD -18
|
27 |
+
#define CONTENT_FOG -19
|
28 |
+
Usage:
|
29 |
+
PHP Code:
|
30 |
+
static Float:origin[3]
|
31 |
+
static result
|
32 |
+
result = engfunc(EngFunc_PointContents, origin)
|
33 |
+
// if for example result is CONTENTS_SKY
|
34 |
+
// then the origin that we see is in the sky we can for example use this to see where a player is aming if he is aiming at sky this will be the result!
|
EngFunc_PrecacheModel.txt
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
|
3 |
+
Quote:
|
4 |
+
EngFunc_PrecacheModel
|
5 |
+
|
6 |
+
Description :
|
7 |
+
|
8 |
+
Precaches a model or sprite file.
|
9 |
+
|
10 |
+
This should be used only when you would need to postpone the precache processus in plugin_init() or plugin_cfg(), otherwise you should use precache_model() native directly in plugin_precache() forward.
|
11 |
+
It can be useful for example when you want to manage models with cvars and to avoid registering them in plugin_precache() then getting some trouble, you could manage out of this forward.
|
12 |
+
|
13 |
+
|
14 |
+
Usage :
|
15 |
+
|
16 |
+
Code:
|
17 |
+
engfunc( EngFunc_PrecacheModel, "models/MyModel.mdl" );
|
18 |
+
engfunc( EngFunc_PrecacheModel, "sprites/MySprite.spr" );
|
19 |
+
It returns the precached model/sprite index if successful, otherwise 0.
|
EngFunc_PrecacheSound.txt
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
|
3 |
+
Quote:
|
4 |
+
EngFunc_PrecacheSound
|
5 |
+
|
6 |
+
Description :
|
7 |
+
|
8 |
+
Precaches a sound, only *.wav file. ( for mp3, see EngFunc_PrecacheGeneric )
|
9 |
+
|
10 |
+
This should be used only when you would need to postpone the precache processus in plugin_init() or plugin_cfg(), otherwise you should use precache_sound() native directly in plugin_precache() forward.
|
11 |
+
It can be useful for example when you want to manage sounds with cvars and to avoid registering them in plugin_precache() then getting some trouble, you could manage out of this forward.
|
12 |
+
|
13 |
+
|
14 |
+
Usage :
|
15 |
+
|
16 |
+
Code:
|
17 |
+
engfunc( EngFunc_PrecacheSound, "sound/MySound.wav" );
|
18 |
+
It returns the precached sound index if successful, otherwise 0.
|
EngFunc_SetModel.txt
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
Code:
|
3 |
+
EngFunc_SetModel
|
4 |
+
|
5 |
+
Description :
|
6 |
+
Properly sets a new model on an entity.
|
7 |
+
|
8 |
+
|
9 |
+
Usage :
|
10 |
+
Code:
|
11 |
+
engfunc(EngFunc_SetModel, iEnt, sModel);
|
12 |
+
|
13 |
+
Parameters
|
14 |
+
iEnt = Entity index
|
15 |
+
sModel = Model file name to set on entity (ex: "models/player/vip/vip.mdl")
|
16 |
+
Engine Replacement :
|
17 |
+
|
18 |
+
Code:
|
19 |
+
entity_set_model( entity, Model[] );
|
EngFunc_SetOrigin.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
Code:
|
3 |
+
EngFunc_SetSize
|
4 |
+
|
5 |
+
Description :
|
6 |
+
Sets the bounds of an entity.
|
7 |
+
|
8 |
+
|
9 |
+
Usage :
|
10 |
+
Code:
|
11 |
+
engfunc(EngFunc_SetSize, iEnt, Float:fMins[3], Float:fMaxs[3]);
|
12 |
+
|
13 |
+
Parameters
|
14 |
+
iEnt = Entity index
|
15 |
+
fMins[3] = Mins boundings values (x,y,z)
|
16 |
+
fMaxs[3] = Maxs boundings values (x,y,z)
|
17 |
+
Engine Replacement :
|
18 |
+
Code:
|
19 |
+
entity_set_size( index, Float:mins[3], Float:maxs[3] );
|
20 |
+
__________________
|
EngFunc_SetSize.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
Code:
|
3 |
+
EngFunc_SetSize
|
4 |
+
|
5 |
+
Description :
|
6 |
+
Sets the bounds of an entity.
|
7 |
+
|
8 |
+
|
9 |
+
Usage :
|
10 |
+
Code:
|
11 |
+
engfunc(EngFunc_SetSize, iEnt, Float:fMins[3], Float:fMaxs[3]);
|
12 |
+
|
13 |
+
Parameters
|
14 |
+
iEnt = Entity index
|
15 |
+
fMins[3] = Mins boundings values (x,y,z)
|
16 |
+
fMaxs[3] = Maxs boundings values (x,y,z)
|
17 |
+
Engine Replacement :
|
18 |
+
http://www.amxmodx.org/funcwiki.php?go=func&id=328
|
19 |
+
Code:
|
20 |
+
entity_set_size( index, Float:mins[3], Float:maxs[3] );
|
EngFunc_TraceLine Explanation.txt
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function:
|
2 |
+
PHP Code:
|
3 |
+
EngFunc_TraceLine
|
4 |
+
Description:
|
5 |
+
This function traces between 2 origins and gives us information about it.
|
6 |
+
|
7 |
+
The constants that we can use in flags:
|
8 |
+
PHP Code:
|
9 |
+
#define DONT_IGNORE_MONSTERS 0
|
10 |
+
#define IGNORE_MONSTERS 1
|
11 |
+
#define IGNORE_MISSILE 2
|
12 |
+
#define IGNORE_GLASS 0x100
|
13 |
+
These constants can be used together.
|
14 |
+
Ex: IGNORE_MISSILE | IGNORE_MONSTERS | IGNORE_GLASS - This makes the traceline ignore missiles, monsters (players) and glass.
|
15 |
+
|
16 |
+
Here is a drawing that will show you how it works!
|
17 |
+
PHP Code:
|
18 |
+
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, 0, tr)
|
19 |
+
[IMG]http://img529.**************/img529/1863/traceline1.jpg[/IMG]
|
20 |
+
|
21 |
+
PHP Code:
|
22 |
+
engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, 0, tr)
|
23 |
+
|
24 |
+
|
25 |
+
PHP Code:
|
26 |
+
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, 0, tr)
|
27 |
+
|
28 |
+
|
29 |
+
PHP Code:
|
30 |
+
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, 0, tr)
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
Functions that come with the TraceLine pack:
|
35 |
+
PHP Code:
|
36 |
+
// Description: This creates a trace handle!
|
37 |
+
// It is important to use because we don't want our plugins to mess with eachothers info!
|
38 |
+
new ptr = create_tr2()
|
39 |
+
PHP Code:
|
40 |
+
// Description: This creates a trace handle!
|
41 |
+
// It is important to use because we don't want our plugins to mess with each others info!
|
42 |
+
free_tr2(ptr)
|
43 |
+
PHP Code:
|
44 |
+
// Description: Gets/Sets information from/in the trace_handle
|
45 |
+
[g|s]et_tr2(trace_handle, CONSTANT, number_if_needed!)
|
46 |
+
CONSTANT Expresion has this posible values:
|
47 |
+
Code:
|
48 |
+
enum TraceResult
|
49 |
+
{
|
50 |
+
TR_AllSolid, // int
|
51 |
+
TR_StartSolid, // int
|
52 |
+
TR_InOpen, // int
|
53 |
+
TR_InWater, // int
|
54 |
+
TR_flFraction, // float
|
55 |
+
TR_vecEndPos, // float array[3]
|
56 |
+
TR_flPlaneDist, // float
|
57 |
+
TR_vecPlaneNormal, // float array[3]
|
58 |
+
TR_pHit, // int (edict_t*)
|
59 |
+
TR_iHitgroup, // int
|
60 |
+
};
|
61 |
+
The float and array values need the third argument! Example:
|
62 |
+
|
63 |
+
PHP Code:
|
64 |
+
new allsolid = get_tr2(trace, TR_AllSolid)
|
65 |
+
new startsolid = get_tr2(trace, TR_StartSolid)
|
66 |
+
// TR_StartSolid is a boolean that says whether you were "inside" something
|
67 |
+
// (usually the world) when the trace started (point A)
|
68 |
+
// TR_AllSolid tells you if you ever got out of the "inside" or not.
|
69 |
+
|
70 |
+
new inopen = get_tr2(trace, TR_InOpen)
|
71 |
+
// TR_InOpen means that the start point is in Open
|
72 |
+
// That means in the world and not in an ent or something
|
73 |
+
|
74 |
+
new hit = get_tr2(trace, TR_pHit)
|
75 |
+
// What was hit by the traceline. It will either be a player index,
|
76 |
+
// entity index, 0 (part of map), or -1 (didn't hit anything;
|
77 |
+
// doesn't happen with player tracelines).
|
78 |
+
|
79 |
+
new hitgroup = get_tr2(trace, TR_iHitgroup)
|
80 |
+
// If the traceline hit another player, returns will be HIT_HEAD,
|
81 |
+
// HIT_CHEST, HIT_LEFTLEG... etc. If the traceline hit part of the
|
82 |
+
// map, this returns HIT_GENERIC.
|
83 |
+
|
84 |
+
new Float:fraction
|
85 |
+
get_tr2(trace, TR_flFraction, fraction)
|
86 |
+
// Returns a number between 0.0 and 1.0, indicating how far the
|
87 |
+
// traceline traveled start to end before it hit something. Depending
|
88 |
+
// on what conditions were passed to this traceline forward function,
|
89 |
+
// it could either be a wall or another entity.
|
90 |
+
|
91 |
+
new Float:end_origin[3]
|
92 |
+
get_tr2(trace, TR_vecEndPos, end_origin)
|
93 |
+
// The official end of the traceline. Not necesarily the same as the
|
94 |
+
// second argument passed to this traceline forward function.
|
95 |
+
|
96 |
+
new Float:normal[3]
|
97 |
+
get_tr2(trace, TR_vecPlaneNormal, normal)
|
98 |
+
// Returns a 1 unit long vector normal to the spot that it hit. Note
|
99 |
+
// that "normal" has a special connotation here. It doesn't mean "regular."
|
100 |
+
Example Stock:
|
101 |
+
PHP Code:
|
102 |
+
stock is_wall_between_points(Float:start[3], Float:end[3], ignore_ent)
|
103 |
+
{
|
104 |
+
// Create the trace handle! It is best to create it!
|
105 |
+
new ptr = create_tr2()
|
106 |
+
|
107 |
+
// The main traceline function!
|
108 |
+
// This function ignores GLASS, MISSILE and MONSTERS!
|
109 |
+
// Here is an example of how you should combine all the flags!
|
110 |
+
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS | IGNORE_MONSTERS | IGNORE_MISSILE, ignore_ent, ptr)
|
111 |
+
|
112 |
+
// We are interested in the fraction parameter
|
113 |
+
new fraction
|
114 |
+
get_tr2(ptr, TR_flFraction, fraction)
|
115 |
+
|
116 |
+
// Free the trace handle (don't forget to do this!)
|
117 |
+
free_tr2(ptr)
|
118 |
+
|
119 |
+
// If = 1.0 then it didn't hit anything!
|
120 |
+
return (fraction != 1.0)
|
121 |
+
}
|
EngFunc_TraceLine.txt
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function:
|
2 |
+
PHP Code:
|
3 |
+
EngFunc_TraceLine
|
4 |
+
Description:
|
5 |
+
This function traces between 2 origins and gives us information about it.
|
6 |
+
|
7 |
+
The constants that we can use in flags:
|
8 |
+
PHP Code:
|
9 |
+
#define DONT_IGNORE_MONSTERS 0
|
10 |
+
#define IGNORE_MONSTERS 1
|
11 |
+
#define IGNORE_MISSILE 2
|
12 |
+
#define IGNORE_GLASS 0x100
|
13 |
+
These constants can be used together.
|
14 |
+
Ex: IGNORE_MISSILE | IGNORE_MONSTERS | IGNORE_GLASS - This makes the traceline ignore missiles, monsters (players) and glass.
|
15 |
+
|
16 |
+
Here is a drawing that will show you how it works!
|
17 |
+
PHP Code:
|
18 |
+
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, 0, tr)
|
19 |
+
[IMG]http://img529.**************/img529/1863/traceline1.jpg[/IMG]
|
20 |
+
|
21 |
+
PHP Code:
|
22 |
+
engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, 0, tr)
|
23 |
+
[IMG]http://img529.**************/img529/1415/traceline2.jpg[/IMG]
|
24 |
+
|
25 |
+
PHP Code:
|
26 |
+
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, 0, tr)
|
27 |
+
[IMG]http://img529.**************/img529/5815/traceline3.jpg[/IMG]
|
28 |
+
|
29 |
+
PHP Code:
|
30 |
+
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, 0, tr)
|
31 |
+
[IMG]http://img529.**************/img529/326/traceline4.jpg[/IMG]
|
32 |
+
|
33 |
+
Functions that come with the TraceLine pack:
|
34 |
+
PHP Code:
|
35 |
+
// Description: This creates a trace handle!
|
36 |
+
// It is important to use because we don't want our plugins to mess with eachothers info!
|
37 |
+
new ptr = create_tr2()
|
38 |
+
PHP Code:
|
39 |
+
// Description: This creates a trace handle!
|
40 |
+
// It is important to use because we don't want our plugins to mess with each others info!
|
41 |
+
free_tr2(ptr)
|
42 |
+
PHP Code:
|
43 |
+
// Description: Gets/Sets information from/in the trace_handle
|
44 |
+
[g|s]et_tr2(trace_handle, CONSTANT, number_if_needed!)
|
45 |
+
CONSTANT Expresion has this posible values:
|
46 |
+
Code:
|
47 |
+
enum TraceResult
|
48 |
+
{
|
49 |
+
TR_AllSolid, // int
|
50 |
+
TR_StartSolid, // int
|
51 |
+
TR_InOpen, // int
|
52 |
+
TR_InWater, // int
|
53 |
+
TR_flFraction, // float
|
54 |
+
TR_vecEndPos, // float array[3]
|
55 |
+
TR_flPlaneDist, // float
|
56 |
+
TR_vecPlaneNormal, // float array[3]
|
57 |
+
TR_pHit, // int (edict_t*)
|
58 |
+
TR_iHitgroup, // int
|
59 |
+
};
|
60 |
+
The float and array values need the third argument! Example:
|
61 |
+
|
62 |
+
PHP Code:
|
63 |
+
new allsolid = get_tr2(trace, TR_AllSolid)
|
64 |
+
new startsolid = get_tr2(trace, TR_StartSolid)
|
65 |
+
// TR_StartSolid is a boolean that says whether you were "inside" something
|
66 |
+
// (usually the world) when the trace started (point A)
|
67 |
+
// TR_AllSolid tells you if you ever got out of the "inside" or not.
|
68 |
+
|
69 |
+
new inopen = get_tr2(trace, TR_InOpen)
|
70 |
+
// TR_InOpen means that the start point is in Open
|
71 |
+
// That means in the world and not in an ent or something
|
72 |
+
|
73 |
+
new hit = get_tr2(trace, TR_pHit)
|
74 |
+
// What was hit by the traceline. It will either be a player index,
|
75 |
+
// entity index, 0 (part of map), or -1 (didn't hit anything;
|
76 |
+
// doesn't happen with player tracelines).
|
77 |
+
|
78 |
+
new hitgroup = get_tr2(trace, TR_iHitgroup)
|
79 |
+
// If the traceline hit another player, returns will be HIT_HEAD,
|
80 |
+
// HIT_CHEST, HIT_LEFTLEG... etc. If the traceline hit part of the
|
81 |
+
// map, this returns HIT_GENERIC.
|
82 |
+
|
83 |
+
new Float:fraction
|
84 |
+
get_tr2(trace, TR_flFraction, fraction)
|
85 |
+
// Returns a number between 0.0 and 1.0, indicating how far the
|
86 |
+
// traceline traveled start to end before it hit something. Depending
|
87 |
+
// on what conditions were passed to this traceline forward function,
|
88 |
+
// it could either be a wall or another entity.
|
89 |
+
|
90 |
+
new Float:end_origin[3]
|
91 |
+
get_tr2(trace, TR_vecEndPos, end_origin)
|
92 |
+
// The official end of the traceline. Not necesarily the same as the
|
93 |
+
// second argument passed to this traceline forward function.
|
94 |
+
|
95 |
+
new Float:normal[3]
|
96 |
+
get_tr2(trace, TR_vecPlaneNormal, normal)
|
97 |
+
// Returns a 1 unit long vector normal to the spot that it hit. Note
|
98 |
+
// that "normal" has a special connotation here. It doesn't mean "regular."
|
99 |
+
Example Stock:
|
100 |
+
PHP Code:
|
101 |
+
stock is_wall_between_points(Float:start[3], Float:end[3], ignore_ent)
|
102 |
+
{
|
103 |
+
// Create the trace handle! It is best to create it!
|
104 |
+
new ptr = create_tr2()
|
105 |
+
|
106 |
+
// The main traceline function!
|
107 |
+
// This function ignores GLASS, MISSILE and MONSTERS!
|
108 |
+
// Here is an example of how you should combine all the flags!
|
109 |
+
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS | IGNORE_MONSTERS | IGNORE_MISSILE, ignore_ent, ptr)
|
110 |
+
|
111 |
+
// We are interested in the fraction parameter
|
112 |
+
new fraction
|
113 |
+
get_tr2(ptr, TR_flFraction, fraction)
|
114 |
+
|
115 |
+
// Free the trace handle (don't forget to do this!)
|
116 |
+
free_tr2(ptr)
|
117 |
+
|
118 |
+
// If = 1.0 then it didn't hit anything!
|
119 |
+
return (fraction != 1.0)
|
120 |
+
}
|
EngFunc_TraceModel.txt
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function:
|
2 |
+
PHP Code:
|
3 |
+
EngFunc_TraceModel
|
4 |
+
Description:
|
5 |
+
This function traces between 2 origins a model and gives us properties about it.
|
6 |
+
It acts just like a TraceLine but it ignores all the entities except the one we want to hit!
|
7 |
+
|
8 |
+
The constants that we can use in hull:
|
9 |
+
PHP Code:
|
10 |
+
#define HULL_POINT 0 // This means that we are moving a point from the start to the end
|
11 |
+
#define HULL_HUMAN 1 // That means that we move a cube of a player from start to end
|
12 |
+
#define HULL_LARGE 2 // That means that we move a bigger cube that one of the player from start to end (used in HL for big monsters!)
|
13 |
+
#define HULL_HEAD 3 // This means that we move from start to end the hull of a ducked player
|
14 |
+
Usage:
|
15 |
+
PHP Code:
|
16 |
+
// start - start origin
|
17 |
+
// end - end origin
|
18 |
+
// hull - the hull that is moved check above to see them
|
19 |
+
// ent_to_hit - the entity that you want to hit (this is a must!)
|
20 |
+
// ptr - the trace handle pointer, acts the same as the one in trace line!
|
21 |
+
engfunc(EngFunc_TraceModel, const Float:start[3], const Float:end[3], hull, ent_to_hit, ptr)
|
EngFunc_TraceToss.txt
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Fakemeta function :
|
2 |
+
Code:
|
3 |
+
EngFunc_TraceToss
|
4 |
+
|
5 |
+
Description :
|
6 |
+
Trace the point where some entity movement will finish.
|
7 |
+
If for some reason the entity movement must be blocked for other entity (or worldspawn), TraceToss will detect that situation taking in account the original entity bounding boxes.
|
8 |
+
|
9 |
+
|
10 |
+
Usage :
|
11 |
+
Code:
|
12 |
+
engfunc(EngFunc_TraceToss, ent, skipent, tr);
|
13 |
+
|
14 |
+
Parameters
|
15 |
+
ent = The entity which movement we want to trace
|
16 |
+
skipent = The entity to skip in trace
|
17 |
+
tr = trace result
|
18 |
+
Example:
|
19 |
+
|
20 |
+
If you open the attached image, you can see a player jumping and 2 points.
|
21 |
+
|
22 |
+
Start Point: Is the origin of the player when TraceToss was called
|
23 |
+
End Point: Is the point returned in TR result
|
24 |
+
|
25 |
+
So the player is making a parabola from START to END.
|
26 |
+
The green line is only for testing purposes and show from where to where the trace is.
|
27 |
+
This was tested with gravity = 400.
|
TraceModel usage simple example..txt
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
cvars
|
2 |
+
shoot_c4 0 - disabled , 1 - ct's can shoot it, 2 - everybody can shoot it
|
3 |
+
shoot_smoke 0 - disabled , 1 - enabled
|
4 |
+
shoot_flash 0 - disabled , 1 - enabled
|
5 |
+
shoot_he 0 - disabled , 1 - enabled
|
6 |
+
|
7 |
+
|
8 |
+
#include <amxmodx>
|
9 |
+
|
10 |
+
#include <fakemeta>
|
11 |
+
#include <engine>
|
12 |
+
#include <hamsandwich>
|
13 |
+
|
14 |
+
#include <cstrike>
|
15 |
+
|
16 |
+
#include <xs>
|
17 |
+
|
18 |
+
new const Plugin[] = "Shoot Grenades"
|
19 |
+
new const Author[] = "joaquimandrade"
|
20 |
+
new const Version[] = "1.1"
|
21 |
+
|
22 |
+
enum Grenade
|
23 |
+
{
|
24 |
+
Flashbang,
|
25 |
+
He,
|
26 |
+
Smoke,
|
27 |
+
C4
|
28 |
+
}
|
29 |
+
|
30 |
+
new Cvars[Grenade]
|
31 |
+
|
32 |
+
new CvarsNames[Grenade][] =
|
33 |
+
{
|
34 |
+
"flash",
|
35 |
+
"he",
|
36 |
+
"smoke",
|
37 |
+
"c4"
|
38 |
+
}
|
39 |
+
|
40 |
+
// Arkshine
|
41 |
+
const m_flC4Blow = 100
|
42 |
+
|
43 |
+
new Trie:RegisteredClasses
|
44 |
+
|
45 |
+
public plugin_precache()
|
46 |
+
{
|
47 |
+
RegisteredClasses = TrieCreate()
|
48 |
+
|
49 |
+
register_forward(FM_Spawn,"spawn")
|
50 |
+
}
|
51 |
+
|
52 |
+
public spawn(id)
|
53 |
+
{
|
54 |
+
if(pev_valid(id))
|
55 |
+
{
|
56 |
+
static classname[32]
|
57 |
+
pev(id,pev_classname,classname,charsmax(classname))
|
58 |
+
|
59 |
+
if(!TrieKeyExists(RegisteredClasses,classname))
|
60 |
+
{
|
61 |
+
RegisterHam(Ham_TraceAttack,classname,"globalTraceAttack")
|
62 |
+
TrieSetCell(RegisteredClasses,classname,true)
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
public plugin_init()
|
68 |
+
{
|
69 |
+
register_plugin(Plugin,Version,Author)
|
70 |
+
|
71 |
+
RegisterHam(Ham_TraceAttack,"worldspawn","globalTraceAttack")
|
72 |
+
RegisterHam(Ham_TraceAttack,"player","globalTraceAttack")
|
73 |
+
|
74 |
+
register_cvar("shootGrenades_version",Version,FCVAR_SERVER|FCVAR_SPONLY)
|
75 |
+
}
|
76 |
+
|
77 |
+
public plugin_cfg()
|
78 |
+
{
|
79 |
+
new cvarName[15]
|
80 |
+
|
81 |
+
for(new Grenade:i=Grenade:0;i<Grenade;i++)
|
82 |
+
{
|
83 |
+
formatex(cvarName,charsmax(cvarName),"shoot_%s",CvarsNames[i])
|
84 |
+
Cvars[i] = register_cvar(cvarName,"1")
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
public globalTraceAttack(this,attackerID,Float:damage,Float:direction[3],tracehandle,damagebits)
|
89 |
+
{
|
90 |
+
if(1 <= attackerID <= 32)
|
91 |
+
{
|
92 |
+
static Float:origin[3]
|
93 |
+
pev(attackerID,pev_origin,origin)
|
94 |
+
|
95 |
+
static Float:viewOfs[3]
|
96 |
+
pev(attackerID,pev_view_ofs,viewOfs)
|
97 |
+
|
98 |
+
xs_vec_add(origin,viewOfs,origin)
|
99 |
+
|
100 |
+
static Float:end[3]
|
101 |
+
get_tr2(tracehandle,TR_vecEndPos,end)
|
102 |
+
|
103 |
+
new trace = create_tr2()
|
104 |
+
|
105 |
+
new grenade = -1
|
106 |
+
|
107 |
+
while((grenade = find_ent_by_class(grenade,"grenade")))
|
108 |
+
{
|
109 |
+
engfunc(EngFunc_TraceModel,origin,end,HULL_POINT,grenade,trace)
|
110 |
+
|
111 |
+
if(get_tr2(trace,TR_pHit) == grenade)
|
112 |
+
{
|
113 |
+
new Grenade:id = fm_cs_get_grenade_type_myid(grenade)
|
114 |
+
|
115 |
+
if(id == C4)
|
116 |
+
{
|
117 |
+
new cvarValue = get_pcvar_num(Cvars[C4])
|
118 |
+
|
119 |
+
if((cvarValue == 2) || (cvarValue && (cs_get_user_team(attackerID) == CS_TEAM_CT)))
|
120 |
+
{
|
121 |
+
set_pdata_float(grenade,m_flC4Blow,0.0)
|
122 |
+
dllfunc(DLLFunc_Think,grenade)
|
123 |
+
}
|
124 |
+
}
|
125 |
+
else
|
126 |
+
{
|
127 |
+
if(get_pcvar_num(Cvars[id]))
|
128 |
+
{
|
129 |
+
if(id == Smoke)
|
130 |
+
set_pev(grenade,pev_flags,pev(grenade,pev_flags) | FL_ONGROUND)
|
131 |
+
|
132 |
+
// Connor
|
133 |
+
set_pev(grenade,pev_dmgtime,0.0)
|
134 |
+
dllfunc(DLLFunc_Think,grenade)
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
free_tr2(trace)
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
// VEN
|
145 |
+
Grenade:fm_cs_get_grenade_type_myid(index)
|
146 |
+
{
|
147 |
+
if(get_pdata_int(index, 96) & (1<<8))
|
148 |
+
{
|
149 |
+
return C4
|
150 |
+
}
|
151 |
+
|
152 |
+
return Grenade:(get_pdata_int(index, 114) & 3)
|
153 |
+
}
|
154 |
+
|
Traceline Tutorial.txt
ADDED
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Theory
|
2 |
+
|
3 |
+
What is traceline, really? Traceline is a function in the Half-Life engine which is used to draw lines from one point to another in a 3D setting. It can return information, like who (or what) was hit, and various other useful bits of info.
|
4 |
+
|
5 |
+
Traceline is used in every mod in order to determine where a player is looking and shooting. Therefore, it's quite useful to learn how to manipulate traceline to your liking.
|
6 |
+
|
7 |
+
The mod you're scripting for (in my case, CS) is separate from the HL engine. Metamod (and, by extension, AMX Mod X) sits between the mod DLL and the HL engine. This gives us the ability to intercept anything the mod DLL sends to the engine, and visa versa. So, when CS asks the HL engine to calculate a traceline, we can completely change the outcome.
|
8 |
+
|
9 |
+
The Code
|
10 |
+
|
11 |
+
We will use forwards in Fakemeta in capture the communication between CS and the HL engine. This means we'll see the data CS was going to pass the engine in order to calculate a traceline.
|
12 |
+
PHP Code:
|
13 |
+
#include <amxmodx>
|
14 |
+
#include <fakemeta>
|
15 |
+
|
16 |
+
public plugin_init()
|
17 |
+
{
|
18 |
+
register_plugin("Traceline Tutorial", "1.0", "Nomexous")
|
19 |
+
|
20 |
+
register_forward(FM_TraceLine, "traceline_forward")
|
21 |
+
}
|
22 |
+
|
23 |
+
public traceline_forward(Float:start[3], Float:end[3], conditions, id, trace)
|
24 |
+
{
|
25 |
+
// Our traceline forward.
|
26 |
+
}
|
27 |
+
The meaning of the arguments forwarded to our function may not be entirely clear, so:
|
28 |
+
|
29 |
+
Float:start[3] The origin from which the traceline starts.
|
30 |
+
|
31 |
+
Float:end[3] The origin the traceline is drawn to.
|
32 |
+
|
33 |
+
conditions Specifies whether or not to ignore certain entities when drawing the traceline. Values can be DONT_IGNORE_MONSTERS, IGNORE_GLASS, IGNORE_MISSLE, and IGNORE_MONSTERS.
|
34 |
+
|
35 |
+
id This is the entity to ignore when drawing the traceline. Presumably, you're drawing from the origin of one entity (which is inside it) to another point. With player tracelines, id is the player index of whomever is firing the traceline.
|
36 |
+
|
37 |
+
trace Our trace result. This is the most important part. It holds the information about what was hit, among other things. Use get_tr2 and set_tr2 with this.
|
38 |
+
|
39 |
+
The Trace Result
|
40 |
+
|
41 |
+
This is the most exciting part. The variable trace holds detailed information, which can be retreived as outlined:
|
42 |
+
PHP Code:
|
43 |
+
public traceline_forward(Float:start[3], Float:end[3], conditions, id, trace)
|
44 |
+
{
|
45 |
+
// There are more TR_* constants than are listed here; these are the
|
46 |
+
// ones I use most.
|
47 |
+
|
48 |
+
new hit = get_tr2(trace, TR_pHit)
|
49 |
+
// What was hit by the traceline. It will either be a player index,
|
50 |
+
// entity index, 0 (part of map), or -1 (didn't hit anything;
|
51 |
+
// doesn't happen with player tracelines).
|
52 |
+
|
53 |
+
new hitgroup = get_tr2(trace, TR_iHitgroup)
|
54 |
+
// If the traceline hit another player, returns will be HIT_HEAD,
|
55 |
+
// HIT_CHEST, HIT_LEFTLEG... etc. If the traceline hit part of the
|
56 |
+
// map, this returns HIT_GENERIC.
|
57 |
+
|
58 |
+
new Float:fraction
|
59 |
+
get_tr2(trace, TR_flFraction, fraction)
|
60 |
+
// Returns a number between 0.0 and 1.0, indicating how far the
|
61 |
+
// traceline traveled start to end before it hit something. Depending
|
62 |
+
// on what conditions were passed to this traceline forward function,
|
63 |
+
// it could either be a wall or another entity.
|
64 |
+
|
65 |
+
new Float:end_origin[3]
|
66 |
+
get_tr2(trace, TR_vecEndPos, end_origin)
|
67 |
+
// The official end of the traceline. Not necesarily the same as the
|
68 |
+
// second argument passed to this traceline forward function.
|
69 |
+
|
70 |
+
new Float:normal[3]
|
71 |
+
get_tr2(trace, TR_vecPlaneNormal, normal)
|
72 |
+
// Returns a 1 unit long vector normal to the spot that it hit. Note
|
73 |
+
// that "normal" has a special connotation here. It doesn't mean "regular."
|
74 |
+
}
|
75 |
+
(Check this out if you don't know what we mean by "normal" in this context.)
|
76 |
+
|
77 |
+
Now, changing these value is as easy as using the set_tr2 function.
|
78 |
+
|
79 |
+
A Potentially Evil Plugin
|
80 |
+
|
81 |
+
I'm sure you've all played on a server which allowed headshots only. Good practice; body shots do no damage, headshots kill instantly, yadda yadda. But what if we could redirect a shot on any part of the body to the head? Foot shot turns into a headshot? Amazing!
|
82 |
+
PHP Code:
|
83 |
+
public traceline_forward(Float:start[3], Float:end[3], conditions, id, trace)
|
84 |
+
{
|
85 |
+
set_tr2(trace, TR_iHitgroup, HIT_HEAD)
|
86 |
+
return FMRES_IGNORED
|
87 |
+
}
|
88 |
+
It's quite amusing, really. Try it. If you're used to seeing blood spurt out of head on a headshot, you'll be amazed at the blood spurting out of the foot on a foot/headshot. Shotguns are extra deadly; multiple pellets are all redirected to the head at the same time. Do some if (is_user_admin(id)), and you have yourself an evil plugin.
|
89 |
+
|
90 |
+
But it gets kinda hard trying to hide the fact that the blood from a headshot came out of the foot, or stomach, or whatever part of the body you happened to hit. What you want is for blood to also be redirected to the head. Because this relies on traceline, we are still fully in control:
|
91 |
+
PHP Code:
|
92 |
+
public traceline_forward(Float:start[3], Float:end[3], conditions, id, trace)
|
93 |
+
{
|
94 |
+
set_tr2(trace, TR_iHitgroup, HIT_HEAD) // Redirect shot to head
|
95 |
+
|
96 |
+
// Variable angles doesn't really have a use here.
|
97 |
+
static hit, Float:head_origin[3], Float:angles[3]
|
98 |
+
|
99 |
+
hit = get_tr2(trace, TR_pHit) // Whomever was shot
|
100 |
+
engfunc(EngFunc_GetBonePosition, hit, 8, head_origin, angles) // Find origin of head bone (8)
|
101 |
+
|
102 |
+
set_tr2(trace, TR_vecEndPos, head_origin) // Blood now comes out of the head!
|
103 |
+
|
104 |
+
return FMRES_IGNORED
|
105 |
+
}
|
106 |
+
This is even more evil. Now you can run around your own server, endlessly headshotting, no unexplainable blood. Though now you might need to explain why you can't do anything other than headshot.
|
107 |
+
|
108 |
+
You can of course change whom you are shooting. Consider this anti-team attack plugin for cs:
|
109 |
+
PHP Code:
|
110 |
+
#include <amxmodx>
|
111 |
+
#include <fakemeta>
|
112 |
+
#include <cstrike>
|
113 |
+
|
114 |
+
public plugin_init()
|
115 |
+
{
|
116 |
+
register_plugin("Traceline Tutorial - No TA", "1.0", "Nomexous")
|
117 |
+
|
118 |
+
register_forward(FM_TraceLine, "traceline_forward")
|
119 |
+
}
|
120 |
+
|
121 |
+
public traceline_forward(Float:start[3], Float:end[3], conditions, id, trace)
|
122 |
+
{
|
123 |
+
static hit
|
124 |
+
|
125 |
+
hit = get_tr2(trace, TR_pHit)
|
126 |
+
|
127 |
+
// Variable id is shooter's index.
|
128 |
+
if (cs_get_user_team(id) == cs_get_user_team(hit))
|
129 |
+
{
|
130 |
+
// Redirect onto himself!
|
131 |
+
set_tr2(trace, TR_pHit, id)
|
132 |
+
}
|
133 |
+
|
134 |
+
return FMRES_IGNORED
|
135 |
+
}
|
136 |
+
Blood will still spray out of whomever is being shot, but the damage will be dealt to the shooter. People quickly lose the urge to team attack.
|
137 |
+
|
138 |
+
I've submitted a plugin (Shot Administration) that demonstrates the evil capabilities of manipulating traceline. Take a look; tracehull is also hooked (for knife damage).
|
139 |
+
|
140 |
+
Less Evil Uses of Traceline
|
141 |
+
|
142 |
+
We will now use tracelines to do our bidding outside the context of player aiming. Using engfunc(), we can call draw our own tracelines to see what we hit. Of course, we're not actually shooting and dealing damage, but with the information that the trace result gives us, it can be just as useful.
|
143 |
+
|
144 |
+
Lets find out if two origins are in line of sight:
|
145 |
+
PHP Code:
|
146 |
+
stock bool:is_in_line_of_sight(Float:origin1[3], Float:origin[2], bool:ignore_players = true)
|
147 |
+
{
|
148 |
+
new trace = 0
|
149 |
+
engfunc(EngFunc_TraceLine, origin1, origin2, (ignore_players ? IGNORE_MONSTERS : DONT_IGNORE_MONSTERS), 0, trace)
|
150 |
+
|
151 |
+
new Float:fraction
|
152 |
+
get_tr2(trace, TR_flFraction, fraction)
|
153 |
+
|
154 |
+
return (fraction == 1.0) ? true : false
|
155 |
+
}
|
156 |
+
This stock sees how far it went before it hit something. If TR_flFraction is 1.0, that means it went 100% of the way without hitting an obstacle. Therefore, the two origins are in line of sight. Alternatively, you can see what TR_pHit returns. If it returns -1, you hit nothing (meaning the two points are in line of sight). A return of 0 means you hit part of the map (you can assume it's a wall), and anything else would be the index of an entity in the way. Be careful; it might not be a player. It could possibly be a door or a func_wall.
|
157 |
+
|
158 |
+
Now, let's make use of the TR_vecPlaneNormal part of our trace result. There are multiple things this is useful for. Here, I'll outline how to draw a laser normal to a surface.
|
159 |
+
|
160 |
+
When a trace hits something, TR_vecPlaneNormal will have a unit vector (1 unit in length) stored to it, pointing perpendicularly away from surface at the spot it hit. To get the endpoint of the laser, we merely need to extend the length of the normal vector and add it to the origin of where we want the laser to start from. Here is a sample:
|
161 |
+
PHP Code:
|
162 |
+
#include <amxmodx>
|
163 |
+
#include <fakemeta>
|
164 |
+
|
165 |
+
#define PLUGIN "Draw Normal Laser Example"
|
166 |
+
#define VERSION "1.0"
|
167 |
+
#define AUTHOR "Nomexous"
|
168 |
+
|
169 |
+
new beampoint
|
170 |
+
|
171 |
+
public plugin_precache()
|
172 |
+
{
|
173 |
+
// Needed to show the laser.
|
174 |
+
beampoint = precache_model("sprites/laserbeam.spr")
|
175 |
+
}
|
176 |
+
|
177 |
+
public plugin_init()
|
178 |
+
{
|
179 |
+
register_plugin(PLUGIN, VERSION, AUTHOR)
|
180 |
+
|
181 |
+
// I included the entire plugin because in order to draw the laser, you need to precache a sprite. Incorporate
|
182 |
+
// these elements into your own plugin.
|
183 |
+
|
184 |
+
// The shoot_laser() will (if the entity is on the floor) fire a laser from the entity, normal to the surface it's resting on.
|
185 |
+
}
|
186 |
+
|
187 |
+
public shoot_laser(ent)
|
188 |
+
{
|
189 |
+
// We get the origin of the entity.
|
190 |
+
new Float:origin[3]
|
191 |
+
pev(ent, pev_origin, origin)
|
192 |
+
|
193 |
+
// We want to trace down to the floor, if it's there.
|
194 |
+
new Float:traceto[3]
|
195 |
+
traceto[0] = origin[0]
|
196 |
+
traceto[1] = origin[1]
|
197 |
+
traceto[2] = origin[2] - 10.0
|
198 |
+
|
199 |
+
new trace = 0
|
200 |
+
// Draw the traceline. We're assuming the object is resting on the floor.
|
201 |
+
engfunc(EngFunc_TraceLine, origin, traceto, IGNORE_MONSTERS, ent, trace)
|
202 |
+
|
203 |
+
new Float:fraction
|
204 |
+
get_tr2(trace, TR_flFraction, fraction)
|
205 |
+
// If we didn't hit anything, then we won't get a valid TR_vecPlaneNormal.
|
206 |
+
if (fraction == 1.0) return
|
207 |
+
|
208 |
+
new Float:normal[3]
|
209 |
+
get_tr2(trace, TR_vecPlaneNormal, normal)
|
210 |
+
// We'll multiply the the normal vector by a scalar to make it longer.
|
211 |
+
normal[0] *= 400.0 // Mathematically, we multiplied the length of the vector by 400*(3)^(1/2),
|
212 |
+
normal[1] *= 400.0 // or, in words, four hundred times root three.
|
213 |
+
normal[2] *= 400.0
|
214 |
+
|
215 |
+
// To get the endpoint, we add the normal vector and the origin.
|
216 |
+
new Float:endpoint[3]
|
217 |
+
endpoint[0] = origin[0] + normal[0]
|
218 |
+
endpoint[1] = origin[1] + normal[1]
|
219 |
+
endpoint[2] = origin[2] + normal[2]
|
220 |
+
|
221 |
+
// Finally, we draw from the laser!
|
222 |
+
draw_laser(origin, endpoint, 100) // Make it stay for 10 seconds. Not a typo; staytime is in 10ths of a second.
|
223 |
+
}
|
224 |
+
|
225 |
+
public draw_laser(Float:start[3], Float:end[3], staytime)
|
226 |
+
{
|
227 |
+
message_begin(MSG_ALL, SVC_TEMPENTITY)
|
228 |
+
write_byte(TE_BEAMPOINTS)
|
229 |
+
engfunc(EngFunc_WriteCoord, start[0])
|
230 |
+
engfunc(EngFunc_WriteCoord, start[1])
|
231 |
+
engfunc(EngFunc_WriteCoord, start[2])
|
232 |
+
engfunc(EngFunc_WriteCoord, end[0])
|
233 |
+
engfunc(EngFunc_WriteCoord, end[1])
|
234 |
+
engfunc(EngFunc_WriteCoord, end[2])
|
235 |
+
write_short(beampoint)
|
236 |
+
write_byte(0)
|
237 |
+
write_byte(0)
|
238 |
+
write_byte(staytime) // In tenths of a second.
|
239 |
+
write_byte(10)
|
240 |
+
write_byte(1)
|
241 |
+
write_byte(255) // Red
|
242 |
+
write_byte(0) // Green
|
243 |
+
write_byte(0) // Blue
|
244 |
+
write_byte(127)
|
245 |
+
write_byte(1)
|
246 |
+
message_end()
|
247 |
+
}
|