Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <fun>
- #include <hamsandwich>
- #include <fakemeta_util>
- #include <cstrike>
- #define PLUGIN "Pumpkin Grenade"
- #define VERSION "3.0"
- #define AUTHOR "Chrescoe1"
- //Resource
- new const v_model_pumpkin[] = "models/Top/JB/Days/v_pumpkin.mdl"
- new const p_model_pumpkin[] = "models/Top/JB/Days/p_pumpkin.mdl"
- new const w_model_pumpkin[] = "models/Top/JB/Days/w_pumpkin.mdl"
- new const cluster_models[] = "models/Top/JB/Days/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 = 70.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"
- native is_day();
- native get_running_day_pumpkin();
- native is_lr_active();
- native is_user_lr( index );
- 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_deploy1.wav" )
- precache_sound( "weapons/pump_in1.wav" )
- precache_sound( "weapons/pump_throw1.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")
- register_logevent( "evRoundStart", 2, "1=Round_Start" );
- }
- public evRoundStart()
- {
- for( new i = 0; i < get_maxplayers(); i++ )
- {
- if( is_user_connected( i ) )
- remove_pumpkin( i );
- }
- }
- public plugin_natives()
- {
- register_native( "give_pumpkin__", "_give_pumpkin" );
- register_native( "remove_pumpkin__", "_remove_pumpkin" );
- }
- public _give_pumpkin( plugin, params )
- {
- new client = get_param( 1 );
- if( is_day() && get_running_day_pumpkin() || is_lr_active() && is_user_lr( client ) )
- give_user_pumpkin( client )
- }
- public _remove_pumpkin( plugin, params )
- {
- new client = get_param( 1 );
- remove_pumpkin( client );
- }
- public remove_pumpkin( id )
- g_has_pumpkin[ id ] = false;
- public give_user_pumpkin( id )
- {
- if( g_has_pumpkin[ id ] )
- return PLUGIN_HANDLED;
- g_has_pumpkin[ id ]= true
- give_item( id, "weapon_hegrenade" )
- cs_set_user_bpammo( id, CSW_HEGRENADE, 9999 );
- 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] )
- {
- if( is_day() && get_running_day_pumpkin())
- {
- 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;
- new id = pev( ent, pev_owner )
- if( is_day() && !get_running_day_pumpkin() )
- return FMRES_IGNORED;
- if(equal(Model, "models/w_hegrenade.mdl") ) //If model HE Grenade
- {
- 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
- return FMRES_SUPERCEDE
- }
- }
- return FMRES_IGNORED
- }
- public Fakemeta_Touch(ent, touch)
- {
- if(!pev_valid(ent) )
- return HAM_IGNORED;
- if( is_day() && !get_running_day_pumpkin() )
- 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))
- {
- 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)
- }
- if( pev_valid( ent ) )
- engfunc(EngFunc_RemoveEntity, ent)
- }
- public Cluster_Explode(ent)
- {
- if (!pev_valid( ent ) )
- return;
- new Float:ExpOrigin[3],victim = -1
- new owner = pev( ent, pev_owner );
- if( is_day() && !get_running_day_pumpkin() )
- return;
- 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))
- {
- 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 )
- }
- //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)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement