Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <fakemeta>
- #include <hamsandwich>
- #include <xs>
- #include <engine>
- #include <nst_player>
- #include <nst_wpn>
- #define PLUGIN "NST Zombie Mod3"
- #define VERSION "1.0"
- #define AUTHOR "NST"
- // Setting File Name
- new const SETTING_FILE[] = "nst_zombie_mod3.ini"
- new const CVAR_FILE[] = "nst_zombie_mod3.cfg"
- new const LANG_FILE[] = "nst_zombie.txt"
- new const ZOMBIE_MOD = 1
- // Limiters for stuff not worth making dynamic arrays out of (increase if needed)
- const MAX_STATS_SAVED = 64
- const MAX_SUPPLYBOX = 100
- const MAX_SPAWNS = 128
- new const SPAWNS_URL[] = "%s/csdm/%s.spawns.cfg"
- new const SPAWNS_BOX_URL[] = "%s/nstzb/%s.supplybox_spawns.cfg"
- // Cvar
- new g_maxplayers, g_freezetime, g_endround, g_newround, g_fwSpawn, g_score_human, g_score_zombie, g_zombie_count, g_startcount, g_rount_count
- new cvar_delay, cvar_wait_time, cvar_glowshell_time, cvar_lighting, cvar_thunder, cvar_randspawn, cvar_remove_weapons_newround,
- cvar_time_show_spr, cvar_damage_nade, cvar_damage_grenade, cvar_time_attack_zombie, cvar_nvg_zombie_color[3], cvar_nvg_zombie_give, cvar_nvg_zombie_alpha, cvar_nvg_zombie_size,
- cvar_bot_uclip, cvar_recoil, cvar_level_damage, cvar_zombie_weak, cvar_zombie_flash, cvar_zombie_weak_dmg, cvar_zombie_weak_color[3],
- cvar_drop_weapons_infected, cvar_icon_deplay, cvar_icon, cvar_icon_light, cvar_icon_size, cvar_level_deplay
- // available spawn points counter
- new g_spawnCount, g_spawnCount2
- new Float:g_spawns[MAX_SPAWNS][3], Float:g_spawns2[MAX_SPAWNS][3] // spawn points data
- new g_spawnCount_box, g_spawnCount2_box
- new Float:g_spawns_box[MAX_SPAWNS][3], Float:g_spawns2_box[MAX_SPAWNS][3] // spawn points data
- // natives
- new g_fwUserInfected, g_fwDummyResult, g_fwUserDamage
- // Knock back
- new cvar_knockback, cvar_knockbackdamage, cvar_knockbackpower, cvar_knockbackzvel,
- Float:kb_weapon_power[31] = {-1.0, ... }
- // Player
- new g_level[33], g_zombie[33], g_hero[33], g_evolution[33], g_dmg_attack[33], g_start_health[33], g_star_armor[33],
- g_buyammo[33], g_restore_health[33], g_team[33], g_respawning[33], g_zombieclass[33], g_zombie_die[33],
- g_victim_time_attack[33], g_victim_damage[33], g_nvg[33], g_supplybox_num, g_supplybox_wait[33], g_zombie_weak[33],
- g_level_effect[33], Float:g_icon_delay[33], Float:g_level_delay[33]
- // Msg
- new g_msgBarTime, g_msgDeathMsg, g_msgScoreAttrib, g_msgStatusIcon, g_msgScoreInfo, g_HudMsg_Health, g_HudMsg_Power,
- g_msgScenario, g_msgDamage, g_HudMsg_ScoreMatch, g_msgHostagePos, g_msgHostageK, g_msgFlashBat, g_msgNVGToggle, g_msgHudTextArgs,
- g_msgWeapPickup, g_msgHealth, g_msgAmmoPickup, g_msgTextMsg, g_msgSendAudio, g_msgTeamScore, g_msgScreenFade, g_msgClCorpse
- // Customization vars
- new Array:lights_thunder, g_lights_i, g_lights_cycle[64], g_lights_cycle_len, Array:sound_thunder, id_sprites_levelup,
- g_ambience_rain, g_ambience_snow, g_ambience_fog, g_fog_color[12], g_fog_density[10], g_sky_enable, sprites_effects_levelup[64],
- Array:g_sky_names, Array:g_objective_ents, Array:weapons_pri, Array:weapons_pri_name, sound_zombie_count[64], g_blockbuy,
- Array:weapons_sec, Array:weapons_sec_name, Array:weapons_nade, Array:sound_zombie_start, Array:supplybox_item, supplybox_count,
- supplybox_ent[MAX_SUPPLYBOX], restore_health_spr[64], restore_health_idspr, Array:sound_zombie_attack,
- zombie_respawn_spr[64], zombie_respawn_idspr, Array:hero_weapons, sound_win_zombie[64], sound_win_human[64], Array:sound_zombie_hitwall, Array:sound_zombie_swing,
- Array:supplybox_models, Array:sound_human_death, Array:sound_female_death, Array:sound_zombie_coming, Array:sound_zombie_comeback, sound_levelup[64]
- // class zombie var
- new class_count, Array:zombie_name, Array:zombie_gravity, Array:zombie_speed, Array:zombie_knockback, Array:zombie_modelindex,
- Array:zombie_sound_death1, Array:zombie_sound_death2, Array:zombie_sound_hurt1, Array:zombie_sound_hurt2, Array:zombie_wpnmodel,
- Array:zombie_modelindex_host, Array:zombie_modelindex_origin, Array:zombie_viewmodel_host, Array:zombie_viewmodel_origin,
- Array:zombie_sound_heal, Array:zombie_sound_evolution, Array:zombiebom_viewmodel, Array:zombie_sex
- // Config Value
- const MAX_LEVEL_HUMAN = 10
- const MAX_LEVEL_ZOMBIE = 3
- const MAX_EVOLUTION = 30
- new MONEY_START, RESPAWN_TIME_WAIT, ZOMBIE_DAMAGE_LEVEL
- new MAX_HEALTH_ZOMBIE_RANDOM, MIN_HEALTH_ZOMBIE_RANDOM, LEVEL_ZOMBIE_RANDOM
- new HUMAN_HEALTH, HUMAN_ARMOR, Float:HUMAN_GRAVITY
- new MIN_HEALTH_ZOMBIE, MIN_ARMOR_ZOMBIE
- new RESTORE_HEALTH_TIME, RESTORE_HEALTH_DMG_LV1, RESTORE_HEALTH_DMG_LV2
- new Float:SUPPLYBOX_TIME, SUPPLYBOX_NUM, SUPPLYBOX_CLASSNAME[] = "nst_zb3_supplybox", SUPPLYBOX_SOUND_PICKUP[64], SUPPLYBOX_SOUND_DROP[64], SUPPLYBOX_MAX,
- SUPPLYBOX_ICON_SPR[64], SUPPLYBOX_ICON_IDSPR, SUPPLYBOX_TOTAL_IN_TIME
- new ZOMBIEBOM_MODEL[64], Float:ZOMBIEBOM_RADIUS, Float:ZOMBIEBOM_POWER, ZOMBIEBOM_SPRITES_EXP[64], ZOMBIEBOM_SOUND_EXP[64], ZOMBIEBOM_IDSPRITES_EXP,
- ZOMBIEBOM_P_MODEL[64], ZOMBIEBOM_W_MODEL[64]
- // config level zombie
- new ZB_LV2_HEALTH, ZB_LV2_ARMOR
- new ZB_LV3_HEALTH, ZB_LV3_ARMOR
- // config hero
- new HERO_MODEL[64], HERO_HEALTH, HERO_ARMOR, Float:HERO_GRAVITY, HERO_ICON_SPR[64], HERO_ICON_IDSPR
- // Zombie mod
- enum
- {
- MODE_NONE = 0,
- MODE_RESPAWN,
- MODE_INFECTION
- }
- // Customization file sections
- enum
- {
- SECTION_NONE = 0,
- SECTION_CONFIG_VALUE,
- SECTION_HERO,
- SECTION_RESTORE_HEALTH,
- SECTION_SUPPLYBOX,
- SECTION_ZOMBIEBOM,
- SECTION_SOUNDS,
- SECTION_SPRITES,
- SECTION_MENUWEAPONS,
- SECTION_WEATHER_EFFECTS,
- SECTION_SKY,
- SECTION_LIGHTNING,
- SECTION_KNOCKBACK,
- SECTION_OBJECTIVE_ENTS
- }
- // Task offsets
- enum (+= 100)
- {
- TASK_TEAM = 2000,
- TASK_MAKEZOMBIE,
- TASK_MAKEHUMAN,
- TASK_WELLCOME,
- TASK_GLOWSHELL,
- TASK_THUNDER_PRE,
- TASK_THUNDER,
- TASK_SPAWN,
- TASK_MENUWPN,
- TASK_SUPPLYBOX,
- TASK_SUPPLYBOX_MODEL,
- TASK_SUPPLYBOX_HELP,
- TASK_SUPPLYBOX_WAIT,
- TASK_ZOMBIE_RESPAWN,
- TASK_ZOMBIE_RESPAWN_EF,
- TASK_STATUSICON,
- TASK_NVISION
- }
- // IDs inside tasks
- #define ID_TEAM (taskid - TASK_TEAM)
- #define ID_GLOWSHELL (taskid - TASK_GLOWSHELL)
- #define ID_SPAWN (taskid - TASK_SPAWN)
- #define ID_MENUWPN (taskid - TASK_MENUWPN)
- #define ID_SUPPLYBOX_WAIT (taskid - TASK_SUPPLYBOX_WAIT)
- #define ID_ZOMBIE_RESPAWN (taskid - TASK_ZOMBIE_RESPAWN)
- #define ID_ZOMBIE_RESPAWN_EF (taskid - TASK_ZOMBIE_RESPAWN_EF)
- #define ID_STATUSICON (taskid - TASK_STATUSICON)
- #define ID_MAKEHUMAN (taskid - TASK_MAKEHUMAN)
- #define ID_NVISION (taskid - TASK_NVISION)
- // CS Teams
- enum
- {
- FM_CS_TEAM_UNASSIGNED = 0,
- FM_CS_TEAM_T,
- FM_CS_TEAM_CT,
- FM_CS_TEAM_SPECTATOR
- }
- // type item weapons
- enum
- {
- NSTZB_ITEM_WPNDEFAULT = 1,
- NSTZB_ITEM_NSTWPN,
- NSTZB_ITEM_AMMONADE
- }
- // CS Player PData Offsets (win32)
- const OFFSET_PAINSHOCK = 108 // ConnorMcLeod
- const OFFSET_CSTEAMS = 114
- const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
- const IMPULSE_FLASHLIGHT = 100
- const OFFSET_FLASHLIGHT_BATTERY = 244
- const DMG_HEGRENADE = (1<<24)
- // Weapon bitsums
- const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
- const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
- const NADE_WEAPONS_BIT_SUM = ((1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG))
- const NOCLIP_WPN_BS = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
- // Weapon entity names
- new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
- "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
- "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
- "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
- "weapon_ak47", "weapon_knife", "weapon_p90" }
- // Max Clip for weapons
- new const MAXCLIP[] = { -1, 13, -1, 10, -1, 7, -1, 30, 30, -1, 30, 20, 25, 30, 35, 25, 12, 20,
- 10, 30, 100, 8, 30, 30, 20, -1, 7, 30, 30, -1, 50 }
- // Ammo IDs for weapons
- new const AMMOID[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10,
- 1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7 }
- // block cmd buy
- #define MAXMENUPOS 34
- new g_Aliases[MAXMENUPOS][] = {"usp","glock","deagle","p228","elites","fn57","m3","xm1014","mp5","tmp","p90","mac10","ump45","ak47","galil","famas","sg552","m4a1","aug","scout","awp","g3sg1","sg550","m249","vest","vesthelm","flash","hegren","sgren","defuser","nvgs","shield","primammo","secammo"}
- new g_Aliases2[MAXMENUPOS][] = {"km45","9x19mm","nighthawk","228compact","elites","fiveseven","12gauge","autoshotgun","smg","mp","c90","mac10","ump45","cv47","defender","clarion","krieg552","m4a1","bullpup","scout","magnum","d3au1","krieg550","m249","vest","vesthelm","flash","hegren","sgren","defuser","nvgs","shield","primammo","secammo"}
- // HACK: pev_ field used to store additional ammo on weapons
- const PEV_ADDITIONAL_AMMO = pev_iuser1
- // pev_ field used to store custom nade types and their values
- const PEV_NADE_TYPE = pev_flTimeStepSound
- const NADE_TYPE_INFECTION = 1111
- // X Damage value
- new const XDAMAGE[11][] = {
- "1.0",
- "1.1",
- "1.2",
- "1.3",
- "1.4",
- "1.5",
- "1.6",
- "1.7",
- "1.8",
- "1.9",
- "2.0"
- }
- // X Recoil value
- new const XRECOIL[11][] = {
- "1.0",
- "0.9",
- "0.8",
- "0.7",
- "0.6",
- "0.5",
- "0.4",
- "0.3",
- "0.2",
- "0.1",
- "0.0"
- }
- new WpnName[32]
- new Float:cl_pushangle[33][3]
- // HUD messages
- const Float:HUD_SCORE_X = -1.0
- const Float:HUD_SCORE_Y = 0.01
- const Float:HUD_HEALTH_X = 0.015
- const Float:HUD_HEALTH_Y = 0.92
- const Float:HUD_POWER_X = -0.357
- const Float:HUD_POWER_Y = 0.907
- // CS Sound
- new const sound_buyammo[] = "items/9mmclip1.wav"
- new const sound_nvg[2][] = {"items/nvg_off.wav", "items/nvg_on.wav"}
- // Some constants
- const FFADE_IN = 0x0000
- const FFADE_STAYOUT = 0x0004
- const UNIT_SECOND = (1<<12)
- new g_hamczbots, cvar_botquota
- /*================================================================================
- [Natives, Precache and Init]
- =================================================================================*/
- public plugin_natives()
- {
- // Player natives
- register_native("nst_zb_get_mod", "native_get_mod", 1)
- register_native("nst_zb_get_user_sex", "native_get_user_sex", 1)
- register_native("nst_zb_get_user_start_health", "native_get_user_start_health", 1)
- register_native("nst_zb_get_user_level", "native_get_user_level", 1)
- register_native("nst_zb_get_user_zombie", "native_get_user_zombie", 1)
- register_native("nst_zb_get_user_hero", "native_get_user_hero", 1)
- register_native("nst_zb_get_user_zombie_class", "native_get_user_zombie_class", 1)
- register_native("nst_zb_zombie_respawn", "native_zombie_respawn", 1)
- register_native("nst_zb_remove_weapons_newround", "native_remove_weapons_newround", 1)
- register_native("nst_zb_human_kill_zombie", "native_human_kill_zombie", 1)
- register_native("nst_zb_color_saytext", "natives_color_saytext", 1)
- register_native("nst_zb_get_user_damage_attack", "natives_get_user_damage_attack", 1)
- register_native("nst_zb_set_user_damage_attack", "natives_set_user_damage_attack", 1)
- register_native("nst_zb_get_maxlevel_human", "natives_get_maxlevel_human", 1)
- register_native("nst_zb_get_weapons_ammo", "natives_get_weapons_ammo", 1)
- register_native("nst_zb_get_take_damage", "native_get_take_damage", 1)
- register_native("nst_zb_get_damage_nade", "native_get_damage_nade", 1)
- // External additions natives
- register_native("nst_zb3_register_zombie_class", "native_register_zombie_class", 1)
- register_native("nst_zbu_register_zombie_class", "native_novalue", 1)
- register_native("nst_zbs_register_zombie_class", "native_novalue", 1)
- }
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- // Language files
- register_dictionary(LANG_FILE)
- // Events
- register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
- register_logevent("logevent_round_start",2, "1=Round_Start")
- register_logevent("logevent_round_end", 2, "1=Round_End")
- register_event("CurWeapon","CurrentWeapon","be","1=1")
- register_event("DeathMsg", "Death", "a")
- // HAM Forwards
- RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
- RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
- RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
- RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
- RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
- RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
- RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
- for(new i=1; i<=CSW_P90; i++)
- {
- if( !(NOCLIP_WPN_BS & (1<<i)) && get_weaponname(i, WpnName, charsmax(WpnName)) )
- {
- RegisterHam(Ham_Weapon_PrimaryAttack, WpnName, "fw_primary_attack")
- RegisterHam(Ham_Weapon_PrimaryAttack, WpnName, "fw_primary_attack_post",1)
- }
- }
- // FM Forwards
- register_forward(FM_CmdStart, "fw_CmdStart")
- register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
- register_forward(FM_EmitSound, "fw_EmitSound")
- register_forward(FM_SetModel, "fw_SetModel")
- register_forward(FM_Touch, "fw_Touch")
- unregister_forward(FM_Spawn, g_fwSpawn)
- // Message IDs
- g_msgBarTime = get_user_msgid("BarTime")
- g_msgDeathMsg = get_user_msgid("DeathMsg")
- g_msgScoreAttrib = get_user_msgid("ScoreAttrib")
- g_msgStatusIcon = get_user_msgid("StatusIcon")
- g_msgScoreInfo = get_user_msgid("ScoreInfo")
- g_msgScenario = get_user_msgid("Scenario")
- g_msgDamage = get_user_msgid("Damage")
- g_msgHostagePos = get_user_msgid("HostagePos")
- g_msgHostageK = get_user_msgid("HostageK")
- g_msgFlashBat = get_user_msgid("FlashBat")
- g_msgNVGToggle = get_user_msgid("NVGToggle")
- g_msgWeapPickup = get_user_msgid("WeapPickup")
- g_msgHealth = get_user_msgid("Health")
- g_msgAmmoPickup = get_user_msgid("AmmoPickup")
- g_msgTextMsg = get_user_msgid("TextMsg")
- g_msgSendAudio = get_user_msgid("SendAudio")
- g_msgTeamScore = get_user_msgid("TeamScore")
- g_msgScreenFade = get_user_msgid("ScreenFade");
- g_msgHudTextArgs = get_user_msgid("HudTextArgs")
- g_msgClCorpse = get_user_msgid("ClCorpse")
- // Message hooks
- register_message(g_msgHealth, "message_health")
- register_message(g_msgFlashBat, "message_flashbat")
- register_message(g_msgNVGToggle, "message_nvgtoggle")
- register_message(g_msgWeapPickup, "message_weappickup")
- register_message(g_msgAmmoPickup, "message_ammopickup")
- register_message(g_msgScenario, "message_scenario")
- register_message(g_msgHostagePos, "message_hostagepos")
- register_message(g_msgTextMsg, "message_textmsg")
- register_message(g_msgSendAudio, "message_sendaudio")
- register_message(g_msgTeamScore, "message_teamscore")
- register_message(g_msgHudTextArgs, "message_hudtextargs")
- register_message(g_msgClCorpse, "message_msgClCorpse")
- // Block msg
- //set_msg_block(g_msgClCorpse, BLOCK_SET)
- // Admin commands
- register_concmd("nst_zb3_respawn_zombie", "cmd_respawn_zombie", _, "<target> - Respawn someone as Zombie", 0)
- register_concmd("nst_zb3_respawn_human", "cmd_respawn_human", _, "<target> - Respawn someone as Human", 0)
- register_concmd("nst_zb3_respawn_hero", "cmd_respawn_hero", _, "<target> - Respawn someone as Hero", 0)
- //register_concmd("qq", "qq")
- // clie ncommands
- register_clcmd("buyammo1","cmd_buy_ammo")
- register_clcmd("buyammo2","cmd_buy_ammo")
- register_clcmd("primammo","cmd_buy_ammo")
- register_clcmd("secammo","cmd_buy_ammo")
- register_clcmd("nightvision", "cmd_nightvision")
- register_clcmd("cl_autobuy", "cmd_block")
- register_clcmd("cl_rebuy", "cmd_block")
- // CVARS Game
- cvar_lighting = register_cvar("nst_zb3_light", "e")
- cvar_thunder = register_cvar("nst_zb3_thunderclap", "90")
- cvar_delay = register_cvar("nst_zb3_delay", "20")
- cvar_glowshell_time = register_cvar("nst_zb3_glowshell_time", "10")
- cvar_randspawn = register_cvar("nst_zb3_random_spawn", "1")
- cvar_remove_weapons_newround = register_cvar("nst_zb3_remove_weapons_newround", "1")
- cvar_time_show_spr = register_cvar("nst_zb3_time_show_spr", "2.0")
- cvar_damage_nade = register_cvar("nst_zb3_damage_nade", "200")
- cvar_damage_grenade = register_cvar("nst_zb3_damage_grenade", "300")
- cvar_time_attack_zombie = register_cvar("nst_zb3_time_attack_zombie", "3")
- cvar_bot_uclip = register_cvar("nst_zb3_bot_uclip", "2")
- cvar_recoil = register_cvar("nst_zb3_level_recoil", "0")
- cvar_level_damage = register_cvar("nst_zb3_level_damage", "0")
- cvar_drop_weapons_infected = register_cvar("nst_zb3_drop_weapons_infected", "0")
- // Cvar Zombie Weak
- cvar_zombie_weak = register_cvar("nst_zb3_zombie_weak", "1")
- cvar_zombie_weak_dmg = register_cvar("nst_zb3_zombie_weak_dmg", "1000")
- cvar_zombie_flash = register_cvar("nst_zb3_zombie_weak_flash", "3")
- cvar_zombie_weak_color[0] = register_cvar("nst_zb3_zombie_weak_color_r", "255")
- cvar_zombie_weak_color[1] = register_cvar("nst_zb3_zombie_weak_color_g", "255")
- cvar_zombie_weak_color[2] = register_cvar("nst_zb3_zombie_weak_color_b", "255")
- // CVARS - Flashlight and Nightvision
- cvar_nvg_zombie_give = register_cvar("nst_zb3_nvg_zombie_give", "1")
- cvar_nvg_zombie_alpha = register_cvar("nst_zb3_nvg_zombie_alpha", "70")
- cvar_nvg_zombie_size = register_cvar("nst_zb3_nvg_zombie_size", "150")
- cvar_nvg_zombie_color[0] = register_cvar("nst_zb3_nvg_zombie_color_r", "253")
- cvar_nvg_zombie_color[1] = register_cvar("nst_zb3_nvg_zombie_color_g", "110")
- cvar_nvg_zombie_color[2] = register_cvar("nst_zb3_nvg_zombie_color_b", "110")
- // CVARS - Knockback
- cvar_knockback = register_cvar("nst_zb3_knockback", "1")
- cvar_knockbackdamage = register_cvar("nst_zb3_knockback_damage", "0")
- cvar_knockbackpower = register_cvar("nst_zb3_knockback_power", "1")
- cvar_knockbackzvel = register_cvar("nst_zb3_knockback_zvel", "0")
- // CVARS - Other
- cvar_botquota = get_cvar_pointer("bot_quota")
- cvar_icon = register_cvar("nst_zb3_icon", "1")
- cvar_icon_deplay = register_cvar("nst_zb3_icon_deplay", "0.03")
- cvar_icon_light = register_cvar("nst_zb3_icon_light", "100")
- cvar_icon_size = register_cvar("nst_zb3_icon_size", "2")
- cvar_level_deplay = register_cvar("nst_zb3_level_deplay", "0.1")
- // Custom Forwards
- g_fwUserInfected = CreateMultiForward("nst_zb_user_infected", ET_IGNORE, FP_CELL, FP_CELL)
- g_fwUserDamage = CreateMultiForward("nst_zb_human_damage", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
- // Collect random spawn points
- load_spawns()
- load_spawns_box()
- // Set a random skybox?
- if (g_sky_enable)
- {
- new sky[32]
- ArrayGetString(g_sky_names, random_num(0, ArraySize(g_sky_names) - 1), sky, charsmax(sky))
- set_cvar_string("sv_skyname", sky)
- }
- // Disable sky lighting so it doesn't mess with our custom lighting
- set_cvar_num("sv_skycolor_r", 0)
- set_cvar_num("sv_skycolor_g", 0)
- set_cvar_num("sv_skycolor_b", 0)
- // Create the HUD Sync Objects
- g_HudMsg_Health = CreateHudSyncObj()
- g_HudMsg_ScoreMatch = CreateHudSyncObj()
- g_HudMsg_Power = CreateHudSyncObj()
- // Get Max Players
- g_maxplayers = get_maxplayers()
- // Task
- set_task(2.0,"radar_scan",_,_,_,"b")
- set_task(1.0, "show_hud_client", _, _, _, "b")
- }
- public plugin_precache()
- {
- // Initialize a few dynamically sized arrays (alright, maybe more than just a few...)
- lights_thunder = ArrayCreate(32, 1)
- sound_thunder = ArrayCreate(64, 1)
- g_sky_names = ArrayCreate(32, 1)
- g_objective_ents = ArrayCreate(32, 1)
- weapons_pri = ArrayCreate(64, 1)
- weapons_pri_name = ArrayCreate(64, 1)
- weapons_sec = ArrayCreate(64, 1)
- weapons_sec_name = ArrayCreate(64, 1)
- weapons_nade = ArrayCreate(64, 1)
- supplybox_item = ArrayCreate(64, 1)
- hero_weapons = ArrayCreate(64, 1)
- supplybox_models = ArrayCreate(64, 1)
- sound_human_death = ArrayCreate(64, 1)
- sound_female_death = ArrayCreate(64, 1)
- sound_zombie_coming = ArrayCreate(64, 1)
- sound_zombie_comeback = ArrayCreate(64, 1)
- sound_zombie_attack = ArrayCreate(64, 1)
- sound_zombie_hitwall = ArrayCreate(64, 1)
- sound_zombie_swing = ArrayCreate(64, 1)
- sound_zombie_start = ArrayCreate(64, 1)
- // class zombie
- zombie_name = ArrayCreate(64, 1)
- zombie_gravity = ArrayCreate(1, 1)
- zombie_speed = ArrayCreate(1, 1)
- zombie_knockback = ArrayCreate(1, 1)
- zombie_sound_death1 = ArrayCreate(64, 1)
- zombie_sound_death2 = ArrayCreate(64, 1)
- zombie_sound_hurt1 = ArrayCreate(64, 1)
- zombie_sound_hurt2 = ArrayCreate(64, 1)
- zombie_viewmodel_host = ArrayCreate(64, 1)
- zombie_viewmodel_origin = ArrayCreate(64, 1)
- zombie_modelindex_host = ArrayCreate(1, 1)
- zombie_modelindex_origin = ArrayCreate(1, 1)
- zombie_wpnmodel = ArrayCreate(64, 1)
- zombie_sound_heal = ArrayCreate(64, 1)
- zombie_sound_evolution = ArrayCreate(64, 1)
- zombiebom_viewmodel = ArrayCreate(64, 1)
- zombie_sex = ArrayCreate(1, 1)
- zombie_modelindex = ArrayCreate(1, 1)
- // Load customization data
- load_customization_from_files()
- // CS sounds (just in case)
- engfunc(EngFunc_PrecacheSound, sound_buyammo)
- new i, buffer[100]
- // Model hero
- format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", HERO_MODEL, HERO_MODEL)
- engfunc(EngFunc_PrecacheModel, buffer)
- // Custom sounds
- for (i = 0; i < ArraySize(sound_thunder); i++)
- {
- ArrayGetString(sound_thunder, i, buffer, charsmax(buffer))
- //engfunc(EngFunc_PrecacheSound, buffer)
- }
- for (i = 0; i < ArraySize(sound_zombie_coming); i++)
- {
- ArrayGetString(sound_zombie_coming, i, buffer, charsmax(buffer))
- //engfunc(EngFunc_PrecacheSound, buffer)
- }
- for (i = 0; i < ArraySize(sound_zombie_comeback); i++)
- {
- ArrayGetString(sound_zombie_comeback, i, buffer, charsmax(buffer))
- engfunc(EngFunc_PrecacheSound, buffer)
- }
- for (i = 0; i < ArraySize(sound_human_death); i++)
- {
- ArrayGetString(sound_human_death, i, buffer, charsmax(buffer))
- engfunc(EngFunc_PrecacheSound, buffer)
- }
- for (i = 0; i < ArraySize(sound_female_death); i++)
- {
- ArrayGetString(sound_female_death, i, buffer, charsmax(buffer))
- engfunc(EngFunc_PrecacheSound, buffer)
- }
- for (i = 0; i < ArraySize(sound_zombie_attack); i++)
- {
- ArrayGetString(sound_zombie_attack, i, buffer, charsmax(buffer))
- engfunc(EngFunc_PrecacheSound, buffer)
- }
- for (i = 0; i < ArraySize(sound_zombie_hitwall); i++)
- {
- ArrayGetString(sound_zombie_hitwall, i, buffer, charsmax(buffer))
- engfunc(EngFunc_PrecacheSound, buffer)
- }
- for (i = 0; i < ArraySize(sound_zombie_swing); i++)
- {
- ArrayGetString(sound_zombie_swing, i, buffer, charsmax(buffer))
- engfunc(EngFunc_PrecacheSound, buffer)
- }
- for (i = 0; i < ArraySize(sound_zombie_start); i++)
- {
- ArrayGetString(sound_zombie_start, i, buffer, charsmax(buffer))
- //engfunc(EngFunc_PrecacheSound, buffer)
- }
- for (new i = 1; i <= 10; i++)
- {
- new sound_count[64]
- format(sound_count, sizeof sound_count - 1, sound_zombie_count, i)
- //engfunc(EngFunc_PrecacheSound, sound_count)
- }
- precache_sound(SUPPLYBOX_SOUND_PICKUP)
- //precache_sound(SUPPLYBOX_SOUND_DROP)
- //precache_sound(sound_win_zombie)
- //precache_sound(sound_win_human)
- // Custom models
- for (i = 0; i < ArraySize(supplybox_models); i++)
- {
- ArrayGetString(supplybox_models, i, buffer, charsmax(buffer))
- engfunc(EngFunc_PrecacheModel, buffer)
- }
- // Custom sprites
- id_sprites_levelup = precache_model(sprites_effects_levelup)
- restore_health_idspr = precache_model(restore_health_spr)
- zombie_respawn_idspr = precache_model(zombie_respawn_spr)
- SUPPLYBOX_ICON_IDSPR = precache_model(SUPPLYBOX_ICON_SPR)
- HERO_ICON_IDSPR = precache_model(HERO_ICON_SPR)
- // zombie bomb
- engfunc(EngFunc_PrecacheModel, ZOMBIEBOM_P_MODEL)
- engfunc(EngFunc_PrecacheModel, ZOMBIEBOM_W_MODEL)
- ZOMBIEBOM_IDSPRITES_EXP = engfunc(EngFunc_PrecacheModel, ZOMBIEBOM_SPRITES_EXP)
- engfunc(EngFunc_PrecacheSound, ZOMBIEBOM_SOUND_EXP)
- new ent
- // Fake Hostage (to force round ending)
- ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "hostage_entity"))
- if (pev_valid(ent))
- {
- engfunc(EngFunc_SetOrigin, ent, Float:{8192.0,8192.0,8192.0})
- dllfunc(DLLFunc_Spawn, ent)
- }
- // Weather/ambience effects
- if (g_ambience_fog)
- {
- ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_fog"))
- if (pev_valid(ent))
- {
- fm_set_kvd(ent, "density", g_fog_density, "env_fog")
- fm_set_kvd(ent, "rendercolor", g_fog_color, "env_fog")
- }
- }
- if (g_ambience_rain) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_rain"))
- if (g_ambience_snow) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_snow"))
- // Prevent some entities from spawning
- g_fwSpawn = register_forward(FM_Spawn, "fw_Spawn")
- }
- public plugin_cfg()
- {
- // Get configs dir
- new cfgdir[32]
- get_configsdir(cfgdir, charsmax(cfgdir))
- // Execute config file (zombieplague.cfg)
- server_cmd("exec %s/%s", cfgdir, CVAR_FILE)
- // Lighting task
- set_task(5.0, "lighting_effects", _, _, _, "b")
- // Cache CVARs after configs are loaded / call roundstart manually
- set_task(0.5, "event_round_start")
- set_task(0.5, "logevent_round_start")
- }
- /*================================================================================
- [Main Events]
- =================================================================================*/
- // Event Round Start
- public event_round_start()
- {
- // set value
- g_freezetime = 1
- g_newround = 1
- g_endround = 0
- supplybox_count = 0
- if (g_startcount) g_rount_count += 1
- if (g_rount_count)
- {
- // play sound start
- static sound[64]
- ArrayGetString(sound_zombie_start, random(ArraySize(sound_zombie_start)), sound, charsmax(sound))
- PlaySound(0, sound)
- // reset value
- for (new id = 1; id <= g_maxplayers; id++)
- {
- if (!is_user_connected(id)) continue;
- if (g_zombie[id]) reset_wpnmodel(id)
- reset_value(id)
- // menu wpn
- if (task_exists(id+TASK_MENUWPN)) remove_task(id+TASK_MENUWPN)
- set_task(0.5, "menu_wpn", id+TASK_MENUWPN)
- }
- // wellcome
- if (task_exists(TASK_WELLCOME)) remove_task(TASK_WELLCOME)
- set_task(5.0, "wellcome", TASK_WELLCOME)
- }
- }
- // Log Event Round Start
- public logevent_round_start()
- {
- // remove freezetime
- g_freezetime = 0
- if (g_rount_count)
- {
- // start zombie count
- g_zombie_count = get_pcvar_num(cvar_delay)
- task_zombie_count()
- if (task_exists(TASK_MAKEZOMBIE)) remove_task(TASK_MAKEZOMBIE)
- set_task(1.0, "task_zombie_count", TASK_MAKEZOMBIE, _, _, "b")
- }
- }
- public task_zombie_count()
- {
- new message[64], sound_count[64]
- if (!g_zombie_count)
- {
- g_newround = 0
- make_random_zombie()
- format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_APPEAR")
- remove_task(TASK_MAKEZOMBIE)
- }
- else
- {
- if (g_zombie_count<=10)
- {
- format(sound_count, charsmax(sound_count), sound_zombie_count, g_zombie_count)
- PlaySound(0, sound_count)
- }
- format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_COUNT", g_zombie_count)
- }
- SendCenterText(0, message)
- g_zombie_count -= 1
- }
- // Log Event Round End
- public logevent_round_end()
- {
- // set score team
- if (g_rount_count)
- {
- new humans = GetTotalPlayer(4, 1)
- new zombie = GetTotalPlayer(3, 1)
- new message[64]
- if (humans)
- {
- g_score_human += 1
- PlaySound(0, sound_win_human)
- format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_WIN_HUMAN")
- }
- else if (zombie && !humans)
- {
- g_score_zombie += 1
- PlaySound(0, sound_win_zombie)
- format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_WIN_ZOMBIE")
- }
- else
- {
- format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_WIN_NO_ONE")
- }
- // show hud msg
- SendCenterText(0, message)
- // show score match
- //ShowScoreMatch()
- }
- // reset
- g_endround = 1
- reset_teams()
- remove_supplybox()
- }
- public wellcome()
- {
- color_saytext(0, "^x03-=[^x04NST Zombie Mod3^x03]=-")
- if (task_exists(TASK_WELLCOME)) remove_task(TASK_WELLCOME)
- set_task(60.0, "wellcome", TASK_WELLCOME)
- }
- /*================================================================================
- [Clien Public]
- =================================================================================*/
- // Client joins the game
- public client_putinserver(id)
- {
- // reset value
- reset_value(id)
- // Reg Ham Zbot
- if (is_user_bot(id) && !g_hamczbots && cvar_botquota)
- {
- set_task(0.1, "register_ham_czbots", id)
- }
- }
- // Client leaving
- public fw_ClientDisconnect(id)
- {
- reset_value(id)
- }
- // make human if client joins match
- public TaskMakeHuman(taskid)
- {
- new id = ID_MAKEHUMAN
- // make_human
- make_human(id)
- // show menu weapons
- if (task_exists(id+TASK_MENUWPN)) remove_task(id+TASK_MENUWPN)
- set_task(0.1, "menu_wpn", id+TASK_MENUWPN)
- // give nade
- give_nade(id)
- //remove task
- if (task_exists(id+TASK_MAKEHUMAN)) remove_task(id+TASK_MAKEHUMAN)
- }
- public client_command(id)
- {
- new arg[13]
- if (read_argv(0, arg, 12) > 11)
- {
- return PLUGIN_CONTINUE
- }
- // block cmd buy
- if (g_blockbuy)
- {
- new a = 0
- do {
- if (equali(g_Aliases[a], arg) || equali(g_Aliases2[a], arg))
- {
- return PLUGIN_HANDLED
- }
- } while(++a < MAXMENUPOS)
- }
- return PLUGIN_CONTINUE
- }
- public cmd_block(id)
- {
- return PLUGIN_CONTINUE
- }
- public Death()
- {
- new killer = read_data(1)
- new victim = read_data(2)
- new headshot = read_data(3)
- new weaponid = get_user_weapon(killer)
- // Zombie Die
- if (g_zombie[victim])
- {
- human_kill_zombie(killer, victim, weaponid)
- }
- // reset value victim
- turn_off_nvg(victim)
- fm_set_rendering(victim)
- //hide_level(victim)
- }
- public client_damage(attacker,victim,damage,wpnindex,hitplace,TA)
- {
- // check
- if (attacker == victim || g_zombie[attacker] || !g_zombie[victim]) return;
- // get damage attack
- new damage_victim = get_user_health(victim)+damage
- new damage_fire = min(damage_victim, damage)
- // update level of human for damage
- UpdateLevelHumanDamage(attacker, damage_fire)
- // damage victim
- UpdateEvolutionDamage(victim, damage_fire)
- //client_print(attacker, print_chat, "%i", g_dmg_attack[attacker])
- }
- /*================================================================================
- [Main Forwards]
- =================================================================================*/
- public client_PostThink(id)
- {
- show_hud_icon(id)
- show_player_level(id)
- }
- // Entity Spawn Forward
- public fw_Spawn(entity)
- {
- // Invalid entity
- if (!pev_valid(entity)) return FMRES_IGNORED;
- // Get classname
- new classname[32], objective[32], size = ArraySize(g_objective_ents)
- pev(entity, pev_classname, classname, charsmax(classname))
- // Check whether it needs to be removed
- for (new i = 0; i < size; i++)
- {
- ArrayGetString(g_objective_ents, i, objective, charsmax(objective))
- if (equal(classname, objective))
- {
- engfunc(EngFunc_RemoveEntity, entity)
- return FMRES_SUPERCEDE;
- }
- }
- return FMRES_IGNORED;
- }
- // Ham Player Spawn Post Forward
- public fw_PlayerSpawn_Post(id)
- {
- // Not alive or didn't join a team yet
- if (!is_user_alive(id) || !fm_cs_get_user_team(id))
- return;
- // Remove previous tasks
- if (task_exists(id+TASK_SPAWN)) remove_task(id+TASK_SPAWN)
- if (task_exists(id+TASK_GLOWSHELL)) remove_task(id+TASK_GLOWSHELL)
- // remove glow
- fm_set_rendering(id)
- // remove weapons in new round
- if (get_pcvar_num(cvar_remove_weapons_newround) && !is_user_bot(id))
- {
- fm_strip_user_weapons(id)
- fm_give_item(id, "weapon_knife")
- }
- // Spawn at a random location?
- if (get_pcvar_num(cvar_randspawn)) do_random_spawn(id)
- // set money
- fm_cs_set_user_money(id, MONEY_START)
- }
- // Ham Take Damage Forward
- public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
- {
- // Non-player damage or self damage
- if (victim == attacker)
- return HAM_IGNORED;
- // Fix bug player not connect
- if (!is_user_connected(victim) || !is_user_connected(attacker))
- return HAM_IGNORED;
- // Remove Damage when Freetime
- if (g_newround || g_endround)
- return HAM_SUPERCEDE;
- // attacker is zombie
- if (g_zombie[attacker] && !g_zombie[victim])
- {
- // Fix Bug zombie has weapons # knife
- if (get_user_weapon(attacker) != CSW_KNIFE) return HAM_SUPERCEDE;
- // infection
- new human_alive = GetTotalPlayer(4, 1)
- if (human_alive>1)
- {
- zombie_infection_human(attacker, victim)
- return HAM_SUPERCEDE;
- }
- else
- {
- SetHamParamFloat(4, float(get_user_health(victim)*2))
- return HAM_IGNORED
- }
- }
- // attacker is human
- else if (!g_zombie[attacker] && g_zombie[victim])
- {
- // remove restore health of zombie
- g_restore_health[victim] = 0
- // he xdamage
- if ( (damage_type & DMG_HEGRENADE) && !g_zombie[attacker] )
- {
- new Float: hedmg = get_pcvar_float(cvar_damage_nade)+get_pcvar_float(cvar_damage_grenade)
- if (damage < hedmg) damage += hedmg
- }
- // X Damage
- else if (g_level[attacker])
- {
- new Float: xdmg = str_to_float(XDAMAGE[g_level[attacker]])
- damage *= xdmg
- }
- SetHamParamFloat(4, damage)
- return HAM_IGNORED
- }
- // fix bug
- else return HAM_SUPERCEDE;
- return HAM_IGNORED
- }
- // Ham Weapon Touch Forward
- public fw_TouchWeapon(weapon, id)
- {
- // Not a player
- if (!is_user_connected(id))
- return HAM_IGNORED;
- // Dont pickup weapons if zombie or survivor (+PODBot MM fix)
- if (g_zombie[id])
- return HAM_SUPERCEDE;
- return HAM_IGNORED;
- }
- // FW CmdStart
- public fw_CmdStart(id, uc_handle, seed)
- {
- if (!is_user_alive(id))
- {
- //hide_level(id)
- return FMRES_IGNORED
- }
- // restore health
- zombie_restore_health(id)
- // zombie weak
- zombie_weak(id)
- //client_print(id, print_chat, "L[%i] E[%i]", g_level[id], g_evolution[id])
- return FMRES_IGNORED
- }
- public fw_PlayerPreThink(id)
- {
- if (!is_user_alive(id) || g_freezetime) return;
- // Set Player MaxSpeed
- if (g_zombie[id])
- {
- new Float:maxspeed
- maxspeed = ArrayGetCell(zombie_speed, g_zombieclass[id])
- set_pev(id, pev_maxspeed, maxspeed)
- }
- }
- // Ham Trace Attack Forward
- public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
- {
- // Non-player damage or self damage
- if (victim == attacker || !is_user_connected(attacker))
- return HAM_IGNORED;
- // New round starting or round ended
- if (g_newround || g_endround)
- return HAM_SUPERCEDE;
- // Prevent friendly fire
- if (g_zombie[attacker] == g_zombie[victim])
- return HAM_SUPERCEDE;
- // Victim isn't a zombie or not bullet damage, nothing else to do here
- if (!g_zombie[victim] || !(damage_type & DMG_BULLET))
- return HAM_IGNORED;
- // Knockback disabled, nothing else to do here
- if (!get_pcvar_num(cvar_knockback))
- return HAM_IGNORED;
- // Get distance between players
- static origin1[3], origin2[3]
- get_user_origin(victim, origin1)
- get_user_origin(attacker, origin2)
- // Get victim's velocity
- static Float:velocity[3]
- pev(victim, pev_velocity, velocity)
- // Use damage on knockback calculation
- if (get_pcvar_num(cvar_knockbackdamage))
- xs_vec_mul_scalar(direction, damage, direction)
- // Use weapon power on knockback calculation
- if (get_pcvar_num(cvar_knockbackpower))
- {
- new Float:weapon_knockback
- weapon_knockback = kb_weapon_power[get_user_weapon(attacker)]
- xs_vec_mul_scalar(direction, weapon_knockback, direction)
- }
- // Apply zombie class knockback multiplier
- if (g_zombie[victim])
- {
- new Float:classzb_knockback
- classzb_knockback = ArrayGetCell(zombie_knockback, g_zombieclass[victim])
- xs_vec_mul_scalar(direction, classzb_knockback, direction)
- }
- // Add up the new vector
- xs_vec_add(velocity, direction, direction)
- // Should knockback also affect vertical velocity?
- if (!get_pcvar_num(cvar_knockbackzvel))
- direction[2] = velocity[2]
- // Set the knockback'd victim's velocity
- set_pev(victim, pev_velocity, direction)
- //client_print(attacker, print_chat, "[%i][%i]", victim_kb, class_kb)
- return HAM_IGNORED;
- }
- // Emit Sound Forward
- public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
- {
- //client_print(id, print_chat, "[%s]", sample)
- // Block all those unneeeded hostage sounds
- if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
- return FMRES_SUPERCEDE;
- // Replace these next sounds for zombies only
- if (!is_user_connected(id) || !g_zombie[id])
- return FMRES_IGNORED;
- static sound[64]
- // Zombie being hit
- if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't' ||
- sample[7] == 'h' && sample[8] == 'e' && sample[9] == 'a' && sample[10] == 'd')
- {
- if (g_level[id]==1) ArrayGetString(zombie_sound_hurt1, g_zombieclass[id], sound, charsmax(sound))
- else ArrayGetString(zombie_sound_hurt2, g_zombieclass[id], sound, charsmax(sound))
- emit_sound(id, channel, sound, volume, attn, flags, pitch)
- return FMRES_SUPERCEDE;
- }
- // Zombie dies
- if (sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a')))
- {
- if (g_level[id]==1) ArrayGetString(zombie_sound_death1, g_zombieclass[id], sound, charsmax(sound))
- else ArrayGetString(zombie_sound_death2, g_zombieclass[id], sound, charsmax(sound))
- emit_sound(id, channel, sound, volume, attn, flags, pitch)
- return FMRES_SUPERCEDE;
- }
- // Zombie Attack
- new attack_type
- if (equal(sample,"weapons/knife_hitwall1.wav")) attack_type = 1
- else if (equal(sample,"weapons/knife_hit1.wav") ||
- equal(sample,"weapons/knife_hit3.wav") ||
- equal(sample,"weapons/knife_hit2.wav") ||
- equal(sample,"weapons/knife_hit4.wav") ||
- equal(sample,"weapons/knife_stab.wav")) attack_type = 2
- else if(equal(sample,"weapons/knife_slash1.wav") ||
- equal(sample,"weapons/knife_slash2.wav")) attack_type = 3
- if (attack_type)
- {
- new sound[64]
- if (attack_type == 1) ArrayGetString(sound_zombie_hitwall, random(ArraySize(sound_zombie_hitwall)), sound, charsmax(sound))
- else if (attack_type == 2) ArrayGetString(sound_zombie_attack, random(ArraySize(sound_zombie_attack)), sound, charsmax(sound))
- else if (attack_type == 3) ArrayGetString(sound_zombie_swing, random(ArraySize(sound_zombie_swing)), sound, charsmax(sound))
- emit_sound(id, channel, sound, volume, attn, flags, pitch)
- return FMRES_SUPERCEDE;
- }
- return FMRES_IGNORED;
- }
- // Forward Set Model
- public fw_SetModel(entity, const model[])
- {
- // We don't care
- if (strlen(model) < 8)
- return FMRES_IGNORED;
- // Narrow down our matches a bit
- //if (model[7] != 'w' || model[8] != '_')
- // return FMRES_IGNORED;
- // Get damage time of grenade
- static Float:dmgtime
- pev(entity, pev_dmgtime, dmgtime)
- // Grenade not yet thrown
- if (dmgtime == 0.0)
- return FMRES_IGNORED;
- // Get attacker
- static attacker
- attacker = pev(entity, pev_owner)
- // Get whether grenade's owner is a zombie
- if (g_zombie[attacker])
- {
- if (model[9] == 'h' && model[10] == 'e') // Zombie Bomb
- {
- // Set grenade type on the thrown grenade entity
- set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
- engfunc(EngFunc_SetModel, entity, ZOMBIEBOM_W_MODEL)
- return FMRES_SUPERCEDE
- }
- }
- return FMRES_IGNORED
- }
- // Ham Grenade Think Forward
- public fw_ThinkGrenade(entity)
- {
- // Invalid entity
- if (!pev_valid(entity)) return FMRES_IGNORED;
- // Get damage time of grenade
- static Float:dmgtime
- pev(entity, pev_dmgtime, dmgtime)
- // Check if it's time to go off
- if (dmgtime > get_gametime())
- return HAM_IGNORED;
- // Check if it's one of our custom nades
- switch (pev(entity, PEV_NADE_TYPE))
- {
- case NADE_TYPE_INFECTION:
- {
- zombiebom_explode(entity)
- }
- default: return HAM_IGNORED;
- }
- return HAM_SUPERCEDE;
- }
- public fw_primary_attack(ent)
- {
- new id = pev(ent,pev_owner)
- pev(id,pev_punchangle,cl_pushangle[id])
- return HAM_IGNORED
- }
- public fw_primary_attack_post(ent)
- {
- new id = pev(ent,pev_owner)
- if (!g_zombie[id] && g_level[id] && get_pcvar_num(cvar_recoil))
- {
- //Recoil Wpn
- new Float: xrecoil = str_to_float(XRECOIL[g_level[id]])
- new Float:push[3]
- pev(id,pev_punchangle,push)
- xs_vec_sub(push,cl_pushangle[id],push)
- xs_vec_mul_scalar(push,xrecoil,push)
- xs_vec_add(push,cl_pushangle[id],push)
- set_pev(id,pev_punchangle,push)
- }
- return HAM_IGNORED
- }
- /*================================================================================
- [Main Public]
- =================================================================================*/
- // Menu Weapons
- public menu_wpn(taskid)
- {
- new id = ID_MENUWPN
- if (!is_user_alive(id)) return PLUGIN_HANDLED
- menu_wpn_item(id, 1)
- give_weapons_bot(id)
- make_human_firt(id)
- if (task_exists(taskid)) remove_task(taskid)
- return PLUGIN_HANDLED
- }
- public menu_wpn_item(id, type)
- {
- if (g_zombie[id]) return PLUGIN_HANDLED
- // check size
- new size_id, size_name, fun_run[32]
- new size_pri = ArraySize(weapons_pri)
- new size_pri_name = ArraySize(weapons_pri_name)
- new size_sec = ArraySize(weapons_sec)
- new size_sec_name = ArraySize(weapons_sec_name)
- if (type == 1)
- {
- size_id = size_pri
- size_name = size_pri_name
- format(fun_run, 31, "menu_wpn_pri_handler")
- }
- else
- {
- size_id = size_sec
- size_name = size_sec_name
- format(fun_run, 31, "menu_wpn_sec_handler")
- }
- // create menu wpn
- new menuwpn_title[64]
- format(menuwpn_title, 63, "[NST Zombie] %L:", LANG_PLAYER, "ZB3_MENU_WPN_TITLE")
- new mHandleID = menu_create(menuwpn_title, fun_run)
- new item_id[32], item_name[32]
- for (new i = 0; i < size_id && i < size_name; i++)
- {
- if (type == 1)
- {
- ArrayGetString(weapons_pri, i, item_id, charsmax(item_id))
- ArrayGetString(weapons_pri_name, i, item_name, charsmax(item_name))
- }
- else
- {
- ArrayGetString(weapons_sec, i, item_id, charsmax(item_id))
- ArrayGetString(weapons_sec_name, i, item_name, charsmax(item_name))
- }
- menu_additem(mHandleID, item_name, item_id, 0)
- }
- menu_display(id, mHandleID, 0)
- return PLUGIN_HANDLED
- }
- public menu_wpn_pri_handler(id, menu, item)
- {
- if (item == MENU_EXIT)
- {
- menu_destroy(menu)
- return PLUGIN_HANDLED
- }
- new idwpn[32], name[32], access
- menu_item_getinfo(menu, item, access, idwpn, 31, name, 31, access)
- new idweapon = csw_name_to_id(idwpn)
- drop_weapons(id, 1)
- give_weapon(id, idweapon)
- menu_destroy(menu)
- // show menu wpn sec
- menu_wpn_item(id, 2)
- return PLUGIN_HANDLED
- }
- public menu_wpn_sec_handler(id, menu, item)
- {
- if (item == MENU_EXIT)
- {
- menu_destroy(menu)
- return PLUGIN_HANDLED
- }
- new idwpn[32], name[32], access
- menu_item_getinfo(menu, item, access, idwpn, 31, name, 31, access)
- new idweapon = csw_name_to_id(idwpn)
- drop_weapons(id, 2)
- give_weapon(id, idweapon)
- menu_destroy(menu)
- return PLUGIN_HANDLED
- }
- // Buy ammo
- public cmd_buy_ammo(id)
- {
- return PLUGIN_HANDLED
- }
- // Current Weapon
- public CurrentWeapon(id)
- {
- if (!is_user_alive(id)) return;
- // check weapons
- CheckWeapon(id)
- // Uclip
- new bot_uclip = get_pcvar_num(cvar_bot_uclip)
- if (is_user_bot(id) && bot_uclip && !g_zombie[id])
- {
- new WpnName[64]
- new idwpn = get_user_weapon(id)
- if ( idwpn && !(NOCLIP_WPN_BS & (1<<idwpn)) && get_weaponname(idwpn, WpnName, charsmax(WpnName)) )
- {
- if (bot_uclip == 1)
- {
- new ent = get_weapon_ent(id, idwpn)
- new uclip = max(1, MAXCLIP[idwpn])
- if (ent) cs_set_weapon_ammo(ent, uclip)
- //client_print(0, print_chat, "[%i]", ent)
- }
- else cs_set_user_bpammo(id, idwpn, 150)
- }
- }
- return;
- }
- //get weapon ent
- get_weapon_ent(id, weaponid)
- {
- static wname[32], weapon_ent
- get_weaponname(weaponid, wname, charsmax(wname))
- weapon_ent = fm_find_ent_by_owner(-1, wname, id)
- return weapon_ent
- }
- CheckWeapon(id)
- {
- if (!is_user_alive(id)) return;
- // zombie weapons
- new current_weapon = get_user_weapon(id)
- if (g_zombie[id] && current_weapon)
- {
- // remove weapon # knife & he
- if (current_weapon != CSW_KNIFE && current_weapon != CSW_HEGRENADE)
- {
- drop_weapons(id, get_weapon_type(current_weapon), 1)
- }
- // set model zonbie bom
- else if (current_weapon == CSW_HEGRENADE)
- {
- new idclass, v_model[64]
- idclass = g_zombieclass[id]
- ArrayGetString(zombiebom_viewmodel, idclass, v_model, charsmax(v_model))
- set_pev(id, pev_viewmodel2, v_model)
- set_pev(id, pev_weaponmodel2, ZOMBIEBOM_P_MODEL)
- }
- // set model knife zombie
- else
- {
- new model_wpn[64], idclass
- idclass = g_zombieclass[id]
- ArrayGetString(zombie_wpnmodel, idclass, model_wpn, charsmax(model_wpn))
- set_pev(id, pev_viewmodel2, model_wpn)
- set_pev(id, pev_weaponmodel2, "")
- }
- }
- }
- public reset_wpnmodel(id)
- {
- if (get_user_weapon(id) == CSW_KNIFE)
- {
- set_pev(id, pev_viewmodel2, "models/v_knife.mdl")
- set_pev(id, pev_weaponmodel2, "models/p_knife.mdl")
- }
- }
- // Make Zombie Random
- public make_random_zombie()
- {
- // Give Team player
- give_team_player()
- // check total player
- static total_players
- total_players = GetTotalPlayer(0, 1)
- if (!total_players) return;
- // Ramdom zombie
- static total_zombie, zombie_random, num_a, size_zb = 8
- num_a = total_players % size_zb
- total_zombie = (total_players-num_a)/size_zb
- if (num_a) total_zombie += 1
- if (!total_zombie) total_zombie = 1
- // get damage for zombie random
- new humans = total_players - total_zombie
- new zombie_random_dmg = (humans*1000)/total_zombie
- if (zombie_random_dmg < MIN_HEALTH_ZOMBIE_RANDOM) zombie_random_dmg = MIN_HEALTH_ZOMBIE_RANDOM
- else if (zombie_random_dmg > MAX_HEALTH_ZOMBIE_RANDOM) zombie_random_dmg = MAX_HEALTH_ZOMBIE_RANDOM
- // make random
- new zombies_name[64]
- for (new i = 1; i <= total_zombie; i++)
- {
- // get id zombie random
- zombie_random = fnGetRandomPlayer()
- //zombie_random = 1
- // set star health armor od random zombie
- g_level[zombie_random] = LEVEL_ZOMBIE_RANDOM
- // make zombie
- g_zombieclass[zombie_random] = random(class_count)
- make_zombie(zombie_random)
- // show menu class zombie
- show_menu_class_zombie(zombie_random)
- // give health
- g_start_health[zombie_random] = zombie_random_dmg
- g_star_armor[zombie_random] = zombie_random_dmg/2
- fm_set_user_health(zombie_random, g_start_health[zombie_random])
- fm_set_user_armor(zombie_random, g_star_armor[zombie_random])
- // play sound human death
- new sound[64], sex
- sex = nst_get_user_sex(zombie_random)
- if (sex == 2) ArrayGetString(sound_female_death, random(ArraySize(sound_female_death)), sound, charsmax(sound))
- else ArrayGetString(sound_human_death, random(ArraySize(sound_human_death)), sound, charsmax(sound))
- PlayEmitSound(zombie_random, CHAN_VOICE, sound)
- // play sound zombie coming
- ArrayGetString(sound_zombie_coming, random(ArraySize(sound_zombie_coming)), sound, charsmax(sound))
- PlaySound(0, sound)
- // Post user infect forward
- ExecuteForward(g_fwUserInfected, g_fwDummyResult, zombie_random, 0)
- // get hud msg zombies
- new zombie_name[32]
- get_user_name(zombie_random, zombie_name, 31)
- if (i==1) format(zombies_name, charsmax(zombies_name), "%s", zombie_name)
- else format(zombies_name, charsmax(zombies_name), "%s - %s", zombies_name, zombie_name)
- }
- // random hero
- // get hero random
- static num_aa, total_hero, total_human, hero_random, size_hero = 10
- total_human = GetTotalPlayer(4, 1)
- num_aa = total_human % size_hero
- total_hero = (total_human-num_aa)/size_hero
- if (num_aa>=(size_hero/2)) total_hero += 1
- // make hero random
- new heros_name[64]
- for (new i = 1; i <= total_hero; i++)
- {
- // get id hero random
- hero_random = fnGetRandomPlayer()
- //hero_random = 1
- // make hero
- make_hero(hero_random)
- // give nade
- give_nade(hero_random)
- // create effect
- EffectLevelUp(hero_random)
- // get hud msg
- new hero_name[32]
- get_user_name(hero_random, hero_name, 31)
- if (i==1) format(heros_name, charsmax(heros_name), "%s", hero_name)
- else format(heros_name, charsmax(heros_name), "%s - %s", heros_name, hero_name)
- }
- // make human
- make_human_team()
- // Hud Msg
- format(zombies_name, charsmax(zombies_name), "%L", LANG_PLAYER, "ZB3_NOTICE_FIRST_ZOMBIE", zombies_name)
- format(heros_name, charsmax(heros_name), "%L", LANG_PLAYER, "ZB3_NOTICE_FIRST_HERO", heros_name)
- new msg[100]
- format(msg, charsmax(msg), "%L", LANG_PLAYER, "ZB3_NOTICE_APPEAR")
- SendCenterText(0, msg)
- //set_hudmessage(255, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 5.0, 0.2, 0.2, -1)
- //ShowSyncHudMsg(0, g_HudMsg_Event, "%s", msg)
- // make supply box
- if (task_exists(TASK_SUPPLYBOX)) remove_task(TASK_SUPPLYBOX)
- set_task(SUPPLYBOX_TIME, "create_supply_box", TASK_SUPPLYBOX)
- // thong bao
- //client_print(0, print_chat, "Z[%i] H[%i] HU[%i]", total_zombie, total_hero, total_human)
- if (task_exists(TASK_MAKEZOMBIE)) remove_task(TASK_MAKEZOMBIE)
- }
- // menu class zombie
- public show_menu_class_zombie(id)
- {
- if (!g_zombie[id]) return PLUGIN_HANDLED
- // create menu wpn
- new menuwpn_title[64]
- format(menuwpn_title, 63, "[NST Zombie] %L:", LANG_PLAYER, "ZB3_MENU_CLASSZOMBIE_TITLE")
- new mHandleID = menu_create(menuwpn_title, "select_class_zombie")
- new class_name[32], class_id[32]
- for (new i = 0; i < class_count; i++)
- {
- ArrayGetString(zombie_name, i, class_name, charsmax(class_name))
- formatex(class_id, charsmax(class_name), "%i", i)
- menu_additem(mHandleID, class_name, class_id, 0)
- }
- menu_display(id, mHandleID, 0)
- return PLUGIN_HANDLED
- }
- public select_class_zombie(id, menu, item)
- {
- if (!g_zombie[id]) return PLUGIN_HANDLED
- if (item == MENU_EXIT)
- {
- menu_destroy(menu)
- give_zombiebom(id)
- return PLUGIN_HANDLED
- }
- new idclass[32], name[32], access
- menu_item_getinfo(menu, item, access, idclass, 31, name, 31, access)
- // set class zombie
- g_zombieclass[id] = str_to_num(idclass)
- make_zombie(id)
- give_zombiebom(id)
- menu_destroy(menu)
- //client_print(id, print_chat, "item: %i - id: %s", name, idclass)
- return PLUGIN_HANDLED
- }
- // Spawn a player [admin cmd]
- public cmd_respawn_hero(id, level, cid)
- {
- if (!cmd_access(id, level, cid, 2))
- return PLUGIN_HANDLED
- // Retrieve arguments
- static arg[32], player
- read_argv(1, arg, charsmax(arg))
- player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
- // Remove Respawn when Freetime
- if (g_newround || g_endround || !is_user_connected(player)) return PLUGIN_HANDLED
- reset_value(player)
- respawn_player_manually(player)
- make_hero(player)
- // give nade
- give_nade(player)
- return PLUGIN_HANDLED
- }
- // Spawn a player [admin cmd]
- public cmd_respawn_human(id, level, cid)
- {
- if (!cmd_access(id, level, cid, 2))
- return PLUGIN_HANDLED
- // Retrieve arguments
- static arg[32], player
- read_argv(1, arg, charsmax(arg))
- player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
- // Remove Respawn when Freetime
- if (g_newround || g_endround || !is_user_connected(player)) return PLUGIN_HANDLED
- reset_value(player)
- respawn_player_manually(player)
- make_human(player)
- // show menu weapons
- if (task_exists(player+TASK_MENUWPN)) remove_task(player+TASK_MENUWPN)
- set_task(0.1, "menu_wpn", player+TASK_MENUWPN)
- // give nade
- give_nade(player)
- return PLUGIN_HANDLED
- }
- // Spawn a player [admin cmd]
- public cmd_respawn_zombie(id, level, cid)
- {
- if (!cmd_access(id, level, cid, 2))
- return PLUGIN_HANDLED
- // Retrieve arguments
- static arg[32], player
- read_argv(1, arg, charsmax(arg))
- player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
- // Remove Respawn when Freetime
- if (g_newround || g_endround || !is_user_connected(player)) return PLUGIN_HANDLED
- reset_value(player)
- respawn_player_manually(player)
- // make zombie
- g_zombieclass[player] = random(class_count)
- make_zombie(player)
- // show menu class zombie
- show_menu_class_zombie(player)
- // play sound zombie coming
- new sound[64]
- ArrayGetString(sound_zombie_coming, random(ArraySize(sound_zombie_coming)), sound, charsmax(sound))
- PlaySound(0, sound)
- // Post user infect forward
- ExecuteForward(g_fwUserInfected, g_fwDummyResult, player, 0)
- return PLUGIN_HANDLED
- }
- // Zombie Respawn
- public zombie_respawn(taskid)
- {
- new id = ID_ZOMBIE_RESPAWN
- // Remove Respawn when Freetime
- if (g_newround || g_endround || !is_user_connected(id)) return PLUGIN_HANDLED
- g_respawning[id] = 0
- respawn_player_manually(id)
- make_zombie(id)
- // play sound zombie comback
- new sound[64]
- ArrayGetString(sound_zombie_comeback, random(ArraySize(sound_zombie_comeback)), sound, charsmax(sound))
- PlayEmitSound(id, CHAN_VOICE, sound)
- // Post user infect forward
- ExecuteForward(g_fwUserInfected, g_fwDummyResult, id, 0)
- if (task_exists(taskid)) remove_task(taskid)
- return PLUGIN_HANDLED
- }
- public zombie_respawn_effect(taskid)
- {
- new id = ID_ZOMBIE_RESPAWN_EF
- // Remove Respawn when Freetime
- if (g_newround || g_endround || !is_user_connected(id) || is_user_alive(id)) return;
- EffectZombieRespawn(id)
- if (task_exists(id+TASK_ZOMBIE_RESPAWN_EF)) remove_task(id+TASK_ZOMBIE_RESPAWN_EF)
- set_task(2.0, "zombie_respawn_effect", id+TASK_ZOMBIE_RESPAWN_EF)
- return;
- }
- public show_hud_client()
- {
- new message[101]
- // show score match
- new humans[32], zombies[32], humans_alive[32], zombies_alive[32], match_count[32]
- format(humans, 31, "%s", FixNumber(g_score_human))
- format(zombies, 31, "%s", FixNumber(g_score_zombie))
- format(humans_alive, 31, "%s", FixNumber(GetTotalPlayer(4, 1)))
- format(zombies_alive, 31, "%s", FixNumber(GetTotalPlayer(3, 1)))
- format(match_count, 31, "%s", FixNumber( g_score_human+g_score_zombie ))
- format(message, 100, "%L", LANG_PLAYER, "ZB3_HUD_SCORE_MATCH", humans, match_count, zombies, humans_alive, zombies_alive)
- set_hudmessage(255, 255, 255, HUD_SCORE_X, HUD_SCORE_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
- ShowSyncHudMsg(0, g_HudMsg_ScoreMatch, "%s", message)
- // show health & level
- for (new id = 1; id <= g_maxplayers; id++)
- {
- if (!is_user_alive(id)) continue;
- // show health
- if (g_zombie[id]) format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_HUD_ZOMBIE_HEALTH", get_user_health(id), g_level[id])
- else format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_HUD_HUMAN_HEALTH", get_user_health(id), g_level[id])
- set_hudmessage(0, 125, 0, HUD_HEALTH_X, HUD_HEALTH_Y, 0, 6.0, 2.0, 0.0, 0.0, -1)
- ShowSyncHudMsg(id, g_HudMsg_Health, "%s", message)
- if (!g_zombie[id])
- {
- new message_power[128], color[3]
- color[0] = get_color_level(id, 0)
- color[1] = get_color_level(id, 1)
- color[2] = get_color_level(id, 2)
- format(message_power, charsmax(message_power), "%L", LANG_PLAYER, "ZB3_HUD_HUMAN_POWER", g_level[id]*10+100)
- set_hudmessage(color[0], color[1], color[2], HUD_POWER_X, HUD_POWER_Y, 0, 6.0, 2.0, 0.0, 0.0, -1)
- ShowSyncHudMsg(id, g_HudMsg_Power, "%s", message_power)
- }
- }
- }
- // HUD LEVEL SCREENT
- show_player_level(id)
- {
- if (!is_user_alive(id)) return;
- if ((g_level_delay[id] + get_pcvar_float(cvar_level_deplay)) > get_gametime()) return;
- g_level_delay[id] = get_gametime()
- g_level_effect[id] += 1
- if (g_level_effect[id]>8) g_level_effect[id] = 1
- new level, sprname[64]
- if (g_zombie[id])
- {
- new MaxEvo = MAX_EVOLUTION/MAX_LEVEL_ZOMBIE
- level = min(g_evolution[id], MaxEvo)
- if (level) format(sprname, charsmax(sprname), "zombie_level_%i%i", level, g_level_effect[id])
- else format(sprname, charsmax(sprname), "zombie_level_%i", level)
- }
- else
- {
- level = min(g_level[id], MAX_LEVEL_HUMAN)
- format(sprname, charsmax(sprname), "human_level_%i", level)
- }
- message_begin(MSG_ONE, g_msgScenario, _, id)
- write_byte(1)// Active
- write_string(sprname)// Sprite
- write_byte(1000)// Alpha
- write_short(3)// FlashRate
- write_short(0)// Unknown
- message_end()
- }
- // HUD ICON
- show_hud_icon(id)
- {
- if (!get_pcvar_num(cvar_icon) || !is_user_alive(id) || g_zombie[id]) return;
- if ((g_icon_delay[id] + get_pcvar_float(cvar_icon_deplay)) > get_gametime()) return;
- g_icon_delay[id] = get_gametime()
- // Hud Icon Suppplybox
- if (supplybox_count)
- {
- new i = 1, box_ent
- while (i<=supplybox_count)
- {
- box_ent = supplybox_ent[i]
- create_icon_origin(id, box_ent, SUPPLYBOX_ICON_IDSPR)
- i++
- }
- }
- // Hud Icon Hero
- static Players[32], iNum
- get_players(Players, iNum, "a")
- for (new i = 0; i < iNum; ++i) if(id != Players[i])
- {
- new hero = Players[i]
- if (!g_hero[hero]) continue;
- create_icon_origin(id, hero, HERO_ICON_IDSPR)
- }
- }
- stock create_icon_origin(id, ent, sprite)
- {
- if (!pev_valid(ent)) return;
- new Float:fMyOrigin[3]
- entity_get_vector(id, EV_VEC_origin, fMyOrigin)
- new target = ent
- new Float:fTargetOrigin[3]
- entity_get_vector(target, EV_VEC_origin, fTargetOrigin)
- fTargetOrigin[2] += 40.0
- if (!is_in_viewcone(id, fTargetOrigin)) return;
- new Float:fMiddle[3], Float:fHitPoint[3]
- xs_vec_sub(fTargetOrigin, fMyOrigin, fMiddle)
- trace_line(-1, fMyOrigin, fTargetOrigin, fHitPoint)
- new Float:fWallOffset[3], Float:fDistanceToWall
- fDistanceToWall = vector_distance(fMyOrigin, fHitPoint) - 10.0
- normalize(fMiddle, fWallOffset, fDistanceToWall)
- new Float:fSpriteOffset[3]
- xs_vec_add(fWallOffset, fMyOrigin, fSpriteOffset)
- new Float:fScale, Float:fDistanceToTarget = vector_distance(fMyOrigin, fTargetOrigin)
- fScale = 0.01 * fDistanceToWall
- new scale = floatround(fScale)
- scale = max(scale, 1)
- scale = min(scale, get_pcvar_num(cvar_icon_size))
- scale = max(scale, 1)
- if (is_user_alive(ent) && g_hero[ent] && (floatround(fDistanceToWall)+10) == floatround(fDistanceToTarget)) return;
- te_sprite(id, fSpriteOffset, sprite, scale, get_pcvar_num(cvar_icon_light))
- //client_print(id, print_chat, "W[%i]P[%i]S[%i]", floatround(fDistanceToWall), floatround(fDistanceToTarget), scale)
- }
- stock te_sprite(id, Float:origin[3], sprite, scale, brightness)
- {
- message_begin(MSG_ONE, SVC_TEMPENTITY, _, id)
- write_byte(TE_SPRITE)
- write_coord(floatround(origin[0]))
- write_coord(floatround(origin[1]))
- write_coord(floatround(origin[2]))
- write_short(sprite)
- write_byte(scale)
- write_byte(brightness)
- message_end()
- }
- stock normalize(Float:fIn[3], Float:fOut[3], Float:fMul)
- {
- new Float:fLen = xs_vec_len(fIn)
- xs_vec_copy(fIn, fOut)
- fOut[0] /= fLen, fOut[1] /= fLen, fOut[2] /= fLen
- fOut[0] *= fMul, fOut[1] *= fMul, fOut[2] *= fMul
- }
- // Nightvision toggle
- public cmd_nightvision(id)
- {
- if (!is_user_alive(id)) return PLUGIN_HANDLED;
- if (!g_nvg[id])
- {
- g_nvg[id] = 1
- if (g_zombie[id])
- {
- remove_task(id+TASK_NVISION)
- set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
- }
- else set_user_gnvision(id, g_nvg[id])
- PlaySound(id, sound_nvg[1])
- }
- else
- {
- g_nvg[id] = 0
- if (g_zombie[id])
- {
- remove_task(id+TASK_NVISION)
- set_user_screen_fade(id)
- }
- else set_user_gnvision(id, g_nvg[id])
- PlaySound(id, sound_nvg[0])
- }
- return PLUGIN_HANDLED;
- }
- turn_off_nvg(id)
- {
- if (!is_user_connected(id)) return;
- g_nvg[id] = 0
- remove_task(id+TASK_NVISION)
- set_user_screen_fade(id)
- set_user_gnvision(id, 0)
- }
- // Custom Night Vision
- public set_user_nvision(taskid)
- {
- new id = ID_NVISION
- if (!is_user_alive(id)) return;
- // Get player's origin
- static origin[3]
- get_user_origin(id, origin)
- // Nightvision message
- message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
- write_byte(TE_DLIGHT) // TE id
- write_coord(origin[0]) // x
- write_coord(origin[1]) // y
- write_coord(origin[2]) // z
- write_byte(get_pcvar_num(cvar_nvg_zombie_size)) // radius
- write_byte(get_pcvar_num(cvar_nvg_zombie_color[0])) // r
- write_byte(get_pcvar_num(cvar_nvg_zombie_color[1])) // g
- write_byte(get_pcvar_num(cvar_nvg_zombie_color[2])) // b
- write_byte(2) // life
- write_byte(0) // decay rate
- message_end()
- // screen_fade
- set_user_screen_fade(id)
- }
- set_user_gnvision(id, toggle)
- {
- // Toggle NVG message
- message_begin(MSG_ONE, g_msgNVGToggle, _, id)
- write_byte(toggle) // toggle
- message_end()
- }
- set_user_screen_fade(id)
- {
- if (!is_user_connected(id)) return;
- new alpha
- if (g_nvg[id]) alpha = get_pcvar_num(cvar_nvg_zombie_alpha)
- else alpha = 0
- message_begin(MSG_ONE, g_msgScreenFade, _, id)
- write_short(0) // duration
- write_short(0) // hold time
- write_short(FFADE_STAYOUT) // fade type
- write_byte(get_pcvar_num(cvar_nvg_zombie_color[0])) // r
- write_byte(get_pcvar_num(cvar_nvg_zombie_color[1])) // g
- write_byte(get_pcvar_num(cvar_nvg_zombie_color[2])) // b
- write_byte(alpha) // alpha
- message_end()
- }
- // Other
- public qq(id)
- {
- client_print(id, print_chat, "L[%i]", ArrayGetCell(zombie_modelindex, get_pcvar_num(cvar_knockback)))
- }
- // ##################### SupplyBox #####################
- // SupplyBox Pickup
- public fw_Touch(ent, id)
- {
- if (!pev_valid(ent) || !is_user_alive(id) || g_zombie[id] || g_supplybox_wait[id]) return FMRES_IGNORED
- new classname[32]
- entity_get_string(ent,EV_SZ_classname,classname,31)
- //client_print(id, print_chat, "[%s][%i]", classname, ent)
- if (equal(classname, SUPPLYBOX_CLASSNAME))
- {
- // get item from supply pickup
- new item_id, item[64]
- item_id = entity_get_int(ent, EV_INT_iuser1)
- ArrayGetString(supplybox_item, item_id, item, charsmax(item))
- // give item for player
- give_weapons_item(id, item)
- // play sound
- PlayEmitSound(id, CHAN_VOICE, SUPPLYBOX_SOUND_PICKUP)
- // remove ent in supplybox_ent
- new num_box = entity_get_int(ent, EV_INT_iuser2)
- supplybox_ent[num_box] = 0
- remove_entity(ent)
- // waiting
- g_supplybox_wait[id] = 1
- if (task_exists(id+TASK_SUPPLYBOX_WAIT)) remove_task(id+TASK_SUPPLYBOX_WAIT)
- set_task(2.0, "remove_supplybox_wait", id+TASK_SUPPLYBOX_WAIT)
- }
- return FMRES_IGNORED
- }
- public remove_supplybox_wait(taskid)
- {
- new id = ID_SUPPLYBOX_WAIT
- g_supplybox_wait[id] = 0
- if (task_exists(taskid)) remove_task(taskid)
- }
- give_weapons_item(id, item[])
- {
- new item_type = supplybox_get_type_item(item)
- // give cs weapons default
- if (item_type == NSTZB_ITEM_WPNDEFAULT)
- {
- new idweapon = csw_name_to_id(item)
- new wpn_type = get_weapon_type(idweapon)
- if (wpn_type==1 || wpn_type==2) drop_weapons(id, wpn_type)
- give_weapon(id, idweapon)
- }
- // give weapon mod nst wpn
- else if (item_type == NSTZB_ITEM_NSTWPN)
- {
- replace(item, 32, "nst_", "")
- nst_wpn_give_weapon(id, item)
- }
- // give nade
- else if (item_type == NSTZB_ITEM_AMMONADE)
- {
- give_nade(id)
- give_ammo(id)
- }
- //client_print(0, print_chat, "[%i]", item_type)
- }
- supplybox_get_type_item(item[])
- {
- new left[64], right[64], type
- strbreak(item, left, 4, right, 63)
- if (equali(left, "csw_")) type = NSTZB_ITEM_WPNDEFAULT
- else if (equali(left, "nst_")) type = NSTZB_ITEM_NSTWPN
- else if (equali(item, "item_ammonade")) type = NSTZB_ITEM_AMMONADE
- return type
- }
- // Create SupplyBox
- public create_supply_box()
- {
- // check max supplybox
- if (supplybox_count>=SUPPLYBOX_MAX || g_newround || g_endround) return;
- // continue create supply
- if (task_exists(TASK_SUPPLYBOX)) remove_task(TASK_SUPPLYBOX)
- set_task(SUPPLYBOX_TIME, "create_supply_box", TASK_SUPPLYBOX)
- if (get_total_supplybox()>=SUPPLYBOX_TOTAL_IN_TIME) return;
- // create model
- g_supplybox_num = 0
- create_supply_box_model()
- // play sound
- PlaySound(0, SUPPLYBOX_SOUND_DROP)
- // show hudtext
- new message[100]
- format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_SUPPLYBOX")
- SendCenterText(0, message)
- // show text help
- if (task_exists(TASK_SUPPLYBOX_HELP)) remove_task(TASK_SUPPLYBOX_HELP)
- set_task(2.0, "supply_box_help", TASK_SUPPLYBOX_HELP)
- // create 2 supply box
- if (task_exists(TASK_SUPPLYBOX_MODEL)) remove_task(TASK_SUPPLYBOX_MODEL)
- set_task(0.5, "create_supply_box_model", TASK_SUPPLYBOX_MODEL, _, _, "b")
- }
- get_total_supplybox()
- {
- new total
- for (new i=1; i<=supplybox_count; i++)
- {
- if (supplybox_ent[i]) total += 1
- }
- return total;
- }
- public create_supply_box_model()
- {
- // check max supplybox
- if (supplybox_count>=SUPPLYBOX_MAX || get_total_supplybox()>=SUPPLYBOX_TOTAL_IN_TIME || g_newround || g_endround)
- {
- remove_task(TASK_SUPPLYBOX_MODEL)
- return;
- }
- // supply box count
- supplybox_count += 1
- g_supplybox_num += 1
- // get item in SupplyBox
- new item = random(ArraySize(supplybox_item))
- // get random model supplybox
- static model_w[64]
- ArrayGetString(supplybox_models, random(ArraySize(supplybox_models)), model_w, charsmax(model_w))
- // create supply box
- new ent_box = create_entity("info_target")
- entity_set_string(ent_box, EV_SZ_classname, SUPPLYBOX_CLASSNAME)
- entity_set_model(ent_box,model_w)
- entity_set_size(ent_box,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
- entity_set_int(ent_box,EV_INT_solid,1)
- entity_set_int(ent_box,EV_INT_movetype,6)
- entity_set_int(ent_box, EV_INT_iuser1, item)
- entity_set_int(ent_box, EV_INT_iuser2, supplybox_count)
- //entity_set_vector(ent_box,EV_VEC_origin,origin)
- // set origin
- if (g_spawnCount_box) do_random_spawn_box(ent_box)
- else if (g_spawnCount) do_random_spawn(ent_box)
- // give ent SupplyBox
- supplybox_ent[supplybox_count] = ent_box
- // remove task
- if ((g_supplybox_num>=SUPPLYBOX_NUM) && task_exists(TASK_SUPPLYBOX_MODEL)) remove_task(TASK_SUPPLYBOX_MODEL)
- }
- // SupplyBox Help
- public supply_box_help()
- {
- new message[100]
- format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_SUPPLYBOX_HELP")
- SendCenterText(0, message)
- }
- // Remove SupplyBox
- remove_supplybox()
- {
- remove_ent_by_class(SUPPLYBOX_CLASSNAME)
- new supplybox_ent_reset[MAX_SUPPLYBOX]
- supplybox_ent = supplybox_ent_reset
- }
- // ##################### RADAR SCAN #####################
- public radar_scan()
- {
- for (new id=1; id<=g_maxplayers; id++)
- {
- if (!is_user_alive(id)) continue;
- // scan supply box
- if (!supplybox_count) continue;
- if (g_zombie[id]) continue;
- new i = 1, next_ent
- while(i<=supplybox_count)
- {
- next_ent = supplybox_ent[i]
- if (next_ent)
- {
- static Float:origin[3]
- pev(next_ent, pev_origin, origin)
- message_begin(MSG_ONE_UNRELIABLE, g_msgHostagePos, {0,0,0}, id)
- write_byte(id)
- write_byte(i)
- write_coord(fnFloatToNum(origin[0]))
- write_coord(fnFloatToNum(origin[1]))
- write_coord(fnFloatToNum(origin[2]))
- message_end()
- message_begin(MSG_ONE_UNRELIABLE, g_msgHostageK, {0,0,0}, id)
- write_byte(i)
- message_end()
- //client_print(id, print_chat, "[%i] [%i] [%i] [%i]", next_ent, origin[0], origin[1], origin[2])
- }
- i++
- }
- //client_print(id, print_chat, "[%i][%i]", supplybox_count, i)
- }
- }
- // Register Ham Forwards for CZ bots
- public register_ham_czbots(id)
- {
- // Make sure it's a CZ bot and it's still connected
- if (g_hamczbots || !is_user_connected(id) || !get_pcvar_num(cvar_botquota))
- return;
- RegisterHamFromEntity(Ham_Spawn, id, "fw_PlayerSpawn_Post", 1)
- RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
- RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
- // Ham forwards for CZ bots succesfully registered
- g_hamczbots = true
- // If the bot has already spawned, call the forward manually for him
- if (is_user_alive(id)) fw_PlayerSpawn_Post(id)
- }
- /*================================================================================
- [Main Function]
- =================================================================================*/
- // Make Human Function
- make_human_firt(id)
- {
- if (!is_user_alive(id)) return;
- fm_set_user_health(id, HUMAN_HEALTH)
- fm_set_user_armor(id, HUMAN_ARMOR)
- set_pev(id, pev_gravity, HUMAN_GRAVITY)
- //show_level(id)
- turn_off_nvg(id)
- }
- make_human(id)
- {
- if (!is_user_alive(id)) return;
- // set value
- g_zombie[id] = 0
- g_hero[id] = 0
- fm_cs_set_user_team(id, FM_CS_TEAM_CT)
- fm_set_user_health(id, HUMAN_HEALTH)
- fm_set_user_armor(id, HUMAN_ARMOR)
- set_pev(id, pev_gravity, HUMAN_GRAVITY)
- // set model
- set_model_for_player(id)
- //show_level(id)
- turn_off_nvg(id)
- }
- // Make Hero Function
- make_hero(id)
- {
- if (!is_user_alive(id)) return;
- // set value
- g_zombie[id] = 0
- g_hero[id] = 1
- // set info
- fm_cs_set_user_team(id, FM_CS_TEAM_CT)
- fm_set_user_health(id, HERO_HEALTH)
- fm_set_user_armor(id, HERO_ARMOR)
- set_pev(id, pev_gravity, HERO_GRAVITY)
- nst_set_user_sex(id, 1)
- nst_set_user_hand(id, 0)
- // set model
- set_model_for_player(id)
- // Drop previous weapons
- drop_weapons(id, 1)
- drop_weapons(id, 2)
- // give weapons
- new weapon[32]
- for (new i = 0; i < ArraySize(hero_weapons); i++)
- {
- ArrayGetString(hero_weapons, i, weapon, charsmax(weapon))
- give_weapons_item(id, weapon)
- }
- // show spr
- ShowStatusIcon(id, 1)
- if (task_exists(id+TASK_STATUSICON)) remove_task(id+TASK_STATUSICON)
- set_task(get_pcvar_float(cvar_time_show_spr), "Task_HideStatusIcon", id+TASK_STATUSICON)
- //show_level(id)
- turn_off_nvg(id)
- }
- // Make a Zombie Function
- make_zombie(id)
- {
- if (!is_user_alive(id)) return;
- // set value
- g_hero[id] = 0
- g_zombie[id] = 1
- if (!g_level[id]) g_level[id] = 1
- // Remove survivor's aura (bugfix)
- set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_BRIGHTLIGHT)
- // Remove spawn protection (bugfix)
- set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_NODRAW)
- // Remove any zoom (bugfix)
- cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
- // Remove armor
- set_pev(id, pev_armorvalue, 0.0)
- // Drop previous weapons
- if (get_pcvar_num(cvar_drop_weapons_infected))
- {
- drop_weapons(id, 1)
- drop_weapons(id, 2)
- }
- else
- {
- drop_weapons(id, 1, 1)
- drop_weapons(id, 2, 1)
- }
- // Strip off from weapons
- fm_strip_user_weapons(id)
- fm_give_item(id, "weapon_knife")
- // give zombie bom
- //give_zombiebom(id)
- // set team
- fm_cs_set_user_team(id, FM_CS_TEAM_T)
- // give info zombie
- new Float:gravity, Float:speed
- gravity = ArrayGetCell(zombie_gravity, g_zombieclass[id])
- speed = ArrayGetCell(zombie_speed, g_zombieclass[id])
- set_pev(id, pev_gravity, gravity)
- set_pev(id, pev_maxspeed, speed)
- UpdateHealthZombie(id)
- // set model
- set_model_for_player(id)
- // create effects
- infection_effects(id)
- // show level
- //show_level(id)
- // check model
- CurrentWeapon(id)
- // Show Score of Match
- //ShowScoreMatch()
- // turn off flashlight
- turn_off_flashlight(id)
- // nvg
- turn_off_nvg(id)
- if (get_pcvar_num(cvar_nvg_zombie_give)) cmd_nightvision(id)
- }
- set_model_for_player(id)
- {
- if (!is_user_connected(id)) return;
- if (g_zombie[id])
- {
- // set model player
- new model_view[64], model_index, idclass
- idclass = g_zombieclass[id]
- if (g_level[id]==1)
- {
- ArrayGetString(zombie_viewmodel_host, idclass, model_view, charsmax(model_view))
- model_index = ArrayGetCell(zombie_modelindex_host, idclass)
- }
- else
- {
- ArrayGetString(zombie_viewmodel_origin, idclass, model_view, charsmax(model_view))
- model_index = ArrayGetCell(zombie_modelindex_origin, idclass)
- }
- nst_set_user_model(id, model_view)
- if (get_zombie_set_modelindex(id)) nst_set_user_model_index(id, model_index)
- else nst_reset_user_model_index(id)
- //client_print(id, print_chat, "[%s][%s]", model_view, model_wpn)
- }
- else if (g_hero[id])
- {
- nst_set_user_model(id, HERO_MODEL)
- }
- else
- {
- nst_reset_user_model(id)
- }
- }
- get_zombie_set_modelindex(id)
- {
- if (!g_zombie[id]) return 0;
- new modelindex = ArrayGetCell(zombie_modelindex, g_zombieclass[id])
- if ( (modelindex==3) || (modelindex==2 && g_level[id]>1) || (modelindex==1 && g_level[id]==1) ) return 1;
- else return 0;
- return 0;
- }
- zombie_infection_human(attacker, victim)
- {
- // show Msg Death
- SendDeathMsg(attacker, victim)
- FixDeadAttrib(victim)
- // update frags of attacker and deaths of victim
- UpdateFrags(attacker, 1)
- UpdateDeaths(victim, 1)
- // update evolution of zombie attacker
- new xlevel, evo_up
- if (g_hero[victim]) xlevel = 4
- else xlevel = 1
- if (g_level[attacker]==1) evo_up = xlevel*3
- else if (g_level[attacker]==2) evo_up = xlevel*2
- UpdateEvolution(attacker, evo_up)
- // make zombie infection
- g_evolution[victim] = 0
- g_level[victim] = 1
- g_start_health[victim] = get_user_health(attacker)*1/2
- g_star_armor[victim] = get_user_armor(attacker)*1/2
- // make zombie
- g_zombieclass[victim] = random(class_count)
- make_zombie(victim)
- // show menu class zombie
- show_menu_class_zombie(victim)
- // remove glow of victim
- fm_set_rendering(victim)
- // play sound human death
- new sound[64], sex
- sex = nst_get_user_sex(victim)
- if (sex == 2) ArrayGetString(sound_female_death, random(ArraySize(sound_female_death)), sound, charsmax(sound))
- else ArrayGetString(sound_human_death, random(ArraySize(sound_human_death)), sound, charsmax(sound))
- PlayEmitSound(victim, CHAN_VOICE, sound)
- // play sound zombie coming
- ArrayGetString(sound_zombie_coming, random(ArraySize(sound_zombie_coming)), sound, charsmax(sound))
- PlaySound(0, sound)
- // Post user infect forward
- ExecuteForward(g_fwUserInfected, g_fwDummyResult, victim, attacker)
- //client_print(attacker, print_chat, "L[%i] E[%i]", g_level[attacker], g_evolution[attacker])
- //client_print(victim, print_chat, "DA[%i] DV[%i]", get_user_health(attacker), g_start_health[victim])
- //client_print(victim, print_chat, "AA[%i] AV[%i]", get_user_armor(attacker), g_star_armor[victim])
- }
- human_kill_zombie(killer, victim, weaponid)
- {
- // update zombie die
- g_zombie_die[victim] ++
- // check killer is human
- new human
- if (is_user_connected(killer) && killer!=victim) human = killer
- // respawn zombie if not headshot
- if (weaponid != CSW_KNIFE)
- {
- g_respawning[victim] = 1
- // Set time respawn zombie
- if (task_exists(victim+TASK_ZOMBIE_RESPAWN)) remove_task(victim+TASK_ZOMBIE_RESPAWN)
- set_task(float(RESPAWN_TIME_WAIT), "zombie_respawn", victim+TASK_ZOMBIE_RESPAWN)
- // effect
- if (task_exists(victim+TASK_ZOMBIE_RESPAWN_EF)) remove_task(victim+TASK_ZOMBIE_RESPAWN_EF)
- set_task(0.5, "zombie_respawn_effect", victim+TASK_ZOMBIE_RESPAWN_EF)
- // Run BarTime
- run_bartime(victim, RESPAWN_TIME_WAIT)
- // fix frags of human & deaths of zombie
- if (human)
- {
- //UpdateFrags(killer, -1)
- UpdateDeaths(victim, -1)
- }
- }
- // else zombie is death
- else
- {
- // Show Score of Match
- //ShowScoreMatch()
- }
- // update level of human and show effect
- if (human)
- {
- UpdateLevelTeamHuman()
- }
- //client_print(killer, print_chat, "L[%i]", g_level[killer])
- }
- // reset value of player
- reset_value(id)
- {
- if (task_exists(id+TASK_GLOWSHELL)) remove_task(id+TASK_GLOWSHELL)
- if (task_exists(id+TASK_SPAWN)) remove_task(id+TASK_SPAWN)
- if (task_exists(id+TASK_MENUWPN)) remove_task(id+TASK_MENUWPN)
- if (task_exists(id+TASK_ZOMBIE_RESPAWN)) remove_task(id+TASK_ZOMBIE_RESPAWN)
- if (task_exists(id+TASK_ZOMBIE_RESPAWN_EF)) remove_task(id+TASK_ZOMBIE_RESPAWN_EF)
- if (task_exists(id+TASK_NVISION)) remove_task(id+TASK_NVISION)
- g_level[id] = 0
- g_zombie[id] = 0
- g_hero[id] = 0
- g_evolution[id] = 0
- g_dmg_attack[id] = 0
- g_start_health[id] = 0
- g_star_armor[id] = 0
- g_buyammo[id] = 0
- g_restore_health[id] = 0
- g_respawning[id] = 0
- g_nvg[id] = 0
- g_supplybox_wait[id] = 0
- g_zombie_weak[id] = 0
- g_zombie_die[id] = 0
- if (is_user_alive(id))
- {
- fm_set_rendering(id)
- set_pev(id, pev_gravity, 1.0)
- }
- }
- // Restore health for zombie
- zombie_restore_health(id)
- {
- if (!g_zombie[id] || g_newround || g_endround) return;
- static Float:velocity[3]
- pev(id, pev_velocity, velocity)
- if (!velocity[0] && !velocity[1] && !velocity[2])
- {
- if (!g_restore_health[id]) g_restore_health[id] = get_systime()
- }
- else g_restore_health[id] = 0
- if (g_restore_health[id])
- {
- new rh_time = get_systime() - g_restore_health[id]
- if (rh_time == RESTORE_HEALTH_TIME+1 && get_user_health(id) < g_start_health[id])
- {
- // get health add
- new health_add
- if (g_level[id]==1) health_add = RESTORE_HEALTH_DMG_LV1
- else health_add = RESTORE_HEALTH_DMG_LV2
- // get health new
- new health_new = get_user_health(id)+health_add
- health_new = min(health_new, g_start_health[id])
- // set health
- fm_set_user_health(id, health_new)
- g_restore_health[id] += 1
- // effect
- SendMsgDamage(id)
- EffectRestoreHealth(id)
- // play sound heal
- new sound_heal[64]
- ArrayGetString(zombie_sound_heal, g_zombieclass[id], sound_heal, charsmax(sound_heal))
- PlaySound(id, sound_heal)
- }
- }
- }
- // Zombie Weak
- zombie_weak(id)
- {
- // check value
- if (!g_zombie[id] || !get_pcvar_num(cvar_zombie_weak)) return;
- // set zombie Weak
- if (get_user_health(id)<=get_pcvar_num(cvar_zombie_weak_dmg) && !g_zombie_weak[id])
- {
- g_zombie_weak[id] = 1
- }
- else if (get_user_health(id)>get_pcvar_num(cvar_zombie_weak_dmg) && g_zombie_weak[id])
- {
- fm_set_rendering(id)
- g_zombie_weak[id] = 0
- }
- // repeat glow
- if (g_zombie_weak[id])
- {
- g_zombie_weak[id] += 1
- new glow_num = g_zombie_weak[id] % max(2, get_pcvar_num(cvar_zombie_flash))
- if (glow_num) zombie_weak_create_glow(id)
- else fm_set_rendering(id)
- //client_print(0, print_chat, "AT[%i]", glow_num)
- }
- }
- zombie_weak_create_glow(id)
- {
- new color[3]
- color[0] = get_pcvar_num(cvar_zombie_weak_color[0])
- color[1] = get_pcvar_num(cvar_zombie_weak_color[1])
- color[2] = get_pcvar_num(cvar_zombie_weak_color[2])
- fm_set_rendering(id, kRenderFxGlowShell, color[0], color[1], color[2], kRenderNormal, 0)
- }
- // ZombieBom Grenade Explosion
- zombiebom_explode(ent)
- {
- // Round ended (bugfix)
- if (g_newround || g_endround) return;
- // Get origin
- static Float:originF[3]
- pev(ent, pev_origin, originF)
- // Make the explosion
- EffectZombieBomExp(ent)
- // explode sound
- engfunc(EngFunc_EmitSound, ent, CHAN_WEAPON, ZOMBIEBOM_SOUND_EXP, 1.0, ATTN_NORM, 0, PITCH_NORM)
- // Get attacker
- //static attacker
- //attacker = pev(ent, pev_owner)
- // Collisions
- static victim
- victim = -1
- new Float:fOrigin[3],Float:fDistance,Float:fDamage
- while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, ZOMBIEBOM_RADIUS)) != 0)
- {
- // Only effect alive non-spawnprotected humans
- if (!is_user_alive(victim))
- continue;
- // get value
- pev(victim, pev_origin, fOrigin)
- fDistance = get_distance_f(fOrigin, originF)
- fDamage = ZOMBIEBOM_POWER - floatmul(ZOMBIEBOM_POWER, floatdiv(fDistance, ZOMBIEBOM_RADIUS))//get the damage value
- fDamage *= estimate_take_hurt(originF, victim, 0)//adjust
- if ( fDamage < 0 )
- continue
- // create effect
- manage_effect_action(victim, fOrigin, originF, fDistance, fDamage * 8.0)
- continue;
- }
- // Get rid of the grenade
- engfunc(EngFunc_RemoveEntity, ent)
- //client_print(0, print_chat, "AT[%i]", attacker)
- }
- EffectZombieBomExp(id)
- {
- static Float:origin[3];
- pev(id,pev_origin,origin);
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(TE_EXPLOSION); // TE_EXPLOSION
- write_coord(floatround(origin[0])); // origin x
- write_coord(floatround(origin[1])); // origin y
- write_coord(floatround(origin[2])); // origin z
- write_short(ZOMBIEBOM_IDSPRITES_EXP); // sprites
- write_byte(40); // scale in 0.1's
- write_byte(30); // framerate
- write_byte(14); // flags
- message_end(); // message end
- }
- manage_effect_action(iEnt, Float:fEntOrigin[3], Float:fPoint[3], Float:fDistance, Float:fDamage)
- {
- //return 1
- new Float:Velocity[3]
- pev(iEnt, pev_velocity, Velocity)
- new Float:fTime = floatdiv(fDistance, fDamage)
- new Float:fVelocity[3]
- fVelocity[0] = floatdiv((fEntOrigin[0] - fPoint[0]), fTime) + Velocity[0]*0.5
- fVelocity[1] = floatdiv((fEntOrigin[1] - fPoint[1]), fTime) + Velocity[1]*0.5
- fVelocity[2] = floatdiv((fEntOrigin[2] - fPoint[2]), fTime) + Velocity[2]*0.5
- set_pev(iEnt, pev_velocity, fVelocity)
- return 1
- }
- give_ammo(id)
- {
- new weapons[32], num, i, idwpn, ammo
- num = 0
- get_user_weapons(id, weapons, num)
- for (i = 0; i < num; i++)
- {
- idwpn = weapons[i]
- ammo = get_ammo_buywpn(idwpn)
- if (ammo>2)
- {
- show_hud_ammo(id, idwpn, ammo)
- cs_set_user_bpammo(id, idwpn, ammo)
- }
- }
- // set full ammo for nst wpn
- nst_wpn_set_fullammo(id)
- }
- // Give Nade for player
- give_nade(id)
- {
- // Get user weapons
- new weapons[32], num, i, weaponid
- num = 0 // reset passed weapons count (bugfix)
- get_user_weapons(id, weapons, num)
- // Loop through them and drop primaries or secondaries
- for (i = 0; i < num; i++)
- {
- // Prevent re-indexing the array
- weaponid = weapons[i]
- new idnade_str[32], idnade_num
- for (new i = 0; i < ArraySize(weapons_nade); i++)
- {
- ArrayGetString(weapons_nade, i, idnade_str, charsmax(idnade_str))
- idnade_num = csw_name_to_id(idnade_str)
- if (weaponid != idnade_num) give_weapon(id, idnade_num)
- }
- }
- }
- give_zombiebom(id)
- {
- // Get user weapons
- new weapons[32], num, i, weaponid
- num = 0 // reset passed weapons count (bugfix)
- get_user_weapons(id, weapons, num)
- // Loop through them and drop primaries or secondaries
- for (i = 0; i < num; i++)
- {
- weaponid = weapons[i]
- if (weaponid != CSW_HEGRENADE) fm_give_item(id, WEAPONENTNAMES[CSW_HEGRENADE])
- }
- }
- // StatusIcon
- ShowStatusIcon(id, idspr)
- {
- StatusIcon(id, idspr, 1)
- }
- HideStatusIcon(id)
- {
- for (new i = 1; i <= 1; i++)
- {
- StatusIcon(id, i, 0)
- }
- }
- StatusIcon(id, idspr, run)
- {
- message_begin(MSG_ONE, g_msgStatusIcon, {0,0,0}, id);
- write_byte(run); // status (0=hide, 1=show, 2=flash)
- write_string(GetStatusIconName(idspr)); // sprite name
- message_end();
- }
- GetStatusIconName(idspr)
- {
- new spr_name[33]
- switch (idspr)
- {
- case 1: spr_name = "g_hero"
- }
- return spr_name
- }
- public Task_HideStatusIcon(taskid)
- {
- new id = ID_STATUSICON
- HideStatusIcon(id)
- if (task_exists(taskid)) remove_task(taskid)
- }
- // Infection special effects
- infection_effects(id)
- {
- // Get player's origin
- static origin[3]
- get_user_origin(id, origin)
- // Tracers?
- 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()
- // Particle burst?
- message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
- write_byte(TE_PARTICLEBURST) // TE id
- write_coord(origin[0]) // x
- write_coord(origin[1]) // y
- write_coord(origin[2]) // z
- write_short(50) // radius
- write_byte(70) // color
- write_byte(3) // duration (will be randomized a bit)
- message_end()
- // Light sparkle?
- message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
- write_byte(TE_DLIGHT) // TE id
- write_coord(origin[0]) // x
- write_coord(origin[1]) // y
- write_coord(origin[2]) // z
- write_byte(20) // radius
- write_byte(0) // r
- write_byte(150) // g
- write_byte(0) // b
- write_byte(2) // life
- write_byte(0) // decay rate
- message_end()
- }
- // Respawn Player Manually (called after respawn checks are done)
- respawn_player_manually(id)
- {
- if (is_user_connected(id))
- {
- fm_cs_set_user_team(id, FM_CS_TEAM_T)
- ExecuteHamB(Ham_CS_RoundRespawn, id)
- }
- }
- make_human_team()
- {
- static id
- for (id = 1; id <= g_maxplayers; id++)
- {
- if (is_user_connected(id) && !g_zombie[id] && !g_hero[id])
- {
- make_human(id)
- give_nade(id)
- nst_reset_user_model(id)
- }
- }
- }
- give_team_player()
- {
- // Get amount of users playing
- static iPlayersnum
- iPlayersnum = fnGetPlaying()
- // No players, don't bother
- if (iPlayersnum < 1) return;
- // reset team
- for (new id = 1; id <= g_maxplayers; id++)
- {
- // Skip if not connected
- if (!is_user_connected(id)) continue;
- g_team[id] = fm_cs_get_user_team(id)
- }
- }
- reset_teams()
- {
- // Get amount of users playing
- static iPlayersnum
- iPlayersnum = fnGetPlaying()
- // No players, don't bother
- if (iPlayersnum < 1) return;
- // reset team
- for (new id = 1; id <= g_maxplayers; id++)
- {
- // Skip if not connected
- if (!is_user_connected(id)) continue;
- // get model
- new model[32]
- cs_get_user_model(id, model, charsmax(model))
- // reset teams
- new team = g_team[id]
- if (team == 1) fm_cs_set_user_team(id, FM_CS_TEAM_T)
- else if (team == 2) fm_cs_set_user_team(id, FM_CS_TEAM_CT)
- // set model
- nst_set_user_model(id, model)
- }
- /*
- // Get amount of users playing
- static iPlayersnum
- iPlayersnum = fnGetPlaying()
- // No players, don't bother
- if (iPlayersnum < 1) return;
- // Split players evenly
- static iTerrors, iMaxTerrors, id, team[33]
- iMaxTerrors = iPlayersnum/2
- iTerrors = 0
- // First, set everyone to CT
- for (id = 1; id <= g_maxplayers; id++)
- {
- // Skip if not connected
- if (!is_user_connected(id))
- continue;
- team[id] = fm_cs_get_user_team(id)
- // Skip if not playing
- if (team[id] == FM_CS_TEAM_SPECTATOR || team[id] == FM_CS_TEAM_UNASSIGNED)
- continue;
- // Set team
- if (task_exists(id+TASK_TEAM)) remove_task(id+TASK_TEAM)
- fm_cs_set_user_team(id, FM_CS_TEAM_CT)
- team[id] = FM_CS_TEAM_CT
- }
- // Then randomly set half of the players to Terrorists
- while (iTerrors < iMaxTerrors)
- {
- // Keep looping through all players
- if (++id > g_maxplayers) id = 1
- // Skip if not connected
- if (!is_user_connected(id))
- continue;
- // Skip if not playing or already a Terrorist
- if (team[id] != FM_CS_TEAM_CT)
- continue;
- // Random chance
- if (random_num(0, 1))
- {
- fm_cs_set_user_team(id, FM_CS_TEAM_T)
- team[id] = FM_CS_TEAM_T
- iTerrors++
- }
- }
- */
- }
- // Get Playing -returns number of users playing-
- fnGetPlaying()
- {
- static iPlaying, id, team
- iPlaying = 0
- for (id = 1; id <= g_maxplayers; id++)
- {
- if (is_user_connected(id))
- {
- team = fm_cs_get_user_team(id)
- if (team != FM_CS_TEAM_SPECTATOR && team != FM_CS_TEAM_UNASSIGNED)
- iPlaying++
- }
- }
- return iPlaying;
- }
- // Get Random Player
- fnGetRandomPlayer()
- {
- new id, check_vl
- while (!check_vl)
- {
- id = random_num(1, g_maxplayers)
- if (is_user_alive(id) && !g_zombie[id] && !g_hero[id]) check_vl = 1
- }
- return id
- }
- // get total player
- GetTotalPlayer(team, alive)
- {
- // team: 1 is TE, 2 is CT, 3 is Zombie, 4 is Human, 0 is all
- // alive: 0 is death and alive, 1 is alive
- static total, id
- total = 0
- for (id = 1; id <= g_maxplayers; id++)
- {
- if ( (alive && is_user_alive(id)) || (!alive && is_user_connected(id)) )
- {
- if (
- team == 1 && fm_cs_get_user_team(id) == FM_CS_TEAM_T ||
- team == 2 && fm_cs_get_user_team(id) == FM_CS_TEAM_CT ||
- team == 3 && g_zombie[id] ||
- team == 4 && !g_zombie[id] ||
- team == 0
- ) total++
- }
- }
- return total;
- }
- // bartime
- run_bartime(id, wait_time)
- {
- message_begin(MSG_ONE, g_msgBarTime, _, id)
- write_short(wait_time)
- message_end()
- }
- // Send Death Message for infections
- SendDeathMsg(attacker, victim)
- {
- message_begin(MSG_BROADCAST, g_msgDeathMsg)
- write_byte(attacker) // killer
- write_byte(victim) // victim
- write_byte(0) // headshot flag
- write_string("knife") // killer's weapon
- message_end()
- }
- // Fix Dead Attrib on scoreboard
- FixDeadAttrib(id)
- {
- message_begin(MSG_BROADCAST, g_msgScoreAttrib)
- write_byte(id) // id
- write_byte(0) // attrib
- message_end()
- }
- // Plays a sound on clients
- PlaySound(id, const sound[])
- {
- client_cmd(id, "spk ^"%s^"", sound)
- }
- // Plays Emit sound
- PlayEmitSound(id, type, const sound[])
- {
- emit_sound(id, type, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
- }
- // Effect level up
- EffectLevelUp(id)
- {
- if (!is_user_alive(id)) return;
- // get origin
- static Float:origin[3]
- pev(id, pev_origin, origin)
- // set color
- new color[3]
- color[0] = get_color_level(id, 0)
- color[1] = get_color_level(id, 1)
- color[2] = get_color_level(id, 2)
- // create effect
- engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
- write_byte(TE_BEAMCYLINDER) // TE id
- engfunc(EngFunc_WriteCoord, origin[0]) // x
- engfunc(EngFunc_WriteCoord, origin[1]) // y
- engfunc(EngFunc_WriteCoord, origin[2]) // z
- engfunc(EngFunc_WriteCoord, origin[0]) // x axis
- engfunc(EngFunc_WriteCoord, origin[1]) // y axis
- engfunc(EngFunc_WriteCoord, origin[2]+100.0) // z axis
- write_short(id_sprites_levelup) // sprite
- write_byte(0) // startframe
- write_byte(0) // framerate
- write_byte(4) // life
- write_byte(60) // width
- write_byte(0) // noise
- write_byte(color[0]) // red
- write_byte(color[1]) // green
- write_byte(color[2]) // blue
- write_byte(200) // brightness
- write_byte(0) // speed
- message_end()
- // create glow shell
- fm_set_rendering(id)
- fm_set_rendering(id, kRenderFxGlowShell, color[0], color[1], color[2], kRenderNormal, 0)
- if (task_exists(id+TASK_GLOWSHELL)) remove_task(id+TASK_GLOWSHELL)
- set_task(get_pcvar_float(cvar_glowshell_time), "RemoveGlowShell", id+TASK_GLOWSHELL)
- }
- get_color_level(id, num)
- {
- new color[3]
- if (g_zombie[id])
- {
- switch (g_level[id])
- {
- case 2: color = {251,168,0}
- case 3: color = {255,10,0}
- default: color = {41,138,255}
- }
- }
- else
- {
- switch (g_level[id])
- {
- case 1: color = {0,177,0}
- case 2: color = {0,177,0}
- case 3: color = {0,177,0}
- case 4: color = {137,191,20}
- case 5: color = {137,191,20}
- case 6: color = {250,229,0}
- case 7: color = {250,229,0}
- case 8: color = {243,127,1}
- case 9: color = {243,127,1}
- case 10: color = {255,3,0}
- case 11: color = {127,40,208}
- case 12: color = {127,40,208}
- case 13: color = {127,40,208}
- default: color = {0,177,0}
- }
- }
- return color[num];
- }
- // Effect
- EffectRestoreHealth(id)
- {
- if (!is_user_alive(id)) return;
- static Float:origin[3];
- pev(id,pev_origin,origin);
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(TE_EXPLOSION); // TE_EXPLOSION
- write_coord(floatround(origin[0])); // origin x
- write_coord(floatround(origin[1])); // origin y
- write_coord(floatround(origin[2])); // origin z
- write_short(restore_health_idspr); // sprites
- write_byte(15); // scale in 0.1's
- write_byte(12); // framerate
- write_byte(14); // flags
- message_end(); // message end
- message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade , _, id);
- write_short(1<<10);
- write_short(1<<10);
- write_short(0x0000);
- write_byte(255);//r
- write_byte(0); //g
- write_byte(0); //b
- write_byte(75);
- message_end();
- }
- EffectZombieRespawn(id)
- {
- static Float:origin[3];
- pev(id,pev_origin,origin);
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(TE_EXPLOSION); // TE_EXPLOSION
- write_coord(floatround(origin[0])); // origin x
- write_coord(floatround(origin[1])); // origin y
- write_coord(floatround(origin[2])); // origin z
- write_short(zombie_respawn_idspr); // sprites
- write_byte(10); // scale in 0.1's
- write_byte(20); // framerate
- write_byte(14); // flags
- message_end(); // message end
- }
- public RemoveGlowShell(taskid)
- {
- fm_set_rendering(ID_GLOWSHELL)
- if (task_exists(taskid)) remove_task(taskid)
- }
- UpdateLevelZombie(id, num)
- {
- // give level
- g_level[id] += num
- if (g_level[id] > MAX_LEVEL_ZOMBIE) g_level[id] = MAX_LEVEL_ZOMBIE
- // check model
- CurrentWeapon(id)
- //client_print(id, print_chat, "L[%i]", g_level[id])
- }
- UpdateEvolutionDamage(id, damageup)
- {
- // check zombie
- if (!g_zombie[id]) return;
- // get damage
- new damage
- new sec_c = get_systime()
- new time_attack_zombie = get_pcvar_num(cvar_time_attack_zombie)
- new timeleft = sec_c - g_victim_time_attack[id]
- g_victim_time_attack[id] = sec_c
- if (timeleft <= time_attack_zombie) damage = g_victim_damage[id]+damageup
- else damage = damageup
- // Update Evolution
- new evo_dmg = damage % (ZOMBIE_DAMAGE_LEVEL*g_level[id])
- new evo_up = (damage - evo_dmg)/(ZOMBIE_DAMAGE_LEVEL*g_level[id])
- UpdateEvolution(id, evo_up)
- g_victim_damage[id] = evo_dmg
- //client_print(id, print_chat, "[%i][%i]", g_victim_damage[id], evo_up)
- }
- UpdateEvolution(id, num)
- {
- if (!num || !g_zombie[id]) return;
- // update Evolution of zombie
- g_evolution[id] += num
- if (g_evolution[id] > MAX_EVOLUTION) g_evolution[id] = MAX_EVOLUTION
- // update level of zombie
- new evolution_zb = g_evolution[id] % 10
- new levelup = (g_evolution[id]-evolution_zb)/10
- if (levelup && g_level[id]<MAX_LEVEL_ZOMBIE)
- {
- // reset zombie die
- g_zombie_die[id] = 0
- // update level
- UpdateLevelZombie(id, levelup)
- // set health & armor
- UpdateHealthZombie(id)
- // create effect
- EffectLevelUp(id)
- // play sound evolution
- new sound_ev[64]
- ArrayGetString(zombie_sound_evolution, g_zombieclass[id], sound_ev, charsmax(sound_ev))
- PlayEmitSound(id, CHAN_VOICE, sound_ev)
- }
- // max level zombie
- g_evolution[id] = evolution_zb
- if (g_level[id] >= MAX_LEVEL_ZOMBIE) g_evolution[id] = MAX_EVOLUTION
- // show Evolution
- //show_level(id)
- //client_print(id, print_chat, "E[%i]", g_evolution[id])
- }
- UpdateHealthZombie(id)
- {
- if (!g_zombie[id]) return;
- // set value
- new health, armor
- if (g_level[id]==2)
- {
- health = ZB_LV2_HEALTH
- armor = ZB_LV2_ARMOR
- }
- else if (g_level[id]==3)
- {
- health = ZB_LV3_HEALTH
- armor = ZB_LV3_ARMOR
- }
- else
- {
- health = g_start_health[id]
- armor = g_star_armor[id]
- }
- // zombie has 1/2 health if die
- if (g_zombie_die[id])
- {
- if (g_level[id]==1) health = health/2
- else health = health/(g_zombie_die[id]*2)
- }
- // check value
- health = max(MIN_HEALTH_ZOMBIE, health)
- armor = max(MIN_ARMOR_ZOMBIE, armor)
- // set again start value
- g_start_health[id] = health
- g_star_armor[id] = armor
- // give health
- fm_set_user_health(id, health)
- fm_set_user_armor(id, armor)
- }
- UpdateLevelTeamHuman()
- {
- static id
- for (id = 1; id <= g_maxplayers; id++)
- {
- if (is_user_alive(id) && !g_zombie[id])
- {
- UpdateLevelHuman(id, 1)
- }
- }
- return 1
- }
- UpdateLevelHuman(id, num)
- {
- // update level
- g_level[id] += num
- if (g_level[id] > MAX_LEVEL_HUMAN) g_level[id] = MAX_LEVEL_HUMAN
- else
- {
- // show level
- //show_level(id)
- // play sound
- PlaySound(id, sound_levelup)
- // Effect
- EffectLevelUp(id)
- // show hudtext
- new message[100]
- format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_HUMAN_LEVELUP", g_level[id])
- SendCenterText(id, message)
- }
- //client_print(id, print_chat, "L[%i]", g_level[id])
- }
- UpdateLevelHumanDamage(id, damageup)
- {
- new level_damage = get_pcvar_num(cvar_level_damage)
- if (!level_damage) return;
- // ExecuteForward
- ExecuteForward(g_fwUserDamage, g_fwDummyResult, id, damageup, level_damage)
- // get value
- new k_old = get_k(g_dmg_attack[id])
- new k_new = get_k(g_dmg_attack[id]+damageup)
- new level_up = k_new - k_old
- // if human attack 1000 dmg of zombie then level up
- if (level_damage==1)
- {
- if (level_up && g_level[id]<MAX_LEVEL_HUMAN)
- {
- UpdateLevelHuman(id, level_up)
- }
- }
- // if human attack 1000 dmg of zombie then frags up
- else
- {
- if (level_up) UpdateFrags(id, level_up)
- }
- // update dmg attack
- g_dmg_attack[id] += damageup
- }
- get_k(num)
- {
- new aaa,aaaa
- if (num >= 1000)
- {
- aaa = num % 1000
- aaaa = (num - aaa)/1000
- }
- else aaaa = 0
- return aaaa
- }
- UpdateFrags(player, num)
- {
- if (!is_user_connected(player)) return;
- set_pev(player, pev_frags, float(pev(player, pev_frags) + num))
- message_begin(MSG_BROADCAST, g_msgScoreInfo)
- write_byte(player) // id
- write_short(pev(player, pev_frags)) // frags
- write_short(get_user_deaths(player)) // deaths
- write_short(0) // class?
- write_short(get_user_team(player)) // team
- message_end()
- }
- UpdateDeaths(player, num)
- {
- if (!is_user_connected(player)) return;
- new deaths = get_user_deaths(player) + num
- cs_set_user_deaths(player, deaths)
- message_begin(MSG_BROADCAST, g_msgScoreInfo)
- write_byte(player) // id
- write_short(pev(player, pev_frags)) // frags
- write_short(deaths) // deaths
- write_short(0) // class?
- write_short(get_user_team(player)) // team
- message_end()
- }
- give_weapons_bot(id)
- {
- if (!is_user_bot(id)) return;
- static wpn_pri[32], wpn_sec[32]
- ArrayGetString(weapons_pri, random(ArraySize(weapons_pri)), wpn_pri, charsmax(wpn_pri))
- ArrayGetString(weapons_sec, random(ArraySize(weapons_sec)), wpn_sec, charsmax(wpn_sec))
- new idwpn_pri = csw_name_to_id(wpn_pri)
- new idwpn_sec = csw_name_to_id(wpn_sec)
- give_weapon(id, idwpn_pri)
- give_weapon(id, idwpn_sec)
- }
- // Place user at a random spawn
- do_random_spawn(id, regularspawns = 0)
- {
- static hull, sp_index, i
- // Get whether the player is crouching
- hull = (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
- // Use regular spawns?
- if (!regularspawns)
- {
- // No spawns?
- if (!g_spawnCount)
- return;
- // Choose random spawn to start looping at
- sp_index = random_num(0, g_spawnCount - 1)
- // Try to find a clear spawn
- for (i = sp_index + 1; /*no condition*/; i++)
- {
- // Start over when we reach the end
- if (i >= g_spawnCount) i = 0
- // Free spawn space?
- if (is_hull_vacant(g_spawns[i], hull))
- {
- // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
- engfunc(EngFunc_SetOrigin, id, g_spawns[i])
- break;
- }
- // Loop completed, no free space found
- if (i == sp_index) break;
- }
- }
- else
- {
- // No spawns?
- if (!g_spawnCount2)
- return;
- // Choose random spawn to start looping at
- sp_index = random_num(0, g_spawnCount2 - 1)
- // Try to find a clear spawn
- for (i = sp_index + 1; /*no condition*/; i++)
- {
- // Start over when we reach the end
- if (i >= g_spawnCount2) i = 0
- // Free spawn space?
- if (is_hull_vacant(g_spawns2[i], hull))
- {
- // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
- engfunc(EngFunc_SetOrigin, id, g_spawns2[i])
- break;
- }
- // Loop completed, no free space found
- if (i == sp_index) break;
- }
- }
- }
- do_random_spawn_box(id, regularspawns = 0)
- {
- static hull, sp_index, i
- // Get whether the player is crouching
- hull = (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
- // Use regular spawns?
- if (!regularspawns)
- {
- // No spawns?
- if (!g_spawnCount_box)
- return;
- // Choose random spawn to start looping at
- sp_index = random_num(0, g_spawnCount_box - 1)
- // Try to find a clear spawn
- for (i = sp_index + 1; /*no condition*/; i++)
- {
- // Start over when we reach the end
- if (i >= g_spawnCount_box) i = 0
- // Free spawn space?
- if (is_hull_vacant(g_spawns_box[i], hull))
- {
- // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
- engfunc(EngFunc_SetOrigin, id, g_spawns_box[i])
- break;
- }
- // Loop completed, no free space found
- if (i == sp_index) break;
- }
- }
- else
- {
- // No spawns?
- if (!g_spawnCount2_box)
- return;
- // Choose random spawn to start looping at
- sp_index = random_num(0, g_spawnCount2_box - 1)
- // Try to find a clear spawn
- for (i = sp_index + 1; /*no condition*/; i++)
- {
- // Start over when we reach the end
- if (i >= g_spawnCount2_box) i = 0
- // Free spawn space?
- if (is_hull_vacant(g_spawns2[i], hull))
- {
- // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
- engfunc(EngFunc_SetOrigin, id, g_spawns2[i])
- break;
- }
- // Loop completed, no free space found
- if (i == sp_index) break;
- }
- }
- }
- csw_name_to_id(wpn[])
- {
- new weapons[32]
- format(weapons, charsmax(weapons), "weapon_%s", wpn)
- replace(weapons, charsmax(weapons), "csw_", "")
- return cs_weapon_name_to_id(weapons)
- }
- give_weapon(id, idwpn)
- {
- if (g_zombie[id]) return;
- fm_give_item(id, WEAPONENTNAMES[idwpn])
- new ammo = get_ammo_buywpn(idwpn)
- if (ammo > 2)
- {
- cs_set_user_bpammo(id, idwpn, ammo)
- show_hud_ammo(id, idwpn, ammo)
- }
- }
- show_hud_ammo(id, weapon, ammo)
- {
- message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
- write_byte(AMMOID[weapon]) // ammo id
- write_byte(ammo) // ammo amount
- message_end()
- PlayEmitSound(id, CHAN_ITEM, sound_buyammo)
- }
- get_ammo_buywpn(wpn)
- {
- new ammo = 1
- if (wpn == CSW_P228 || wpn == CSW_ELITE || wpn == CSW_FIVESEVEN || wpn == CSW_USP || wpn == CSW_GLOCK18)
- {
- ammo = 200
- }
- else if (wpn == CSW_DEAGLE)
- {
- ammo = 70
- }
- else if (wpn == CSW_M3 || wpn == CSW_XM1014)
- {
- ammo = 64
- }
- else if (wpn == CSW_MAC10 || wpn == CSW_UMP45 || wpn == CSW_MP5NAVY || wpn == CSW_TMP || wpn == CSW_P90)
- {
- ammo = 180
- }
- else if (wpn == CSW_AUG || wpn == CSW_FAMAS || wpn == CSW_GALIL || wpn == CSW_M4A1 || wpn == CSW_SG552 || wpn == CSW_AK47 || wpn == CSW_SCOUT || wpn == CSW_G3SG1 || wpn == CSW_SG550)
- {
- ammo = 180
- }
- else if (wpn == CSW_M249)
- {
- ammo = 200
- }
- else if (wpn == CSW_AWP)
- {
- ammo = 30
- }
- else if (wpn == CSW_HEGRENADE || wpn == CSW_SMOKEGRENADE || wpn == CSW_FLASHBANG)
- {
- ammo = 1
- }
- return ammo;
- }
- SendMsgDamage(id)
- {
- message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, id)
- write_byte(0) // damage save
- write_byte(0) // damage take
- write_long(DMG_NERVEGAS) // damage type - DMG_RADIATION
- write_coord(0) // x
- write_coord(0) // y
- write_coord(0) // z
- message_end()
- }
- FixNumber(number)
- {
- new numstr[32]
- if (number<0) format(numstr, 31, "0")
- else if (number<10) format(numstr, 31, "0%i", number)
- else format(numstr, 31, "%i", number)
- return numstr
- }
- fnFloatToNum(Float:floatn)
- {
- new str[64], num
- float_to_str(floatn, str, 63)
- num = str_to_num(str)
- return num
- }
- // Turn Off Flashlight and Restore Batteries
- turn_off_flashlight(id)
- {
- // Restore batteries for the next use
- fm_cs_set_user_batteries(id, 100)
- // Check if flashlight is on
- if (pev(id, pev_effects) & EF_DIMLIGHT)
- {
- // Turn it off
- set_pev(id, pev_impulse, IMPULSE_FLASHLIGHT)
- }
- else
- {
- // Clear any stored flashlight impulse (bugfix)
- set_pev(id, pev_impulse, 0)
- }
- // Update flashlight HUD
- message_begin(MSG_ONE, get_user_msgid("Flashlight"), _, id)
- write_byte(0) // toggle
- write_byte(100) // battery
- message_end()
- }
- color_saytext(player, const message[], any:...)
- {
- new text[301]
- format(text, 300, "%s", message)
- new dest
- if (player) dest = MSG_ONE
- else dest = MSG_ALL
- message_begin(dest, get_user_msgid("SayText"), {0,0,0}, player)
- write_byte(1)
- write_string(check_text(text))
- return message_end()
- }
- check_text(text1[])
- {
- new text[301]
- format(text, 300, "%s", text1)
- replace(text, 300, ">x04", "^x04")
- replace(text, 300, ">x03", "^x03")
- replace(text, 300, ">x01", "^x01")
- return text
- }
- SendCenterText(id, message[])
- {
- new dest
- if (id) dest = MSG_ONE
- else dest = MSG_ALL
- message_begin(dest, g_msgTextMsg, {0,0,0}, id)
- write_byte(4)
- write_string(message)
- message_end()
- }
- get_weapon_type(weaponid)
- {
- new type_wpn = 0
- if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM) type_wpn = 1
- else if ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM) type_wpn = 2
- else if ((1<<weaponid) & NADE_WEAPONS_BIT_SUM) type_wpn = 4
- return type_wpn
- }
- remove_ent_by_class(classname[])
- {
- new nextitem = find_ent_by_class(-1, classname)
- while(nextitem)
- {
- remove_entity(nextitem)
- nextitem = find_ent_by_class(-1, classname)
- }
- }
- // ##################### Lighting Effects #####################
- // Lighting Effects Task
- public lighting_effects()
- {
- // Get lighting style
- static lighting[2]
- get_pcvar_string(cvar_lighting, lighting, charsmax(lighting))
- strtolower(lighting)
- // Lighting disabled? ["0"]
- if (lighting[0] == '0')
- return;
- // Darkest light settings?
- if (lighting[0] >= 'a' && lighting[0] <= 'd')
- {
- static thunderclap_in_progress, Float:thunder
- thunderclap_in_progress = task_exists(TASK_THUNDER)
- thunder = get_pcvar_float(cvar_thunder)
- // Set thunderclap tasks if not existant
- if (thunder > 0.0 && !task_exists(TASK_THUNDER_PRE) && !thunderclap_in_progress)
- {
- g_lights_i = 0
- ArrayGetString(lights_thunder, random_num(0, ArraySize(lights_thunder) - 1), g_lights_cycle, charsmax(g_lights_cycle))
- g_lights_cycle_len = strlen(g_lights_cycle)
- //set_task(thunder, "thunderclap", TASK_THUNDER_PRE)
- }
- // Set lighting only when no thunderclaps are going on
- if (!thunderclap_in_progress) engfunc(EngFunc_LightStyle, 0, lighting)
- }
- else
- {
- // Remove thunderclap tasks
- if (task_exists(TASK_THUNDER_PRE)) remove_task(TASK_THUNDER_PRE)
- if (task_exists(TASK_THUNDER)) remove_task(TASK_THUNDER)
- // Set lighting
- engfunc(EngFunc_LightStyle, 0, lighting)
- }
- }
- // Thunderclap task
- public thunderclap()
- {
- // Play thunder sound
- if (g_lights_i == 0)
- {
- static sound[64]
- ArrayGetString(sound_thunder, random_num(0, ArraySize(sound_thunder) - 1), sound, charsmax(sound))
- PlaySound(0, sound)
- }
- // Set lighting
- static light[2]
- light[0] = g_lights_cycle[g_lights_i]
- engfunc(EngFunc_LightStyle, 0, light)
- g_lights_i++
- // Lighting cycle end?
- if (g_lights_i >= g_lights_cycle_len)
- {
- if (task_exists(TASK_THUNDER)) remove_task(TASK_THUNDER)
- lighting_effects()
- }
- // Lighting cycle start?
- else if (!task_exists(TASK_THUNDER))
- set_task(0.1, "thunderclap", TASK_THUNDER, _, _, "b")
- }
- /*================================================================================
- [Message Hooks]
- =================================================================================*/
- // Fix for the HL engine bug when HP is multiples of 256
- public message_health(msg_id, msg_dest, msg_entity)
- {
- // Get player's health
- static health
- health = get_msg_arg_int(1)
- // Don't bother
- if (health < 256) return;
- // Check if we need to fix it
- if (health % 256 == 0)
- fm_set_user_health(msg_entity, pev(msg_entity, pev_health) + 1)
- // HUD can only show as much as 255 hp
- set_msg_arg_int(1, get_msg_argtype(1), 255)
- }
- // Block flashlight battery messages if custom flashlight is enabled instead
- public message_flashbat()
- {
- return PLUGIN_HANDLED;
- }
- // Prevent spectators' nightvision from being turned off when switching targets, etc.
- public message_nvgtoggle()
- {
- return PLUGIN_HANDLED;
- }
- // Prevent zombies from seeing any weapon pickup icon
- public message_weappickup(msg_id, msg_dest, msg_entity)
- {
- if (g_zombie[msg_entity])
- return PLUGIN_HANDLED;
- return PLUGIN_CONTINUE;
- }
- // Prevent zombies from seeing any ammo pickup icon
- public message_ammopickup(msg_id, msg_dest, msg_entity)
- {
- if (g_zombie[msg_entity])
- return PLUGIN_HANDLED;
- return PLUGIN_CONTINUE;
- }
- // Block hostage HUD display
- public message_scenario()
- {
- if (get_msg_args() > 1)
- {
- static sprite[8]
- get_msg_arg_string(2, sprite, charsmax(sprite))
- if (equal(sprite, "hostage"))
- return PLUGIN_HANDLED;
- }
- return PLUGIN_CONTINUE;
- }
- // Block hostages from appearing on radar
- public message_hostagepos()
- {
- return PLUGIN_HANDLED;
- }
- // Block some text messages
- public message_textmsg()
- {
- static textmsg[22]
- get_msg_arg_string(2, textmsg, charsmax(textmsg))
- // Game restarting, reset scores and call round end to balance the teams
- if (equal(textmsg, "#Game_will_restart_in"))
- {
- g_score_human = 0
- g_score_zombie = 0
- logevent_round_end()
- }
- else if (equal(textmsg, "#Game_Commencing"))
- {
- g_startcount = 1
- }
- // Block round end related messages
- else if (equal(textmsg, "#Hostages_Not_Rescued") || equal(textmsg, "#Round_Draw") || equal(textmsg, "#Terrorists_Win") || equal(textmsg, "#CTs_Win"))
- {
- return PLUGIN_HANDLED;
- }
- return PLUGIN_CONTINUE;
- }
- // Block CS round win audio messages, since we're playing our own instead
- public message_sendaudio()
- {
- static audio[17]
- get_msg_arg_string(2, audio, charsmax(audio))
- if(equal(audio[7], "terwin") || equal(audio[7], "ctwin") || equal(audio[7], "rounddraw"))
- return PLUGIN_HANDLED;
- return PLUGIN_CONTINUE;
- }
- // Send actual team scores (T = zombies // CT = humans)
- public message_teamscore()
- {
- static team[2]
- get_msg_arg_string(1, team, charsmax(team))
- switch (team[0])
- {
- // CT
- case 'C': set_msg_arg_int(2, get_msg_argtype(2), g_score_human)
- // Terrorist
- case 'T': set_msg_arg_int(2, get_msg_argtype(2), g_score_zombie)
- }
- }
- public message_hudtextargs()
- {
- return PLUGIN_HANDLED;
- }
- public message_msgClCorpse()
- {
- new victim = get_msg_arg_int(12)
- if (g_respawning[victim] || is_user_alive(victim)) return PLUGIN_HANDLED;
- return PLUGIN_CONTINUE
- }
- /*================================================================================
- [Main Stock]
- =================================================================================*/
- // Set a Player's Team
- stock fm_cs_set_user_team(id, team)
- {
- // Our task params
- static params[1]
- params[0] = team
- if (task_exists(id+TASK_TEAM)) remove_task(id+TASK_TEAM)
- set_task(0.1, "task_set_user_team", id+TASK_TEAM, params, sizeof params)
- }
- // Task Set Model
- public task_set_user_team(params[1], taskid)
- {
- new id = ID_TEAM
- new team = params[0]
- cs_set_user_team(id, team, 0)
- set_model_for_player(id)
- if (task_exists(id+TASK_TEAM)) remove_task(id+TASK_TEAM)
- }
- // Set user money
- stock fm_cs_set_user_money(id, money)
- {
- cs_set_user_money(id, money, 1)
- }
- // Set player's health (from fakemeta_util)
- stock fm_set_user_health(id, health)
- {
- (health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
- }
- // Drop primary/secondary weapons
- stock drop_weapons(id, dropwhat, type=0)
- {
- // Get user weapons
- static weapons[32], num, i, weaponid
- num = 0 // reset passed weapons count (bugfix)
- get_user_weapons(id, weapons, num)
- // Loop through them and drop primaries or secondaries
- for (i = 0; i < num; i++)
- {
- // Prevent re-indexing the array
- weaponid = weapons[i]
- if (get_weapon_type(weaponid) == dropwhat)
- {
- if (type==1)
- {
- fm_strip_user_gun(id, weaponid)
- }
- else
- {
- // Get weapon entity
- static wname[32], weapon_ent
- get_weaponname(weaponid, wname, charsmax(wname))
- weapon_ent = fm_find_ent_by_owner(-1, wname, id)
- // Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
- set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, cs_get_user_bpammo(id, weaponid))
- // Player drops the weapon and looses his bpammo
- engclient_cmd(id, "drop", wname)
- }
- }
- }
- }
- // Find entity by its owner (from fakemeta_util)
- stock fm_find_ent_by_owner(entity, const classname[], owner)
- {
- while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ }
- return entity;
- }
- // Get User Team
- stock fm_set_user_armor(id, armor)
- {
- set_pev(id, pev_armorvalue, float(min(armor, 999)))
- }
- // Get User Team
- stock fm_cs_get_user_team(id)
- {
- return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
- }
- // Set entity's rendering type (from fakemeta_util)
- stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
- {
- static Float:color[3]
- color[0] = float(r)
- color[1] = float(g)
- color[2] = float(b)
- set_pev(entity, pev_renderfx, fx)
- set_pev(entity, pev_rendercolor, color)
- set_pev(entity, pev_rendermode, render)
- set_pev(entity, pev_renderamt, float(amount))
- }
- // only weapon index or its name can be passed, if neither is passed then the current gun will be stripped
- stock fm_strip_user_gun(index, wid = 0, const wname[] = "") {
- new ent_class[32];
- if (!wid && wname[0])
- copy(ent_class, sizeof ent_class - 1, wname);
- else {
- new weapon = wid, clip, ammo;
- if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))
- return false;
- get_weaponname(weapon, ent_class, sizeof ent_class - 1);
- }
- new ent_weap = fm_find_ent_by_owner(-1, ent_class, index);
- if (!ent_weap)
- return false;
- engclient_cmd(index, "drop", ent_class);
- new ent_box = pev(ent_weap, pev_owner);
- if (!ent_box || ent_box == index)
- return false;
- dllfunc(DLLFunc_Think, ent_box);
- return true;
- }
- // Simplified get_weaponid (CS only)
- stock cs_weapon_name_to_id(const weapon[])
- {
- static i
- for (i = 0; i < sizeof WEAPONENTNAMES; i++)
- {
- if (equal(weapon, WEAPONENTNAMES[i]))
- return i;
- }
- return 0;
- }
- // Give an item to a player (from fakemeta_util)
- stock fm_give_item(id, const item[])
- {
- static ent
- ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
- if (!pev_valid(ent)) return;
- static Float:originF[3]
- pev(id, pev_origin, originF)
- set_pev(ent, pev_origin, originF)
- set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
- dllfunc(DLLFunc_Spawn, ent)
- static save
- save = pev(ent, pev_solid)
- dllfunc(DLLFunc_Touch, ent, id)
- if (pev(ent, pev_solid) != save)
- return;
- engfunc(EngFunc_RemoveEntity, ent)
- }
- // Set an entity's key value (from fakemeta_util)
- stock fm_set_kvd(entity, const key[], const value[], const classname[])
- {
- set_kvd(0, KV_ClassName, classname)
- set_kvd(0, KV_KeyName, key)
- set_kvd(0, KV_Value, value)
- set_kvd(0, KV_fHandled, 0)
- dllfunc(DLLFunc_KeyValue, entity, 0)
- }
- // Checks if a space is vacant (credits to VEN)
- stock is_hull_vacant(Float:origin[3], hull)
- {
- engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, 0)
- if (!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid) && get_tr2(0, TR_InOpen))
- return true;
- return false;
- }
- // Collect random spawn points
- stock load_spawns()
- {
- // Check for CSDM spawns of the current map
- new cfgdir[32], mapname[32], filepath[100], linedata[64]
- get_configsdir(cfgdir, charsmax(cfgdir))
- get_mapname(mapname, charsmax(mapname))
- formatex(filepath, charsmax(filepath), SPAWNS_URL, cfgdir, mapname)
- // Load CSDM spawns if present
- if (file_exists(filepath))
- {
- new csdmdata[10][6], file = fopen(filepath,"rt")
- while (file && !feof(file))
- {
- fgets(file, linedata, charsmax(linedata))
- // invalid spawn
- if(!linedata[0] || str_count(linedata,' ') < 2) continue;
- // get spawn point data
- parse(linedata,csdmdata[0],5,csdmdata[1],5,csdmdata[2],5,csdmdata[3],5,csdmdata[4],5,csdmdata[5],5,csdmdata[6],5,csdmdata[7],5,csdmdata[8],5,csdmdata[9],5)
- // origin
- g_spawns[g_spawnCount][0] = floatstr(csdmdata[0])
- g_spawns[g_spawnCount][1] = floatstr(csdmdata[1])
- g_spawns[g_spawnCount][2] = floatstr(csdmdata[2])
- // increase spawn count
- g_spawn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement