Поиск Cluster Grenade

Сообщения
141
Реакции
55
Помог
2 раз(а)
Looking for a plugin equal to this, but with ability to set access flags and a price.
C++:
/*
    Plugin generated by AMXX-Studio
    
    Plugin: Pumpkin Grenade
    Creator: Chrescoe1    //Cluster code used from http://forum.zombielite.ru/index.php?/topic/81-clustergrenade/ by Alexander.3
    Version: 3.0
    
    Changelog:
    v1.0 - First released
    v2.0 - Little Fixed - Optimization
    v3.0 - Too many fixed from ZP - Little Optimization
    
    Visit to ZombieLite.ru
*/

#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <fakemeta_util>

#define PLUGIN "Pumpkin Grenade"
#define VERSION "3.0"
#define AUTHOR "Chrescoe1"

// #define ZombiePlague    //if you don't use ZombiePlague - delete this line!

#if defined ZombiePlague
#include <zombieplague>
#endif

//Resource
new const v_model_pumpkin[] =     "models/v_pumpkin.mdl"
new const p_model_pumpkin[] =     "models/p_pumpkin.mdl"
new const w_model_pumpkin[] =     "models/w_pumpkin.mdl"
new const cluster_models[] =    "models/w_pumpkinSmall3.mdl"
new const g_soundexpl[] =         "weapons/pump_exp.wav"
new const blast_sprite[] =     "sprites/shockwave.spr"
new const cluster_trail[] =    "sprites/laserbeam.spr"    
new const exp_sprite[] =         "sprites/pumpkin_exp.spr"

//Settings
const Float:expl_damage =  45.0 // Урон наносимый гранатой
const Float:expl_damage_ent = 60.0 // Урон наносимый ентити \ нпц
const Float:expl_radius =  240.0 // Радиус урона гранаты
const Float:cluster_damage = 13.0 // Урон наносимый осколками
const Float:cluster_damage_ent = 20.0 // Урон наносимый ентити \ нпц
const Float:cluster_radius = 140.0 // Радиус урона осколок

const cluster_num_min = 15 // Мин кол-во осколков
const cluster_num_max = 30 // Макс кол-во осколков
const Float:cluster_rad_min =  250.0 // Мин радиус разлета осколок
const Float:cluster_rad_max =  350.0 // Макс радиус разлета осколок
const Float:cluster_up_min =  350.0 // Мин взлёт осколков вверх
const Float:cluster_up_max =  450.0 // Макс взлёт осколков вверх

#define weapon_name "weapon_hegrenade"
#define Bomb_Classname "Pumpkin_Grenade"
#define Cluster_Classname "Pumpkin_ClusterBomb"
#define weaponlist_name "weapon_pumpkin"
#define weaponlist_original "weapon_hegrenade"


#if defined ZombiePlague
new g_itemid_pumpkin
#endif

new bool:g_has_pumpkin[32]
new g_sprRing,spriteexpl,g_Trail
new Msg_Weaponlist,Msg_ScreenShake,Msg_ScreenFade
public plugin_precache()
{
    precache_generic( "sprites/weapon_pumpkin.txt" )
    precache_generic( "sprites/640hud41.spr" )
    precache_generic( "sprites/640hud7.spr" )

    precache_sound( "weapons/pump_deploy.wav" )
    precache_sound( "weapons/pump_in.wav" )
    precache_sound( "weapons/pump_throw.wav" )
    
    precache_model(w_model_pumpkin)
    precache_model(v_model_pumpkin)
    precache_model(p_model_pumpkin)
    precache_model(cluster_models)
    precache_sound(g_soundexpl)
    
    spriteexpl    = precache_model(exp_sprite)
    g_Trail        = precache_model(cluster_trail)
    g_sprRing    = precache_model(blast_sprite)
}
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    Msg_Weaponlist = get_user_msgid("WeaponList")
    Msg_ScreenShake = get_user_msgid("ScreenShake")
    Msg_ScreenFade = get_user_msgid("ScreenFade")
    
    //Ham
    RegisterHam(Ham_Item_AddToPlayer, weapon_name, "Ham_AddToPlayer_Post", 1)
    RegisterHam(Ham_Item_Deploy, weapon_name, "Ham_Item_Deploy_Post", 1)
    
    //Fakemeta
    register_forward(FM_SetModel, "Fakemeta_SetModel")
    register_forward(FM_Touch, "Fakemeta_Touch")
    
    //Hook Weapon
    register_clcmd(weaponlist_name, "hook_weapon")
    
    #if defined ZombiePlague
        //Register item in ZP
        g_itemid_pumpkin = zp_register_extra_item("Pumpkin Grenade", 5, ZP_TEAM_HUMAN)
    #else
        //Get with chat command
        register_clcmd("say /get_pumpkin","zp_extra_item_selected")
    #endif
    // Add your code here...
}
public zp_extra_item_selected(id,itemid)
{
    #if defined ZombiePlague
    if(itemid!=g_itemid_pumpkin)return PLUGIN_HANDLED
    if(g_has_pumpkin[id])return ZP_PLUGIN_HANDLED
    #endif
    g_has_pumpkin[id]=true
    give_item(id, weapon_name)
    return PLUGIN_HANDLED
}
public hook_weapon(id){client_cmd(id,weaponlist_original);return PLUGIN_HANDLED;}

//Ham
public Ham_AddToPlayer_Post(ent, id)
{
    if(!pev_valid(ent))return HAM_IGNORED    
    //Update WeaponList
    message_begin(MSG_ONE_UNRELIABLE, Msg_Weaponlist, _, id)
    write_string(g_has_pumpkin[id]? weaponlist_name : weaponlist_original)
    write_byte(12)
    write_byte(1)
    write_byte(-1)
    write_byte(-1)
    write_byte(3)
    write_byte(1)
    write_byte(CSW_HEGRENADE)
    write_byte(24)
    message_end()            
    return HAM_HANDLED        
}
public Ham_Item_Deploy_Post(ent)
{
    if(!pev_valid(ent))return
    
    new id = get_pdata_cbase(ent, 41, 4)
    
    if (is_user_alive(id))
    if(g_has_pumpkin[id])
    {
        set_pev(id, pev_viewmodel2, v_model_pumpkin)
        set_pev(id, pev_weaponmodel2, p_model_pumpkin)
    }
}
//Fakemeta
public Fakemeta_SetModel(ent, const Model[])
{
    if(!pev_valid(ent))return FMRES_IGNORED
    if(equal(Model, "models/w_hegrenade.mdl"))    //If model HE Grenade
    {
        new id = pev(ent, pev_owner)
        if(g_has_pumpkin[id])    //if owner has bomb
        {
            Trail(ent,g_Trail,12,8,255,155,55,255)
            set_pev(ent, pev_classname, Bomb_Classname)    //Set classname    
            set_pev(ent, pev_dmgtime, 9999999.0)        //Block Explode
            engfunc(EngFunc_SetModel, ent, w_model_pumpkin)    //Change Model
            g_has_pumpkin[id]=false                //Remove bomb on player

            return FMRES_SUPERCEDE
        }
    }
    return FMRES_IGNORED    
}
public Fakemeta_Touch(ent, touch)
{
    if(!pev_valid(ent))return HAM_IGNORED
    
    new EntClassname[32],TouchClassname[32]
    pev(ent, pev_classname, EntClassname, sizeof(EntClassname))
    
    if(pev_valid(touch))
        pev(touch, pev_classname, TouchClassname, sizeof(TouchClassname))
    
    if(equal(EntClassname, Bomb_Classname))
    {
        if(pev_valid(touch))
        {
            if(equal(TouchClassname, Cluster_Classname))return HAM_SUPERCEDE
            if(equal(TouchClassname, Bomb_Classname))return HAM_SUPERCEDE
        }
        Pumpkin_Explode(ent)
        return HAM_SUPERCEDE
    }
    
    if(equal(EntClassname, Cluster_Classname))
    {
        if(pev_valid(touch))
        {
            if(equal(TouchClassname, Cluster_Classname))return HAM_SUPERCEDE
            if(equal(TouchClassname, Bomb_Classname))return HAM_SUPERCEDE
        }
        Cluster_Explode(ent)
        return HAM_SUPERCEDE
    }
    return HAM_IGNORED
}
//Public Func
public Pumpkin_Explode(ent)
{
    new Float:ExpOrigin[3],owner= pev(ent, pev_owner)
    pev(ent,pev_origin,ExpOrigin)
        
    engfunc(EngFunc_EmitSound, ent, CHAN_WEAPON,g_soundexpl, 1.0, ATTN_NORM, 0, PITCH_NORM)
    
    //Explode    
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ExpOrigin, 0)
    write_byte(TE_EXPLOSION)
    engfunc(EngFunc_WriteCoord, ExpOrigin[0])
    engfunc(EngFunc_WriteCoord, ExpOrigin[1])
    engfunc(EngFunc_WriteCoord, ExpOrigin[2]+50.0)
    write_short(spriteexpl)
    write_byte(30)
    write_byte(10)
    write_byte(0)
    message_end()
    
    ExplodeDecals(ExpOrigin)
    Light(ExpOrigin,45,250,150,50,15)    
    Ring(ExpOrigin,20,80)
    Ring(ExpOrigin,40,60)
    Ring(ExpOrigin,60,40)
    Ring(ExpOrigin,80,20)
    
    static victim = -1
    while((victim = engfunc(EngFunc_FindEntityInSphere, victim, ExpOrigin, expl_radius)) != 0)
    {
        if(victim>0&&pev(victim, pev_takedamage)!=DAMAGE_NO&&pev(victim, pev_solid)!=SOLID_NOT)
        {    
            if(is_user_connected(victim))
            {
                #if defined ZombiePlague
                if(zp_get_user_zombie(victim))
                #else
                if(get_user_team(victim)!=get_user_team(owner))
                #endif
                    ExecuteHamB(Ham_TakeDamage, victim, ent, owner,expl_damage , DMG_NERVEGAS),
                    ScreenFadeAndShake(victim)
            }
            else ExecuteHamB(Ham_TakeDamage, victim, ent, owner,expl_damage_ent , DMG_NERVEGAS)
        }
    }
    
    //Make Cluster Grenade
    //Code by Alexander.3 - http://forum.zombielite.ru/index.php?/topic/81-clustergrenade/
    for (new i=0;i<random_num(cluster_num_min,cluster_num_max); i++)
    {    
        new bomb            
        bomb = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))    // Создаем энтити
        engfunc(EngFunc_SetOrigin, bomb, ExpOrigin)    // Устанавливаем координаты для созданной энтити
        engfunc(EngFunc_SetModel, bomb, cluster_models)    // Устанавливаем модельку
        set_pev(bomb, pev_solid, SOLID_TRIGGER)        // Солидность ставим на TRGGGER, что бы не взрывались раньше нужного времени
        set_pev(bomb, pev_classname, Cluster_Classname)    // Устанавливаем ClassName для проверки в Touch эвенте
        set_pev(bomb, pev_movetype, MOVETYPE_TOSS)    // Устанавливаем MOVETYPE_TOSS
        set_pev(bomb, pev_owner, pev(ent, pev_owner))    // Устанавливаем индекс игрока для энтити
        Util_PlayAnimation(bomb,1,0.6)    //Play Anim
        // Работа с разбросом, будет рандомная в пределе лимита.
        new Float:velocity[3]
        velocity[0] = random_float(-random_float(cluster_rad_min,cluster_rad_max), random_float(cluster_rad_min,cluster_rad_max))    
        velocity[1] = random_float(-random_float(cluster_rad_min,cluster_rad_max), random_float(cluster_rad_min,cluster_rad_max))    
        velocity[2] = random_float(-random_float(cluster_rad_min,cluster_rad_max), random_float(cluster_rad_min,cluster_rad_max))+ random_float(cluster_up_min,cluster_up_max)
        
        // Устанавливаем силу разлета осколок
        set_pev(bomb, pev_velocity, velocity)
        
        new Float: Angles[3]
        Angles[1]=random_float(0.0,360.0)
        set_pev(bomb,pev_angles,Angles)
        
        Trail(bomb,g_Trail,4,4,255,155,55,255)
    }
    //And remove pumkin...
    if(pev_valid(ent))engfunc(EngFunc_RemoveEntity, ent)
}
public Cluster_Explode(ent)
{
    if (!pev_valid( ent ))return
    
    new Float:ExpOrigin[3],victim = -1
    
    pev(ent, pev_origin, ExpOrigin)
    
    Ring(ExpOrigin,20,40)
    Ring(ExpOrigin,40,20)
    Light(ExpOrigin,15,250,150,50,15)
    
    //Explode
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ExpOrigin, 0)
    write_byte(TE_EXPLOSION)
    engfunc(EngFunc_WriteCoord, ExpOrigin[0])
    engfunc(EngFunc_WriteCoord, ExpOrigin[1])
    engfunc(EngFunc_WriteCoord, ExpOrigin[2] + 15.0)
    write_short(spriteexpl)
    write_byte(5)
    write_byte(10)
    write_byte(0)
    message_end()
    
    while((victim = engfunc(EngFunc_FindEntityInSphere, victim, ExpOrigin, cluster_radius)) != 0)
    {
        if(victim>0&&pev(victim, pev_takedamage)!=DAMAGE_NO&&pev(victim, pev_solid)!=SOLID_NOT)
        {    
            if(is_user_connected(victim))
            {
                #if defined ZombiePlague
                if(zp_get_user_zombie(victim))
                #else
                if(get_user_team(victim)!=get_user_team(pev(ent,pev_owner)))
                #endif
                    ExecuteHamB(Ham_TakeDamage, victim, ent, pev(ent,pev_owner),cluster_damage , DMG_NERVEGAS),
                    ScreenFadeAndShake(victim)
            }
            else ExecuteHamB(Ham_TakeDamage, victim, ent, pev(ent,pev_owner),cluster_damage_ent , DMG_NERVEGAS)
        }
    }
    if(pev_valid(ent))engfunc(EngFunc_RemoveEntity, ent)    //and remove entity
}
//Stocks
stock Trail(ent,sprite,life,size,R,G,B,F)
{
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(TE_BEAMFOLLOW)
        write_short(ent)
        write_short(sprite)
        write_byte(life)
        write_byte(size)
        write_byte(R)
        write_byte(G)
        write_byte(B)
        write_byte(F)
        message_end()
}
stock ExplodeDecals(Float:Origin[3])
{
    engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, Origin, 0)
    write_byte(TE_WORLDDECAL)
    engfunc(EngFunc_WriteCoord, Origin[0])
    engfunc(EngFunc_WriteCoord, Origin[1])
    engfunc(EngFunc_WriteCoord, Origin[2])
    write_byte(engfunc(EngFunc_DecalIndex,"{scorch3"))
    message_end()
}

stock Light(Float:Origin[3],RAD,R,G,B,Life)
{
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(TE_DLIGHT)
    engfunc(EngFunc_WriteCoord, Origin[0])
    engfunc(EngFunc_WriteCoord, Origin[1])
    engfunc(EngFunc_WriteCoord, Origin[2])
    write_byte(RAD)    //Radius
    write_byte(R)    // r
    write_byte(G)    // g
    write_byte(B)    // b
    write_byte(Life)    //Life
    write_byte(10)
    message_end() 
}
stock Ring(Float:flOrigin[3],Size,width)
{
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flOrigin, 0)
    write_byte(TE_BEAMCYLINDER)            // TE id
    engfunc(EngFunc_WriteCoord, flOrigin[0])        // x
    engfunc(EngFunc_WriteCoord, flOrigin[1])        // y
    engfunc(EngFunc_WriteCoord, flOrigin[2]-20.0)        // z
    engfunc(EngFunc_WriteCoord, flOrigin[0])        // x axis
    engfunc(EngFunc_WriteCoord, flOrigin[1])        // y axis
    engfunc(EngFunc_WriteCoord, flOrigin[2] + Size)    // z axis
    write_short(g_sprRing)     // sprite
    write_byte(0)         // startframe
    write_byte(0)         // framerate
    write_byte(10)         // life
    write_byte(width)     // width
    write_byte(0)         // noise
    write_byte(255)         // red
    write_byte(155)         // green
    write_byte(55)         // blue
    write_byte(255)         // brightness
    write_byte(0)         // speed
    message_end()
}
stock ScreenFadeAndShake(victim)
{
    // ScreenShake        
    message_begin(MSG_ONE_UNRELIABLE, Msg_ScreenShake, {0,0,0}, victim)
    write_short(1<<14)
    write_short((1<<12) * 8)
    write_short((2<<12) * 7)
    message_end()
            
    //ScreenFade
    message_begin(MSG_ONE_UNRELIABLE, Msg_ScreenFade, _, victim)
    write_short(6<<8)
    write_short(6<<10)
    write_short(1<<1)
    write_byte(255)
    write_byte(155)
    write_byte(55)
    write_byte(255)
    message_end()    
}
stock Util_PlayAnimation(index, sequence, Float: framerate = 1.0)
{
      set_pev(index, pev_animtime, get_gametime())
      set_pev(index, pev_framerate,  framerate)
      set_pev(index, pev_frame, 0.0)
      set_pev(index, pev_sequence, sequence)
}
I have another plugin that is not using hamsandwich where I could pick the needed code. But this one is using ham, so I cannot understand.
Thanks in advance.
 
Последнее редактирование:

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу