AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   Automatic func_tanks in Counter Strike (https://forums.alliedmods.net/showthread.php?t=126074)

capostrike93 05-05-2010 23:17

Re: Automatic func_tanks in Counter Strike
 
Quote:

Originally Posted by AntiBots (Post 1172031)
Caostrike, you example they will only shoot people with the last index in the Radio.

You understand me?

no, my example does that attack the player closest to the tank ..
by default only attack to team terrorist

#define KILL_ONLYT

capostrike93 05-05-2010 23:20

Re: Automatic func_tanks in Counter Strike
 
Quote:

Originally Posted by joropito (Post 1172091)
It works using fakemeNta too

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

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



well, but it is clear that has to verify the integrity of random_num

I mean a. player is alive? check team? other?

and I almost forgot..

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

:P

joropito 05-06-2010 08:33

Re: Automatic func_tanks in Counter Strike
 
Quote:

Originally Posted by capostrike93 (Post 1172139)
well, but it is clear that has to verify the integrity of random_num

I mean a. player is alive? check team? other?

It was just a test the fakemeta alternative. It's just an example.

Quote:

Originally Posted by capostrike93 (Post 1172139)
set_pdata_float(id,41,360.0,4) // For full rotation (360º)

Only if I need :P

Btw, I think it's possible to set full rotation using key "yawrange".

Arkshine 05-06-2010 08:50

Re: Automatic func_tanks in Counter Strike
 
If you want to use the keyvalue, I guess you need to hook the spawn as pre.

Like Quim said, you can get a list of offsets there http://wiki.amxmodx.org/CFuncTank_(CS) ; and you can see the name is enough explicit to understand the keyvalue name related :

Code:

void CFuncTank :: KeyValue( KeyValueData *pkvd )
{
        if (FStrEq(pkvd->szKeyName, "yawrate"))
        {
                m_yawRate = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "yawrange"))
        {
                m_yawRange = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "yawtolerance"))
        {
                m_yawTolerance = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "pitchrange"))
        {
                m_pitchRange = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "pitchrate"))
        {
                m_pitchRate = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "pitchtolerance"))
        {
                m_pitchTolerance = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "firerate"))
        {
                m_fireRate = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "barrel"))
        {
                m_barrelPos.x = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "barrely"))
        {
                m_barrelPos.y = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "barrelz"))
        {
                m_barrelPos.z = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "spritescale"))
        {
                m_spriteScale = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "spritesmoke"))
        {
                m_iszSpriteSmoke = ALLOC_STRING(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "spriteflash"))
        {
                m_iszSpriteFlash = ALLOC_STRING(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "rotatesound"))
        {
                pev->noise = ALLOC_STRING(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "persistence"))
        {
                m_persist = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "bullet"))
        {
                m_bulletType = (TANKBULLET)atoi(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if ( FStrEq(pkvd->szKeyName, "bullet_damage" ))
        {
                m_iBulletDamage = atoi(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "firespread"))
        {
                m_spread = atoi(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "minRange"))
        {
                m_minRange = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "maxRange"))
        {
                m_maxRange = atof(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else if (FStrEq(pkvd->szKeyName, "master"))
        {
                m_iszMaster = ALLOC_STRING(pkvd->szValue);
                pkvd->fHandled = TRUE;
        }
        else
                CBaseEntity::KeyValue( pkvd );
}

But I guess it would be more appropriate to work with keyvalue when you can.

Seta00 05-06-2010 11:16

Re: Automatic func_tanks in Counter Strike
 
This is awesome, good work. It's amazing how the CS modding capabilities are still growing after all these years.

capostrike93 05-06-2010 23:43

Re: Automatic func_tanks in Counter Strike
 
Quote:

Originally Posted by joropito (Post 1172462)
It was just a test the fakemeta alternative. It's just an example.



Only if I need :P

Btw, I think it's possible to set full rotation using key "yawrange".

ammm xD??

...

m_yawRange is num 41
set_pdata_float(id,41,360.0,4)

:wink:

http://wiki.amxmodx.org/CFuncTank_%28CS%29

Arkshine 05-07-2010 06:08

Re: Automatic func_tanks in Counter Strike
 
It's more safe to deal with keyvalues than offset since this one can change on update. So if you can, use keyvalues.

Also, if I'm right ( but I've seen some tutorials saying the same thing ), to have a full rotation you should write 180, 180 left + 180 right = 360. Like the Joropito's example : "yawrange 55" ; meaning the range is : 55 + 55 = 110.

joropito 05-07-2010 08:54

Re: Automatic func_tanks in Counter Strike
 
Quote:

Originally Posted by Arkshine (Post 1172489)
If you want to use the keyvalue, I guess you need to hook the spawn as pre

Why must be done at precache (in func_tank case)?

This should work (not tested).

PHP Code:

set_kvd(0KV_ClassName"func_tank")
set_kvd(0KV_KeyName"yawrange")
set_kvd(0KV_Value180)
set_kvd(0KV_fHandled0)
dllfunc(DLLFunc_KeyValueent0

In hlsdk I can see that at CFuncTank::KeyValue() every offset is updated with the new values.

Arkshine 05-07-2010 09:53

Re: Automatic func_tanks in Counter Strike
 
I have read somewhere after using DispatchKeyValue you must use DispatchSpawn but looking the HLSDK I don't find any reference to that, so I guess it should work right away. I'm going to try to see.

joropito 05-07-2010 10:29

Re: Automatic func_tanks in Counter Strike
 
Quote:

Originally Posted by Arkshine (Post 1173341)
I have read somewhere after using DispatchKeyValue you must use DispatchSpawn but looking the HLSDK I don't find any reference to that, so I guess it should work right away. I'm going to try to see.

Yeah, maybe that dispatch it's for some entities but for func_tank it seems to be quite different unless CFuncTank::KeyValue isn't related to DLLFunc_KeyValue.


All times are GMT -4. The time now is 23:17.

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