- Ошибка
-
x_knife_balrog9.sma(164) : error 017: undefined symbol "IsUserHasBalrog9"
x_knife_balrog9.sma(164) : error 017: undefined symbol "iPlayer"
x_knife_balrog9.sma(164 -- 165) : warning 215: expression has no effect
x_knife_balrog9.sma(165) : error 028: invalid subscript (not an array or too many subscripts): "g_iBitUserHasBalrog9"
x_knife_balrog9.sma(165) : fatal error 107: too many error messages on one line
- Компилятор
- WEB-компилятор
- Amx Mod X
- 1.9.0
- Исходный код
-
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#define IsValidEntity(%1) (pev_valid(%1) == PDATA_SAFE)
#define IsCustomItem(%1) (get_pdata_int(%1, m_iId, linux_diff_weapon) == CSW_KNIFE)
#define IsUserHasBalrog9(%1) Get_Bit(g_iBitUserHasBalrog9, %1)
#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 Set_NextAttack(%1) \
set_pdata_float(iItem, m_flNextPrimaryAttack, %1, linux_diff_weapon), \
set_pdata_float(iItem, m_flNextSecondaryAttack, %1, linux_diff_weapon), \
set_pdata_float(iPlayer, m_flNextAttack, %1, linux_diff_player)
#define PDATA_SAFE 2
#define OBS_IN_EYE 4
#define DONT_BLEED -1
#define DMG_GRENADE (1<<24)
// Linux extra offsets
#define linux_diff_weapon 4
#define linux_diff_player 5
// CBasePlayerItem
#define m_pPlayer 41
#define m_iId 43
// CBasePlayerWeapon
#define m_flNextPrimaryAttack 46
#define m_flNextSecondaryAttack 47
#define m_flTimeWeaponIdle 48
#define m_iWeaponState 74
// CBaseMonster
#define m_LastHitGroup 75
#define m_flNextAttack 83
// CBasePlayer
#define m_iPlayerTeam 114
#define m_pActiveItem 373
enum _: e_AnimList
{
ANIM_IDLE = 0,
ANIM_SLASH1,
ANIM_SLASH2,
ANIM_SLASH3,
ANIM_SLASH4,
ANIM_SLASH5,
ANIM_DRAW,
ANIM_CHARGE_START,
ANIM_CHARGE_FINISH,
ANIM_CHARGE_IDLE_NOT_FINISH,
ANIM_CHARGE_IDLE_FINISH,
ANIM_CHARGE_ATTACK_NOT_FINISH,
ANIM_CHARGE_ATTACK_FINISH
};
enum _: e_HitResultList
{
SLASH_HIT_NONE = 0,
SLASH_HIT_WORLD,
SLASH_HIT_ENTITY
};
new const KNIFE_SOUNDS[][] =
{
"weapons/balrog9_charge_attack2.wav", // 0
"weapons/balrog9_charge_finish1.wav", // 1
"weapons/balrog9_charge_start1.wav", // 2
"weapons/balrog9_draw.wav", // 3
"weapons/balrog9_hit1.wav", // 4
"weapons/balrog9_hit2.wav", // 5
"weapons/balrog9_slash1.wav" // 6
};
#define ANIM_IDLE_TIME 201/30.0
#define ANIM_SLASH_TIME 37/30.0
#define ANIM_DRAW_TIME 40/30.0
#define ANIM_CHARGE_START_TIME 22/30.0
#define ANIM_CHARGE_FINISH_TIME 10/30.0
#define ANIM_CHARGE_IDLE_TIME 30/30.0
#define ANIM_CHARGE_ATTACK_TIME 49/30.0
#define KNIFE_VIEW_MODEL "models/x/v_balrog9.mdl"
#define KNIFE_PLAYER_MODEL "models/x/p_balrog9.mdl"
#define KNIFE_SLASH_DISTANCE 90.0
#define KNIFE_STAB_DISTANCE 120.0
#define KNIFE_SLASH_DAMAGE 65.0
#define KNIFE_STAB_DAMAGE 90.0
#define KNIFE_EXPLODE_RADIUS 250.0
#define KNIFE_EXPLODE_DAMAGE random_float(350.0, 700.0)
new g_iBitUserHasBalrog9,
g_iszModelIndexBloodSpray,
g_iszModelIndexBloodDrop,
g_iszModelIndexExplode,
g_iszAllocString_ModelView,
g_iszAllocString_ModelPlayer;
public plugin_init()
{
register_plugin("Balrog-9", "1.0", "xUnicorn (t3rkecorejz)");
register_forward(FM_UpdateClientData, "FM_Hook_UpdateClientData_Post", true);
RegisterHam(Ham_Item_PostFrame, "weapon_knife", "CKnife__PostFrame_Pre", false);
RegisterHam(Ham_Item_Deploy, "weapon_knife", "CKnife__Deploy_Post", true);
RegisterHam(Ham_Weapon_WeaponIdle, "weapon_knife", "CKnife__Idle_Pre", false);
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "CKnife__PrimaryAttack_Pre", false);
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "CKnife__SecondaryAttack_Pre", false);
register_clcmd("say b9", "Command__GiveBalrog9");
}
public plugin_precache()
{
// Precache models
engfunc(EngFunc_PrecacheModel, KNIFE_VIEW_MODEL);
engfunc(EngFunc_PrecacheModel, KNIFE_PLAYER_MODEL);
// Precache sounds
new i;
for(i = 0; i < sizeof KNIFE_SOUNDS; i++)
engfunc(EngFunc_PrecacheSound, KNIFE_SOUNDS[i]);
// Other
g_iszAllocString_ModelView = engfunc(EngFunc_AllocString, KNIFE_VIEW_MODEL);
g_iszAllocString_ModelPlayer = engfunc(EngFunc_AllocString, KNIFE_PLAYER_MODEL);
// Model Index
g_iszModelIndexBloodSpray = engfunc(EngFunc_PrecacheModel, "sprites/bloodspray.spr");
g_iszModelIndexBloodDrop = engfunc(EngFunc_PrecacheModel, "sprites/blood.spr");
g_iszModelIndexExplode = engfunc(EngFunc_PrecacheModel, "sprites/x/balrogcritical.spr");
}
public plugin_natives()
{
register_native("give_balrog9", "Command__GiveBalrog9", 1);
register_native("remove_balrog9", "remove_balrog9", 1);
}
public Command__GiveBalrog9(iPlayer)
{
if(!IsUserHasBalrog9(iPlayer)) Set_Bit(g_iBitUserHasBalrog9, iPlayer);
else Reset_Bit(g_iBitUserHasBalrog9, iPlayer);
}
public remove_balrog9(id)
{
IsUserHasBalrog9[iPlayer] = 0
g_iBitUserHasBalrog9[iPlayer] = 0
}
public FM_Hook_UpdateClientData_Post(iPlayer, SendWeapons, CD_Handle)
{
if(get_cd(CD_Handle, CD_DeadFlag) != DEAD_NO) return;
if(!IsUserHasBalrog9(iPlayer) || zp_get_user_zombie(iPlayer) || get_user_weapon(iPlayer) != CSW_KNIFE) return;
set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.01);
}
public CKnife__PostFrame_Pre(iItem)
{
if(!IsCustomItem(iItem)) return;
new iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
if(!IsUserHasBalrog9(iPlayer) || zp_get_user_zombie(iPlayer)) return;
static iWeaponState; iWeaponState = get_pdata_int(iItem, m_iWeaponState, linux_diff_weapon);
static iButton; iButton = pev(iPlayer, pev_button);
static Float: vecOrigin[3]; pev(iPlayer, pev_origin, vecOrigin);
static Float: vecVelocity[3]; velocity_by_aim(iPlayer, 50, vecVelocity);
static iVictim; iVictim = -1;
vecVelocity[0] += vecOrigin[0];
vecVelocity[1] += vecOrigin[1];
vecVelocity[2] += vecOrigin[2];
if(!(iButton & IN_ATTACK2))
{
switch(iWeaponState)
{
case 1, 2:
{
UTIL_SendWeaponAnim(iPlayer, ANIM_CHARGE_ATTACK_NOT_FINISH, 0);
set_pdata_int(iItem, m_iWeaponState, 0, linux_diff_weapon);
set_pdata_float(iItem, m_flTimeWeaponIdle, ANIM_SLASH_TIME, linux_diff_weapon);
FakeTraceLine(iPlayer, iItem, KNIFE_STAB_DISTANCE, KNIFE_STAB_DAMAGE, true);
}
case 3, 4:
{
UTIL_SendWeaponAnim(iPlayer, ANIM_CHARGE_ATTACK_FINISH, 0);
set_pdata_int(iItem, m_iWeaponState, 0, linux_diff_weapon);
set_pdata_float(iItem, m_flTimeWeaponIdle, ANIM_SLASH_TIME, linux_diff_weapon);
FakeTraceLine(iPlayer, iItem, KNIFE_STAB_DISTANCE, KNIFE_STAB_DAMAGE, false);
while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecVelocity, KNIFE_EXPLODE_RADIUS)) > 0)
{
if(pev(iVictim, pev_takedamage) == DAMAGE_NO)
{
continue;
}
if(is_user_alive(iVictim))
{
if(iVictim == iPlayer || zp_get_user_zombie(iPlayer) || !zp_get_user_zombie(iVictim))
{
continue;
}
}
else if(pev(iVictim, pev_solid) == SOLID_BSP)
{
if(pev(iVictim, pev_spawnflags) & SF_BREAK_TRIGGER_ONLY)
{
continue;
}
}
set_pev(iVictim, pev_punchangle, Float: { 10.0, 10.0, 10.0 });
set_pdata_int(iVictim, m_LastHitGroup, HIT_GENERIC, linux_diff_player);
ExecuteHamB(Ham_TakeDamage, iVictim, iPlayer, iPlayer, KNIFE_EXPLODE_DAMAGE, DMG_GRENADE);
}
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_EXPLOSION);
engfunc(EngFunc_WriteCoord, vecVelocity[0]);
engfunc(EngFunc_WriteCoord, vecVelocity[1]);
engfunc(EngFunc_WriteCoord, vecVelocity[2]);
write_short(g_iszModelIndexExplode);
write_byte(2); // Scale
write_byte(1); // Framerate
write_byte(0); // Flags
message_end();
}
}
}
}
public CKnife__Deploy_Post(iItem)
{
if(!IsCustomItem(iItem)) return;
new iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
if(!IsUserHasBalrog9(iPlayer) || zp_get_user_zombie(iPlayer)) return;
set_pev_string(iPlayer, pev_viewmodel2, g_iszAllocString_ModelView);
set_pev_string(iPlayer, pev_weaponmodel2, g_iszAllocString_ModelPlayer);
UTIL_SendWeaponAnim(iPlayer, ANIM_DRAW, 0);
set_pdata_int(iItem, m_iWeaponState, 0, linux_diff_weapon);
set_pdata_float(iItem, m_flTimeWeaponIdle, ANIM_DRAW_TIME, linux_diff_weapon);
Set_NextAttack(ANIM_DRAW_TIME + 0.1);
}
public CKnife__Idle_Pre(iItem)
{
if(!IsCustomItem(iItem)) return HAM_IGNORED;
if(get_pdata_float(iItem, m_flTimeWeaponIdle, linux_diff_weapon) > 0.0) return HAM_IGNORED;
new iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
if(!IsUserHasBalrog9(iPlayer) || zp_get_user_zombie(iPlayer)) return HAM_IGNORED;
UTIL_SendWeaponAnim(iPlayer, ANIM_IDLE, 0);
set_pdata_float(iItem, m_flTimeWeaponIdle, ANIM_IDLE_TIME, linux_diff_weapon);
return HAM_SUPERCEDE;
}
public CKnife__PrimaryAttack_Pre(iItem)
{
if(!IsCustomItem(iItem)) return HAM_IGNORED;
new iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
if(!IsUserHasBalrog9(iPlayer) || zp_get_user_zombie(iPlayer)) return HAM_IGNORED;
static iAnim;
UTIL_SendWeaponAnim(iPlayer, iAnim + ANIM_SLASH1, 0);
if(iAnim + ANIM_SLASH1 == ANIM_SLASH5) iAnim = 0;
else iAnim++;
set_pdata_float(iItem, m_flTimeWeaponIdle, ANIM_SLASH_TIME, linux_diff_weapon);
FakeTraceLine(iPlayer, iItem, KNIFE_SLASH_DISTANCE, KNIFE_SLASH_DAMAGE, true);
return HAM_SUPERCEDE;
}
public CKnife__SecondaryAttack_Pre(iItem)
{
if(!IsCustomItem(iItem)) return HAM_IGNORED;
new iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
if(!IsUserHasBalrog9(iPlayer) || zp_get_user_zombie(iPlayer)) return HAM_IGNORED;
static iWeaponState; iWeaponState = get_pdata_int(iItem, m_iWeaponState, linux_diff_weapon);
switch(iWeaponState)
{
case 0:
{
UTIL_SendWeaponAnim(iPlayer, ANIM_CHARGE_START, 0);
set_pdata_int(iItem, m_iWeaponState, 1, linux_diff_weapon);
Set_NextAttack(ANIM_CHARGE_START_TIME);
}
case 1:
{
UTIL_SendWeaponAnim(iPlayer, ANIM_CHARGE_IDLE_NOT_FINISH, 0);
set_pdata_int(iItem, m_iWeaponState, 2, linux_diff_weapon);
Set_NextAttack(ANIM_CHARGE_IDLE_TIME * 1.5);
}
case 2:
{
UTIL_SendWeaponAnim(iPlayer, ANIM_CHARGE_FINISH, 0);
set_pdata_int(iItem, m_iWeaponState, 3, linux_diff_weapon);
Set_NextAttack(ANIM_CHARGE_FINISH_TIME);
}
case 3, 4:
{
UTIL_SendWeaponAnim(iPlayer, ANIM_CHARGE_IDLE_FINISH, 0);
set_pdata_int(iItem, m_iWeaponState, 4, linux_diff_weapon);
Set_NextAttack(ANIM_CHARGE_IDLE_TIME);
}
}
return HAM_SUPERCEDE;
}
public FakeTraceLine(iPlayer, iItem, Float: flDistance, Float: flDamage, bool: bEffect)
{
new Float: flOrigin[3], Float: flAngle[3], Float: flEnd[3], Float: flViewOfs[3];
new Float: flForw[3], Float: flUp[3], Float: flRight[3];
pev(iPlayer, pev_origin, flOrigin);
pev(iPlayer, pev_view_ofs, flViewOfs);
flOrigin[0] += flViewOfs[0];
flOrigin[1] += flViewOfs[1];
flOrigin[2] += flViewOfs[2];
pev(iPlayer, pev_v_angle, flAngle);
engfunc(EngFunc_AngleVectors, flAngle, flForw, flRight, flUp);
new iTrace = create_tr2();
new Float: flSendAngles[] = { 0.0 };
new Float: flSendAnglesUp[] = { 0.0 };
new Float: flTan;
new Float: flMul;
static Float: flFraction, pHit;
static pHitEntity; pHitEntity = SLASH_HIT_NONE;
static iHitResult; iHitResult = SLASH_HIT_NONE;
for(new i; i < sizeof flSendAngles; i++)
{
flTan = floattan(flSendAngles[i], degrees);
flEnd[0] = (flForw[0] * flDistance) + (flRight[0] * flTan * flDistance) + flUp[0] * flSendAnglesUp[i];
flEnd[1] = (flForw[1] * flDistance) + (flRight[1] * flTan * flDistance) + flUp[1] * flSendAnglesUp[i];
flEnd[2] = (flForw[2] * flDistance) + (flRight[2] * flTan * flDistance) + flUp[2] * flSendAnglesUp[i];
flMul = (flDistance/vector_length(flEnd));
flEnd[0] *= flMul;
flEnd[1] *= flMul;
flEnd[2] *= flMul;
flEnd[0] = flEnd[0] + flOrigin[0];
flEnd[1] = flEnd[1] + flOrigin[1];
flEnd[2] = flEnd[2] + flOrigin[2];
engfunc(EngFunc_TraceLine, flOrigin, flEnd, DONT_IGNORE_MONSTERS, iPlayer, iTrace);
get_tr2(iTrace, TR_flFraction, flFraction);
if(flFraction == 1.0)
{
engfunc(EngFunc_TraceHull, flOrigin, flEnd, HULL_HEAD, iPlayer, iTrace);
get_tr2(iTrace, TR_flFraction, flFraction);
engfunc(EngFunc_TraceLine, flOrigin, flEnd, DONT_IGNORE_MONSTERS, iPlayer, iTrace);
pHit = get_tr2(iTrace, TR_pHit);
}
else
{
pHit = get_tr2(iTrace, TR_pHit);
}
if(flFraction != 1.0)
{
if(!iHitResult) iHitResult = SLASH_HIT_WORLD;
}
if(pHit > 0 && pHitEntity != pHit)
{
if(pev(pHit, pev_solid) == SOLID_BSP && !(pev(pHit, pev_spawnflags) & SF_BREAK_TRIGGER_ONLY))
{
ExecuteHamB(Ham_TakeDamage, pHit, iPlayer, iPlayer, flDamage, DMG_NEVERGIB | DMG_CLUB);
}
else
{
FakeTraceAttack(pHit, iPlayer, flDamage, flForw, iTrace, DMG_NEVERGIB | DMG_CLUB);
}
iHitResult = SLASH_HIT_ENTITY;
pHitEntity = pHit;
}
}
free_tr2(iTrace);
if(bEffect)
{
switch(iHitResult)
{
case SLASH_HIT_NONE:
{
emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[6], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
Set_NextAttack(0.6);
}
case SLASH_HIT_WORLD:
{
emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[4], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
set_pev(iPlayer, pev_punchangle, Float: { -2.0, 0.0, 0.0 });
Set_NextAttack(0.3);
}
case SLASH_HIT_ENTITY:
{
emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[5], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
set_pev(iPlayer, pev_punchangle, Float: { -2.0, 0.0, 0.0 });
Set_NextAttack(0.3);
}
}
}
}
public FakeTraceAttack(iVictim, iAttacker, Float: flDamage, Float: vecDirection[3], iTrace, ibitsDamageBits)
{
static Float: flTakeDamage; pev(iVictim, pev_takedamage, flTakeDamage);
if(flTakeDamage == DAMAGE_NO) return 0;
if(!(is_user_alive(iVictim))) return 0;
if(is_user_connected(iVictim))
{
if(get_pdata_int(iVictim, m_iPlayerTeam, linux_diff_player) == get_pdata_int(iAttacker, m_iPlayerTeam, linux_diff_player))
return 0;
}
static iHitgroup; iHitgroup = get_tr2(iTrace, TR_iHitgroup);
static Float: vecEndPos[3]; get_tr2(iTrace, TR_vecEndPos, vecEndPos);
static iBloodColor; iBloodColor = ExecuteHamB(Ham_BloodColor, iVictim);
set_pdata_int(iVictim, m_LastHitGroup, iHitgroup, linux_diff_player);
switch(iHitgroup)
{
case HIT_HEAD: flDamage *= 3.0;
case HIT_LEFTARM, HIT_RIGHTARM: flDamage *= 0.75;
case HIT_LEFTLEG, HIT_RIGHTLEG: flDamage *= 0.75;
case HIT_STOMACH: flDamage *= 1.5;
}
ExecuteHamB(Ham_TakeDamage, iVictim, iAttacker, iAttacker, flDamage, ibitsDamageBits);
//if(zp_get_user_zombie(iVictim))
{
if(iBloodColor != DONT_BLEED)
{
ExecuteHamB(Ham_TraceBleed, iVictim, flDamage, vecDirection, iTrace, ibitsDamageBits);
UTIL_BloodDrips(vecEndPos, iBloodColor, floatround(flDamage));
}
}
return 1;
}
stock UTIL_SendWeaponAnim(iPlayer, iAnim, iBody)
{
set_pev(iPlayer, pev_weaponanim, iAnim);
message_begin(MSG_ONE, SVC_WEAPONANIM, _, iPlayer);
write_byte(iAnim);
write_byte(iBody);
message_end();
static i, iCount, iSpectator, iszSpectators[32];
if(pev(iPlayer, pev_iuser1)) return;
get_players(iszSpectators, iCount, "bch");
for(i = 0; i < iCount; i++)
{
iSpectator = iszSpectators[i];
if(pev(iSpectator, pev_iuser1) != OBS_IN_EYE) continue;
if(pev(iSpectator, pev_iuser2) != iPlayer) continue;
set_pev(iSpectator, pev_weaponanim, iAnim);
message_begin(MSG_ONE, SVC_WEAPONANIM, _, iSpectator);
write_byte(iAnim);
write_byte(iBody);
message_end();
}
}
public UTIL_BloodDrips(Float:vecOrigin[3], iColor, iAmount) {
if(iAmount > 255) iAmount = 255;
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin, 0);
write_byte(TE_BLOODSPRITE);
engfunc(EngFunc_WriteCoord, vecOrigin[0]);
engfunc(EngFunc_WriteCoord, vecOrigin[1]);
engfunc(EngFunc_WriteCoord, vecOrigin[2]);
write_short(g_iszModelIndexBloodSpray);
write_short(g_iszModelIndexBloodDrop);
write_byte(iColor);
write_byte(min(max(3,iAmount/10),16));
message_end();
}
В общем, не могу создать изъятие ножа с нативом, я не шарю особо в этом, кто может помочь?
В этой теме было размещено решение! Перейти к решению.