Parent Directory | Revision Log
Revision 17 - (view) (download)
1 : | ian | 1 | /* Xtrafun backwards compatibility |
2 : | * | ||
3 : | * by the AMX Mod X Development Team | ||
4 : | * These natives were originally made by SpaceDude, EJ, and JustinHoMi. | ||
5 : | * | ||
6 : | * This file is provided as is (no warranties). | ||
7 : | */ | ||
8 : | |||
9 : | #if !defined _xtrafun_included | ||
10 : | #define _xtrafun_included | ||
11 : | |||
12 : | #if !defined _engine_included | ||
13 : | #include <engine.inc> | ||
14 : | #endif | ||
15 : | |||
16 : | /* Gets the velocity of an entity */ | ||
17 : | stock get_entity_velocity(index, velocity[3]) { | ||
18 : | ian | 17 | new Float:vector[3]; |
19 : | entity_get_vector(index, EV_VEC_velocity, vector); | ||
20 : | FVecIVec(vector, velocity); | ||
21 : | ian | 1 | } |
22 : | |||
23 : | /* Sets the velocity of an entity */ | ||
24 : | stock set_entity_velocity(index, velocity[3]) { | ||
25 : | ian | 17 | new Float:vector[3]; |
26 : | IVecFVec(velocity, vector); | ||
27 : | entity_set_vector(index, EV_VEC_velocity, vector); | ||
28 : | ian | 1 | } |
29 : | |||
30 : | /* Gets the origin of an entity */ | ||
31 : | stock get_entity_origin(index, origin[3]) { | ||
32 : | ian | 17 | new Float:vector[3]; |
33 : | entity_get_vector(index, EV_VEC_origin, vector); | ||
34 : | FVecIVec(vector, origin); | ||
35 : | ian | 1 | } |
36 : | |||
37 : | /* Sets the origin of an entity */ | ||
38 : | stock set_entity_origin(index, origin[3]) { | ||
39 : | ian | 17 | new Float:vector[3]; |
40 : | IVecFVec(origin, vector); | ||
41 : | entity_set_vector(index, EV_VEC_origin, vector); | ||
42 : | ian | 1 | } |
43 : | |||
44 : | /* Get the index of the grenade belonging to index. | ||
45 : | * Model of grenade is returned in model[]. | ||
46 : | * Specify the grenadeindex to start searching from, | ||
47 : | * or leave it at 0 to search from the start. | ||
48 : | * Returns grenade index. | ||
49 : | * Paths + models of grenades in Counter-Strike: | ||
50 : | * HEGRENADE = "models/w_hegrenade.mdl" | ||
51 : | * FLASHBANG = "models/w_flashbang.mdl" | ||
52 : | * SMOKEGRENADE = "models/w_smokegrenade.mdl" */ | ||
53 : | stock get_grenade_index(index, model[], len, grenadeindex = 0) { | ||
54 : | ian | 17 | new entfind = grenadeindex; |
55 : | new entowner = index; | ||
56 : | ian | 1 | |
57 : | for (;;) { | ||
58 : | ian | 17 | entfind = find_ent_by_class(entfind, "grenade"); |
59 : | ian | 1 | |
60 : | if (entfind && is_valid_ent(entfind)) { | ||
61 : | if (entity_get_edict(entFind, EV_ENT_owner) == entowner) { | ||
62 : | ian | 17 | entity_get_string(entfind, EV_SZ_model, model); |
63 : | return entfind; | ||
64 : | ian | 1 | } |
65 : | } | ||
66 : | else { | ||
67 : | // Eventually comes here if loop fails to find a grenade with specified owner. | ||
68 : | return 0; | ||
69 : | } | ||
70 : | } | ||
71 : | } | ||
72 : | |||
73 : | /* Find the number of entities in the game */ | ||
74 : | stock current_num_ents() { | ||
75 : | return entity_count(); | ||
76 : | } | ||
77 : | |||
78 : | enum { | ||
79 : | classname = 0, | ||
80 : | target, | ||
81 : | targetname | ||
82 : | ian | 17 | }; |
83 : | ian | 1 | |
84 : | #if !defined _vexd_bcompat_included | ||
85 : | /* Find an entity ID from start_from_ent id (use 0 to start from | ||
86 : | * the beginning, category is either "classname", "target" or | ||
87 : | * "targetname", value is the name you are searching for */ | ||
88 : | stock find_entity(start_from_ent, category, value[]) { | ||
89 : | switch (category) { | ||
90 : | ian | 17 | case target: return find_ent_by_target(start_from_ent, value); |
91 : | case targetname: return find_ent_by_tname(start_from_ent, value); | ||
92 : | ian | 1 | } |
93 : | ian | 17 | return find_ent_by_class(start_from_ent, value); |
94 : | ian | 1 | } |
95 : | #endif | ||
96 : | |||
97 : | #endif // _xtrafun_included |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |