Raised This Month: $32 Target: $400
 8% 

[ZP] Dual Phantom Sword


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
strangeguy
Senior Member
Join Date: Mar 2019
Old 12-07-2019 , 07:48   [ZP] Dual Phantom Sword
Reply With Quote #1

Hi!
Can anyone help me to make two natives: first one give_dualsword and second one remove_dualsword
When I can add this knife into my knife menu.

Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <xs>
#include <zombieplague>

native GetUserItemName(iPlayer, szBuffer[]);

#define PLUGIN_NAME			"[CSO] Knife: Dual Sword Phantom Slayer"
#define PLUGIN_VERSION		"0.2"
#define PLUGIN_AUTHOR		"Phenix / Finish: t3rkecorejz"	

#define ALLOC_STRING(%1)		engfunc(EngFunc_AllocString,%1)
#define PRECACHE_MODEL(%1)		engfunc(EngFunc_PrecacheModel,%1)
#define PRECACHE_SOUND(%1)		engfunc(EngFunc_PrecacheSound,%1)
#define PRECACHE_GENERIC(%1)	engfunc(EngFunc_PrecacheGeneric,%1)
#define SET_MODEL(%1,%2)		engfunc(EngFunc_SetModel,%1,%2)
#define SET_ORIGIN(%1,%2)		engfunc(EngFunc_SetOrigin,%1,%2)
#define REMOVE_ENTITY(%1)		set_pev(%1,pev_flags,FL_KILLME)
#define MODEL_INDEX(%1)			engfunc(EngFunc_ModelIndex,%1)
#define DECAL_INDEX(%1)			engfunc(EngFunc_DecalIndex,%1)
#define TRACE_LINE(%1,%2,%3,%4,%5)	engfunc(EngFunc_TraceLine,%1,%2,%3,%4,%5)
#define TRACE_HULL(%1,%2,%3,%4,%5,%6)	engfunc(EngFunc_TraceHull,%1,%2,%3,%4,%5,%6)
#define FIND_ENTITY_IN_SPHERE(%1,%2,%3)	engfunc(EngFunc_FindEntityInSphere,%1,%2,%3)
#define CREATE_NAMED_ENTITY(%1) 	engfunc(EngFunc_CreateNamedEntity,%1)
#define MESSAGE_BEGIN(%1,%2,%3,%4)	engfunc(EngFunc_MessageBegin,%1,%2,%3,%4)
#define WRITE_COORD(%1)			engfunc(EngFunc_WriteCoord,%1)

#define SET_NEXTATTACK(%1) 								\
	set_pdata_float(pItem, m_flNextPrimaryAttack, %1, linux_diff_weapon), 		\
	set_pdata_float(pItem, m_flNextSecondaryAttack, %1, linux_diff_weapon),		\
	set_pdata_float(pPlayer, m_flNextAttack, %1, linux_diff_player)
	
#define RESET_DUALSWORD_ITEM()								\
	Set_DualSword_State(pItem, Get_DualSword_State(pItem) & ~(WPNSTATE_KNIFE_ATTACK|WPNSTATE_KNIFE_SKILL)),\
	Set_DualSword_Swing(pItem, 0),							\
	Set_DualSword_Delay(pItem, 0.0),						\
	Set_DualSword_Data01(pItem, 0),							\
	set_pev(pItem, pev_fuser1, 0.0)
	
#define IsValidEntity(%1)		(pev_valid(%1) == PDATA_SAFE)
#define IsCustomItem(%1)		(get_pdata_int(%1, m_iId, linux_diff_weapon) == CSW_KNIFE)
#define IsObserver(%1) 			pev(%1, pev_iuser1)

#define get_bit(%1,%2)			((%1 & (1 << (%2 & 31))) ? 1 : 0)
#define set_bit(%1,%2)			%1 |= (1 << (%2 & 31))
#define reset_bit(%1,%2)		%1 &= ~(1 << (%2 & 31))

#define MAX_CLIENTS			32
#define PDATA_SAFE			2
#define OBS_IN_EYE			4
#define ACT_RANGE_ATTACK1	28

// Linux extra offsets
#define linux_diff_weapon 		4
#define linux_diff_player 		5
#define linux_diff_animation		4

// CWeaponBox
#define m_rgpPlayerItems_CWeaponBox	34

// CBasePlayerItem
#define m_pPlayer                   	41
#define m_pNext                     	42
#define m_iId                       	43

// CBaseAnimating
#define m_flFrameRate               	36
#define m_flGroundSpeed             	37
#define m_flLastEventCheck          	38
#define m_fSequenceFinished         	39
#define m_fSequenceLoops            	40

// CBasePlayerWeapon
#define m_flNextPrimaryAttack       	46
#define m_flNextSecondaryAttack     	47
#define m_flTimeWeaponIdle          	48
#define m_iPrimaryAmmoType          	49
#define m_iClip                     	51
#define m_fInReload                 	54
#define m_fInSpecialReload          	55
#define m_iDefaultAmmo			56
#define m_iShellLate                	57
#define m_iDirection			60
#define m_flAccuracy			62
#define m_flGlock18Shoot		69
#define m_iGlock18ShotsFired		70
#define m_flFamasShoot			71
#define m_iFamasShotsFired		72
#define m_fWeaponState		    	74
#define m_flNextReload                	75

// CBaseMonster
#define m_Activity			73
#define m_IdealActivity             	74
#define m_LastHitGroup			75
#define m_flNextAttack              	83

// CBasePlayer
#define m_flEjectBrass              	111
#define m_iKevlarType			112
#define m_iPlayerTeam               	114
#define m_flLastAttackTime  		220
#define m_afButtonPressed		246
#define m_afButtonReleased		247
#define m_rgpPlayerItems_CBasePlayer    367
#define m_pActiveItem               	373
#define m_rgAmmo_CBasePlayer            376
#define m_szAnimExtention	    	492

#define WPNSTATE_KNIFE_A				(1<<6)
#define WPNSTATE_KNIFE_SKILL				(1<<7)
#define WPNSTATE_KNIFE_ATTACK				(1<<8)
#define WPNSTATE_KNIFE_HIT				(1<<9)

#define Get_DualSword_State(%1)		get_pdata_int(%1, m_fWeaponState, linux_diff_weapon)
#define Set_DualSword_State(%1,%2)	set_pdata_int(%1, m_fWeaponState,%2, linux_diff_weapon)
#define Get_DualSword_Swing(%1)		get_pdata_int(%1, m_fInSpecialReload, linux_diff_weapon)
#define Set_DualSword_Swing(%1,%2)	set_pdata_int(%1, m_fInSpecialReload,%2, linux_diff_weapon)
#define Get_DualSword_Delay(%1)		get_pdata_float(%1, m_flNextReload, linux_diff_weapon)
#define Set_DualSword_Delay(%1,%2)	set_pdata_float(%1, m_flNextReload,%2, linux_diff_weapon)
#define Get_DualSword_Data01(%1)	get_pdata_int(%1, m_iGlock18ShotsFired, linux_diff_weapon)
#define Set_DualSword_Data01(%1,%2)	set_pdata_int(%1, m_iGlock18ShotsFired,%2, linux_diff_weapon)

new const Float: DUALSOWRD_DAMAGE_SLASH = 55.0 // Урон от жёлтых мечей (всего 4 удара, в итоге 65.0 * 4)
new const Float: DUALSOWRD_DAMAGE_STAB = 100.0 // Урон от синего меча
new const Float: DUALSOWRD_DAMAGE_STAB_HIT = 100.0 // Урон от синего меча если анимация попадания (та что с эффектом как будто меч застрял в жертве)
new const Float: DUALSWORD_DAMAGE_MODE = 50.0 // Урон от летающих мечей (раз в 0.2 сек)

new const WEAPON_ANIM_EXTENSION[]	=	"knife" // Анимация ударов
new const WEAPON_REFERANCE[]		=	"weapon_knife"
new const WEAPON_MODEL_VIEW[]		=	"models/xman2030/v_dualsword.mdl"
new const WEAPON_MODEL_VIEW2[]		=	"models/xman2030/v_dualswordfx.mdl"
new const WEAPON_MODEL_PLAYER_A[]	=	"models/xman2030/p_dualsword_a.mdl"
new const WEAPON_MODEL_PLAYER_B[]	=	"models/xman2030/p_dualsword_b.mdl"

new const SKILL_REFERANCE[] = "info_target"
new const SKILL_CLASSNAME[] = "effect_dualsword"
new const SKILL_MODELS[][] =
{
	"models/xman2030/p_dualsword_skill.mdl",
	"models/xman2030/p_dualsword_skillfx1.mdl",
	"models/xman2030/p_dualsword_skillfx2.mdl"
}
new const SKILL_SOUNDS[][] =
{
	"weapons/dualsword_fly1.wav",	//0
	"weapons/dualsword_fly2.wav",	//1
	"weapons/dualsword_fly3.wav",	//2
	"weapons/dualsword_fly4.wav",	//3
	"weapons/dualsword_fly5.wav"	//4
}

new const SAKURA_SPRITES[][] =
{
	"sprites/x/leaf01_dualsword.spr",	// 0
	"sprites/x/leaf02_dualsword.spr",	// 1
	"sprites/x/petal01_dualsword.spr",	// 2
	"sprites/x/petal02_dualsword.spr"	// 3
}

// 0 - Правая кнопка | 1 - Левая кнопка
// Комбинация: П Л П П Л
new const WEAPON_SKILL_DATA[] = {0, 1}

new const WEAPON_SOUND_ATTACK[][] =
{
	"weapons/dualsword_slash_1.wav",	//0
	"weapons/dualsword_slash_2.wav",	//1
	"weapons/dualsword_slash_3.wav",	//2
	"weapons/dualsword_slash_4.wav",	//3
	"weapons/dualsword_hit1.wav",		//4
	"weapons/dualsword_hit2.wav",		//5
	"weapons/dualsword_hit3.wav",		//6
	"weapons/dualsword_stab1.wav",		//7
	"weapons/dualsword_stab1_hit.wav",	//8
	"weapons/dualsword_stab2.wav",		//9
	"weapons/dualsword_stab2_hit.wav",	//10
	"weapons/dualsword_wall.wav"		//11
}
new const WEAPON_SOUND_OTHER[][] =
{
	"weapons/dualsword_idle_a.wav",
	"weapons/dualsword_idle_b.wav",
	"weapons/dualsword_slash_end.wav",
	"weapons/dualsword_stab_end.wav",
	"weapons/dualsword_slash_4_1.wav",
	"weapons/dualsword_skill_end.wav",
	"weapons/dualsword_skill_loop_end.wav",
	"weapons/dualsword_skill_start.wav"
}

enum _: e_SkillEffect
{
	SE_0_1,
	SE_0_2,
	SE_1_1,
	SE_1_2,
	SE_1_3,
	SE_2_1
}

enum _: e_WeaponAnim
{
	ANIM_IDLE_A,
	ANIM_SLASH_END_A = 5,
	ANIM_DRAW_A,
	ANIM_SWAB_A = 12,
	ANIM_IDLE_B = 7,
	ANIM_STAB_B,
	ANIM_STAB2_B,
	ANIM_STAB_END_B,
	ANIM_DRAW_B,
	ANIM_SWAB_B = 13,
	ANIM_SKILL_START_A,
	ANIM_SKILL_A
}
enum _: e_WeaponAnim2
{
	ANIM_SLASH1_A,
	ANIM_SLASH2_A,
	ANIM_SLASH3_A,
	ANIM_SLASH4_A
}

new gl_iszAllocStringMdlView, 
	gl_iszAllocStringMdlView2, 
	gl_iszAllocStringMdlPlayerA, 
	gl_iszAllocStringMdlPlayerB,
	gl_iszAllocSrtingSkillRef,
	gl_iszAllocStringSkillName,

	gl_iModelIndexLeaf01,
	gl_iModelIndexLeaf02,
	gl_iModelIndexPetal01,
	gl_iModelIndexPetal02;
	
new Float:g_flUserLastSkill[33];
new const Float:g_flSkillCooldown = 30.0;
new const g_iTaskCooldown = 99597766;
	
public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);

	RegisterHam(Ham_Item_Deploy,			WEAPON_REFERANCE,	"CBasePlayerWeapon_Deploy_Post",	true);
	RegisterHam(Ham_Item_Holster,			WEAPON_REFERANCE,	"CBasePlayerWeapon_Holster_Post",	true);
	RegisterHam(Ham_Item_PostFrame,			WEAPON_REFERANCE,	"CBasePlayerWeapon_PostFrame",		false);
	RegisterHam(Ham_Weapon_WeaponIdle,		WEAPON_REFERANCE,	"CBasePlayerWeapon_WeaponIdle",		false);
	RegisterHam(Ham_Weapon_PrimaryAttack,	WEAPON_REFERANCE,	"CBasePlayerWeapon_PrimaryAttack",	false);
	RegisterHam(Ham_Weapon_SecondaryAttack, WEAPON_REFERANCE, 	"CBasePlayerWeapon_SecAttack", 		false);
	
	register_forward(FM_UpdateClientData, 	"FM_Hook_UpdateClientData_Post", 	true);

	register_think(SKILL_CLASSNAME, 		"DualSwordEf_Think");
}	
public plugin_precache()
{
	PRECACHE_MODEL(WEAPON_MODEL_VIEW);
	PRECACHE_MODEL(WEAPON_MODEL_VIEW2);
	PRECACHE_MODEL(WEAPON_MODEL_PLAYER_A);	
	PRECACHE_MODEL(WEAPON_MODEL_PLAYER_B);	
	
	for(new i; i < sizeof WEAPON_SOUND_ATTACK; i++)
	{
		PRECACHE_SOUND(WEAPON_SOUND_ATTACK[i]);
	}
	for(new i; i < sizeof WEAPON_SOUND_OTHER; i++)
	{
		PRECACHE_SOUND(WEAPON_SOUND_OTHER[i]);
	}
	for(new i; i < sizeof SKILL_MODELS; i++)
	{
		PRECACHE_MODEL(SKILL_MODELS[i]);
	}
	for(new i; i < sizeof SKILL_SOUNDS; i++)
	{
		PRECACHE_SOUND(SKILL_SOUNDS[i]);
	}
	
	gl_iszAllocStringMdlView	=	ALLOC_STRING(WEAPON_MODEL_VIEW);
	gl_iszAllocStringMdlView2	=	ALLOC_STRING(WEAPON_MODEL_VIEW2);
	gl_iszAllocStringMdlPlayerA	=	ALLOC_STRING(WEAPON_MODEL_PLAYER_A);
	gl_iszAllocStringMdlPlayerB	=	ALLOC_STRING(WEAPON_MODEL_PLAYER_B);
	gl_iszAllocSrtingSkillRef	=	ALLOC_STRING(SKILL_REFERANCE);
	gl_iszAllocStringSkillName	=	ALLOC_STRING(SKILL_CLASSNAME);

	gl_iModelIndexLeaf01		=	PRECACHE_MODEL(SAKURA_SPRITES[0]);
	gl_iModelIndexLeaf02		= 	PRECACHE_MODEL(SAKURA_SPRITES[1]);
	gl_iModelIndexPetal01		= 	PRECACHE_MODEL(SAKURA_SPRITES[2]);
	gl_iModelIndexPetal02		= 	PRECACHE_MODEL(SAKURA_SPRITES[3]);
}
public FM_Hook_UpdateClientData_Post(pPlayer, const SendWeapons, const CD_Handle) 
{
	if(zp_get_user_zombie(pPlayer) || !IsUserHasPhantomSlayer(pPlayer))
	{
		return;
	}

	if(get_cd(CD_Handle, CD_DeadFlag) != DEAD_NO)
	{
		if(get_cd(CD_Handle, CD_iUser1) != OBS_IN_EYE) 
		{
			return;
		}
		pPlayer = get_cd(CD_Handle, CD_iUser2);
		if(!pPlayer || !IsValidEntity(pPlayer))
		{
			return;
		}
	}
	static pActiveItem; pActiveItem = get_pdata_cbase(pPlayer, m_pActiveItem, linux_diff_weapon);
	if(!IsValidEntity(pActiveItem) || !IsCustomItem(pActiveItem))
	{
		return;
	}
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001);
}
public CBasePlayerWeapon_Deploy_Post(const pItem)
{
	if(!IsCustomItem(pItem))
	{
		return;
	}

	new bool:bIsA = (Get_DualSword_State(pItem) & WPNSTATE_KNIFE_A) ? true : false;
	
	new pPlayer = get_pdata_cbase(pItem, m_pPlayer, linux_diff_weapon);

	if(zp_get_user_zombie(pPlayer) || !IsUserHasPhantomSlayer(pPlayer))
	{
		return;
	}
	set_pev_string(pPlayer, pev_viewmodel2, gl_iszAllocStringMdlView);
	set_pev_string(pPlayer, pev_weaponmodel2, bIsA ? gl_iszAllocStringMdlPlayerA : gl_iszAllocStringMdlPlayerB);
	set_pdata_float(pItem, m_flTimeWeaponIdle, 0.4, linux_diff_weapon);
	set_pdata_string(pPlayer, m_szAnimExtention * 4, WEAPON_ANIM_EXTENSION, -1, linux_diff_player * 4);
	SendWeaponAnim(pPlayer, bIsA ? ANIM_DRAW_A : ANIM_DRAW_B);
	SET_NEXTATTACK(0.3);
	
	RESET_DUALSWORD_ITEM();
	DualSwordEf_Remove(pPlayer);
}
public CBasePlayerWeapon_Holster_Post(pItem)
{
	if(!IsCustomItem(pItem))
	{
		return;
	}
	
	new pPlayer = get_pdata_cbase(pItem, m_pPlayer, linux_diff_weapon);

	if(zp_get_user_zombie(pPlayer) || !IsUserHasPhantomSlayer(pPlayer))
	{
		return;
	}
	RESET_DUALSWORD_ITEM();
	DualSwordEf_Remove(pPlayer);
}
public CBasePlayerWeapon_PostFrame(pItem)
{
	if(!IsCustomItem(pItem))
	{
		return;
	}
	
	static Float:flDualSwordDelay01; pev(pItem, pev_fuser1, flDualSwordDelay01);
	static Float:flGameTime; flGameTime = get_gametime();
	static pPlayer; pPlayer = get_pdata_cbase(pItem, m_pPlayer, linux_diff_weapon);

	if(zp_get_user_zombie(pPlayer) || !IsUserHasPhantomSlayer(pPlayer))
	{
		return;
	}
	if(flDualSwordDelay01 != 0.0 && flDualSwordDelay01 <= flGameTime)
	{
		static Float:vecSrc[3];
		static Float:vecOrigin[3]; pev(pPlayer, pev_origin, vecOrigin);
		static Float:vecViewOfs[3]; pev(pPlayer, pev_view_ofs, vecViewOfs);
		static Float:vecAngles[3]; pev(pPlayer, pev_angles, vecAngles);
		static Float:vecForward[3], Float:vecRight[3], Float:vecUp[3];
		engfunc(EngFunc_AngleVectors, vecAngles, vecForward, vecRight, vecUp);
		xs_vec_add(vecOrigin, vecViewOfs, vecOrigin);
		xs_vec_copy(vecOrigin, vecSrc);
		
		static Float:flTemp[3];
		static iDirection; iDirection = get_pdata_int(pItem, m_iDirection, linux_diff_weapon);
		
		flTemp[0] = random_float(40.0, 100.0);
		flTemp[1] = random_float(30.0, 80.0);
		flTemp[2] = random_float(10.0, 40.0);
		
		xs_vec_mul_scalar(vecForward, flTemp[0], vecForward);
		xs_vec_mul_scalar(vecRight, flTemp[1], vecRight);
		xs_vec_mul_scalar(vecUp, flTemp[2], vecUp);
		
		xs_vec_add(vecSrc, vecForward, vecSrc);
		xs_vec_add(vecSrc, vecRight, vecSrc);
		xs_vec_add(vecSrc, vecUp, vecSrc);
		
		static iFlySword; iFlySword = DualSwordEf_Create(pPlayer, SE_2_1, vecSrc);
		if(iFlySword)
		{
			xs_vec_copy(vecAngles, flTemp);
			flTemp[1] = float(random_num(0, 360));
			flTemp[2] = float(random_num(-30, 60));
			set_pev(iFlySword, pev_angles, flTemp);
			angle_vector(flTemp, ANGLEVECTOR_FORWARD, flTemp);
			xs_vec_mul_scalar(flTemp, 500.0, flTemp);
			set_pev(iFlySword, pev_velocity, flTemp);
			emit_sound(iFlySword, CHAN_WEAPON, SKILL_SOUNDS[random(5)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
		}
		
		flTemp[0] = random_float(40.0, 100.0);
		flTemp[1] = random_float(30.0, 80.0);
		flTemp[2] = random_float(5.0, 40.0);
		
		if(random_num(0, 1))
		{
			flTemp[0] = -flTemp[0];
		}
		if(iDirection)
		{
			flTemp[1] = -flTemp[1];
		}
		
		engfunc(EngFunc_AngleVectors, vecAngles, vecForward, vecRight, vecUp);
		
		xs_vec_copy(vecOrigin, vecSrc);
		
		xs_vec_mul_scalar(vecForward, flTemp[0], vecForward);
		xs_vec_mul_scalar(vecRight, flTemp[1], vecRight);
		xs_vec_mul_scalar(vecUp, flTemp[2], vecUp);
		
		xs_vec_add(vecSrc, vecForward, vecSrc);
		xs_vec_add(vecSrc, vecRight, vecSrc);
		xs_vec_add(vecSrc, vecUp, vecSrc);
		
		vecAngles[0] += random_num(-60, 0);
		
		if(iDirection)
		{
			vecAngles[2] += (iDirection == 2) ? random_num(30, 60) : random_num(-30, -60);
		}
		
		DualSwordEf_Create(pPlayer, SE_1_1, vecSrc, vecAngles);
		
		static pVictim; pVictim = -1;
		static Float:vecTemp[3];
		static Float:flFraction;
		new tr = create_tr2();
		while((pVictim = FIND_ENTITY_IN_SPHERE(pVictim, vecSrc, 200.0)))
		{		
			if(pVictim == pPlayer) continue;
			if(!is_user_alive(pVictim)) continue;
			if(!zp_get_user_zombie(pVictim)) continue;
			pev(pVictim, pev_origin, vecTemp);
			
			engfunc(EngFunc_TraceLine, vecSrc, vecTemp, IGNORE_MONSTERS, pPlayer, tr);
			get_tr2(tr, TR_flFraction, flFraction);
			if(flFraction != 1.0) continue;
			
			ExecuteHamB(Ham_TakeDamage, pVictim, pPlayer, pPlayer, DUALSWORD_DAMAGE_MODE, (DMG_NEVERGIB | DMG_BULLET));
			UTIL_BloodDrips(vecTemp, DUALSWORD_DAMAGE_MODE);
		}
		free_tr2(tr);
			
		set_pev(pItem, pev_fuser1, flGameTime + 0.2);
		iDirection++;
		if(iDirection >= 2) iDirection = 0;
		set_pdata_int(pItem, m_iDirection, iDirection, linux_diff_weapon);
	}
	
	static Float:flDualSwordDelay; flDualSwordDelay = Get_DualSword_Delay(pItem);
	
	if(flDualSwordDelay == 0.0)
	{
		return;
	}
	
	set_pev(pPlayer, pev_button, pev(pPlayer, pev_button) & ~(IN_ATTACK|IN_ATTACK2));
	
	if(flDualSwordDelay <= flGameTime)
	{
		if(Get_DualSword_State(pItem) & WPNSTATE_KNIFE_SKILL)
		{
			DualSword_Skill(pItem);
			g_flUserLastSkill[pPlayer] = get_gametime();
			if(!task_exists(g_iTaskCooldown + pPlayer)) set_task(1.0, "task_Cooldown", g_iTaskCooldown + pPlayer, _, _, "b");
		}
		else
		{
			DualSword_PrimaryAttack(pItem);
		}
	}
}
public task_Cooldown(iPlayer) {

	iPlayer -= g_iTaskCooldown;
	if(get_gametime() - g_flUserLastSkill[iPlayer] > g_flSkillCooldown) {
	
		if(task_exists(g_iTaskCooldown + iPlayer)) remove_task(g_iTaskCooldown + iPlayer);
		return PLUGIN_HANDLED;
		
	}
	
	set_hudmessage(255, 120, 20, 0.7, 0.7, 0, _, 1.0, 0.2, 0.5, -1);
	show_hudmessage(iPlayer, "До следующей способности %d сек", floatround(g_flSkillCooldown - (get_gametime() - g_flUserLastSkill[iPlayer])));
	
	return PLUGIN_HANDLED;

}
public CBasePlayerWeapon_WeaponIdle(const pItem)
{
	if(!IsCustomItem(pItem))
	{
		return HAM_IGNORED;
	}
	if(get_pdata_float(pItem, m_flTimeWeaponIdle, linux_diff_weapon) > 0.0)
	{
		return HAM_IGNORED;
	}
	
	new iDualSwordState = Get_DualSword_State(pItem);
	new bool:bIsA = (iDualSwordState & WPNSTATE_KNIFE_A) ? true : false;
	new pPlayer = get_pdata_cbase(pItem, m_pPlayer, linux_diff_weapon);
	
	if(zp_get_user_zombie(pPlayer) || !IsUserHasPhantomSlayer(pPlayer))
	{
		return HAM_IGNORED;
	}
	if(iDualSwordState & WPNSTATE_KNIFE_ATTACK)
	{
		SendWeaponAnim(pPlayer, bIsA ? ANIM_SLASH_END_A : ANIM_STAB_END_B);
		set_pdata_float(pItem, m_flTimeWeaponIdle, bIsA ? 2.0 : 1.5, linux_diff_weapon);
		Set_DualSword_State(pItem, iDualSwordState & ~WPNSTATE_KNIFE_ATTACK);
		set_pev_string(pPlayer, pev_viewmodel2, gl_iszAllocStringMdlView);
	}
	else
	{
		SendWeaponAnim(pPlayer, bIsA ? ANIM_IDLE_A : ANIM_IDLE_B);
		set_pdata_float(pItem, m_flTimeWeaponIdle, 9999.0, linux_diff_weapon);
	}
	
	return HAM_SUPERCEDE;
}
public CBasePlayerWeapon_PrimaryAttack(const pItem)
{
	if(!IsCustomItem(pItem))
	{
		return HAM_IGNORED;
	}

	new pPlayer = get_pdata_cbase(pItem, m_pPlayer, linux_diff_weapon);

	if(zp_get_user_zombie(pPlayer) || !IsUserHasPhantomSlayer(pPlayer))
	{
		return HAM_IGNORED;
	}
	new iDualSwordState = Get_DualSword_State(pItem);

	if(~iDualSwordState & WPNSTATE_KNIFE_A)
	{
		Set_DualSword_State(pItem, iDualSwordState | WPNSTATE_KNIFE_A);
		set_pdata_float(pItem, m_flTimeWeaponIdle, 0.4, linux_diff_weapon);
		SendWeaponAnim(pPlayer, ANIM_SWAB_B);
		SET_NEXTATTACK(0.1);
		
		return HAM_SUPERCEDE;
	}
	
	set_pev_string(pPlayer,	pev_viewmodel2, gl_iszAllocStringMdlView2);
	set_pev_string(pPlayer, pev_weaponmodel2, gl_iszAllocStringMdlPlayerA);
	Set_DualSword_Delay(pItem, get_gametime());
	
	return HAM_SUPERCEDE;
}
public CBasePlayerWeapon_SecAttack(pItem)
{
	if(!IsCustomItem(pItem))
	{
		return HAM_IGNORED;
	}
	
	new pPlayer = get_pdata_cbase(pItem, m_pPlayer, linux_diff_weapon);

	if(zp_get_user_zombie(pPlayer) || !IsUserHasPhantomSlayer(pPlayer))
	{
		return HAM_IGNORED;
	}
	new iDualSwordState = Get_DualSword_State(pItem);
	new szAnimation[64];
	
	if(iDualSwordState & WPNSTATE_KNIFE_A)
	{
		Set_DualSword_State(pItem, iDualSwordState & ~WPNSTATE_KNIFE_A);
		set_pdata_float(pItem, m_flTimeWeaponIdle, 0.4, linux_diff_weapon);
		SendWeaponAnim(pPlayer, ANIM_SWAB_A);
		SET_NEXTATTACK(0.1);
		
		return HAM_SUPERCEDE;
	}
	
	set_pev_string(pPlayer,	pev_viewmodel2, gl_iszAllocStringMdlView);
	set_pev_string(pPlayer, pev_weaponmodel2, gl_iszAllocStringMdlPlayerB);

	new iResult = DualSword_Attack(pPlayer, 150.0, (iDualSwordState & WPNSTATE_KNIFE_HIT) ? DUALSOWRD_DAMAGE_STAB_HIT : DUALSOWRD_DAMAGE_STAB, 20.0, gl_iModelIndexLeaf01, gl_iModelIndexLeaf02);
	
	if(iDualSwordState & WPNSTATE_KNIFE_HIT)
	{
		SendWeaponAnim(pPlayer, ANIM_STAB2_B);
		SET_NEXTATTACK(0.4);
		set_pdata_float(pItem, m_flTimeWeaponIdle, 0.7, linux_diff_weapon);

		formatex(szAnimation, charsmax(szAnimation), pev(pPlayer, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", WEAPON_ANIM_EXTENSION);
		UTIL_PlayerAnimation(pPlayer, szAnimation);
		
		iDualSwordState &= ~WPNSTATE_KNIFE_HIT;
	}
	else
	{
		SendWeaponAnim(pPlayer, ANIM_STAB_B);
		SET_NEXTATTACK(0.4);
		set_pdata_float(pItem, m_flTimeWeaponIdle, 0.9, linux_diff_weapon);

		formatex(szAnimation, charsmax(szAnimation), pev(pPlayer, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", WEAPON_ANIM_EXTENSION);
		UTIL_PlayerAnimation(pPlayer, szAnimation);
		
		if(iResult == 2)
		{
			iDualSwordState |= WPNSTATE_KNIFE_HIT;
		}
	}
	
	switch(iResult)
	{
		case 0: emit_sound(pPlayer, CHAN_WEAPON, WEAPON_SOUND_ATTACK[9], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
		case 1: emit_sound(pPlayer, CHAN_WEAPON, WEAPON_SOUND_ATTACK[11], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
		case 2: emit_sound(pPlayer, CHAN_WEAPON, WEAPON_SOUND_ATTACK[10], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
	}
	
	DualSword_CheckSkill(pItem, pPlayer);
	
	if(iDualSwordState & WPNSTATE_KNIFE_SKILL)
	{
		iDualSwordState &= ~WPNSTATE_KNIFE_ATTACK;
	}
	else
	{
		iDualSwordState |= WPNSTATE_KNIFE_ATTACK;
	}
	Set_DualSword_State(pItem, iDualSwordState);
	
	return HAM_SUPERCEDE;
}

public DualSword_PrimaryAttack(pItem)
{
	new pPlayer = get_pdata_cbase(pItem, m_pPlayer, linux_diff_weapon);

	if(zp_get_user_zombie(pPlayer) || !IsUserHasPhantomSlayer(pPlayer))
	{
		return;
	}
	new iSwing = Get_DualSword_Swing(pItem);
	new szAnimation[64];
	
	SendWeaponAnim(pPlayer, iSwing);
	
	set_pdata_float(pItem, m_flTimeWeaponIdle, 0.9, linux_diff_weapon);
	SET_NEXTATTACK(0.15);
	
	switch(DualSword_Attack(pPlayer, 100.0, DUALSOWRD_DAMAGE_SLASH, 40.0, gl_iModelIndexPetal01, gl_iModelIndexPetal02))
	{
		case 0: emit_sound(pPlayer, CHAN_WEAPON, WEAPON_SOUND_ATTACK[iSwing], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
		case 1: emit_sound(pPlayer, CHAN_WEAPON, WEAPON_SOUND_ATTACK[11], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
		case 2: emit_sound(pPlayer, CHAN_WEAPON, WEAPON_SOUND_ATTACK[random_num(4, 6)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
	}
	
	iSwing++;
	if(iSwing >= 4)
	{
		iSwing = 0;
		Set_DualSword_Delay(pItem, 0.0);
		DualSword_CheckSkill(pItem, pPlayer);
	}
	else
	{
		Set_DualSword_Delay(pItem, get_gametime() + 0.15);
	}

	formatex(szAnimation, charsmax(szAnimation), pev(pPlayer, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", WEAPON_ANIM_EXTENSION);
	UTIL_PlayerAnimation(pPlayer, szAnimation);
	
	Set_DualSword_Swing(pItem, iSwing);
	
	new iDualSwordState = Get_DualSword_State(pItem);
	if(iDualSwordState & WPNSTATE_KNIFE_SKILL)
	{
		iDualSwordState &= ~WPNSTATE_KNIFE_ATTACK;
	}
	else
	{
		iDualSwordState |= WPNSTATE_KNIFE_ATTACK;
	}
	Set_DualSword_State(pItem, iDualSwordState);
}
public DualSword_Skill(pItem)
{
	new pPlayer = get_pdata_cbase(pItem, m_pPlayer, linux_diff_weapon);

	if(zp_get_user_zombie(pPlayer) || !IsUserHasPhantomSlayer(pPlayer))
	{
		return;
	}
	switch(Get_DualSword_Data01(pItem))
	{
		case 0:
		{
			set_pev_string(pPlayer, pev_viewmodel2, gl_iszAllocStringMdlView);
			SendWeaponAnim(pPlayer, ANIM_SKILL_START_A);
			SET_NEXTATTACK(0.9);
			set_pdata_float(pItem, m_flTimeWeaponIdle, 1.0, linux_diff_weapon);
			Set_DualSword_Data01(pItem, 1);	
			Set_DualSword_Delay(pItem, get_gametime() + 0.9);
			DualSwordEf_Create(pPlayer, SE_0_1);
		}
		case 1:
		{
			SendWeaponAnim(pPlayer, ANIM_SKILL_A);
			set_pdata_float(pItem, m_flTimeWeaponIdle, 11.6, linux_diff_weapon);
			Set_DualSword_Delay(pItem, get_gametime() + 10.7);
			Set_DualSword_Data01(pItem, 2);	
			set_pev(pItem, pev_fuser1, get_gametime());
		}
		case 2:
		{
			DualSwordEf_Create(pPlayer, SE_0_2);
			Set_DualSword_State(pItem, Get_DualSword_State(pItem) & ~WPNSTATE_KNIFE_SKILL);
			Set_DualSword_Data01(pItem, 0);	
			Set_DualSword_Delay(pItem, 0.0);
			set_pev(pItem, pev_fuser1, 0.0);
		}
	}
}

stock SendWeaponAnim(const pPlayer, const iAnim, const iBody = 0) 
{
	set_pev(pPlayer, pev_weaponanim, iAnim);
	message_begin(MSG_ONE, SVC_WEAPONANIM, _, pPlayer);
	write_byte(iAnim);
	write_byte(iBody);
	message_end();
	
	new iPlayersID[MAX_CLIENTS], pPlayerID, iCount, i;
	get_players(iPlayersID, iCount, "bch");
	for(i = 0; i < iCount; i++) 
	{
		pPlayerID = iPlayersID[i];
		if(IsObserver(pPlayerID) != OBS_IN_EYE || pev(pPlayerID, pev_iuser2) != pPlayer) 
		{
			continue;
		}

		set_pev(pPlayerID, pev_weaponanim, iAnim);
		message_begin(MSG_ONE, SVC_WEAPONANIM, _, pPlayerID);
		write_byte(iAnim);
		write_byte(iBody);
		message_end();
	}
	return iAnim;
}
stock FindHullIntersection(const Float: vecSrc[3], &iTrace, const Float: vecMins[3], const Float: vecMaxs[3], const iEntity)
{
	new iTempTrace;
	
	new Float: flFraction;
	new Float: flThisDistance;
	
	new Float: vecEnd[3];
	new Float: vecEndPos[3];
	new Float: vecHullEnd[3];
	new Float: vecMinMaxs[2][3];
	
	new Float: flDistance = 999999.0;
	
	xs_vec_copy(vecMins, vecMinMaxs[0]);
	xs_vec_copy(vecMaxs, vecMinMaxs[1]);
	
	get_tr2(iTrace, TR_vecEndPos, vecHullEnd);
	
	xs_vec_sub(vecHullEnd, vecSrc, vecHullEnd);
	xs_vec_mul_scalar(vecHullEnd, 2.0, vecHullEnd);
	xs_vec_add(vecHullEnd, vecSrc, vecHullEnd);
	
	engfunc(EngFunc_TraceLine, vecSrc, vecHullEnd, DONT_IGNORE_MONSTERS, iEntity, (iTempTrace = create_tr2()));
	get_tr2(iTempTrace, TR_flFraction, flFraction);
	
	if (flFraction < 1.0)
	{
		free_tr2(iTrace);
		
		iTrace = iTempTrace;
		return;
	}
	
	for (new j, k, i = 0; i < 2; i++)
	{
		for (j = 0; j < 2; j++)
		{
			for (k = 0; k < 2; k++)
			{
				vecEnd[0] = vecHullEnd[0] + vecMinMaxs[i][0];
				vecEnd[1] = vecHullEnd[1] + vecMinMaxs[j][1];
				vecEnd[2] = vecHullEnd[2] + vecMinMaxs[k][2];
				
				engfunc(EngFunc_TraceLine, vecSrc, vecEnd, DONT_IGNORE_MONSTERS, iEntity, iTempTrace);
				get_tr2(iTempTrace, TR_flFraction, flFraction);
				
				if (flFraction < 1.0)
				{
					get_tr2(iTempTrace, TR_vecEndPos, vecEndPos);
					xs_vec_sub(vecEndPos, vecSrc, vecEndPos);
					
					if ((flThisDistance = xs_vec_len(vecEndPos)) < flDistance)
					{
						free_tr2(iTrace);
						
						iTrace = iTempTrace;
						flDistance = flThisDistance;
					}
				}
			}
		}
	}
}

stock DualSword_Attack(const pPlayer, const Float:flDistance, const Float:flDamage, const Float:flAngle, const iModelIndex01, const iModelIndex02)
{
	new Float:vecOrigin[3], Float:vecViewOfs[3];
	new Float:vecSrc[3], Float:vecEnd[3];
	new Float:vecViewAngle[3];
	new Float:vecDir[3], Float:vecForward[3];

	new pTrace = create_tr2();
	new Float:flFraction, pHit;

	pev(pPlayer, pev_origin, vecOrigin);
	pev(pPlayer, pev_view_ofs, vecViewOfs);
	pev(pPlayer, pev_v_angle, vecViewAngle);

	angle_vector(vecViewAngle, ANGLEVECTOR_FORWARD, vecForward);

	xs_vec_add(vecOrigin, vecViewOfs, vecSrc);
	
	new bitsDamageType = (DMG_NEVERGIB | DMG_BULLET);
	
	new iResult = 0;
	
	xs_vec_mul_scalar(vecForward, flDistance, vecDir);
	xs_vec_copy(vecSrc, vecEnd);
	xs_vec_add(vecEnd, vecDir, vecEnd);

	engfunc(EngFunc_TraceLine, vecSrc, vecEnd, DONT_IGNORE_MONSTERS, pPlayer, pTrace);
	get_tr2(pTrace, TR_flFraction, flFraction);
	
	if(flFraction == 1.0)
	{
		engfunc(EngFunc_TraceHull, vecSrc, vecEnd, DONT_IGNORE_MONSTERS, HULL_HEAD, pPlayer, pTrace);
		get_tr2(pTrace, TR_flFraction, flFraction);
	}
	
	if(flFraction < 1.0) 
	{
		iResult = 1;
	}
	
	new pVictim = -1;
	new Float:flDirAngle;
	new Float:vecTemp[3];
	while((pVictim = FIND_ENTITY_IN_SPHERE(pVictim, vecOrigin, flDistance)))
	{		
		if(pVictim == pPlayer) continue;
		
		if(pev(pVictim, pev_solid) == SOLID_BSP)
		{
			xs_vec_mul_scalar(vecForward, flDistance, vecDir);
			xs_vec_copy(vecSrc, vecEnd);
			xs_vec_add(vecEnd, vecDir, vecEnd);
		}
		else
		{
			pev(pVictim, pev_origin, vecEnd);
		
			xs_vec_sub(vecEnd, vecSrc, vecDir);
			xs_vec_normalize(vecDir, vecDir);
		
			flDirAngle = floatacos(xs_vec_dot(vecDir, vecForward), degrees);
		
			if(flDirAngle > flAngle)
			{
				continue;
			}
		
			vector_to_angle(vecDir, vecTemp);
			vecTemp[0] = vecViewAngle[0];
			vecTemp[2] = vecViewAngle[2];
			angle_vector(vecTemp, ANGLEVECTOR_FORWARD, vecTemp);
		
			xs_vec_mul_scalar(vecTemp, flDistance, vecDir);
			xs_vec_copy(vecSrc, vecEnd);
			xs_vec_add(vecEnd, vecDir, vecEnd);
		}
		
		xs_vec_copy(vecForward,	vecTemp);
		
		TRACE_LINE(vecSrc, vecEnd, DONT_IGNORE_MONSTERS, pPlayer, pTrace);
		get_tr2(pTrace, TR_flFraction, flFraction);
		
		if(flFraction >= 1.0)
		{
			TRACE_HULL(vecSrc, vecEnd, DONT_IGNORE_MONSTERS, HULL_HEAD, pPlayer, pTrace);
			get_tr2(pTrace, TR_flFraction, flFraction);
		
			if(flFraction < 1.0)
			{
				pHit = get_tr2(pTrace, TR_pHit);
				if(!IsValidEntity(pHit)) pHit = 0;
			
				if(!pHit || ExecuteHamB(Ham_IsBSPModel, pHit))
				{
					FindHullIntersection(vecSrc, pTrace, Float:{-16.0, -16.0, -18.0}, Float:{16.0, 16.0, 36.0}, pPlayer);
				}
			}
		}
		
		if(flFraction >= 1.0)
		{
			continue;
		}
		
		pHit = get_tr2(pTrace, TR_pHit);
		if(!IsValidEntity(pHit)) pHit = 0;
	
		if(!pHit)
		{
			if(!iResult) iResult = 1;
			continue;
		}
		
		if(pHit != pVictim)
		{
			continue;
		}
		
		if(pev(pHit, pev_flags) & (FL_CLIENT|FL_MONSTER))
		{
			FakeTraceAttack(pHit, pPlayer, flDamage, vecTemp, pTrace, bitsDamageType);
			iResult = 2;
		}
		else if(pev(pVictim, pev_solid) == SOLID_BSP && !(pev(pHit, pev_spawnflags) & SF_BREAK_TRIGGER_ONLY))
		{
			ExecuteHamB(Ham_TakeDamage, pHit, pPlayer, pPlayer, flDamage, bitsDamageType);
			if(iResult != 2) iResult = 1;
		}
	}

	new Float:vecEndPos[3]; get_tr2(pTrace, TR_vecEndPos, vecEndPos);

	if(iResult)
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_SPRITETRAIL);
		engfunc(EngFunc_WriteCoord, vecEndPos[0]); // Start pos X
		engfunc(EngFunc_WriteCoord, vecEndPos[1]); // Start pos Y
		engfunc(EngFunc_WriteCoord, vecEndPos[2]); // Start pos Z
		engfunc(EngFunc_WriteCoord, vecEndPos[0]); // End pos X
		engfunc(EngFunc_WriteCoord, vecEndPos[1]); // End pos Y
		engfunc(EngFunc_WriteCoord, vecEndPos[2] + 10.0); // End pos Z
		write_short(iModelIndex01); // Model index
		write_byte(5); // Count
		write_byte(1); // Life
		write_byte(random_num(1, 2)); // Scale
		write_byte(25); // Speed noise
		write_byte(5); // Speed
		message_end();

		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(TE_SPRITETRAIL);
		engfunc(EngFunc_WriteCoord, vecEndPos[0]); // Start pos X
		engfunc(EngFunc_WriteCoord, vecEndPos[1]); // Start pos Y
		engfunc(EngFunc_WriteCoord, vecEndPos[2]); // Start pos Z
		engfunc(EngFunc_WriteCoord, vecEndPos[0]); // End pos X
		engfunc(EngFunc_WriteCoord, vecEndPos[1]); // End pos Y
		engfunc(EngFunc_WriteCoord, vecEndPos[2] + 10.0); // End pos Z
		write_short(iModelIndex02); // Model index
		write_byte(5); // Count
		write_byte(1); // Life
		write_byte(random_num(1, 2)); // Scale
		write_byte(25); // Speed noise
		write_byte(5); // Speed
		message_end();
	}
	
	free_tr2(pTrace);
	return iResult;
}
stock bool:FakeTraceAttack(const pVictim, const pAttacker, const Float:flDamage, const Float:vecDir[3], const pTrace, const bitsDamageType)
{
	if(pev(pVictim, pev_takedamage) == DAMAGE_NO) 
	{
		return false; 
	}

	new iHitGroup = get_tr2(pTrace, TR_iHitgroup);
	new bool:bBlockBlood;

	if(is_user_connected(pVictim)) //Is victim player
	{
		if(!zp_get_user_zombie(pVictim))
		{
			return false;
		}
	}

	new Float:flTake = flDamage;
	new iBloodColor = ExecuteHamB(Ham_BloodColor, pVictim);

	switch(iHitGroup) 
	{
		case HIT_HEAD:
		{
			flTake *= 3.0;
		}
		case HIT_LEFTARM, HIT_RIGHTARM, HIT_LEFTLEG, HIT_RIGHTLEG: 
		{
			flTake *= 0.75;
		}
		case HIT_STOMACH:
		{
			flTake *= 1.5;
		}
	}

	set_pdata_int(pVictim, m_LastHitGroup, iHitGroup, linux_diff_player);

	ExecuteHamB(Ham_TakeDamage, pVictim, pAttacker, pAttacker, flTake, bitsDamageType);

	if(iBloodColor != -1 && !bBlockBlood)
	{
		ExecuteHamB(Ham_TraceBleed, pVictim, flTake, vecDir, pTrace, bitsDamageType);

		new Float:vecEndPos[3]; get_tr2(pTrace, TR_vecEndPos, vecEndPos);

		UTIL_BloodDrips(vecEndPos, flTake);
	}

	return true;
}
stock Entity_PlayAnimation(pEntity, iAnimation, Float:flFrameRate = 1.0)
{
	set_pev(pEntity, pev_framerate, flFrameRate);
	set_pev(pEntity, pev_sequence, iAnimation);
	set_pev(pEntity, pev_animtime, get_gametime());
	set_pev(pEntity, pev_frame, 0.0);
	return iAnimation;
}
public DualSword_CheckSkill(pItem, pPlayer)
{
	new iDualSwordState = Get_DualSword_State(pItem);
	new iDualSwordData01 = Get_DualSword_Data01(pItem);
	new iValue = (iDualSwordState & WPNSTATE_KNIFE_A) ? 1 : 0;
	
	if(WEAPON_SKILL_DATA[iDualSwordData01] != iValue)
	{
		iDualSwordData01 = 0;
	}
	else
	{
		iDualSwordData01++;

		if(iDualSwordData01 >= sizeof WEAPON_SKILL_DATA)
		{
			iDualSwordData01 = 0;
			if(get_gametime() - g_flUserLastSkill[pPlayer] >= g_flSkillCooldown) {
			
				Set_DualSword_State(pItem, iDualSwordState | WPNSTATE_KNIFE_SKILL);
				Set_DualSword_Delay(pItem, get_gametime());
			
			}
		}
	}	
		
	Set_DualSword_Data01(pItem, iDualSwordData01);
}
stock DualSwordEf_Create(pPlayer, iEffect, Float:vecOrigin[3] = {0.0, 0.0, 0.0}, Float:vecAngles[3] = {0.0, 0.0, 0.0})
{
	static pEntity; pEntity = CREATE_NAMED_ENTITY(gl_iszAllocSrtingSkillRef);
	if(!IsValidEntity(pEntity))
	{
		return 0;
	}
	
	switch(iEffect)
	{
		case SE_0_1:
		{
			SET_MODEL(pEntity, SKILL_MODELS[0]);
			Entity_PlayAnimation(pEntity, 0);
			set_pev_string(pEntity, pev_classname, gl_iszAllocStringSkillName);
			set_pev(pEntity, pev_owner, pPlayer);
			set_pev(pEntity, pev_nextthink, get_gametime());
			set_pev(pEntity, pev_fuser1, get_gametime() + 1.4);
		}
		case SE_0_2:
		{
			SET_MODEL(pEntity, SKILL_MODELS[0]);
			Entity_PlayAnimation(pEntity, 1);
			set_pev_string(pEntity, pev_classname, gl_iszAllocStringSkillName);
			set_pev(pEntity, pev_owner, pPlayer);
			set_pev(pEntity, pev_nextthink, get_gametime());
			set_pev(pEntity, pev_fuser1, get_gametime() + 1.1);
		}
		case SE_1_1:
		{
			
			SET_MODEL(pEntity, SKILL_MODELS[1]);
			Entity_PlayAnimation(pEntity, 0);
			set_pev_string(pEntity, pev_classname, gl_iszAllocStringSkillName);
			set_pev(pEntity, pev_owner, pPlayer);
			set_pev(pEntity, pev_nextthink, get_gametime() + random_float(0.65, 1.0));
		}
		case SE_1_2:
		{
			SET_MODEL(pEntity, SKILL_MODELS[1]);
			Entity_PlayAnimation(pEntity, 1);
			set_pev_string(pEntity, pev_classname, gl_iszAllocStringSkillName);
			set_pev(pEntity, pev_owner, pPlayer);
			set_pev(pEntity, pev_nextthink, get_gametime() + random_float(0.65, 1.0));
		}
		case SE_1_3:
		{
			SET_MODEL(pEntity, SKILL_MODELS[1]);
			Entity_PlayAnimation(pEntity, 2);
			set_pev_string(pEntity, pev_classname, gl_iszAllocStringSkillName);
			set_pev(pEntity, pev_owner, pPlayer);
			set_pev(pEntity, pev_nextthink, get_gametime() + random_float(0.65, 1.0));
		}
		case SE_2_1:
		{
			SET_MODEL(pEntity, SKILL_MODELS[2]);
			Entity_PlayAnimation(pEntity, 2);
			set_pev_string(pEntity, pev_classname, gl_iszAllocStringSkillName);
			set_pev(pEntity, pev_movetype, MOVETYPE_FLY);
			set_pev(pEntity, pev_owner, pPlayer);
			set_pev(pEntity, pev_nextthink, get_gametime() + random_float(0.2, 0.4));
		}
	}
	
	SET_ORIGIN(pEntity, vecOrigin);
	set_pev(pEntity, pev_angles, vecAngles);
	
	set_pev(pEntity, pev_impulse, iEffect);
	
	return pEntity;
}
stock DualSwordEf_Remove(pPlayer, iEffect = -1)
{
	if(!is_user_connected(pPlayer)) return;

	new pEntity = -1;
	if(iEffect == -1)
	{
		while((pEntity = find_ent_by_owner(pEntity, SKILL_CLASSNAME, pPlayer)))
		{
			REMOVE_ENTITY(pEntity);
		}
	}
	else 
	{
		while((pEntity = find_ent_by_owner(pEntity, SKILL_CLASSNAME, pPlayer)))
		{
			if(pev(pEntity, pev_impulse) == iEffect)
			{
				REMOVE_ENTITY(pEntity);
			}
		}
	}
}
public DualSwordEf_Think(pEntity)
{
	static Float:vecOrigin[3], Float:vecAngles[3], pOwner;
	static Float:flLiveTime; pev(pEntity, pev_fuser1, flLiveTime);
			
	if(flLiveTime != 0.0 && flLiveTime <= get_gametime())
	{
		REMOVE_ENTITY(pEntity);
		return;
	}
	
	switch(pev(pEntity, pev_impulse))
	{
		case SE_0_1, SE_0_2:
		{
			pOwner = pev(pEntity, pev_owner);
			
			pev(pOwner, pev_origin, vecOrigin);
			pev(pOwner, pev_angles, vecAngles);
			
			SET_ORIGIN(pEntity, vecOrigin);
			set_pev(pEntity, pev_angles, vecAngles);
			set_pev(pEntity, pev_nextthink, get_gametime());
			set_pev(pEntity, pev_velocity, Float:{0.0, 0.0, 1.0});
			
		}
		default:
		{
			REMOVE_ENTITY(pEntity);
		}
	}
}
public UTIL_BloodDrips(Float:vecEndPos[3], Float:flDamage)
{
	static iSpriteIndexBloodSpray, iSpriteIndexBloodDrop;
	if(!iSpriteIndexBloodSpray)
	{
		iSpriteIndexBloodSpray = MODEL_INDEX("sprites/bloodspray.spr");
	}
	if(!iSpriteIndexBloodDrop)
	{
		iSpriteIndexBloodDrop = MODEL_INDEX("sprites/blood.spr");
	}

	new iAmount = min(floatround(flDamage * 1.5), 255);

	MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, vecEndPos, 0);
	write_byte(TE_BLOODSPRITE);
	WRITE_COORD(vecEndPos[0]);
	WRITE_COORD(vecEndPos[1]);
	WRITE_COORD(vecEndPos[2]);
	write_short(iSpriteIndexBloodSpray);
	write_short(iSpriteIndexBloodDrop);
	write_byte(247);
	write_byte(min(max(3,iAmount/10),16));
	message_end();
}
stock UTIL_PlayerAnimation(const iPlayer, const szAnim[]) 
{
	new iAnimDesired, Float: flFrameRate, Float: flGroundSpeed, bool: bLoops;
		
	if ((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1) 
	{
		iAnimDesired = 0;
	}
	
	new Float: flGametime = get_gametime();

	set_pev(iPlayer, pev_frame, 0.0);
	set_pev(iPlayer, pev_framerate, 1.0);
	set_pev(iPlayer, pev_animtime, flGametime);
	set_pev(iPlayer, pev_sequence, iAnimDesired);
	
	set_pdata_int(iPlayer, m_fSequenceLoops, bLoops, linux_diff_animation);
	set_pdata_int(iPlayer, m_fSequenceFinished, 0, linux_diff_animation);
	
	set_pdata_float(iPlayer, m_flFrameRate, flFrameRate, linux_diff_animation);
	set_pdata_float(iPlayer, m_flGroundSpeed, flGroundSpeed, linux_diff_animation);
	set_pdata_float(iPlayer, m_flLastEventCheck, flGametime , linux_diff_animation);
	
	set_pdata_int(iPlayer, m_Activity, ACT_RANGE_ATTACK1, linux_diff_player);
	set_pdata_int(iPlayer, m_IdealActivity, ACT_RANGE_ATTACK1, linux_diff_player);
	set_pdata_float(iPlayer, m_flLastAttackTime, flGametime , linux_diff_player);
}

stock IsUserHasPhantomSlayer(iPlayer) {

	new szName[128];
	GetUserItemName(iPlayer, szName);
	return equal(szName, "PhantomSlayer");

}
strangeguy is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 12-07-2019 , 13:32   Re: [ZP] Dual Phantom Sword
Reply With Quote #2

set the variable IsUserHasPhantomSlayer[] to either 1 or 0.This tutorial will help
DjSoftero is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode