CSLover
Участник
- Сообщения
- 60
- Реакции
- 5
- Помог
- 2 раз(а)
- Баллы
- 8
This plugin is used so that when someone uses a weapon that can scope, a red laser dot appears on the wall where they’re aiming.
However, there’s also a visible white light beam coming from the weapon, like a flashlight.
Could someone remove that white light from the plugin please?
I’d like it so that only the red laser is visible.
Thank you for your help.
However, there’s also a visible white light beam coming from the weapon, like a flashlight.
Could someone remove that white light from the plugin please?
I’d like it so that only the red laser is visible.
Thank you for your help.
Код:
/**
*
* Sniper Spark / Laser Dot
* by Numb
*
*
* Description:
* This plugin adds a spark coming from sniper scope when zoomed-in. Everyone in your
* field of view will be able to see it. Closer the person is to the middle of your screen
* - brighter the spark will appear for him. Also once zoomed-in everyone including
* yourself will be able to see a laser dot identifying where you are currently aiming.
*
*
* Requires:
* FakeMeta
* HamSandWich
*
*
* Additional Info:
* Tested in Counter-Strike 1.6 with amxmodx 1.8.2 (dev build hg21). Original idea for
* this plugin is to balance advantage on issue of camping snipers.
*
*
* Notes:
* Sniper spark is not visible within 64 units of it.
*
*
* Warnings:
* Custom zoom plugins will not provide neither spark, neither laser dot effect.
*
*
* Credits:
* Special thanks to eDark for calculation functions!
*
*
* ChangeLog:
*
* + 1.2
* - Fixed: Using custom zoom doesn't create laser dot anymore.
*
* + 1.1
* - Fixed: Sniper dot now includes recoil calculation.
* - Fixed: Sniper spark now includes recoil calculation.
*
* + 1.0
* - First release.
*
*
* Downloads:
* Amx Mod X forums: http://forums.alliedmods.net/showthread.php?p=1486369#post1486369
*
**/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN_NAME "Sniper Spark / Laser Dot"
#define PLUGIN_VERSION "1.2"
#define PLUGIN_AUTHOR "Numb"
#define m_pActiveItem 373
#define m_iId 43
#define ENT_LIMIT 1380
#define RECOIL_FIX
#define SetPlayerBit(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) )
#define ClearPlayerBit(%1,%2) ( %1 &= ~( 1 << ( %2 & 31 ) ) )
#define CheckPlayerBit(%1,%2) ( %1 & ( 1 << ( %2 & 31 ) ) )
new g_iMaxPlayers
new g_iLightEnts[33];
new g_iSparkEnts[33];
new g_iSparkOwner[ENT_LIMIT];
new g_iConnectedUsers;
new g_iAliveUsers;
new g_iValidSparks;
new Float:g_fUserAngle[33][3];
new Float:g_fUserOrigin[33][3];
new Float:g_fViewOrigin[33][3];
new Float:g_fUserViewAngle[33][3];
new Float:g_fExtraData[33][3];
new bool:g_bMakeExtraCheck[33];
public plugin_precache()
{
precache_model("sprites/yelflare1.spr"); // awp
precache_model("sprites/redflare1.spr"); // scout
precache_model("sprites/flare1.spr"); // g3sg1
precache_model("sprites/blueflare1.spr"); // sg550
precache_model("sprites/glow03.spr"); // sg550
precache_model("sprites/glow04.spr"); // aug
precache_model("sprites/gargeye1.spr"); // laser dot
}
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
new iTemp = engfunc(EngFunc_AllocString, "info_target");
g_iMaxPlayers = clamp(get_maxplayers(), 1, 32);
new iPlrId;
for( iPlrId=1; iPlrId<=g_iMaxPlayers; iPlrId++ )
{
if( (g_iSparkEnts[iPlrId]=engfunc(EngFunc_CreateNamedEntity, iTemp))>g_iMaxPlayers )
{
g_iSparkOwner[g_iSparkEnts[iPlrId]] = iPlrId;
set_pev(g_iSparkEnts[iPlrId], pev_classname, "sniper_spark");
set_pev(g_iSparkEnts[iPlrId], pev_solid, SOLID_NOT);
set_pev(g_iSparkEnts[iPlrId], pev_rendermode, kRenderGlow);
set_pev(g_iSparkEnts[iPlrId], pev_renderfx, kRenderFxNoDissipation);
set_pev(g_iSparkEnts[iPlrId], pev_renderamt, 0.0);
set_pev(g_iSparkEnts[iPlrId], pev_owner, iPlrId);
}
else
{
g_iSparkEnts[iPlrId] = 0;
break;
}
if( (g_iLightEnts[iPlrId]=engfunc(EngFunc_CreateNamedEntity, iTemp))>g_iMaxPlayers )
{
set_pev(g_iLightEnts[iPlrId], pev_classname, "laser_dot");
set_pev(g_iLightEnts[iPlrId], pev_solid, SOLID_NOT);
set_pev(g_iLightEnts[iPlrId], pev_rendermode, kRenderGlow);
set_pev(g_iLightEnts[iPlrId], pev_renderfx, kRenderFxNoDissipation);
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
set_pev(g_iLightEnts[iPlrId], pev_scale, 0.075);
engfunc(EngFunc_SetModel, g_iLightEnts[iPlrId], "sprites/gargeye1.spr");
set_pev(g_iLightEnts[iPlrId], pev_owner, iPlrId);
}
else
{
g_iLightEnts[iPlrId] = 0;
break;
}
}
if( iPlrId>g_iMaxPlayers ) // loop was successful
{
register_forward(FM_PlayerPostThink, "FM_PlayerPostThink_Post", 1);
register_forward(FM_AddToFullPack, "FM_AddToFullPack_Post", 1);
register_event("SetFOV", "Event_SetFOV", "be");
register_event("ResetHUD", "Event_ResetHUD", "be");
register_event("Health", "Event_Health", "bd");
}
}
public plugin_pause()
{
for( new iPlrId=1; iPlrId<=g_iMaxPlayers; iPlrId++ )
{
ClearPlayerBit(g_iConnectedUsers, iPlrId);
ClearPlayerBit(g_iAliveUsers, iPlrId);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
ClearPlayerBit(g_iValidSparks, iPlrId);
}
}
public plugin_unpause()
{
g_iConnectedUsers = 0;
g_iAliveUsers = 0;
g_iValidSparks = 0;
new Float:fFov;
for( new iPlrId=1; iPlrId<=g_iMaxPlayers; iPlrId++ )
{
if( is_user_connected(iPlrId) )
{
SetPlayerBit(g_iConnectedUsers, iPlrId);
if( is_user_alive(iPlrId) )
{
SetPlayerBit(g_iAliveUsers, iPlrId);
pev(iPlrId, pev_fov, fFov);
if( fFov<=0.0 )
fFov = 90.0;
player_fov_changed(iPlrId, floatround(fFov, floatround_round));
}
else
{
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
}
}
else
{
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
}
}
}
public client_connect(iPlrId)
{
ClearPlayerBit(g_iConnectedUsers, iPlrId);
ClearPlayerBit(g_iAliveUsers, iPlrId);
ClearPlayerBit(g_iValidSparks, iPlrId);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
}
public client_putinserver(iPlrId)
{
SetPlayerBit(g_iConnectedUsers, iPlrId);
if( is_user_alive(iPlrId) )
SetPlayerBit(g_iAliveUsers, iPlrId);
else
ClearPlayerBit(g_iAliveUsers, iPlrId);
}
public client_disconnect(iPlrId)
{
ClearPlayerBit(g_iConnectedUsers, iPlrId);
ClearPlayerBit(g_iAliveUsers, iPlrId);
ClearPlayerBit(g_iValidSparks, iPlrId);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
}
public Event_ResetHUD(iPlrId)
{
if( CheckPlayerBit(g_iConnectedUsers, iPlrId) )
{
if( is_user_alive(iPlrId) )
SetPlayerBit(g_iAliveUsers, iPlrId);
else
{
ClearPlayerBit(g_iAliveUsers, iPlrId);
ClearPlayerBit(g_iValidSparks, iPlrId);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
}
}
}
public Event_Health(iPlrId)
{
if( CheckPlayerBit(g_iConnectedUsers, iPlrId) )
{
if( is_user_alive(iPlrId) )
SetPlayerBit(g_iAliveUsers, iPlrId);
else
{
ClearPlayerBit(g_iAliveUsers, iPlrId);
ClearPlayerBit(g_iValidSparks, iPlrId);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
}
}
}
public Event_SetFOV(iPlrId)
{
if( CheckPlayerBit(g_iConnectedUsers, iPlrId) && CheckPlayerBit(g_iAliveUsers, iPlrId) )
{
new iFov = read_data(1);
if( iFov<=0 )
iFov = 90;
player_fov_changed(iPlrId, iFov);
}
}
public FM_PlayerPostThink_Post(iPlrId)
{
static Float:s_fOrigin[3];
pev(iPlrId, pev_v_angle, g_fUserViewAngle[iPlrId]);
#if defined RECOIL_FIX
pev(iPlrId, pev_punchangle, s_fOrigin);
g_fUserViewAngle[iPlrId][0] += s_fOrigin[0];
g_fUserViewAngle[iPlrId][1] += s_fOrigin[1];
#endif
pev(iPlrId, pev_origin, s_fOrigin);
pev(iPlrId, pev_view_ofs, g_fViewOrigin[iPlrId]);
g_fViewOrigin[iPlrId][0] += s_fOrigin[0];
g_fViewOrigin[iPlrId][1] += s_fOrigin[1];
g_fViewOrigin[iPlrId][2] += s_fOrigin[2];
if( CheckPlayerBit(g_iConnectedUsers, iPlrId) && CheckPlayerBit(g_iAliveUsers, iPlrId) && CheckPlayerBit(g_iValidSparks, iPlrId) )
{
static Float:s_fAngles[3], Float:s_fViewAngle[3], Float:s_fTemp[3];
pev(iPlrId, pev_angles, s_fAngles);
s_fOrigin[2] += 17.0;
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
{
s_fViewAngle = g_fUserViewAngle[iPlrId];
s_fViewAngle[0] *= -1.0;
SphereToCartesian(s_fTemp, g_fViewOrigin[iPlrId], s_fViewAngle, Float:{0.0, 0.0, 9999.0});
engfunc(EngFunc_TraceLine, g_fViewOrigin[iPlrId], s_fTemp, DONT_IGNORE_MONSTERS, iPlrId, 0);
get_tr2(0, TR_vecEndPos, s_fTemp);
engfunc(EngFunc_SetOrigin, g_iLightEnts[iPlrId], s_fTemp);
}
if( s_fAngles[0]==g_fUserAngle[iPlrId][0] && s_fAngles[1]==g_fUserAngle[iPlrId][1] && !g_bMakeExtraCheck[iPlrId]
&& s_fOrigin[0]==g_fUserOrigin[iPlrId][0] && s_fOrigin[1]==g_fUserOrigin[iPlrId][1] && s_fOrigin[2]==g_fUserOrigin[iPlrId][2] )
return FMRES_IGNORED;
g_bMakeExtraCheck[iPlrId] = false;
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
{
g_fUserAngle[iPlrId][0] = s_fAngles[0];
g_fUserAngle[iPlrId][1] = s_fAngles[1];
g_fUserAngle[iPlrId][2] = s_fAngles[2];
g_fUserOrigin[iPlrId][0] = s_fOrigin[0];
g_fUserOrigin[iPlrId][1] = s_fOrigin[1];
g_fUserOrigin[iPlrId][2] = s_fOrigin[2];
static Float:s_fExtraData[3];
s_fExtraData = g_fExtraData[iPlrId];
if( s_fAngles[0]>16.0 )
s_fAngles[0] = 16.0;
else if( s_fAngles[0]<-16.0 )
s_fAngles[0] = -16.0;
s_fAngles[0] *= 2.0;
SphereToCartesian(s_fTemp, s_fOrigin, s_fAngles, s_fExtraData);
engfunc(EngFunc_SetOrigin, g_iSparkEnts[iPlrId], s_fTemp);
//client_print(iPlrId, print_center, "Setting pos: %f %f %f", s_fTemp[0], s_fTemp[1], s_fTemp[2]);
}
}
return FMRES_IGNORED;
}
public FM_AddToFullPack_Post(iEsHandle, iE, iEnt, iHost, iHostFlags, iPlayer, iPSet)
{
if( 1<=iHost<=g_iMaxPlayers && get_orig_retval() )
{
static s_iOwner;
s_iOwner = g_iSparkOwner[iEnt];
if( s_iOwner )
{
if( CheckPlayerBit(g_iAliveUsers, s_iOwner) && CheckPlayerBit(g_iValidSparks, s_iOwner) )
{
if( iHost!=s_iOwner && get_distance_f(g_fViewOrigin[s_iOwner], g_fViewOrigin[iHost])>64.0 )
{
static Float:s_fScale;
s_fScale = get_visibility_scale(g_fViewOrigin[s_iOwner], g_fUserViewAngle[s_iOwner], g_fViewOrigin[iHost]);
if( s_fScale>=0.0 && s_fScale<=1.0 )
set_es(iEsHandle, ES_Scale, (0.25+((1.0-s_fScale)*0.25)));
else
set_es(iEsHandle, ES_RenderAmt, 0); //set_es(iEsHandle, ES_Effects, EF_NODRAW);
}
else
set_es(iEsHandle, ES_RenderAmt, 0);
}
}
}
}
player_fov_changed(iPlrId, iFov)
{
if( iFov>=90 )
{
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
ClearPlayerBit(g_iValidSparks, iPlrId);
}
else
{
new iActiveItem = get_pdata_cbase(iPlrId, m_pActiveItem, 5); // active item ent id
if( iActiveItem )
{
new iWeaponType = get_pdata_int(iActiveItem, m_iId, 4); // weapon type
switch( iWeaponType )
{
case CSW_SCOUT:
{
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 255.0);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
{
g_bMakeExtraCheck[iPlrId] = true;
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "sprites/redflare1.spr");
set_pev(g_iSparkEnts[iPlrId], pev_renderamt, 255.0);
}
g_fExtraData[iPlrId][0] = 5.0;
g_fExtraData[iPlrId][1] = -7.0;
g_fExtraData[iPlrId][2] = 27.0;
SetPlayerBit(g_iValidSparks, iPlrId);
}
case CSW_AUG:
{
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 255.0);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
{
g_bMakeExtraCheck[iPlrId] = true;
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "sprites/glow04.spr");
set_pev(g_iSparkEnts[iPlrId], pev_renderamt, 127.0);
}
g_fExtraData[iPlrId][0] = 5.0;
g_fExtraData[iPlrId][1] = -10.0;
g_fExtraData[iPlrId][2] = 22.0;
SetPlayerBit(g_iValidSparks, iPlrId);
}
case CSW_SG550:
{
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 255.0);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
{
g_bMakeExtraCheck[iPlrId] = true;
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "sprites/blueflare1.spr");
set_pev(g_iSparkEnts[iPlrId], pev_renderamt, 255.0);
}
g_fExtraData[iPlrId][0] = -3.0;
g_fExtraData[iPlrId][1] = -7.0;
g_fExtraData[iPlrId][2] = 25.0;
SetPlayerBit(g_iValidSparks, iPlrId);
}
case CSW_AWP:
{
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 255.0);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
{
g_bMakeExtraCheck[iPlrId] = true;
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "sprites/yelflare1.spr");
set_pev(g_iSparkEnts[iPlrId], pev_renderamt, 255.0);
}
g_fExtraData[iPlrId][0] = 3.0;
g_fExtraData[iPlrId][1] = -7.0;
g_fExtraData[iPlrId][2] = 27.0;
SetPlayerBit(g_iValidSparks, iPlrId);
}
case CSW_G3SG1:
{
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 255.0);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
{
g_bMakeExtraCheck[iPlrId] = true;
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "sprites/flare1.spr");
set_pev(g_iSparkEnts[iPlrId], pev_renderamt, 255.0);
}
g_fExtraData[iPlrId][0] = -10.0;
g_fExtraData[iPlrId][1] = -10.0;
g_fExtraData[iPlrId][2] = 25.0;
SetPlayerBit(g_iValidSparks, iPlrId);
}
case CSW_SG552:
{
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 255.0);
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
{
g_bMakeExtraCheck[iPlrId] = true;
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "sprites/glow03.spr");
set_pev(g_iSparkEnts[iPlrId], pev_renderamt, 127.0);
}
g_fExtraData[iPlrId][0] = -10.0;
g_fExtraData[iPlrId][1] = -10.0;
g_fExtraData[iPlrId][2] = 22.0;
SetPlayerBit(g_iValidSparks, iPlrId);
}
default:
{
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
ClearPlayerBit(g_iValidSparks, iPlrId);
}
}
}
else
{
if( g_iSparkEnts[iPlrId] && pev_valid(g_iSparkEnts[iPlrId]) )
engfunc(EngFunc_SetModel, g_iSparkEnts[iPlrId], "");
if( g_iLightEnts[iPlrId] && pev_valid(g_iLightEnts[iPlrId]) )
set_pev(g_iLightEnts[iPlrId], pev_renderamt, 0.0);
ClearPlayerBit(g_iValidSparks, iPlrId);
}
}
}
Float:get_visibility_scale(const Float:fCamPos[3], const Float:fCamAngle[3], const Float:fObjectOrigin[3])
{
static Float:s_fObjectPos[3], Float:s_fTemp[3], Float:s_fAngle[2];
s_fAngle[0] = (fCamAngle[0]*M_PI/180.0);
s_fAngle[1] = (fCamAngle[1]*M_PI/180.0);
s_fObjectPos[0] = (fObjectOrigin[0]-fCamPos[0]);
s_fObjectPos[1] = (fObjectOrigin[1]-fCamPos[1]);
s_fObjectPos[2] = (fObjectOrigin[2]-fCamPos[2]);
static Float:s_fSin0, Float:s_fCos0, Float:s_fSin1, Float:s_fCos1;
s_fSin0 = floatsin(s_fAngle[0]);
s_fCos0 = floatcos(s_fAngle[0]);
s_fSin1 = floatsin(s_fAngle[1]);
s_fCos1 = floatcos(s_fAngle[1]);
s_fTemp[0] = (s_fObjectPos[0]*s_fCos1*s_fCos0);
s_fTemp[0] += (s_fObjectPos[1]*s_fSin1*s_fCos0);
s_fTemp[0] -= (s_fObjectPos[2]*s_fSin0);
if( s_fTemp[0]<0.0 )
return -1.0;
s_fTemp[1] = (s_fObjectPos[1]*s_fCos1);
s_fTemp[1] -= (s_fObjectPos[0]*s_fSin1);
s_fTemp[2] = (s_fObjectPos[0]*s_fCos1*s_fSin0);
s_fTemp[2] += (s_fObjectPos[1]*s_fSin1*s_fSin0);
s_fTemp[2] += (s_fObjectPos[2]*s_fCos0);
static Float:s_fScreenWidth;
s_fScreenWidth = (s_fTemp[0]*3.09715552293636);
if( ((s_fTemp[1]*s_fTemp[1])+(s_fTemp[2]*s_fTemp[2]))<floatpower(s_fScreenWidth, 2.0) )
{
static Float:s_fPosX, Float:s_fPosY;
s_fPosX = (s_fTemp[1]/s_fScreenWidth);
s_fPosY = (s_fTemp[2]/(s_fScreenWidth*0.75));
return (floatsqroot(((s_fPosX*s_fPosX)+(s_fPosY*s_fPosY)))/0.707106781186548);
}
return -1.0;
}
// This function is useful cause when vertical angle isn't 0, horizontal angle isn't what we expect
// it to be. Trust me - if we look up, than 45 degrees to the left isn't the edge of our screen,
// but is directly up. Well, this one fixes it. Baiscally what it does is gives us a position what
// we want to our cam-pos, cam-angle, and radius. Something like get_user_aiming(), but here we
// can choose distance and angle and angle within an angle what we want.
//
// dest - return origin
// origin - cam position
// view - cam angle
// anlge - angle to where "dest" should be (![z] is the distance/radius we want - not angle!)
//
// NOTES: ".ha" = horizontal (Y) or [1]; ".va" = vertical (X) or [0]; ".r" = (Z) or [2]
// "angle.r" is angle[2] what actually is a radius or a distance we want from "origin" to "dest",
// so don't get confused. WARNING: fView and fAngle variables do change within the function.
bool:SphereToCartesian(Float:fDest[3], Float:fOrigin[3], Float:fView[3], Float:fAngle[3])
{
fView[1] *= (M_PI/180.0); // and now angle[0] and angle[1] has no effect?
fView[0] *= (M_PI/180.0);
fAngle[0] *= (M_PI/-180.0);
fAngle[1] *= (M_PI/180.0);
static Float:s_fSin0, Float:s_fCos0, Float:s_fSin1, Float:s_fCos1;
s_fSin0 = floatsin((fAngle[0]+(M_PI*0.5)), radian);
fDest[0] = fAngle[2]*s_fSin0*floatcos(fAngle[1], radian);
fDest[1] = fAngle[2]*s_fSin0*floatsin(fAngle[1], radian);
fDest[2] = fAngle[2]*floatcos((fAngle[0]+(M_PI*0.5)), radian);
s_fSin0 = floatsin(fView[0], radian);
s_fCos0 = floatcos(fView[0], radian);
s_fSin1 = floatsin(fView[1], radian);
s_fCos1 = floatcos(fView[1], radian);
static Float:s_fTemp[3];
s_fTemp[0] = (fDest[0]*s_fCos0*s_fCos1)-(fDest[1]*s_fSin1)+(fDest[2]*s_fSin0*s_fCos1);
s_fTemp[1] = (fDest[0]*s_fCos0*s_fSin1)+(fDest[1]*s_fCos1)+(fDest[2]*s_fSin1*s_fSin0);
s_fTemp[2] = (fDest[2]*s_fCos0)-(fDest[0]*s_fSin0);
fDest[0] = (fOrigin[0]+s_fTemp[0]);
fDest[1] = (fOrigin[1]+s_fTemp[1]);
fDest[2] = (fOrigin[2]-s_fTemp[2]);
return true;
}
/*
bool:is_origin_in_fov(const Float:fCamPos[3], const Float:fCamAngle[3], const Float:fObjectOrigin[3], &Float:fScreenPosX, &Float:fScreenPosY, const Float:fCamFov=90.0, const bool:bAwpSupport=true, const Float:fScreenSizeX=4.0, const Float:fScreenSizeY=3.0)
{
if( fCamFov>=180.0 )
{
fScreenPosX = -1.0;
fScreenPosY = -1.0;
return false;
}
new Float:fObjectPos[3], Float:fTemp[3], Float:fAngle[2], Float:fFov, bool:bCircleSniperZoom;
if( fCamFov<45 )
bCircleSniperZoom = true;
fAngle[0] = (fCamAngle[0]*M_PI/180.0);
fAngle[1] = (fCamAngle[1]*M_PI/180.0);
fFov = (fCamFov*M_PI/180.0);
fObjectPos[0] = (fObjectOrigin[0]-fCamPos[0]);
fObjectPos[1] = (fObjectOrigin[1]-fCamPos[1]);
fObjectPos[2] = (fObjectOrigin[2]-fCamPos[2]);
fTemp[0] = (fObjectPos[0]*floatcos(fAngle[1])*floatcos(fAngle[0]));
fTemp[0] += (fObjectPos[1]*floatsin(fAngle[1])*floatcos(fAngle[0]));
fTemp[0] -= (fObjectPos[2]*floatsin(fAngle[0]));
if( fTemp[0]<0.0 )
{
fScreenPosX = -1.0;
fScreenPosY = -1.0;
return false;
}
fTemp[1] = (fObjectPos[1]*floatcos(fAngle[1]));
fTemp[1] -= (fObjectPos[0]*floatsin(fAngle[1]));
fTemp[2] = (fObjectPos[0]*floatcos(fAngle[1])*floatsin(fAngle[0]));
fTemp[2] += (fObjectPos[1]*floatsin(fAngle[1])*floatsin(fAngle[0]));
fTemp[2] += (fObjectPos[2]*floatcos(fAngle[0]));
new Float:fScreenWidth = (2.0*fTemp[0]*floattan((fFov*0.5)));
if( bCircleSniperZoom && bAwpSupport )
{
if( ((fTemp[1]*fTemp[1])+(fTemp[2]*fTemp[2]))<floatpower((fScreenWidth*0.327), 2.0) ) // 0.654*0.5
{
fScreenPosX = (0.5-(fTemp[1]/fScreenWidth));
fScreenPosY = (0.5-(fTemp[2]/(fScreenWidth*fScreenSizeY/fScreenSizeX)));
return true;
}
fScreenPosX = -1.0;
fScreenPosY = -1.0;
return false;
}
new Float:fScreenHigh = (fScreenWidth*fScreenSizeY/fScreenSizeX);
if( (fTemp[1]>(fScreenWidth*0.5) || fTemp[1]<(fScreenWidth*-0.5))
|| (fTemp[2]>(fScreenHigh*0.5) || fTemp[2]<(fScreenHigh*-0.5)) )
{
fScreenPosX = -1.0;
fScreenPosY = -1.0;
return false;
}
fScreenPosX = (0.5-(fTemp[1]/fScreenWidth));
fScreenPosY = (0.5-(fTemp[2]/fScreenHigh));
return true;
}
*/