#include #include #include #include #include //#define ZOMBIE //Закоментировать если будите использовать не на зомби моде #if defined ZOMBIE #include #endif /*НАСТРОЙКА НОВОГО ОРУЖИЯ*/ /*НАЧАЛО*/ //Прибавлять в следующих плагинах оружия к числу 1 #define WEAPON_KEY 20144 //Меняем на то оружие на котором хотите написать новое //В данном примере оружие написано на Galil #define WEAPON_OLD "weapon_galil" #define WEAPON_CSW CSW_GALIL #define WEAPON_EVENT "events/galil.sc" #define WEAPON_W "models/w_galil.mdl" //Время проигрывания анимации //Получение времени: делим число кадров на ФПС //Cмотреть в HLMV #define TIME_DRAW 1.5 //Достования #define TIME_RELOAD 3.0 //Перезарядка #define TIME_SHOOT 1.0 //Выстрел #define TIME_IDLE 1.5 //Простой //Ресурсы #define SOUND_SHOOT "weapons/m14ebr.wav" //Звук выстрела #define MODEL_SHELL "models/rshell.mdl" //Модель гильз #define MODEL_V "models/zm/v_m14ebr.mdl" //Модель оружия в руках #define MODEL_P "models/zm/p_m14ebr.mdl" //Модель оружия в руках модели игрока #define MODEL_W "models/zm/w_m14ebr.mdl" //Модель оружия на земле //Характеристики оружия const AMMO_CLIP = 20 //Количество патронов в обойме const AMMO_MAX = 120 //Количество патронов в запасе const Float:DAMAGE = 2.0 //Множитель урона const Float:SPEED = 0.15 //Скорострельность const Float:RECOIL = 2.0 //Разброс //Анимации V модели оружия //Cмотреть в HLMV enum { IDLE = 0, RELOAD, DRAW, SHOOT } /*КОНЕЦ*/ new const trace_attack[][] = { "func_breakable", "func_wall", "func_door", "func_plat", "func_rotating", "worldspawn" } new const damage_entity[][] = { "player", "func_breakable", "hostage_entity" } #define get_weapon(%0) (entity_get_int(%0, EV_INT_impulse) == WEAPON_KEY) #define set_weapon(%0) entity_set_int(%0, EV_INT_impulse, WEAPON_KEY) new g_connect #define get_bit(%1,%2) ((%1 & (1 << (%2 & 31))) ? true : false) #define set_bit(%1,%2) %1 |= (1 << (%2 & 31)) #define reset_bit(%1,%2) %1 &= ~(1 << (%2 & 31)) const PRIMARY_WEAPONS_BIT_SUM = (1<= AMMO_CLIP) return HAM_SUPERCEDE clip = get_ammo_clip(weapon_ent) set_ammo_clip(weapon_ent, 0) ExecuteHam(Ham_Weapon_Reload, weapon_ent) set_ammo_clip(weapon_ent, clip) UTIL_PlayWeaponAnimation(id, RELOAD) set_next_attack(id, TIME_RELOAD) set_next_idle(weapon_ent, TIME_RELOAD) return HAM_SUPERCEDE } public Ham_Item_PostFrame_Pre(weapon_ent) { if(!is_valid_ent(weapon_ent)) return HAM_IGNORED static id; id = get_player(weapon_ent) static ammo; ammo = get_ammo(id, WEAPON_CSW) static clip; clip = get_ammo_clip(weapon_ent) static Float:NextAttack, Reload if(!g_weapon_new[id]) return HAM_IGNORED NextAttack = get_pdata_float(id, 83, 5) Reload = get_pdata_int(weapon_ent, 54, 4) if(Reload && NextAttack <= 0.0) { static old; old = min(AMMO_CLIP - clip, ammo) set_ammo_clip(weapon_ent, clip + old) set_ammo(id, ammo - old, WEAPON_CSW) set_pdata_int(weapon_ent, 54, 0, 4) Reload = 0 } return HAM_IGNORED } public Ham_Weapon_PrimaryAttack_Pre(weapon_ent) { if(!is_valid_ent(weapon_ent)) return HAM_IGNORED static id; id = get_player(weapon_ent) if(!g_weapon_new[id]) return HAM_IGNORED if(get_ammo_clip(weapon_ent) == 0) return HAM_IGNORED ExecuteHam(Ham_Weapon_PrimaryAttack, weapon_ent) emit_sound(id, CHAN_WEAPON, SOUND_SHOOT, VOL_NORM, ATTN_NORM, 0, PITCH_NORM) set_weapon_reloil(weapon_ent, RECOIL) UTIL_PlayWeaponAnimation(id, SHOOT) set_next_attack(id, SPEED) set_next_idle(weapon_ent, TIME_SHOOT) create_shell(weapon_ent, id, g_shell_index) return HAM_SUPERCEDE } public Ham_Weapon_WeaponIdle_Pre(weapon_ent) { if(!is_valid_ent(weapon_ent)) return HAM_IGNORED static id, Float:time_idle id = get_player(weapon_ent) if(!g_weapon_new[id]) return HAM_IGNORED time_idle = get_pdata_float(weapon_ent, 48, 4) if(time_idle > 0.0) return HAM_IGNORED UTIL_PlayWeaponAnimation(id, IDLE) set_next_idle(weapon_ent, TIME_IDLE) return HAM_SUPERCEDE } public Ham_Item_AddToPlayer_Post(weapon_ent, id) { if(!is_valid_ent(weapon_ent)) return HAM_IGNORED if(get_weapon(weapon_ent)) { g_weapon_new[id] = true return HAM_HANDLED } return HAM_IGNORED } public Ham_TraceAttack_Post(entity, attacker, Float:damage, Float:fDir[3], ptr, damagetype) { static item; item = get_player_item(attacker) if(!get_weapon(item)) return HAM_HANDLED new Float:vecEnd[3] get_tr2(ptr, TR_vecEndPos, vecEnd); message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_GUNSHOTDECAL) engfunc(EngFunc_WriteCoord, vecEnd[0]) engfunc(EngFunc_WriteCoord, vecEnd[1]) engfunc(EngFunc_WriteCoord, vecEnd[2]) write_short(entity) write_byte(random_num(41, 45)) message_end() return HAM_IGNORED } public Ham_TraceAttack_Pre(entity, attacker, Float:damage) { if(get_bit(g_connect, attacker)) { if(get_user_weapon(attacker) == WEAPON_CSW && g_weapon_new[attacker]) { SetHamParamFloat(3, damage * DAMAGE) return HAM_IGNORED } } return HAM_IGNORED } public FM_SetModel_Pre(entity, model[]) { if(!is_valid_ent(entity)) return FMRES_IGNORED static szClassName[33] entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName)) if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED static id; id = entity_get_edict(entity, EV_ENT_owner) if(equal(model, WEAPON_W)) { static iStoredAugID; iStoredAugID = find_ent_by_owner(-1, WEAPON_OLD, entity) if(!is_valid_ent(iStoredAugID)) return FMRES_IGNORED if(g_weapon_new[id]) { entity_set_model(entity, MODEL_W) g_weapon_new[id] = false return FMRES_SUPERCEDE } } return FMRES_IGNORED } stock set_ammo_clip(weapon, amount) { set_pdata_int(weapon, 51, amount, 4) } set_ammo(const player, const amount, const ammo_type) { if(amount == -1) { return 0 } switch(ammo_type) { case CSW_AWP: set_pdata_int(player, 377, amount, 5) case CSW_SCOUT: set_pdata_int(player, 378, amount, 5) case CSW_G3SG1: set_pdata_int(player, 378, amount, 5) case CSW_AK47: set_pdata_int(player, 378, amount, 5) case CSW_M249: set_pdata_int(player, 379, amount, 5) case CSW_M4A1: set_pdata_int(player, 380, amount, 5) case CSW_FAMAS: set_pdata_int(player, 380, amount, 5) case CSW_AUG: set_pdata_int(player, 380, amount, 5) case CSW_SG550: set_pdata_int(player, 380, amount, 5) case CSW_GALIL: set_pdata_int(player, 380, amount, 5) case CSW_SG552: set_pdata_int(player, 380, amount, 5) case CSW_M3: set_pdata_int(player, 381, amount, 5) case CSW_XM1014: set_pdata_int(player, 381, amount, 5) case CSW_USP: set_pdata_int(player, 382, amount, 5) case CSW_UMP45: set_pdata_int(player, 382, amount, 5) case CSW_MAC10: set_pdata_int(player, 382, amount, 5) case CSW_FIVESEVEN: set_pdata_int(player, 383, amount, 5) case CSW_P90: set_pdata_int(player, 383, amount, 5) case CSW_DEAGLE: set_pdata_int(player, 384, amount, 5) case CSW_P228: set_pdata_int(player, 385, amount, 5) case CSW_GLOCK18: set_pdata_int(player, 386, amount, 5) case CSW_TMP: set_pdata_int(player, 386, amount, 5) case CSW_ELITE: set_pdata_int(player, 386, amount, 5) } return 1 } get_ammo(const player, const ammo_type) { switch(ammo_type) { case CSW_AWP: return get_pdata_int(player, 377, 5) case CSW_SCOUT: return get_pdata_int(player, 378, 5) case CSW_G3SG1: return get_pdata_int(player, 378, 5) case CSW_AK47: return get_pdata_int(player, 378, 5) case CSW_M249: return get_pdata_int(player, 379, 5) case CSW_M4A1: return get_pdata_int(player, 380, 5) case CSW_FAMAS: return get_pdata_int(player, 380, 5) case CSW_AUG: return get_pdata_int(player, 380, 5) case CSW_SG550: return get_pdata_int(player, 380, 5) case CSW_GALIL: return get_pdata_int(player, 380, 5) case CSW_SG552: return get_pdata_int(player, 380, 5) case CSW_M3: return get_pdata_int(player, 381, 5) case CSW_XM1014: return get_pdata_int(player, 381, 5) case CSW_USP: return get_pdata_int(player, 382, 5) case CSW_UMP45: return get_pdata_int(player, 382, 5) case CSW_MAC10: return get_pdata_int(player, 382, 5) case CSW_FIVESEVEN: return get_pdata_int(player, 383, 5) case CSW_P90: return get_pdata_int(player, 383, 5) case CSW_DEAGLE: return get_pdata_int(player, 384, 5) case CSW_P228: return get_pdata_int(player, 385, 5) case CSW_GLOCK18: return get_pdata_int(player, 386, 5) case CSW_TMP: return get_pdata_int(player, 386, 5) case CSW_ELITE: return get_pdata_int(player, 386, 5) } return 1 } stock get_ammo_clip(weapon) { return get_pdata_int(weapon, 51, 4) } stock get_player(weapon) { return get_pdata_cbase(weapon, 41, 4) } stock get_player_item(player) { return get_pdata_cbase(player, 373, 5) } stock set_next_attack(player, Float:time) { set_pdata_float(player, 83, time, 5) } stock set_next_idle(weapon, Float:time) { set_pdata_float(weapon, 48, time, 4) } stock set_weapon_reloil(weapon, Float:recoil) { set_pdata_float(weapon, 62, recoil, 4) } stock create_shell(weapon, player, shell_index) { set_pdata_int(weapon, 57, shell_index, 4) set_pdata_float(player, 111, get_gametime()) } stock UTIL_PlayWeaponAnimation(const Player, const Sequence) { entity_set_int(Player, EV_INT_weaponanim, Sequence) message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player) write_byte(Sequence) write_byte(0) message_end() } stock drop_weapons(player, dropwhat) { static weapons[32], num, i, weaponid num = 0 get_user_weapons(player, weapons, num) for (i = 0; i < num; i++) { weaponid = weapons[i] if (dropwhat == 1 && ((1<