Welcome Soldier.



[TTT] Item: Granada de Choque

GabsHp Sin conexión
Lord Gabs
#1
Wenas tardes panas. Acabo de terminar este pequeño aporte para el mod [TTT]

Item: [TTT] Item: Granada de Choque

Team: Traidores

Descripción: Es un item basado en la Granada de Choque del juego Fortnite. Es una granada con knockback (empuje), que avienta hacia todas direcciones a los jugadores que estén dentro de su rango de explosión. Osea los saca volando hasta la chingada de lejos. 
Tal y como en el juego original de Fortnite, la granada te lanza, mas al caer no te produce daño por caída, por lo tanto no habría muertes estúpidamente rotas dentro del juego. 
Este item puede funcionar para trolear, así como puede ser de utilidad para los traidores al momento de intentar escapar.

*Se aceptan sugerencias a cambios*

Creditos:
  • Metrikcz: Stock del Blast
  • [ZE] Knockback Nade: Parte del código (sin autor)

Video demostrativo: 


Archivos / Recursos: Link Mega

Código:
[spoiler]
Código PHP:
<?php 
/* Sublime AMXX Editor v3.0.0-beta */

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <fun>
#include <ttt>


#define RADIO 400.0
#define pev_nade_type   pev_flTimeStepSound
#define NADE_TYPE_KB    26517
#define make_explode(%1) entity_set_float(%1, EV_FL_dmgtime, 0.0)

//NADEMODELS
new const g_PlayerModel [ ] = { "models/ttt/kb_nade/p_nade.mdl"};
new const
g_ViewModel [ ] = { "models/ttt/kb_nade/v_nade.mdl"};
new const
g_WorldModel [ ] = { "models/ttt/kb_nade/w_nade.mdl" };
new const
grenade_color[] = { 51, 51, 255 };
//NADESOUNDS
new const g_SoundGrenadeBuy [ ] [ ] = { "items/gunpickup2.wav" };
new const
g_SoundAmmoPurchase [ ] [ ] = { "items/9mmclip1.wav" };
new const
g_SoundBombExplode [ ] [ ] = { "ttt/kb_nade/nade_explode.wav" };

new
g_iNade;
new
g_iExplo;
new
g_GlowSpr, g_exploSpr;
new
g_MaxPlayers;
new
g_msgScreenFade;
new
g_isUserHasNade[33];
new
g_iCurrentWeapon[33];
new
bool:ignoreFalling[33];
//CVARS
new cvar_speed;
new
cvar_precio;

public
plugin_precache()
{
precache_model ( g_PlayerModel );
precache_model ( g_ViewModel );
precache_model ( g_WorldModel );
//precache_model("models/rpgrocket.mdl");
new i;
for (
i = 0; i < sizeof g_SoundGrenadeBuy; i++ )
{
precache_sound ( g_SoundGrenadeBuy [ i ] );
}
for (
i = 0; i < sizeof g_SoundAmmoPurchase; i++ )
{
precache_sound ( g_SoundAmmoPurchase [ i ] );
}
for (
i = 0; i < sizeof g_SoundBombExplode; i++ )
{
precache_sound ( g_SoundBombExplode [ i ] );
}
}

public
plugin_init()
{
register_plugin("[TTT] Item: Granada de Choque", "1.0", "GabsHp");
//register_clcmd("say /buynade", "buy_nade");
//register_clcmd("say /tercera", "tercerapersona");
//register_clcmd("say /primera", "primerapersona");
register_event("CurWeapon", "EV_CurWeapon", "be", "1=1");
register_event("HLTV", "EV_NewRound", "a", "1=0", "2=0");
register_event("DeathMsg", "EV_DeathMsg", "a");
register_forward(FM_SetModel, "fw_SetModel");
RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade");
RegisterHam(Ham_Touch, "grenade", "fw_touch");
RegisterHam( Ham_TakeDamage, "player", "Player_TakeDamage" );
g_MaxPlayers = get_maxplayers();
g_msgScreenFade = get_user_msgid( "ScreenFade" );
cvar_speed = register_cvar ( "ttt_kbnade_knockback", "800" );
cvar_precio = my_register_cvar("ttt_kbnade_precio", "2", "Precio de la Granada de Choque");
}

public
ttt_plugin_cfg()
{
    g_iNade = ttt_buymenu_add( "Granada de Choque", get_pcvar_num(cvar_precio), PC_TRAITOR);
    ttt_add_exception( g_iNade );
}

public
ttt_gamemode(gamemode)
{
   
   
if(gamemode == GAME_ENDED || gamemode == GAME_RESTARTING || gamemode == GAME_PREPARING)
    {   
       
for( new i = 1; i <= g_MaxPlayers; i++ )
        {
            g_isUserHasNade[i] = 0;
            if(ignoreFalling[i]){
            ignoreFalling[i]=false;
            }
        }
    }
}

public
ttt_item_selected(id, item, name[], price)
{
if(
g_iNade == item)
{
if(
g_isUserHasNade[id]>0){
client_print_color(id, print_team_default, "%s ^1Ya tienes equipada una ^4Granada de Choque", TTT_TAG);
return
PLUGIN_HANDLED;
}
g_isUserHasNade[id]++;
give_item ( id, "weapon_smokegrenade");
client_print_color(id, print_team_default, "%s ^1Has comprado una ^4Granada de Choque^1!", TTT_TAG);
}
return
PLUGIN_CONTINUE;
}
/*
public buy_nade(id){
if(g_isUserHasNade[id]>0){
client_print(id, print_center, "Ya tienes una granada de choque!");
return PLUGIN_HANDLED;
}
give_item ( id, "weapon_smokegrenade" );
emit_sound ( id, CHAN_ITEM, g_SoundGrenadeBuy[random_num(0, sizeof g_SoundGrenadeBuy-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
client_print(id, print_chat, "Has comprado una granada de choque!");
g_isUserHasNade[id]++;
return PLUGIN_HANDLED;
}
*/
public EV_CurWeapon(id)
{
    if (!is_user_alive(id))
        return PLUGIN_CONTINUE;
   
    g_iCurrentWeapon
[id] = read_data (2);
   
   
if (g_isUserHasNade[id]>0 && g_iCurrentWeapon[id] == CSW_SMOKEGRENADE )
    {
        set_pev (id, pev_viewmodel2, g_ViewModel);
        set_pev (id, pev_weaponmodel2, g_WorldModel);
        set_pev (id, pev_weaponmodel, engfunc(EngFunc_AllocString, g_PlayerModel));
    }
   
   
return PLUGIN_CONTINUE;
}

public
EV_NewRound()
{
    arrayset (g_isUserHasNade, 0, 33);
    arrayset (ignoreFalling, false, 33);
}

public
EV_DeathMsg()
{
    new iVictim = read_data (2);
   
   
if ( !is_user_connected (iVictim))
        return;
   
    g_isUserHasNade
[iVictim] = 0;
    ignoreFalling[iVictim] = false;
}

public
client_connect (id)
{
    g_isUserHasNade[id] = 0;
    ignoreFalling[id]=false;
}

public
fw_SetModel ( Entity, const Model [ ] )
{
if (
Entity < 0 )
return
FMRES_IGNORED;
if (
pev ( Entity, pev_dmgtime ) == 0.0 )
return
FMRES_IGNORED;
   
new iOwner = entity_get_edict ( Entity, EV_ENT_owner );   
   
if(g_isUserHasNade[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
{
set_pev(Entity, pev_nade_type, 0);
set_pev(Entity, pev_nade_type, NADE_TYPE_KB);
       
g_isUserHasNade
[iOwner]--;
       
entity_set_model
( Entity, g_WorldModel );
return
FMRES_SUPERCEDE;
}
return
FMRES_IGNORED;
}

public
fw_ThinkGrenade (Entity)
{
    if(!pev_valid(Entity))
        return HAM_IGNORED;
   
   
static Float:dmg_time;
    pev(Entity, pev_dmgtime, dmg_time);
   
   
if (dmg_time > get_gametime())
        return HAM_IGNORED;
   
   
if(pev(Entity, pev_nade_type) == NADE_TYPE_KB)
    {
    jumping_explode(Entity);
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public
fw_touch(toucher, touched)
{
if(!(
pev(toucher, pev_nade_type) == NADE_TYPE_KB)) return HAM_IGNORED;
if (
is_solid(touched))
{
make_explode(toucher);
entity_set_float(toucher, EV_FL_nextthink, get_gametime() + 0.3);
entity_set_int(toucher, EV_INT_flags, entity_get_int(toucher, EV_INT_flags) | FL_ONGROUND);
return
HAM_HANDLED;
}
return
HAM_IGNORED;
}

public
jumping_explode (Entity)
{
if(
Entity < 0)
return;
   
static Float:flOrigin[3];
pev(Entity, pev_origin, flOrigin);
   
engfunc
(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flOrigin, 0);
write_byte(TE_SPRITE) ;
engfunc(EngFunc_WriteCoord, flOrigin [ 0 ]);
engfunc(EngFunc_WriteCoord, flOrigin [ 1 ]);
engfunc(EngFunc_WriteCoord, flOrigin [ 2 ] + 45.0);
write_short (g_iExplo);
write_byte (35);
write_byte (186);
message_end();
new
iOwner = entity_get_edict ( Entity, EV_ENT_owner );
emit_sound ( Entity, CHAN_WEAPON, g_SoundBombExplode[random_num(0, sizeof g_SoundBombExplode-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
create_blast(flOrigin, grenade_color[0], grenade_color[1], grenade_color[2]);
for ( new
i = 1; i < g_MaxPlayers; i++ )
{
if ( !
is_user_alive  ( i ) )
            continue;
      

       
       
// Debug!
        //client_print ( iOwner, print_chat, "Owner of Smoke Grenade!" )   
       
new Float:flVictimOrigin [ 3 ];
pev ( i, pev_origin, flVictimOrigin );
       
new Float:flDistance = get_distance_f ( flOrigin, flVictimOrigin );
       
if ( flDistance <= RADIO )
        {
message_begin(i ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_msgScreenFade, _, i);
write_short( 1 * 4096 );
write_short( 1 * 4096 );
write_short( 0x0000 );
write_byte(random_num(0, 0));
write_byte(random_num(0, 128));
write_byte(random_num(0, 255));
write_byte(120);
message_end( );
static
Float:flSpeed;
flSpeed = get_pcvar_float ( cvar_speed );
           
static Float:flNewSpeed;
flNewSpeed = flSpeed * ( 1.0 - ( flDistance / RADIO ) );
           
static Float:flVelocity [ 3 ];
get_speed_vector ( flOrigin, flVictimOrigin, flNewSpeed, flVelocity );
set_pev( i, pev_velocity,flVelocity );
set_pev( i, pev_gravity, 0.5);
ignoreFalling[i]=true;
set_task(Float:1.0, "reset_gravity", i);
set_task(Float:4.0, "reset_Fall", i);
        }
    }
   
engfunc
( EngFunc_RemoveEntity, Entity );
}
       

public reset_gravity(id)
{
set_pev(id, pev_gravity, 1.0);
}
public
reset_Fall(id)
{
ignoreFalling[id]=false;
}
public
Player_TakeDamage( victim, inflictor, attacker, Float:damage, damagebits )
{
if(
damagebits==DMG_FALL && ignoreFalling[victim])
{
SetHamParamFloat(4, Float:0.0);
reset_Fall(victim);
return
HAM_HANDLED;
}
return
HAM_IGNORED;
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
new_velocity[0] = origin2[0] - origin1[0];
new_velocity[1] = origin2[1] - origin1[1];
new_velocity[2] = origin2[2] - origin1[2];
new
Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]));
new_velocity[0] *= num;
new_velocity[1] *= num;
new_velocity[2] *= num;
return
1;
}


stock create_blast(const Float:originF[3], red=255, green=255, blue=255)
{
// Les start!
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0);
write_byte(TE_SPRITETRAIL);
engfunc(EngFunc_WriteCoord, originF[0]); // x
engfunc(EngFunc_WriteCoord, originF[1]); // y
engfunc(EngFunc_WriteCoord, originF[2]); // z
engfunc(EngFunc_WriteCoord, originF[0]); // x velocity
engfunc(EngFunc_WriteCoord, originF[1]); // y velocity
engfunc(EngFunc_WriteCoord, originF[2]); // z velocity
write_short(g_GlowSpr); // sprite index
write_byte(35); // sprite count
write_byte(5); // life
write_byte(1); // size
write_byte(60); // velocity
write_byte(60); // velocity
message_end();

// Light!
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0);
write_byte(TE_DLIGHT); // TE id
engfunc(EngFunc_WriteCoord, originF[0]); // x
engfunc(EngFunc_WriteCoord, originF[1]); // y
engfunc(EngFunc_WriteCoord, originF[2]); // z
write_byte(30); // radius
write_byte(red); // red
write_byte(green); // green
write_byte(blue); // blue
write_byte(20); // life
write_byte(20); // decay rate
message_end();

// Smallest ring
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0);
write_byte(TE_BEAMCYLINDER); // TE id
engfunc(EngFunc_WriteCoord, originF[0]); // x
engfunc(EngFunc_WriteCoord, originF[1]); // y
engfunc(EngFunc_WriteCoord, originF[2]); // z
engfunc(EngFunc_WriteCoord, originF[0]); // x axis
engfunc(EngFunc_WriteCoord, originF[1]); // y axis
engfunc(EngFunc_WriteCoord, originF[2]+385.0); // z axis
write_short(g_exploSpr); // sprite
write_byte(0); // startframe
write_byte(0); // framerate
write_byte(4); // life
write_byte(60); // width
write_byte(0); // noise
write_byte(red); // red
write_byte(green); // green
write_byte(blue); // blue
write_byte(200); // brightness
write_byte(0); // speed
message_end();

// Medium ring
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0);
write_byte(TE_BEAMCYLINDER); // TE id
engfunc(EngFunc_WriteCoord, originF[0]); // x
engfunc(EngFunc_WriteCoord, originF[1]); // y
engfunc(EngFunc_WriteCoord, originF[2]); // z
engfunc(EngFunc_WriteCoord, originF[0]); // x axis
engfunc(EngFunc_WriteCoord, originF[1]); // y axis
engfunc(EngFunc_WriteCoord, originF[2]+470.0); // z axis
write_short(g_exploSpr); // sprite
write_byte(0); // startframe
write_byte(0); // framerate
write_byte(4); // life
write_byte(60); // width
write_byte(0); // noise
write_byte(red); // red
write_byte(green); // green
write_byte(blue); // blue
write_byte(200); // brightness
write_byte(0); // speed
message_end();

// Largest ring
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0);
write_byte(TE_BEAMCYLINDER); // TE id
engfunc(EngFunc_WriteCoord, originF[0]); // x
engfunc(EngFunc_WriteCoord, originF[1]);// y
engfunc(EngFunc_WriteCoord, originF[2]); // z
engfunc(EngFunc_WriteCoord, originF[0]); // x axis
engfunc(EngFunc_WriteCoord, originF[1]); // y axis
engfunc(EngFunc_WriteCoord, originF[2]+555.0); // z axis
write_short(g_exploSpr); // sprite
write_byte(0); // startframe
write_byte(0); // framerate
write_byte(4); // life
write_byte(60); // width
write_byte(0); // noise
write_byte(red); // red
write_byte(green); // green
write_byte(blue); // blue
write_byte(200); // brightness
write_byte(0); // speed
message_end();
}

public
bool:is_solid(ent)
{
// Here we account for ent = 0, where 0 means it's part of the map (and therefore is solid)
return ( ent ? ( (entity_get_int(ent, EV_INT_solid) > SOLID_TRIGGER) ? true : false ) : true );
}
/*
public tercerapersona(id)
{
set_view(id, CAMERA_3RDPERSON);
return PLUGIN_HANDLED;
}
public primerapersona(id)
{
set_view(id, CAMERA_NONE);
return PLUGIN_HANDLED;
}
*/
[/spoiler]

 @"mxemexico" @"totopizza"
[+] 3 users say Thank You to GabsHp for this post
Responder



Mensajes en este tema
[TTT] Item: Granada de Choque - por GabsHp - 07-29-2020, 09:23 AM
RE: [TTT] Item: Granada de Choque - por Legend - 07-29-2020, 12:34 PM
RE: [TTT] Item: Granada de Choque - por GabsHp - 07-29-2020, 08:26 PM
RE: [TTT] Item: Granada de Choque - por Alan# - 07-29-2020, 01:11 PM
RE: [TTT] Item: Granada de Choque - por GabsHp - 07-29-2020, 06:43 PM
RE: [TTT] Item: Granada de Choque - por D O N K A N. - 07-29-2020, 11:33 PM



Usuarios navegando en este tema:
1 invitado(s)



Sobre M X E M E X I C O

Comunidad MxE © 2020 - La mejorar comunidad de Counter Strike 1.6 .