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

Automatic func_tanks in Counter Strike


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-05-2010 , 07:26   Automatic func_tanks in Counter Strike
Reply With Quote #1

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:

Code:
public plugin_precache()
{
    RegisterHam(Ham_Spawn,"func_tank","spawnTank",1)    
    OrpheuRegisterHook(OrpheuGetEngineFunction("pfnFindClientInPVS","FindClientInPVS"),"OnFindClientInPVS")
}

public spawnTank(id)
{
    set_pev(id,pev_spawnflags, SF_TANK_ACTIVE | SF_TANK_PLAYER | SF_TANK_HUMANS | SF_TANK_CANCONTROL | SF_TANK_SOUNDON)
    dllfunc(DLLFunc_Think,id)
}

public OrpheuHookReturn:OnFindClientInPVS(id)
{
    OrpheuSetReturn(find_ent_by_class(0,"player"))
    return OrpheuSupercede
}
Arkshine told me that the only flag really needed is SF_TANK_ACTIVE and you can see more about them in hlsdk.

If you want to use this code in a zombie server or something like that just change the function OnFindClientInPVS and use on it an algorithm of yours to find a player to shoot at (like the closer zombie or whatever).

Final notes:
It almost could be made without orpheu because fakemeta also provides hooking for FindClientInPVS but I tested it and it didn't get called.

Offsets for CFuncTank - http://wiki.amxmodx.org/CFuncTank_%28CS%29

FindClientInPVS can be also called in more situations for other entities (though is unusual) so you might want to add it's hook an extra check to see if it is a func_tank using it.

Thanks to Capostrike for testing with me

Example map: http://www.fpsbanana.com/maps/1080
Attached Files
File Type: zip func_tank.zip (1.2 KB, 352 views)
__________________

Last edited by joaquimandrade; 05-05-2010 at 07:36.
joaquimandrade is offline
capostrike93
Veteran Member
Join Date: Feb 2009
Location: adios y??
Old 05-05-2010 , 07:48   Re: Automatic func_tanks in Counter Strike
Reply With Quote #2

Demonstration video: ...

http://www.xfire.com/video/29f364/

please see 2:25 minutes

here useful example:

PHP Code:
#include <amxmodx>
#include <orpheu>
#include <orpheu_stocks>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

#define KILL_ONLYT // Kill only Terrorist Team...
// #define KILL_ONLYCT // Kill only Counter-Terrorist Team...
// #define ZOMBIEPLAGUE // For zombie plague mod...

#if defined ZOMBIEPLAGUE
#include <zombieplague>
#elseif defined KILL_ONLYT || defined KILL_ONLYCT
#include <cstrike>
#endif

public plugin_precache()
{
    
register_plugin("Example Advanced Spawn Tank","1.0","capostrike93/joaquim")
    
RegisterHam(Ham_Spawn,"func_tank","spawnTank",1)    
    
OrpheuRegisterHook(OrpheuGetEngineFunction("pfnFindClientInPVS","FindClientInPVS"),"OnFindClientInPVS")
}

public 
spawnTank(id)
{
    
set_pev(id,pev_spawnflagsSF_TANK_ACTIVE SF_TANK_PLAYER SF_TANK_HUMANS SF_TANK_CANCONTROL SF_TANK_SOUNDON)
    
dllfunc(DLLFunc_Think,id)
    
set_pdata_float(id,41,360.0,4)
}

public 
OrpheuHookReturn:OnFindClientInPVS(id)
{
    
OrpheuSetReturn(findCloserPlayer(id))
    return 
OrpheuSupercede
}

findCloserPlayer(id)
{
    new 
Float:originFTank[3]
    
pev(id,pev_origin,originFTank)
    
    static
    
Float:originFPlayer[3],
    
Float:Distance,
    
Float:CloserDistance;

    
// Reset Distance
    
CloserDistance 999999.0;
    
    new 
CloserPlayer
    
    
for(new i;i<33;i++)
    {
        if(!
is_user_alive(i)) continue
        
#if defined ZP
        
if(!zp_get_user_zombie(i)) continue
        
#endif
        #if defined KILL_ONLYT
        
if(cs_get_user_team(i) != CS_TEAM_T) continue
        
#endif
        #if defined KILL_ONLYCT
        
if(cs_get_user_team(i) != CS_TEAM_CT) continue
        
#endif
        
        
pev(i,pev_origin,originFPlayer)
        
        
Distance get_distance_f(originFTank,originFPlayer)
        if(
CloserDistance Distance)
        {
            
CloserPlayer i;
            
CloserDistance Distance;
        }
    }
    
    return 
CloserPlayer;

set_pdata_float(id,41,360.0,4) // For full rotation (360º)
__________________

Last edited by capostrike93; 05-05-2010 at 19:36.
capostrike93 is offline
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 05-05-2010 , 13:01   Re: Automatic func_tanks in Counter Strike
Reply With Quote #3

Good stuff, gonna test it.
__________________
"There is no knowledge, that is not power"
fezh is offline
capostrike93
Veteran Member
Join Date: Feb 2009
Location: adios y??
Old 05-05-2010 , 19:36   Re: Automatic func_tanks in Counter Strike
Reply With Quote #4

set_pdata_float(id,41,360.0,4) // For full rotation (360º)
__________________
capostrike93 is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 05-05-2010 , 20:44   Re: Automatic func_tanks in Counter Strike
Reply With Quote #5

Caostrike, you example they will only shoot people with the last index in the Radio.

You understand me?
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 05-05-2010 , 21:41   Re: Automatic func_tanks in Counter Strike
Reply With Quote #6

It works using fakemeNta too

(I'm using random 1-32 because I'm too lazy to make it better )

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

public plugin_init()
{
        
register_forward(FM_FindClientInPVS"findclientinpvs")
}

public 
plugin_precache()
{
        
RegisterHam(Ham_Spawn,"func_tank","spawnTank",1)
}

public 
spawnTank(id)
{
        
set_pev(id,pev_spawnflagsSF_TANK_ACTIVE SF_TANK_PLAYER SF_TANK_HUMANS SF_TANK_CANCONTROL SF_TANK_SOUNDON)
        
dllfunc(DLLFunc_Think,id)
}

public 
findclientinpvs(id)
{
        static class[
32]
        if(
pev_valid(id))
        {
                
pev(idpev_classname, class, charsmax(class))
                if(
equal(class, "func_tank"))
                {
                        
forward_return(FMV_CELLrandom_num(132))
                        return 
FMRES_SUPERCEDE
                
}
        }
        return 
FMRES_IGNORED

__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-05-2010 , 21:47   Re: Automatic func_tanks in Counter Strike
Reply With Quote #7

But have you tested? When I tested, FM_FindClientInPVS didn't get called.
__________________
joaquimandrade is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 05-05-2010 , 21:48   Re: Automatic func_tanks in Counter Strike
Reply With Quote #8

Yes, I have tested.

Maybe you miss using forward_return or you use findentityinpvs instead of clientinpvs, I don't know but it's working.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-05-2010 , 21:51   Re: Automatic func_tanks in Counter Strike
Reply With Quote #9

Quote:
Originally Posted by joropito View Post
Yes, I have tested.

Maybe you miss using forward_return or you use findentityinpvs instead of clientinpvs, I don't know but it's working.
I remember testing the right forward but anyway, if it works, it works.
__________________
joaquimandrade is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 05-05-2010 , 21:52   Re: Automatic func_tanks in Counter Strike
Reply With Quote #10

Here's the key name/values used for func_tank
(cs_rats2_final example values)

Code:
model *174
origin -35 576 -198
rotatesound ambience/turretrot1.wav
rendermode 0
renderfx 0
spriteflash sprites/muzzleflash2.spr
bullet 3
maxRange 0
minRange 0
firespread 1
persistence 1
bullet_damage 15
firerate 15
spritescale 1
barrelz 7
barrely 0
barrel 66
pitchtolerance 5
pitchrange 75
pitchrate 500
yawtolerance 15
yawrange 55
yawrate 500
target boom
rendercolor 0 0 0
renderamt 0
targetname gunny
spawnflags 32
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
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 00:32.


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