[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 44 - (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 : ian 44
94 :     entity_get_vector(ent, EV_VEC_origin, orig);
95 : ian 1 entity_get_vector(ent, EV_VEC_mins, Min);
96 :     entity_get_vector(ent, EV_VEC_maxs, Max);
97 :    
98 : ian 44 orig[0] += (Min[0] + Max[0]) * 0.5;
99 :     orig[1] += (Min[1] + Max[1]) * 0.5;
100 :     orig[2] += (Min[2] + Max[2]) * 0.5;
101 : ian 1
102 :     return 1;
103 :     }
104 :    
105 :     /* Remove entity by name */
106 :     stock remove_entity_name(const eName[])
107 :     {
108 :     new iEntity = find_ent_by_class(-1, eName);
109 :     while (iEntity > 0)
110 :     {
111 :     remove_entity(iEntity);
112 :     iEntity = find_ent_by_class(-1, eName);
113 :     }
114 :    
115 :     return 1;
116 :     }
117 :    
118 :     /* Get the contents of the point a user is aiming at */
119 :     stock ViewContents(id)
120 :     {
121 :     new origin[3], Float:Orig[3];
122 :     get_user_origin(id, origin, 3);
123 :     Orig[0] = float(origin[0]);
124 :     Orig[1] = float(origin[1]);
125 :     Orig[2] = float(origin[2]);
126 :    
127 :     return point_contents(Orig);
128 :     }
129 :    
130 :     stock get_speed(ent)
131 :     {
132 :     new Float:Vel[3];
133 :     entity_get_vector(ent, EV_VEC_velocity, Vel);
134 :    
135 :     return floatround(vector_length(Vel));
136 :     }
137 :    
138 :     /* Set rendering of an entity */
139 :     stock set_rendering(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
140 :     {
141 :     entity_set_int(index,EV_INT_renderfx,fx);
142 :     new Float:RenderColor[3];
143 :     RenderColor[0] = float(r);
144 :     RenderColor[1] = float(g);
145 :     RenderColor[2] = float(b);
146 :     entity_set_vector(index,EV_VEC_rendercolor,RenderColor);
147 :     entity_set_int(index,EV_INT_rendermode,render);
148 :     entity_set_float(index,EV_FL_renderamt,float(amount));
149 :    
150 :     return 1;
151 :     }
152 :    
153 :     /* Set flags on an entity */
154 :     stock set_entity_flags(ent,flag,onoff)
155 :     {
156 :     if ((entity_get_int(ent,EV_INT_flags)&flag) > 0)
157 :     {
158 :     if (onoff == 1)
159 :     {
160 :     return 2;
161 :     }
162 :     else
163 :     {
164 :     entity_set_int(ent,EV_INT_flags,entity_get_int(ent,EV_INT_flags)-flag);
165 :     return 1;
166 :     }
167 :     }
168 :     else
169 :     {
170 :     if (onoff == 0)
171 :     {
172 :     return 2;
173 :     }
174 :     else
175 :     {
176 :     entity_set_int(ent,EV_INT_flags,entity_get_int(ent,EV_INT_flags)+flag);
177 :     return 1;
178 :     }
179 :     }
180 :    
181 :     return 0;
182 :     }
183 :    
184 :     /* If visible = 1, entity will be set to be visible, else invisible. */
185 :     stock set_entity_visibility(entity, visible = 1)
186 :     {
187 :     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);
188 :    
189 :     return 1;
190 :     }
191 :    
192 :     /* Returns 1 if entity is visible. */
193 :     stock get_entity_visibility(entity)
194 :     {
195 :     return !(entity_get_int(entity, EV_INT_effects) & EF_NODRAW);
196 :     }
197 :    
198 :     stock set_user_velocity(entity, const Float:vec[3])
199 :     {
200 :     return entity_set_vector(entity, EV_VEC_velocity, vec);
201 :     }
202 :    
203 :     stock get_user_velocity(entity, Float:vec[3])
204 :     {
205 :     return entity_get_vector(entity, EV_VEC_velocity, vec);
206 :     }
207 :    
208 :     /* Backwards compatible */
209 :     /* Hurts/Kills players in a sphere, like an explosion, Multiplier determines damage. */
210 :     stock RadiusDamage(const Float:fExplodeAt[3], iDamageMultiplier, iRadiusMultiplier)
211 :     {
212 :     return radius_damage(fExplodeAt, iDamageMultiplier, iRadiusMultiplier);
213 :     }
214 :     /* Gives you a velocity in the direction a player is looking, iVelocity is the multiplier. */
215 :     stock VelocityByAim(iIndex,iVelocity, Float:vRetValue[3])
216 :     {
217 :     return velocity_by_aim(iIndex,iVelocity,vRetValue);
218 :     }
219 :     /* Will return the contents of a point (inside map? in sky? outside map? etc.). */
220 :     stock PointContents(const Float:fCheckAt[3])
221 :     {
222 :     return point_contents(fCheckAt);
223 :     }
224 :    
225 :     stock set_size(index, const Float:mins[3], const Float:maxs[3])
226 :     {
227 :     return entity_set_size(index,mins,maxs);
228 :     }
229 :    
230 :     //by Twilight Suzuka, request addition at29428
231 :     //"Lifted from HLSDK"
232 :     stock IsInWorld( ent )
233 :     {
234 :     new Float:origin[3];
235 :     entity_get_vector(ent,EV_VEC_origin,origin);
236 :    
237 :     if (origin[0] >= 4096.0) return 0;
238 :     if (origin[1] >= 4096.0) return 0;
239 :     if (origin[2] >= 4096.0) return 0;
240 :     if (origin[0] <= -4096.0) return 0;
241 :     if (origin[1] <= -4096.0) return 0;
242 :     if (origin[2] <= -4096.0) return 0;
243 :    
244 :     new Float:velocity[3];
245 :     entity_get_vector(ent,EV_VEC_velocity,velocity);
246 :    
247 :     if (velocity[0] >= 2000) return 0;
248 :     if (velocity[1] >= 2000) return 0;
249 :     if (velocity[2] >= 2000) return 0;
250 :     if (velocity[0] <= -2000) return 0;
251 :     if (velocity[1] <= -2000) return 0;
252 :     if (velocity[2] <= -2000) return 0;
253 :    
254 :     return 1;
255 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4