Shove Player

In jos

descarca Shove Player

Mesaj Scris de CelRau la data de Sam Noi 26, 2016 11:27 am

Descriere: Pluginul va permite sa impingeti/loviti jucatorii, pe butonul E (+use)

Sursa:
Spoiler:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

#pragma semicolon 1

#define PLUGIN_NAME "[CS] Shove Player"
#define PLUGIN_VERS "5.0"
#define PLUGIN_AUTH "81x08"

#define MAX_PLAYERS 32

#define IsPlayer(%0) (1 <= %0 <= MAX_PLAYERS)

#define XO_PLAYER 5

#define m_flNextAttack 83
#define m_pActiveItem 373

#define MsgId_ScreenFade 98
#define MsgId_ScreenShake 97

#define TASK_FILLING_SHOVE_FORCE 100
#define TASK_ITEM_DEPLOY_POST_ANIM 200

#if !defined Ham_CS_Player_ResetMaxSpeed
#define Ham_CS_Player_ResetMaxSpeed Ham_Item_PreFrame
#endif

#define SP_SHOVE_EFFECTS /* Efecte de pe urma loviturii | Comentati ( // ), daca nu aveti nevoie de efecte */

#define SP_IMMUNITY_FLAG ADMIN_BAN /* Imunitate jucatorilor de a nu fi loviti | Comentati ( // ), daca doriti ca toti sa poata fi loviti */

#define SP_TIME_DELAY 10 /* Peste cat timp se va putea da o noua lovitura */
#define SP_MAX_FORCE_STAGE 5 /* Numarul maxim de trepte al fortei loviturii */

#define SP_MAX_DISTANCE Float: 75.0 /* Distanta maxima dintre jucatori, pentru a putea efectua lovitura */
#define SP_WAIT_TIME_NEXT_FORCE_STAGE Float: 1.0 /* Delay-ul dintre acumularile de forta (pe trepte) */

#define SP_DAMAGE_ONE_STAGE Float: 2.0 /* Damage per treapta de forta [5 trepte * 2.0 = 10.0 HP] | Comentati ( // ), daca nu doriti sa se ia damage */

#define SP_FORCE_STAGE_FACTOR Float: 3.0 /* Coeficient multiplicator al fortei [STAGE_MAX * STAGE_FACTOR] */
#define SP_FORCE_DUCKING_FACTOR 2.0 /* Coeficientul multiplicator al fortei loviturii stand in pozitie asezata in aer */
#define SP_FORCE_STANDING_FACTOR 1.6 /* Coeficientul multiplicator al fortei loviturii stand in pozitie dreapta in aer */
#define SP_FORCE_ONGROUND_DUCKING_FACTOR 0.8 /* Coeficientul multiplicator al fortei loviturii stand in pozitie asezata pe pamant */
#define SP_FORCE_ONGROUND_STANDING_FACTOR 1.4 /* Coeficientul multiplicator al fortei loviturii stand in pozitie dreapta pe pamant */

enum ENUM_DATA_FORCE_STAGE {
FG_R,
FG_G,
FG_B,
FG_STYLE[64]
};

enum _: ENUM_DATA_SHOVE_SOUNDS {
SHOVE_SOUND_HIT,
SHOVE_SOUND_SLASH
};

new const g_szShoveSounds[ENUM_DATA_SHOVE_SOUNDS][] = {
"shove/shove_hit.wav",
"shove/shove_slash.wav"
};

new const g_szShoveAnimation[] = {"models/shove/shove.mdl"};

new const g_szShoveForceStage[SP_MAX_FORCE_STAGE][ENUM_DATA_FORCE_STAGE] = {
{0, 255, 0,    "•       •"},
{125, 255, 0,   "••       ••"},
{255, 255, 0,  "•••       •••"},
{255, 125, 0, "••••       ••••"},
{255, 0, 0, "•••••       •••••"}
};

new g_iSyncShowStatusForceStage;

new bool: gp_bIsDefusing[MAX_PLAYERS + 1 char],
bool: gp_bIsImmunity[MAX_PLAYERS + 1 char],
bool: gp_bIsAnimation[MAX_PLAYERS + 1 char];

new gp_iForceStage[MAX_PLAYERS + 1 char],
gp_iTimeShovePlayer[MAX_PLAYERS + 1 char];

new Float: gp_fTimeNextForceStage[MAX_PLAYERS + 1 char];

/*================================================================================
[PLUGIN]
=================================================================================*/
public plugin_precache() {
for(new iSize = sizeof(g_szShoveSounds), iCount = 0; iCount < iSize; iCount++)
precache_sound(g_szShoveSounds[iCount]);

precache_model(g_szShoveAnimation);
}

public plugin_init() {
/* [PLUGIN] */
register_plugin(PLUGIN_NAME, PLUGIN_VERS, PLUGIN_AUTH);

/* [EVENT] */
register_event("BarTime", "EventHook_DropDefusing", "b", "1=0");
register_event("BarTime", "EventHook_StartDefusing", "be", "1=5", "1=10");

/* [FAKEMETA] */
register_forward(FM_EmitSound, "FMHook_EmitSound", false);

/* [HAMSANDWICH] */
RegisterHam(Ham_CS_Player_ResetMaxSpeed, "player", "HamHook_CS_Player_ResetMaxSpeed", true);

/* [OTHER] */
g_iSyncShowStatusForceStage = CreateHudSyncObj();
}

/*================================================================================
[CLIENT]
=================================================================================*/
#if defined SP_IMMUNITY_FLAG
public client_putinserver(pId) {
if(get_user_flags(pId) & SP_IMMUNITY_FLAG)
gp_bIsImmunity[pId] = true;
}
#endif

#if AMXX_VERSION_NUM < 183
public client_disconnect(pId) {
#else
public client_disconnected(pId) {
#endif
gp_bIsDefusing[pId] = false;
gp_bIsImmunity[pId] = false;
gp_bIsAnimation[pId] = false;

gp_iForceStage[pId] = 0;
gp_iTimeShovePlayer[pId] = 0;

gp_fTimeNextForceStage[pId] = 0.0;

if(task_exists(pId + TASK_FILLING_SHOVE_FORCE))
remove_task(pId + TASK_FILLING_SHOVE_FORCE);
}

/*================================================================================
[FAKEMETA]
=================================================================================*/
public FMHook_EmitSound(const pId, const iChannel, const szSample[]) {
if(IsPlayer(pId)) {
if(szSample[7] == 'w' && szSample[8] == 'p' && szSample[11] == 'd' && szSample[14] == 'y' && szSample[15] == 's') {
/* sound - "common/wpn_denyselect.wav" */
if(!(gp_bIsDefusing[pId])) {
new iSysTime = get_systime();
if(gp_iTimeShovePlayer[pId] <= iSysTime) {
set_task(0.1, "taskFillingShoveForce", pId + TASK_FILLING_SHOVE_FORCE, .flags = "b");
return HAM_SUPERCEDE;
} else client_print(pId, print_center, "Asteptati [%d] sec.", gp_iTimeShovePlayer[pId] - iSysTime);
}
}
}

return FMRES_IGNORED;
}

/*================================================================================
[EVENT]
=================================================================================*/
public EventHook_DropDefusing(const pId)
gp_bIsDefusing[pId] = false;

public EventHook_StartDefusing(const pId)
gp_bIsDefusing[pId] = true;

/*================================================================================
[HAMSANDWICH]
=================================================================================*/
public HamHook_CS_Player_ResetMaxSpeed(const pId) {
if(gp_bIsAnimation[pId])
entity_set_float(pId, EV_FL_maxspeed, 1.0);

return HAM_IGNORED;
}

/*================================================================================
[STOCK]
=================================================================================*/
static stock funcShovePlayer(const pId, const iForceStage) {
new iFlags = entity_get_int(pId, EV_INT_flags);
new iButton = entity_get_int(pId, EV_INT_button);

new Float: fForceFactor;
if(iButton & IN_DUCK) fForceFactor = (iFlags & FL_ONGROUND) ? SP_FORCE_ONGROUND_DUCKING_FACTOR : SP_FORCE_DUCKING_FACTOR;
else fForceFactor = (iFlags & FL_ONGROUND) ? SP_FORCE_ONGROUND_STANDING_FACTOR : SP_FORCE_STANDING_FACTOR;

new tId, iBody;
get_user_aiming(pId, tId, iBody, _:SP_MAX_DISTANCE);

if(IsPlayer(tId) && !(gp_bIsImmunity[tId])) {
new Float: fOrigin[3], Float: fTargetOrigin[3];
entity_get_vector(pId, EV_VEC_origin, fOrigin);
entity_get_vector(tId, EV_VEC_origin, fTargetOrigin);

new Float: fDistance = get_distance_f(fOrigin, fTargetOrigin);
if(fDistance <= SP_MAX_DISTANCE) {
new Float: fVelocity[3];

fVelocity[0] = (fTargetOrigin[0] - fOrigin[0]) * (iForceStage * SP_FORCE_STAGE_FACTOR) * fForceFactor;
fVelocity[1] = (fTargetOrigin[1] - fOrigin[1]) * (iForceStage * SP_FORCE_STAGE_FACTOR) * fForceFactor;
fVelocity[2] = (fTargetOrigin[2] - fOrigin[2]) * (iForceStage * SP_FORCE_STAGE_FACTOR) * fForceFactor;

entity_set_vector(tId, EV_VEC_velocity, fVelocity);

#if defined SP_DAMAGE_ONE_STAGE
new Float: fDamage = iForceStage * SP_DAMAGE_ONE_STAGE;
new Float: fHealth = entity_get_float(tId, EV_FL_health) - fDamage;
fHealth <= 0 ? ExecuteHamB(Ham_Killed, tId, pId, 0) : entity_set_float(tId, EV_FL_health, fHealth);
#endif

#if defined SP_SHOVE_EFFECTS
UTIL_ScreenFade(tId, (1<<(9+iForceStage)), (1<<(9+iForceStage)), 0, {50, 0, 0}, 150);
UTIL_ScreenShake(tId, (1<<(10+iForceStage)), (1<<(10+iForceStage)), (1<<(10+iForceStage)));
#endif

client_print(pId, print_center, "Ai impins jucatorul.");

emit_sound(tId, CHAN_AUTO, "player/pl_die1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
emit_sound(pId, CHAN_AUTO, g_szShoveSounds[SHOVE_SOUND_HIT], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}
}

gp_bIsAnimation[pId] = true;
ExecuteHamB(Ham_CS_Player_ResetMaxSpeed, pId);

entity_set_string(pId, EV_SZ_viewmodel, g_szShoveAnimation);
UTIL_PlayerAnimation(pId, 1);

set_task(0.80, "taskItemDeployPostAnim", pId + TASK_ITEM_DEPLOY_POST_ANIM);

set_pdata_float(pId, m_flNextAttack, 1.03, XO_PLAYER);

gp_iForceStage[pId] = 0;
gp_iTimeShovePlayer[pId] = get_systime() + SP_TIME_DELAY;

emit_sound(pId, CHAN_AUTO, g_szShoveSounds[SHOVE_SOUND_SLASH], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}

/*================================================================================
[TASK]
=================================================================================*/
public taskFillingShoveForce(pId) {
pId -= TASK_FILLING_SHOVE_FORCE;

if(gp_bIsDefusing[pId]) {
remove_task(pId + TASK_FILLING_SHOVE_FORCE);
return;
}

if(entity_get_int(pId, EV_INT_button) & IN_USE) {
new Float: fGameTime = get_gametime();
if(gp_fTimeNextForceStage[pId] <= fGameTime) {
set_hudmessage(g_szShoveForceStage[gp_iForceStage[pId]][FG_R], g_szShoveForceStage[gp_iForceStage[pId]][FG_G], g_szShoveForceStage[gp_iForceStage[pId]][FG_B], -1.0, -1.0, 0, 0.0, SP_WAIT_TIME_NEXT_FORCE_STAGE + 0.1, 0.0, 0.0);
ShowSyncHudMsg(pId, g_iSyncShowStatusForceStage, g_szShoveForceStage[gp_iForceStage[pId]][FG_STYLE]);

gp_iForceStage[pId]++;
gp_fTimeNextForceStage[pId] = fGameTime + SP_WAIT_TIME_NEXT_FORCE_STAGE;

if(gp_iForceStage[pId] >= SP_MAX_FORCE_STAGE) {
funcShovePlayer(pId, gp_iForceStage[pId]);
remove_task(pId + TASK_FILLING_SHOVE_FORCE);
}
}
} else if(gp_iForceStage[pId]) {
funcShovePlayer(pId, gp_iForceStage[pId]);
remove_task(pId + TASK_FILLING_SHOVE_FORCE);
}
}

public taskItemDeployPostAnim(pId) {
pId -= TASK_ITEM_DEPLOY_POST_ANIM;

gp_bIsAnimation[pId] = false;
ExecuteHamB(Ham_CS_Player_ResetMaxSpeed, pId);

new iActiveItem = get_pdata_cbase(pId, m_pActiveItem, XO_PLAYER);
if(iActiveItem > 0) ExecuteHamB(Ham_Item_Deploy, iActiveItem);
}

/*================================================================================
[UTIL]
=================================================================================*/
static stock UTIL_PlayerAnimation(const pId, const iAnimation) {
entity_set_int(pId, EV_INT_weaponanim, iAnimation);

message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = pId);
{
write_byte(iAnimation);
write_byte(0);
}

message_end();
}

static stock UTIL_ScreenShake(const pId, const iAmplitude, const iDuration, const iFrequency,const iReliable = 0) {
message_begin(iReliable ? MSG_ONE : MSG_ONE_UNRELIABLE, MsgId_ScreenShake, .player = pId);
{
write_short(iAmplitude);
write_short(iDuration);
write_short(iFrequency);
}

message_end();
}

static stock UTIL_ScreenFade(const pId, const iDuration, const iHoldTime, const iFlags, const iColor[3], const iAlpha, const iReliable = 0) {
message_begin(iReliable ? MSG_ONE : MSG_ONE_UNRELIABLE, MsgId_ScreenFade, .player = pId);
{
write_short(iDuration);
write_short(iHoldTime);
write_short(iFlags);
write_byte(iColor[0]);
write_byte(iColor[1]);
write_byte(iColor[2]);
write_byte(iAlpha);
}

message_end();
}

Nume: Shove Player
Versiune: 5.0
Download: http://www.girlshare.ro/3489258479.3

Instalare:
1. Fisierul cs_shove_player.amxx.amxx il puneti in addons/amxmodx/plugins
2. Intrati in fisierul addons/amxmodx/configs/plugins.ini si adaugati urmatoarea linie:
Cod:
cs_shove_player.amxx
3. Mutati fisierul .mdl si respectiv sunetele conform folderelor: /models/shove si /sound/shove

Cvar-uri (se adauga in fisierul amxmodx\configs\amxx.cfg):

    setarile pluignului se modifica din defines


Comenzi administrative (se tasteaza in consola si trebuie sa fiti administrator):
-

Comenzi publice (se tasteaza in joc prin apasarea tastei Y):
-

Module necesare (se sterge ; din fata modulului de mai jos; acestea le gasiti in fisierul amxmodx\configs\modules.ini):
engine
fakemeta
hamsandwich

Spoiler:
1. Acumularea fortei: Prima treapta


2. Acumularea fortei: A treia treapta


3. Acumularea fortei: A cincea treapta


4. Animatie

P.S. Pot fi anumite greseli de sens in descrierea defines. M-am straduit sa traduc cat de cat pe intelesul tuturor.
avatar
CelRau
Registered user
Registered user

Mesaje : 184
Data de inscriere : 26/11/2016

Sus In jos

Sus


 
Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum