Здравствуйте, помогите внедрить контроль урона в мод. Третий день копаюсь, пытаюсь - ничего не получается. Сам плагин не работает из-за того, что урон наносится монстрам, а не людям. В основном плагине есть паблик, в котором описывается добавление хедшота и крит.урона. пытался туда вставить код - не сработало...
Упоминания паблика в plugin_init()
RegisterHam(Ham_TakeDamage, "info_target", "TakeDamage")
Мне нужно совместить вышеуказанный паблик и паблик hook_TakeDamage из плагина, который, прикрепленный ниже. И что бы множитель работал, когда стреляешь в монстров... Прошу помощи, ребят. Пробовал внедрить его таким образом - не получилось...
Упоминания паблика в plugin_init()
RegisterHam(Ham_TakeDamage, "info_target", "TakeDamage")
PHP:
public TakeDamage(ent, idinflictor, attacker, Float:damage, damagetype)
{
if(!is_user_connected(attacker))
return HAM_IGNORED
if(IsMonster(ent))
{
/* Additional damage for weapons*/
static bool:isCritical; isCritical = false;
static bool:isHs; isHs = false;
if(damagetype & DMG_BULLET)
{
if(g_PlayerInfo[attacker][PLAYER_EXTRA_DAMAGE])
damage += float(g_PlayerInfo[attacker][PLAYER_EXTRA_DAMAGE])
if(g_IsPlayerVip[attacker])
damage *= g_ConfigValuesFloat[CFG_FLOAT_VIP_EXTRA_DAMAGE_MLTP];
if(random_num(1, 100) < g_PlayerInfo[attacker][PLAYER_CRITICAl_PERCENT])
isCritical = true;
isHs = entity_get_edict(ent, EV_ENT_monster_headshot) == 1;
static iWeapon; iWeapon = get_user_weapon(attacker)
static szData[3];
szData[0] = floatround(damage);
szData[1] = isCritical ? 1 : 0;
szData[2] = isHs ? 1 : 0;
new iRet;
ExecuteForward(g_ForwardTakeDamage, iRet, attacker, ent, iWeapon, damage, PrepareArray(szData, 3, 1))
damage = float(szData[0])
isCritical = szData[1] == 1;
isHs = szData[2] == 1;
if(isCritical) {
damage *= 2.5;
slowMonsterByCriticalShot(ent);
}
if(isHs)
{
entity_set_edict(ent, EV_ENT_monster_headshot, 1)
damage *= g_ConfigValuesFloat[CFG_FLOAT_HEADSHOT_MULTIPLIER];
}
if(floatround(entity_get_float(ent, EV_FL_health)-damage) <= 0)
{
entity_set_int(ent, EV_INT_monster_track, -2);
makeDeathMsg(attacker, isHs, 0)
}
ExecuteForward(g_ForwardTakeDamagePost, iRet, attacker, ent, iWeapon, damage, PrepareArray(szData, 3, 0))
}
else if(damagetype & DMG_BURN)
{
if(floatround(entity_get_float(ent, EV_FL_health)-damage) <= 0)
{
entity_set_int(ent, EV_INT_monster_track, -2);
makeDeathMsg(attacker, 0, 1)
}
}
/* Update healthbar frame */
if(is_valid_ent(entity_get_edict(ent, EV_ENT_monster_healthbar)))
entity_set_float( entity_get_edict(ent, EV_ENT_monster_healthbar) , EV_FL_frame , 0.0 + ( (entity_get_float(ent, EV_FL_health)-floatround(damage)) * 100.0 ) / entity_get_int(ent, EV_INT_monster_maxhealth));
if(!(damagetype & DMG_BLAST) && !(damagetype & DMG_DROWN) && !(damagetype & DMG_BURN))
{
/* Display left HP */
/*
if(g_ConfigValues[CFG_SHOW_LEFT_DAMAGE])
{
if(floatround(entity_get_float(ent, EV_FL_health)-damage) < 0)
client_print(attacker, print_center, "KILL");
else
client_print(attacker, print_center, "Остаток здоровья: %d", floatround(entity_get_float(ent, EV_FL_health)-damage));
}
*/
if(g_ConfigValues[CFG_DAMAGE_MONEY])
{
g_PlayerHittedDamage[attacker] += floatround(damage)
if(g_PlayerHittedDamage[attacker] >= g_ConfigValues[CFG_DAMAGE_RATIO])
{
g_PlayerHittedDamage[attacker] = 0
cs_set_user_money(attacker, (cs_get_user_money(attacker)+g_ConfigValues[CFG_DAMAGE_MONEY]) > 16000 ? 16000 : (cs_get_user_money(attacker)+g_ConfigValues[CFG_DAMAGE_MONEY]))
client_cmd(attacker, "spk sound/%s", g_SoundFile[SND_COIN]);
}
}
}
set_task(0.1, "ShowBloodEffect", ent + TASK_DAMAGE_EFFECT)
}
SetHamParamFloat(4, damage)
return HAM_IGNORED
}
Мне нужно совместить вышеуказанный паблик и паблик hook_TakeDamage из плагина, который, прикрепленный ниже. И что бы множитель работал, когда стреляешь в монстров... Прошу помощи, ребят.
21 Фев 2019
PHP:
public TakeDamage(Useless, ent, idinflictor, attacker, Float:damage, damagetype)
{
if(!is_user_connected(attacker))
return HAM_IGNORED
if(IsMonster(ent))
{
/* Additional damage for weapons*/
static bool:isCritical; isCritical = false;
static bool:isHs; isHs = false;
if(damagetype & DMG_BULLET)
{
static cvar
cvar = get_pcvar_num(P_Cvars[0])
if(!cvar)return HAM_IGNORED
static iWeapon;
if(Useless <= Max_Players && Useless != 0)
iWeapon = get_user_weapon(attacker)
else
{
static classname[32]
pev(Useless,pev_classname,classname,31)
if(equal(classname,"grenade"))iWeapon = 4
else if(!Useless)iWeapon = 2
}
if(!iWeapon)return HAM_IGNORED
static Float:dmg
dmg=get_pcvar_float(P_Cvars[iWeapon])
if(dmg == 1.0)
{
dmg = get_pcvar_float(P_Cvars[9])
if(dmg == 1.0)return HAM_IGNORED
}
damage *= dmg
if(g_PlayerInfo[attacker][PLAYER_EXTRA_DAMAGE])
damage += float(g_PlayerInfo[attacker][PLAYER_EXTRA_DAMAGE])
if(g_IsPlayerVip[attacker])
damage *= g_ConfigValuesFloat[CFG_FLOAT_VIP_EXTRA_DAMAGE_MLTP];
if(random_num(1, 100) < g_PlayerInfo[attacker][PLAYER_CRITICAl_PERCENT])
isCritical = true;
isHs = entity_get_edict(ent, EV_ENT_monster_headshot) == 1;
static szData[3];
szData[0] = floatround(damage);
szData[1] = isCritical ? 1 : 0;
szData[2] = isHs ? 1 : 0;
new iRet;
ExecuteForward(g_ForwardTakeDamage, iRet, attacker, ent, iWeapon, damage, PrepareArray(szData, 3, 1))
damage = float(szData[0])
isCritical = szData[1] == 1;
isHs = szData[2] == 1;
if(isCritical) {
damage *= 2.5;
slowMonsterByCriticalShot(ent);
}
if(isHs)
{
entity_set_edict(ent, EV_ENT_monster_headshot, 1)
damage *= g_ConfigValuesFloat[CFG_FLOAT_HEADSHOT_MULTIPLIER];
}
if(floatround(entity_get_float(ent, EV_FL_health)-damage) <= 0)
{
entity_set_int(ent, EV_INT_monster_track, -2);
makeDeathMsg(attacker, isHs, 0)
}
ExecuteForward(g_ForwardTakeDamagePost, iRet, attacker, ent, iWeapon, damage, PrepareArray(szData, 3, 0))
}
else if(damagetype & DMG_BURN)
{
if(floatround(entity_get_float(ent, EV_FL_health)-damage) <= 0)
{
entity_set_int(ent, EV_INT_monster_track, -2);
makeDeathMsg(attacker, 0, 1)
}
}
/* Update healthbar frame */
if(is_valid_ent(entity_get_edict(ent, EV_ENT_monster_healthbar)))
entity_set_float( entity_get_edict(ent, EV_ENT_monster_healthbar) , EV_FL_frame , 0.0 + ( (entity_get_float(ent, EV_FL_health)-floatround(damage)) * 100.0 ) / entity_get_int(ent, EV_INT_monster_maxhealth));
if(!(damagetype & DMG_BLAST) && !(damagetype & DMG_DROWN) && !(damagetype & DMG_BURN))
{
/* Display left HP */
/*
if(g_ConfigValues[CFG_SHOW_LEFT_DAMAGE])
{
if(floatround(entity_get_float(ent, EV_FL_health)-damage) < 0)
client_print(attacker, print_center, "KILL");
else
client_print(attacker, print_center, "Остаток здоровья: %d", floatround(entity_get_float(ent, EV_FL_health)-damage));
}
*/
if(g_ConfigValues[CFG_DAMAGE_MONEY])
{
g_PlayerHittedDamage[attacker] += floatround(damage)
if(g_PlayerHittedDamage[attacker] >= g_ConfigValues[CFG_DAMAGE_RATIO])
{
g_PlayerHittedDamage[attacker] = 0
cs_set_user_money(attacker, (cs_get_user_money(attacker)+g_ConfigValues[CFG_DAMAGE_MONEY]) > 16000 ? 16000 : (cs_get_user_money(attacker)+g_ConfigValues[CFG_DAMAGE_MONEY]))
client_cmd(attacker, "spk sound/%s", g_SoundFile[SND_COIN]);
}
}
}
set_task(0.1, "ShowBloodEffect", ent + TASK_DAMAGE_EFFECT)
}
SetHamParamFloat(4,damage)
return HAM_IGNORED
}
Вложения
-
2.8 KB Просмотры: 8