Raised This Month: $32 Target: $400
 8% 

Automatic func_tanks in Counter Strike


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-07-2010 , 14:53   Re: Automatic func_tanks in Counter Strike
Reply With Quote #21

You're right, I've tested with this following plugin, type "tank" to spawn an entity in front of you, by default the yaw range is 110°, and if you type "range" it will update the range to 360° and it's well updated right away without needed to spawn again.

PHP Code:

    
#include <amxmodx>
    #include <fakemeta>
    #include <hamsandwich>
    #include <engine>
    #include <xs>
    
    
const MAX_CLIENTS  32;
    const 
MAX_ENTITIES = ( 900 + ( MAX_CLIENTS 15 ) ) / 32;

    new 
isTankMAX_ENTITIES ];

    
#define SetIsTank(%1)     ( isTank[ %1 >> 5 ] |=  ( 1 << ( %1 & 31 ) ) )
    #define ClearIsTank(%1)   ( isTank[ %1 >> 5 ] &= ~( 1 << ( %1 & 31 ) ) )
    #define IsTank(%1)        ( isTank[ %1 >> 5 ] &   ( 1 << ( %1 & 31 ) ) )

    
public plugin_precache()
    {
        
register_forwardFM_Spawn"Entities_Spawn" );
        
        
precache_model"models/turret.mdl" );
        
precache_model"sprites/muzzleflash2.spr" );
        
precache_sound"ambience/turretrot1.wav" );
    }

    public 
Entities_Spawn ( const entity )
    {
        new 
classname32 ];
        
peventitypev_classnameclassnamecharsmaxclassname ) );

        if ( 
pev_validentity ) )
        {
            
equalclassname"func_tank" ) ? SetIsTankentity ) : ClearIsTankentity );
        }
    }

    public 
plugin_init()
    {
        
register_plugin"""""" );
        
        
register_forwardFM_FindClientInPVS"FindClientInPVS" );
        
        
register_clcmd"tank" "ClientCommand_CreateTank" );
        
register_clcmd"range""ClientCommand_ChangeRange" );
    }

    public 
ClientCommand_CreateTank ( const client )
    {
        new 
Float:origin]
        
GetAimOriginDistanceclientorigin200.0 );
    
        new 
tank create_entity"func_tank" );
        
        
engfuncEngFunc_SetModeltank"models/v_m4a1.mdl" );
        
engfuncEngFunc_SetOrigintankorigin );

        
DispatchKeyValuetank"rotatesound"  "ambience/turretrot1.wav"  );
        
DispatchKeyValuetank"spriteflash"  "sprites/muzzleflash2.spr" );
        
DispatchKeyValuetank"spritescale"  "1" );
        
DispatchKeyValuetank"bullet"       "1" );
        
DispatchKeyValuetank"firespread"   "1" );
        
DispatchKeyValuetank"persistence"  "1" );
        
DispatchKeyValuetank"bullet_damage""1" );
        
DispatchKeyValuetank"firerate"     "15"  );
        
DispatchKeyValuetank"yawrate"      "500" );
        
DispatchKeyValuetank"yawrange"     "55"  );
        
DispatchKeyValuetank"yawtolerance" "5"   );
        
DispatchKeyValuetank"pitchrate"    "500" );
        
DispatchKeyValuetank"pitchrange"   "55"  );
        
DispatchKeyValuetank"pitchtolerance""5"  );
        
DispatchKeyValuetank"barrelz"      "4"   );
        
DispatchKeyValuetank"barrely"      "0"   );
        
DispatchKeyValuetank"barrel"       "30"  );
        
        
set_pevtankpev_spawnflagsSF_TANK_ACTIVE );
        
DispatchSpawntank );
    }
    
    public 
ClientCommand_ChangeRange ( const client )
    {
        new 
tank FM_NULLENT;
        
        while ( ( 
tank find_ent_by_classtank"func_tank" ) ) )
        {
            
DispatchKeyValuetank"yawrange""180" );
        }
        
        return 
PLUGIN_HANDLED;
    }   

    public 
FindClientInPVS ( const entity )
    {
        if ( 
IsTankentity ) )
        {
            
forward_returnFMV_CELLfind_ent_by_class0"player" ) );
            return 
FMRES_SUPERCEDE;
        }
        
        return 
FMRES_IGNORED;
    }
    
    
GetAimOriginDistanceindexFloat:origin], Float:distance 
    {
        new 
Float:start];
        new 
Float:view_ofs];
        
        
pevindexpev_originstart );
        
pevindexpev_view_ofsview_ofs );
        
        
xs_vec_addstartview_ofsstart );

        new 
Float:dest];
        
pevindexpev_v_angledest );
        
        
engfuncEngFunc_MakeVectorsdest );
        
global_getglb_v_forwarddest );
        
        
xs_vec_mul_scalardestdistancedest );
        
xs_vec_addstartdestdest );

        
engfuncEngFunc_TraceLinestartdestIGNORE_MONSTERSindex);
        
get_tr20TR_vecEndPosorigin );
    } 
__________________
Arkshine is offline
EXteRmiNaToR
Senior Member
Join Date: Dec 2009
Old 05-08-2010 , 06:04   Re: Automatic func_tanks in Counter Strike
Reply With Quote #22

Nice plugin Arkshine!
Is it possible to make it be "unfriendly" to specific players?
EXteRmiNaToR is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-08-2010 , 06:13   Re: Automatic func_tanks in Counter Strike
Reply With Quote #23

This plugin was just a test, it should not be used like that, but for what you ask, you have to do like in #2, looping through all players and adding your filters instead of using directly find_ent_by_class().
__________________
Arkshine is offline
EXteRmiNaToR
Senior Member
Join Date: Dec 2009
Old 05-08-2010 , 06:21   Re: Automatic func_tanks in Counter Strike
Reply With Quote #24

Okay,will do that.Thanks for your answer!
EXteRmiNaToR is offline
hjkwe654
Member
Join Date: Sep 2005
Location: Taiwan
Old 06-20-2010 , 01:57   Re: Automatic func_tanks in Counter Strike
Reply With Quote #25

Quote:
Originally Posted by joaquimandrade View Post
Hello. I was searching for random functions to test with orpheu and got curious about func_tanks. They have auto aiming and shooting functionality but it doesn't work out of the box in CS so I tried to unlock it. The process is easy: we just have to make them think, have basic flags, and override its search for players because it's code inherited from halflife searches for players in PVS but it seems that they don't have one in CS .

The code:

......
It only target 1 player.
when the player dead, tank still target that player
hjkwe654 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-20-2010 , 06:09   Re: Automatic func_tanks in Counter Strike
Reply With Quote #26

See the second post. You have to filter. It was just an example.
__________________
Arkshine is offline
Reply



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 15:25.


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