Senior Member
Join Date: Jul 2011
Location: Chile
|
12-17-2013
, 13:37
Re: [ZP][Tutorial] How to make our own custom sounds: Idle, Pain & Death
|
#2
|
@ K4rim
Test it.
PD: I can not compile, I get an error. It is because i don't occupy Zombie Plague 5.0
But it should work perfectly, because you occupy Zombie Plague 5.0
Anyway, i do not know if it will work on Zombie Plague 5.0
PHP Code:
/*================================================================================
--------------------------------------- -*- [ZP] Class Zombie: Brute Mother -*- ---------------------------------------
This plugin is part of Zombie Plague Mod and is distributed under the terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
================================================================================*/
#include <amxmodx> #include <cstrike> #include <fakemeta>
#if AMXX_VERSION_NUM < 180 #assert AMX Mod X v1.8.0 or later library required! #endif
#include <hamsandwich>
/*================================================================================ [Zombie Plague 5.0 Includes] =================================================================================*/
#include <cs_ham_bots_api> #include <zp50_class_zombie> #define LIBRARY_NEMESIS "zp50_class_nemesis" #include <zp50_class_nemesis> #define LIBRARY_AMMOPACKS "zp50_ammopacks" #include <zp50_ammopacks>
/*================================================================================ [Sound] // My Custom sound =================================================================================*/ #define ZM_PAIN 3 new pain_zm[ZM_PAIN][] = {"nst_player/f_bhit_flesh-1.wav", "nst_player/f_bhit_flesh-2.wav", "nst_player/f_bhit_flesh-3.wav" }
#define ZM_DEATH 3 new death_zm[ZM_DEATH][] = {"nst_player/f_die1.wav", "nst_player/f_die2.wav", "nst_player/f_die3.wav" }
#define ZM_IDLE 3 new idle_zm[ZM_IDLE][] = {"nst_zombie/zombi_female_laugh.wav", "nst_zombie/zombi_female_scream.wav", "nst_zombie/zombi_female_headup.wav" }
/*================================================================================ [Constants, Offsets, Macros] =================================================================================*/
// Plugin Version new const PLUGIN_VERSION[] = "1.1.0"
// Brute Mother new const zclass_name[] = { "Brute Mother Zombie" } new const zclass_info[] = { "=Balanced= Heal (hold +use)" } new const zclass_model[][] = { "zombie_source" } new const zclass_clawmodel[][] = { "models/zombie_plague/v_knife_zombie.mdl" } const zclass_health = 1800 const Float:zclass_speed = 0.75 const Float:zclass_gravity = 1.00 const Float:zclass_knockback = 1.00
/*================================================================================ [Global Variables] =================================================================================*/
// Player vars new g_bZombie[33] // whether player is zombie new g_bMother[33] // whether player is brute mother new g_bHealing[33] // whether player is healing new g_bInRange[33][33] // whether zombie is in range new Float:g_flMaxHealth[33] // zombie's max health new g_iHealCounter[33] // brute mother heal counter
// Game vars new g_iMotherIndex // index from the class new g_iMaxPlayers // max player counter
// Cvar pointers new cvar_Interval, cvar_Amount, cvar_Range, cvar_Counter
// Healing Color new g_iColor[3] = { 0 , 150 , 0 }
// Player stuff new g_bIsAlive[33] // whether player is alive new g_bIsBot[33] // whether player is bot
// Macro #define is_user_valid_alive(%1) (1 <= %1 <= g_iMaxPlayers && g_bIsAlive[%1])
// ZP 5.0 cvars new cvar_ammopack_to_money_ratio
/*================================================================================ [Precache and Init] =================================================================================*/
public plugin_precache() { register_plugin("[ZP] Class Zombie: Brute Mother", PLUGIN_VERSION, "schmurgel1983") new index g_iMotherIndex = zp_class_zombie_register(zclass_name, zclass_info, zclass_health, zclass_speed, zclass_gravity) zp_class_zombie_register_kb(g_iMotherIndex, zclass_knockback) for (index = 0; index < sizeof zclass_model; index++) zp_class_zombie_register_model(g_iMotherIndex, zclass_model[index]) for (index = 0; index < sizeof zclass_clawmodel; index++) zp_class_zombie_register_claw(g_iMotherIndex, zclass_clawmodel[index]) // Precache Sound new i; for (i = 0; i < ZM_DEATH; i++) precache_sound(death_zm[i]) for (i = 0; i < ZM_IDLE; i++) precache_sound(idle_zm[i]) for (i = 0; i < ZM_PAIN; i++) precache_sound(pain_zm[i]) }
public plugin_init() { // Event register_event("SendAudio", "event_end_round", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw") register_event("TextMsg", "event_end_round", "a", "2=#Game_Commencing", "2=#Game_will_restart_in") register_event("Damage","event_pain_zombie","be","2!0","3=0") RegisterHam(Ham_Spawn, "player", "fwd_PlayerSpawn_Post", 1) RegisterHamBots(Ham_Spawn, "fwd_PlayerSpawn_Post", 1) RegisterHam(Ham_Killed, "player", "fwd_PlayerKilled_Post", 1) RegisterHamBots(Ham_Killed, "fwd_PlayerKilled_Post", 1) // Forward register_forward(FM_PlayerPreThink, "fwd_PlayerPreThink") register_forward(FM_AddToFullPack, "fwd_AddToFullPack_Post", 1) register_forward( FM_EmitSound, "fw_EmitSound" ) cvar_Interval = register_cvar("zp_mother_interval", "0.2") cvar_Amount = register_cvar("zp_mother_amount", "10") cvar_Range = register_cvar("zp_mother_range", "128") cvar_Counter = register_cvar("zp_mother_counter", "200") register_cvar("Brute_Mother_version", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY) set_cvar_string("Brute_Mother_version", PLUGIN_VERSION) g_iMaxPlayers = get_maxplayers() }
public plugin_cfg() cvar_ammopack_to_money_ratio = get_cvar_pointer("zp_ammopack_to_money_ratio")
public client_putinserver(id) { set_cvars(id) if (is_user_bot(id)) g_bIsBot[id] = true; }
public client_disconnected(id) { set_cvars(id) g_bIsBot[id] = false }
public plugin_natives() { set_module_filter("module_filter") set_native_filter("native_filter") }
public module_filter(const module[]) { if (equal(module, LIBRARY_NEMESIS) || equal(module, LIBRARY_AMMOPACKS)) return PLUGIN_HANDLED; return PLUGIN_CONTINUE; }
public native_filter(const name[], index, trap) { if (!trap) return PLUGIN_HANDLED; return PLUGIN_CONTINUE; }
/*================================================================================ [Main Forwards] =================================================================================*/
public event_pain_zombie(id) { if (!is_user_connected(id) || !zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_iMotherIndex ) return PLUGIN_HANDLED if(is_user_connected(id)) { if (zp_get_user_zombie(id)) { if (zp_get_user_zombie_class(id) == g_iMotherIndex && !zp_get_user_nemesis( id )) { emit_sound(id, CHAN_VOICE, pain_zm[random_num(0, ZM_PAIN - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM) } } } return PLUGIN_HANDLED }
public event_end_round() { for (new id = 1; id <= g_iMaxPlayers; id++) set_cvars(id) }
public fw_EmitSound(id, channel, sample[]) { if (!is_user_connected(id) || !zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_iMotherIndex && !zp_get_user_nemesis( id )) return FMRES_IGNORED; if(sample[0] == 'p' && sample[1] == 'l'&& sample[7] == 'd' && !zp_get_user_nemesis( id )) { emit_sound(id, CHAN_VOICE, death_zm[random_num(0, ZM_DEATH - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM) return FMRES_SUPERCEDE } return FMRES_IGNORED; }
public fwd_PlayerSpawn_Post(id) { if (!is_user_alive(id) || !cs_get_user_team(id)) return g_bIsAlive[id] = true }
public fwd_PlayerKilled_Post(victim, attacker, gib) { g_bIsAlive[victim] = false set_cvars(victim) }
public fwd_PlayerPreThink(id) { if (!g_bMother[id] || !g_bIsAlive[id] || g_bIsBot[id]) return g_bHealing[id] = (pev(id, pev_button) & IN_USE) ? true : false; }
public fwd_AddToFullPack_Post(es_handle, e, ent, host, flags, player, pSet) { if (!player || !g_bZombie[host] || !g_bZombie[ent]) return FMRES_IGNORED if (g_bHealing[host] && g_bInRange[host][ent] || g_bHealing[ent]) { set_es(es_handle, ES_RenderFx, kRenderFxGlowShell) set_es(es_handle, ES_RenderColor, g_iColor) set_es(es_handle, ES_RenderAmt, 5) return FMRES_IGNORED } return FMRES_IGNORED }
public zp_fw_core_infect_post(id, attacker) { set_cvars(id) g_bZombie[id] = true pev(id, pev_health, g_flMaxHealth[id]) if (zp_class_zombie_get_current(id) == g_iMotherIndex) { if (LibraryExists(LIBRARY_NEMESIS, LibType_Library) && zp_class_nemesis_get(id)) return g_bMother[id] = true set_task(get_pcvar_float(cvar_Interval), "Mother_Heal", id, _, _, "b") zm_idle(id) if (g_bIsBot[id]) g_bHealing[id] = true } }
public zp_fw_core_cure_post(id) set_cvars(id)
// Support CSO In-Game Theme 5.4 or higher //forward zp_cso_theme_evohp_lvlup(iInfector, iEvoHp) public zp_cso_theme_evohp_lvlup(iInfector, iEvoHp) { new Float:health = float(iEvoHp) if (health > g_flMaxHealth[iInfector]) g_flMaxHealth[iInfector] = health }
/*================================================================================ [Other Functions] =================================================================================*/
set_cvars(id) { remove_task(id) g_bZombie[id] = g_bMother[id] = g_bHealing[id] = false g_iHealCounter[id] = 0 }
public Mother_Heal(id) { if (!g_bHealing[id]) return
static Float:originF[3] pev(id, pev_origin, originF)
for (new i = 1; i <= g_iMaxPlayers; i++) g_bInRange[id][i] = false static Float:range, Float:amount, victim range = get_pcvar_float(cvar_Range) amount = get_pcvar_float(cvar_Amount) victim = -1 while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, range)) != 0) { if (!is_user_valid_alive(victim) || !g_bZombie[victim] || victim == id) continue g_bInRange[id][victim] = true new Float:currentHP pev(victim, pev_health, currentHP) if (currentHP + amount < g_flMaxHealth[victim]) { set_pev(victim, pev_health, currentHP + amount) g_iHealCounter[id]++ } else set_pev(victim, pev_health, g_flMaxHealth[victim]) } while (g_iHealCounter[id] > get_pcvar_num(cvar_Counter)) { static origin[3] get_user_origin(id, origin) message_begin(MSG_PVS, SVC_TEMPENTITY, origin) write_byte(TE_IMPLOSION) // TE id write_coord(origin[0]) // x write_coord(origin[1]) // y write_coord(origin[2]) // z write_byte(128) // radius write_byte(20) // count write_byte(3) // duration message_end() if (LibraryExists(LIBRARY_AMMOPACKS, LibType_Library)) zp_ammopacks_set(id, zp_ammopacks_get(id) + 1) else if (cvar_ammopack_to_money_ratio) cs_set_user_money(id, cs_get_user_money(id) + get_pcvar_num(cvar_ammopack_to_money_ratio)) else cs_set_user_money(id, cs_get_user_money(id) + 160) g_iHealCounter[id] -= get_pcvar_num(cvar_Counter) } }
public zm_idle(id) { if (!is_user_connected(id) || !zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_iMotherIndex && !zp_get_user_nemesis( id )) return PLUGIN_HANDLED if (random_num(1, 35) == 5 && zp_get_user_zombie_class(id) == g_iMotherIndex && !zp_get_user_nemesis( id )) { if(is_user_alive(id) && zp_get_user_zombie(id)) emit_sound(id, CHAN_VOICE, idle_zm[random_num(0, ZM_IDLE -1)], 1.0, ATTN_NORM, 0, PITCH_NORM) } if(zp_get_user_zombie_class(id) == g_iMotherIndex) set_task(1.0,"zm_idle",id) return PLUGIN_HANDLED }
Last edited by Nax0ne; 12-17-2013 at 13:45.
|
|