Raised This Month: $12 Target: $400
 3% 

Distance Based Accuracy / Cone of Fire Creation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 07-24-2007 , 20:29   Distance Based Accuracy / Cone of Fire Creation
Reply With Quote #1

This plugin basically replicates a cone of fire. It is distance based accuracy. Depending on how far away you are from your target, your bullet will be offset by a variable.

I created the plugin but never took it anywhere because I realised the DoD default cone of fire suffices for my purposes, but I figure someone will someday have a use for it, and by that time I might be long dead. So I figured I'd post it here in case anyone else wants to use it.

I have commented it all out so it should be relatively easy to follow.

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #pragma semicolon 1 #define PLUGIN "Distance Accuracy" #define VERSION "1.0" #define AUTHOR "29th ID" // Global CVars new g_cvarDistance, g_cvarOffset; public plugin_init() {     register_plugin( PLUGIN, VERSION, AUTHOR );         // Register Hook     register_forward( FM_TraceLine, "hook_TraceLine", 1 );         // Register CVars     g_cvarDistance = register_cvar( "trace_distance", "300" );     g_cvarOffset = register_cvar( "trace_offset", "50" ); } // The actual hook //                     start origin    end origin    hit players?  shooter   idoftrace public hook_TraceLine( Float:start[3], Float:end[3], monsters,      id,         ptr ) {         // Get victim user id     new victim = get_tr( TR_pHit );         // If the shooter or victim is not alive, exit.     // (Not a bullet..ie putting mouse over someone and seeing their name)     if( !is_user_alive( id ) ) return PLUGIN_CONTINUE;         // Grab the maximum distance cvar     new Float:m_cvarDistance = get_pcvar_float( g_cvarDistance );         // Get the distance between "start origin" and "end origin"     new Float:m_flTraceDistance = vecdist( start, end );         // If start/end distance is greater than the max distance cvar     if( m_flTraceDistance > m_cvarDistance )     {         // Grab the desired offset cvar         new Float:m_cvarOffset = get_pcvar_float( g_cvarOffset );                 // Create a new "end origin" vector         new Float:m_newend[3];                 // Copy the current end origin vector, but add the offset cvar to each line         m_newend[0] = end[0]+m_cvarOffset;         m_newend[1] = end[1]+m_cvarOffset;         m_newend[2] = end[2]+m_cvarOffset;                 // Create this trace again, but with the new "end origin", m_newend         engfunc( EngFunc_TraceLine, start, m_newend, monsters, id, ptr );                 // Debug echo         //client_print( id, print_chat, "Trace: %f > %f", m_flTraceDistance, m_cvarDistance );                 return PLUGIN_HANDLED;     }     return PLUGIN_CONTINUE; } // Space saver for vector distance (distance between two origins) stock Float:vecdist(Float:vec1[3], Float:vec2[3]) {         new Float:x = vec1[0] - vec2[0];         new Float:y = vec1[1] - vec2[1];         new Float:z = vec1[2] - vec2[2];         x*=x;         y*=y;         z*=z;         return floatsqroot(x+y+z); }
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-24-2007 , 20:33   Re: Distance Based Accuracy / Cone of Fire Creation
Reply With Quote #2

"PLUGIN_" ?

You should use "FMRES_" .

FMRES_HANDLED
FMRES_IGNORED
FMRES_OVERRIDE
FMRES_SUPERCEDE
__________________
Arkshine is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode