VexdUM_stock.inc
Original include source with line numbers.
| 1 | /* VexdUM stocks backwards compatibility |
| 2 | * |
| 3 | * by the AMX Mod X Development Team |
| 4 | * |
| 5 | * This file is provided as is (no warranties). |
| 6 | */ |
| 7 | |
| 8 | #if defined _vexd_bcompat_stocks_included |
| 9 | #endinput |
| 10 | #endif |
| 11 | #define _vexd_bcompat_stocks_included |
| 12 | |
| 13 | #if !defined _engine_included |
| 14 | #include <engine> |
| 15 | #endif |
| 16 | |
| 17 | stock is_entity(ent) |
| 18 | { |
| 19 | return pev_valid(ent); |
| 20 | } |
| 21 | |
| 22 | stock get_offset_int(ent, offset, linos = 5) |
| 23 | { |
| 24 | return get_pdata_int(ent, offset, linos); |
| 25 | } |
| 26 | |
| 27 | stock set_offset_int(ent, offset, value, linos = 5) |
| 28 | { |
| 29 | return set_pdata_int(ent, offset, value, linos); |
| 30 | } |
| 31 | |
| 32 | stock in_view_cone(ent, Float:Orig[3]) |
| 33 | { |
| 34 | return is_in_viewcone(ent, Orig); |
| 35 | } |
| 36 | |
| 37 | stock get_maxentities() |
| 38 | { |
| 39 | return global_get(glb_maxEntities); |
| 40 | } |
| 41 | |
| 42 | stock can_see(ent1, ent2) |
| 43 | { |
| 44 | if (is_entity(ent1) && is_entity(ent2)) |
| 45 | { |
| 46 | new flags = pev(ent1, pev_flags); |
| 47 | if (flags & EF_NODRAW || flags & FL_NOTARGET) |
| 48 | { |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | new Float:lookerOrig[3]; |
| 53 | new Float:targetOrig[3]; |
| 54 | new Float:temp[3]; |
| 55 | |
| 56 | pev(ent1, pev_origin, lookerOrig); |
| 57 | pev(ent1, pev_view_ofs, temp); |
| 58 | lookerOrig[0] += temp[0]; |
| 59 | lookerOrig[1] += temp[1]; |
| 60 | lookerOrig[2] += temp[2]; |
| 61 | |
| 62 | pev(ent2, pev_origin, targetOrig); |
| 63 | pev(ent2, pev_view_ofs, temp); |
| 64 | targetOrig[0] += temp[0]; |
| 65 | targetOrig[1] += temp[1]; |
| 66 | targetOrig[2] += temp[2]; |
| 67 | |
| 68 | engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, ent1, 0); |
| 69 | if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater)) |
| 70 | { |
| 71 | return 0; |
| 72 | } else { |
| 73 | new Float:flFraction; |
| 74 | get_tr2(0, TraceResult:TR_flFraction, flFraction); |
| 75 | if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == ent2)) |
| 76 | { |
| 77 | return 1; |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | //From AMX Mod: |
| 86 | // Find an entity in the world, will return -1 if nothing is found |
| 87 | // type = 0: "classname" |
| 88 | // type = 1: "globalname" |
| 89 | // type = 2: "model" |
| 90 | // type = 3: "target" |
| 91 | // type = 4: "targetname" |
| 92 | // type = 5: "netname" |
| 93 | // type = 6: "message" |
| 94 | // type = 7: "noise" |
| 95 | // type = 8: "noise1" |
| 96 | // type = 9: "noise2" |
| 97 | // type = 10: "noise3" |
| 98 | // type = 11: "viewmodel" |
| 99 | // type = 12: "weaponmodel" |
| 100 | |
| 101 | stock vexd_find_entity(ent, szValue[], type=0) |
| 102 | { |
| 103 | static _g_FindEntTypes[13][] = |
| 104 | { |
| 105 | "classname", |
| 106 | "globalname", |
| 107 | "model", |
| 108 | "target", |
| 109 | "targetname", |
| 110 | "netname", |
| 111 | "messages", |
| 112 | "noise", |
| 113 | "noise1", |
| 114 | "noise2", |
| 115 | "noise3", |
| 116 | "viewmodel", |
| 117 | "weaponmodel" |
| 118 | }; |
| 119 | |
| 120 | if (type < 0 || type >= 13) |
| 121 | { |
| 122 | type = 0; |
| 123 | } |
| 124 | |
| 125 | return engfunc(EngFunc_FindEntityByString, ent, _g_FindEntTypes[type], szValue); |
| 126 | } |
| 127 | |
| 128 | #define find_entity vexd_find_entity |
| 129 | |
| 130 | //From AMX Mod: |
| 131 | // Find an entity within a given origin and radius |
| 132 | stock find_entity_sphere(ent, Float:Orig[3], Float:Rad) |
| 133 | { |
| 134 | return engfunc(EngFunc_FindEntityInSphere, ent, Orig, Rad); |
| 135 | } |
| 136 | |