2014-08-04 12:12:15 +00:00
|
|
|
// vim: set ts=4 sw=4 tw=99 noet:
|
|
|
|
//
|
|
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
|
|
// Special thanks to AssKicR, Freecode, and T(+)rget.
|
|
|
|
//
|
|
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
|
|
// https://alliedmods.net/amxmodx-license
|
|
|
|
|
|
|
|
//
|
|
|
|
// Engine Stocks
|
|
|
|
//
|
2004-02-15 02:29:51 +00:00
|
|
|
|
2004-02-21 20:30:04 +00:00
|
|
|
#if defined _engine_stocks_included
|
|
|
|
#endinput
|
|
|
|
#endif
|
|
|
|
#define _engine_stocks_included
|
|
|
|
|
2004-11-17 07:33:29 +00:00
|
|
|
#if !defined _amxmodx_included
|
|
|
|
#include <amxmodx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined _engine_included
|
|
|
|
#include <engine>
|
|
|
|
#endif
|
|
|
|
|
2007-01-26 05:56:10 +00:00
|
|
|
stock fakedamage(idvictim,const szClassname[],Float:takedmgdamage,damagetype)
|
2004-05-26 07:59:33 +00:00
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
new entity = create_entity("trigger_hurt");
|
2004-05-26 07:59:33 +00:00
|
|
|
if (entity)
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
DispatchKeyValue(entity,"classname","trigger_hurt");
|
|
|
|
new szDamage[16];
|
2004-05-26 07:59:33 +00:00
|
|
|
// Takedamages only do half damage per attack (damage is damage per second, and it's triggered in 0.5 second intervals).
|
|
|
|
// Compensate for that.
|
2007-03-05 19:30:40 +00:00
|
|
|
format(szDamage,15,"%f",takedmgdamage * 2);
|
|
|
|
DispatchKeyValue(entity,"dmg",szDamage);
|
|
|
|
format(szDamage,15,"%i",damagetype);
|
|
|
|
DispatchKeyValue(entity,"damagetype",szDamage);
|
|
|
|
DispatchKeyValue(entity,"origin","8192 8192 8192");
|
|
|
|
DispatchSpawn(entity);
|
|
|
|
entity_set_string(entity, EV_SZ_classname, szClassname);
|
|
|
|
fake_touch(entity,idvictim);
|
|
|
|
remove_entity(entity);
|
|
|
|
return 1;
|
2004-05-26 07:59:33 +00:00
|
|
|
}
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
2004-05-26 07:59:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 08:23:42 +00:00
|
|
|
//wrapper for find_ent_by_class
|
2007-01-26 05:56:10 +00:00
|
|
|
stock find_ent(iStart, const szClassname[])
|
2004-03-14 08:23:42 +00:00
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
return find_ent_by_class(iStart, szClassname);
|
2004-03-14 08:23:42 +00:00
|
|
|
}
|
|
|
|
|
2004-02-15 02:29:51 +00:00
|
|
|
/* Get the Button(s) user is pressing */
|
|
|
|
stock get_user_button(id)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
return entity_get_int(id, EV_INT_button);
|
|
|
|
}
|
2004-02-15 02:29:51 +00:00
|
|
|
|
|
|
|
stock get_user_oldbutton(id)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
return entity_get_int(id, EV_INT_oldbuttons);
|
|
|
|
}
|
2004-02-15 02:29:51 +00:00
|
|
|
|
|
|
|
/* Get flags an entity is flagged with */
|
|
|
|
stock get_entity_flags(ent)
|
2007-03-05 19:30:40 +00:00
|
|
|
{
|
|
|
|
return entity_get_int(ent, EV_INT_flags);
|
|
|
|
}
|
2004-02-15 02:29:51 +00:00
|
|
|
|
|
|
|
/* Get the distance between two entities */
|
|
|
|
stock get_entity_distance(ent1, ent2)
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
return floatround(entity_range(ent1, ent2));
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get grenade thrown by this user */
|
|
|
|
stock get_grenade(id)
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
new iGrenade = find_ent_by_class(-1, "grenade");
|
2004-02-15 02:29:51 +00:00
|
|
|
while(iGrenade > 0)
|
|
|
|
{
|
|
|
|
if(entity_get_edict(iGrenade, EV_ENT_owner) == id)
|
2007-03-05 19:30:40 +00:00
|
|
|
return iGrenade;
|
2004-02-15 02:29:51 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
iGrenade = find_ent_by_class(iGrenade, "grenade");
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get origin of a brush entity */
|
|
|
|
stock get_brush_entity_origin(ent, Float:orig[3])
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
new Float:Min[3], Float:Max[3];
|
2008-05-07 05:17:21 +00:00
|
|
|
|
|
|
|
entity_get_vector(ent, EV_VEC_origin, orig);
|
2007-03-05 19:30:40 +00:00
|
|
|
entity_get_vector(ent, EV_VEC_mins, Min);
|
|
|
|
entity_get_vector(ent, EV_VEC_maxs, Max);
|
2006-05-15 13:52:38 +00:00
|
|
|
|
2008-05-07 05:17:21 +00:00
|
|
|
orig[0] += (Min[0] + Max[0]) * 0.5;
|
|
|
|
orig[1] += (Min[1] + Max[1]) * 0.5;
|
|
|
|
orig[2] += (Min[2] + Max[2]) * 0.5;
|
2004-02-15 02:29:51 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return 1;
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove entity by name */
|
2007-01-26 05:56:10 +00:00
|
|
|
stock remove_entity_name(const eName[])
|
2004-02-15 02:29:51 +00:00
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
new iEntity = find_ent_by_class(-1, eName);
|
2004-02-15 02:29:51 +00:00
|
|
|
while (iEntity > 0)
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
remove_entity(iEntity);
|
|
|
|
iEntity = find_ent_by_class(-1, eName);
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return 1;
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the contents of the point a user is aiming at */
|
|
|
|
stock ViewContents(id)
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
new origin[3], Float:Orig[3];
|
|
|
|
get_user_origin(id, origin, 3);
|
|
|
|
Orig[0] = float(origin[0]);
|
|
|
|
Orig[1] = float(origin[1]);
|
|
|
|
Orig[2] = float(origin[2]);
|
2004-02-15 02:29:51 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return point_contents(Orig);
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stock get_speed(ent)
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
new Float:Vel[3];
|
|
|
|
entity_get_vector(ent, EV_VEC_velocity, Vel);
|
2004-02-15 02:29:51 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return floatround(vector_length(Vel));
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
|
2004-11-17 07:33:29 +00:00
|
|
|
/* Set rendering of an entity */
|
|
|
|
stock set_rendering(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
|
2004-02-15 02:29:51 +00:00
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
entity_set_int(index,EV_INT_renderfx,fx);
|
|
|
|
new Float:RenderColor[3];
|
|
|
|
RenderColor[0] = float(r);
|
|
|
|
RenderColor[1] = float(g);
|
|
|
|
RenderColor[2] = float(b);
|
|
|
|
entity_set_vector(index,EV_VEC_rendercolor,RenderColor);
|
|
|
|
entity_set_int(index,EV_INT_rendermode,render);
|
|
|
|
entity_set_float(index,EV_FL_renderamt,float(amount));
|
2004-02-15 02:29:51 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return 1;
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set flags on an entity */
|
|
|
|
stock set_entity_flags(ent,flag,onoff)
|
|
|
|
{
|
2004-03-07 17:28:30 +00:00
|
|
|
if ((entity_get_int(ent,EV_INT_flags)&flag) > 0)
|
2004-02-15 02:29:51 +00:00
|
|
|
{
|
|
|
|
if (onoff == 1)
|
2004-03-07 17:28:30 +00:00
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
return 2;
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
entity_set_int(ent,EV_INT_flags,entity_get_int(ent,EV_INT_flags)-flag);
|
|
|
|
return 1;
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (onoff == 0)
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
return 2;
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
entity_set_int(ent,EV_INT_flags,entity_get_int(ent,EV_INT_flags)+flag);
|
|
|
|
return 1;
|
2004-02-15 02:29:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return 0;
|
2004-03-22 11:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If visible = 1, entity will be set to be visible, else invisible. */
|
2007-03-05 19:30:40 +00:00
|
|
|
stock set_entity_visibility(entity, visible = 1)
|
|
|
|
{
|
|
|
|
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);
|
2004-03-22 11:29:29 +00:00
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
return 1;
|
2004-03-22 11:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns 1 if entity is visible. */
|
2007-03-05 19:30:40 +00:00
|
|
|
stock get_entity_visibility(entity)
|
|
|
|
{
|
|
|
|
return !(entity_get_int(entity, EV_INT_effects) & EF_NODRAW);
|
2004-04-03 05:23:12 +00:00
|
|
|
}
|
|
|
|
|
2007-01-26 05:56:10 +00:00
|
|
|
stock set_user_velocity(entity, const Float:vec[3])
|
2004-05-26 07:59:33 +00:00
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
return entity_set_vector(entity, EV_VEC_velocity, vec);
|
2004-05-26 07:59:33 +00:00
|
|
|
}
|
|
|
|
|
2004-06-07 11:13:20 +00:00
|
|
|
stock get_user_velocity(entity, Float:vec[3])
|
2004-05-26 07:59:33 +00:00
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
return entity_get_vector(entity, EV_VEC_velocity, vec);
|
2004-08-31 15:02:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Backwards compatible */
|
|
|
|
/* Hurts/Kills players in a sphere, like an explosion, Multiplier determines damage. */
|
2007-03-05 19:30:40 +00:00
|
|
|
stock RadiusDamage(const Float:fExplodeAt[3], iDamageMultiplier, iRadiusMultiplier)
|
|
|
|
{
|
|
|
|
return radius_damage(fExplodeAt, iDamageMultiplier, iRadiusMultiplier);
|
2004-08-31 15:02:51 +00:00
|
|
|
}
|
|
|
|
/* Gives you a velocity in the direction a player is looking, iVelocity is the multiplier. */
|
2007-03-05 19:30:40 +00:00
|
|
|
stock VelocityByAim(iIndex,iVelocity, Float:vRetValue[3])
|
|
|
|
{
|
|
|
|
return velocity_by_aim(iIndex,iVelocity,vRetValue);
|
2004-08-31 15:02:51 +00:00
|
|
|
}
|
|
|
|
/* Will return the contents of a point (inside map? in sky? outside map? etc.). */
|
2007-03-05 19:30:40 +00:00
|
|
|
stock PointContents(const Float:fCheckAt[3])
|
|
|
|
{
|
|
|
|
return point_contents(fCheckAt);
|
2004-08-31 15:02:51 +00:00
|
|
|
}
|
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
stock set_size(index, const Float:mins[3], const Float:maxs[3])
|
|
|
|
{
|
|
|
|
return entity_set_size(index,mins,maxs);
|
2006-05-11 08:45:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//by Twilight Suzuka, request addition at29428
|
|
|
|
//"Lifted from HLSDK"
|
|
|
|
stock IsInWorld( ent )
|
|
|
|
{
|
2007-03-05 19:30:40 +00:00
|
|
|
new Float:origin[3];
|
|
|
|
entity_get_vector(ent,EV_VEC_origin,origin);
|
2006-05-11 08:45:06 +00:00
|
|
|
|
|
|
|
if (origin[0] >= 4096.0) return 0;
|
|
|
|
if (origin[1] >= 4096.0) return 0;
|
|
|
|
if (origin[2] >= 4096.0) return 0;
|
|
|
|
if (origin[0] <= -4096.0) return 0;
|
|
|
|
if (origin[1] <= -4096.0) return 0;
|
|
|
|
if (origin[2] <= -4096.0) return 0;
|
|
|
|
|
2007-03-05 19:30:40 +00:00
|
|
|
new Float:velocity[3];
|
|
|
|
entity_get_vector(ent,EV_VEC_velocity,velocity);
|
2006-05-11 08:45:06 +00:00
|
|
|
|
|
|
|
if (velocity[0] >= 2000) return 0;
|
|
|
|
if (velocity[1] >= 2000) return 0;
|
|
|
|
if (velocity[2] >= 2000) return 0;
|
|
|
|
if (velocity[0] <= -2000) return 0;
|
|
|
|
if (velocity[1] <= -2000) return 0;
|
|
|
|
if (velocity[2] <= -2000) return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|