[Half-Life AMXX] / include / engine_stocks.inc Repository:
ViewVC logotype

Annotation of /include/engine_stocks.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (view) (download)

1 : ian 1 /* Engine stocks
2 :     *
3 :     * by the AMX Mod X Development Team
4 :     * thanks to AssKicR, Freecode and T(+)rget
5 :     *
6 :     * This file is provided as is (no warranties).
7 :     */
8 :    
9 :     #if defined _engine_stocks_included
10 :     #endinput
11 :     #endif
12 :     #define _engine_stocks_included
13 :    
14 :     #if !defined _amxmodx_included
15 :     #include <amxmodx>
16 :     #endif
17 :    
18 :     #if !defined _engine_included
19 :     #include <engine>
20 :     #endif
21 :    
22 :     stock fakedamage(idvictim,const szClassname[],Float:takedmgdamage,damagetype)
23 :     {
24 :     new entity = create_entity("trigger_hurt");
25 :     if (entity)
26 :     {
27 :     DispatchKeyValue(entity,"classname","trigger_hurt");
28 :     new szDamage[16];
29 :     // Takedamages only do half damage per attack (damage is damage per second, and it's triggered in 0.5 second intervals).
30 :     // Compensate for that.
31 :     format(szDamage,15,"%f",takedmgdamage * 2);
32 :     DispatchKeyValue(entity,"dmg",szDamage);
33 :     format(szDamage,15,"%i",damagetype);
34 :     DispatchKeyValue(entity,"damagetype",szDamage);
35 :     DispatchKeyValue(entity,"origin","8192 8192 8192");
36 :     DispatchSpawn(entity);
37 :     entity_set_string(entity, EV_SZ_classname, szClassname);
38 :     fake_touch(entity,idvictim);
39 :     remove_entity(entity);
40 :     return 1;
41 :     }
42 :     return 0;
43 :     }
44 :    
45 :     //wrapper for find_ent_by_class
46 :     stock find_ent(iStart, const szClassname[])
47 :     {
48 :     return find_ent_by_class(iStart, szClassname);
49 :     }
50 :    
51 :     /* Get the Button(s) user is pressing */
52 :     stock get_user_button(id)
53 :     {
54 :     return entity_get_int(id, EV_INT_button);
55 :     }
56 :    
57 :     stock get_user_oldbutton(id)
58 :     {
59 :     return entity_get_int(id, EV_INT_oldbuttons);
60 :     }
61 :    
62 :     /* Get flags an entity is flagged with */
63 :     stock get_entity_flags(ent)
64 :     {
65 :     return entity_get_int(ent, EV_INT_flags);
66 :     }
67 :    
68 :     /* Get the distance between two entities */
69 :     stock get_entity_distance(ent1, ent2)
70 :     {
71 :     return floatround(entity_range(ent1, ent2));
72 :     }
73 :    
74 :     /* Get grenade thrown by this user */
75 :     stock get_grenade(id)
76 :     {
77 :     new iGrenade = find_ent_by_class(-1, "grenade");
78 :     while(iGrenade > 0)
79 :     {
80 :     if(entity_get_edict(iGrenade, EV_ENT_owner) == id)
81 :     return iGrenade;
82 :    
83 :     iGrenade = find_ent_by_class(iGrenade, "grenade");
84 :     }
85 :    
86 :     return 0;
87 :     }
88 :    
89 :     /* Get origin of a brush entity */
90 :     stock get_brush_entity_origin(ent, Float:orig[3])
91 :     {
92 :     new Float:Min[3], Float:Max[3];
93 :     entity_get_vector(ent, EV_VEC_mins, Min);
94 :     entity_get_vector(ent, EV_VEC_maxs, Max);
95 :    
96 :     orig[0] = (Min[0] + Max[0]) * 0.5;
97 :     orig[1] = (Min[1] + Max[1]) * 0.5;
98 :     orig[2] = (Min[2] + Max[2]) * 0.5;
99 :    
100 :     return 1;
101 :     }
102 :    
103 :     /* Remove entity by name */
104 :     stock remove_entity_name(const eName[])
105 :     {
106 :     new iEntity = find_ent_by_class(-1, eName);
107 :     while (iEntity > 0)
108 :     {
109 :     remove_entity(iEntity);
110 :     iEntity = find_ent_by_class(-1, eName);
111 :     }
112 :    
113 :     return 1;
114 :     }
115 :    
116 :     /* Get the contents of the point a user is aiming at */
117 :     stock ViewContents(id)
118 :     {
119 :     new origin[3], Float:Orig[3];
120 :     get_user_origin(id, origin, 3);
121 :     Orig[0] = float(origin[0]);
122 :     Orig[1] = float(origin[1]);
123 :     Orig[2] = float(origin[2]);
124 :    
125 :     return point_contents(Orig);
126 :     }
127 :    
128 :     stock get_speed(ent)
129 :     {
130 :     new Float:Vel[3];
131 :     entity_get_vector(ent, EV_VEC_velocity, Vel);
132 :    
133 :     return floatround(vector_length(Vel));
134 :     }
135 :    
136 :     /* Set rendering of an entity */
137 :     stock set_rendering(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
138 :     {
139 :     entity_set_int(index,EV_INT_renderfx,fx);
140 :     new Float:RenderColor[3];
141 :     RenderColor[0] = float(r);
142 :     RenderColor[1] = float(g);
143 :     RenderColor[2] = float(b);
144 :     entity_set_vector(index,EV_VEC_rendercolor,RenderColor);
145 :     entity_set_int(index,EV_INT_rendermode,render);
146 :     entity_set_float(index,EV_FL_renderamt,float(amount));
147 :    
148 :     return 1;
149 :     }
150 :    
151 :     /* Set flags on an entity */
152 :     stock set_entity_flags(ent,flag,onoff)
153 :     {
154 :     if ((entity_get_int(ent,EV_INT_flags)&flag) > 0)
155 :     {
156 :     if (onoff == 1)
157 :     {
158 :     return 2;
159 :     }
160 :     else
161 :     {
162 :     entity_set_int(ent,EV_INT_flags,entity_get_int(ent,EV_INT_flags)-flag);
163 :     return 1;
164 :     }
165 :     }
166 :     else
167 :     {
168 :     if (onoff == 0)
169 :     {
170 :     return 2;
171 :     }
172 :     else
173 :     {
174 :     entity_set_int(ent,EV_INT_flags,entity_get_int(ent,EV_INT_flags)+flag);
175 :     return 1;
176 :     }
177 :     }
178 :    
179 :     return 0;
180 :     }
181 :    
182 :     /* If visible = 1, entity will be set to be visible, else invisible. */
183 :     stock set_entity_visibility(entity, visible = 1)
184 :     {
185 :     entity_set_int(entity, EV_INT_effects, visible == 1 ? entity_get_int(entity, EV_INT_effects) & ~EF_NODRAW : entity_get_int(entity, EV_INT_effects) | EF_NODRAW);
186 :    
187 :     return 1;
188 :     }
189 :    
190 :     /* Returns 1 if entity is visible. */
191 :     stock get_entity_visibility(entity)
192 :     {
193 :     return !(entity_get_int(entity, EV_INT_effects) & EF_NODRAW);
194 :     }
195 :    
196 :     stock set_user_velocity(entity, const Float:vec[3])
197 :     {
198 :     return entity_set_vector(entity, EV_VEC_velocity, vec);
199 :     }
200 :    
201 :     stock get_user_velocity(entity, Float:vec[3])
202 :     {
203 :     return entity_get_vector(entity, EV_VEC_velocity, vec);
204 :     }
205 :    
206 :     /* Backwards compatible */
207 :     /* Hurts/Kills players in a sphere, like an explosion, Multiplier determines damage. */
208 :     stock RadiusDamage(const Float:fExplodeAt[3], iDamageMultiplier, iRadiusMultiplier)
209 :     {
210 :     return radius_damage(fExplodeAt, iDamageMultiplier, iRadiusMultiplier);
211 :     }
212 :     /* Gives you a velocity in the direction a player is looking, iVelocity is the multiplier. */
213 :     stock VelocityByAim(iIndex,iVelocity, Float:vRetValue[3])
214 :     {
215 :     return velocity_by_aim(iIndex,iVelocity,vRetValue);
216 :     }
217 :     /* Will return the contents of a point (inside map? in sky? outside map? etc.). */
218 :     stock PointContents(const Float:fCheckAt[3])
219 :     {
220 :     return point_contents(fCheckAt);
221 :     }
222 :    
223 :     stock set_size(index, const Float:mins[3], const Float:maxs[3])
224 :     {
225 :     return entity_set_size(index,mins,maxs);
226 :     }
227 :    
228 :     //by Twilight Suzuka, request addition at29428
229 :     //"Lifted from HLSDK"
230 :     stock IsInWorld( ent )
231 :     {
232 :     new Float:origin[3];
233 :     entity_get_vector(ent,EV_VEC_origin,origin);
234 :    
235 :     if (origin[0] >= 4096.0) return 0;
236 :     if (origin[1] >= 4096.0) return 0;
237 :     if (origin[2] >= 4096.0) return 0;
238 :     if (origin[0] <= -4096.0) return 0;
239 :     if (origin[1] <= -4096.0) return 0;
240 :     if (origin[2] <= -4096.0) return 0;
241 :    
242 :     new Float:velocity[3];
243 :     entity_get_vector(ent,EV_VEC_velocity,velocity);
244 :    
245 :     if (velocity[0] >= 2000) return 0;
246 :     if (velocity[1] >= 2000) return 0;
247 :     if (velocity[2] >= 2000) return 0;
248 :     if (velocity[0] <= -2000) return 0;
249 :     if (velocity[1] <= -2000) return 0;
250 :     if (velocity[2] <= -2000) return 0;
251 :    
252 :     return 1;
253 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4