Правила форума Гаранты форума
Размещение рекламы AMX-X компилятор

Здравствуйте, гость Вход | Регистрация

Наши новости:

14-дек
24-апр
10-апр
11-апр

Заражение последнего человека в Zp

Статус пользователя Butterfly
сообщение 19.2.2016, 18:09
Сообщение #1


Стаж: 11 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

В общем, суть вопроса такова.
Как сделать заражение последнего человека в ZP 5.0?
Предполагаю, что через TakeDamage, но каким конкретно образом?
Не могли бы вы объяснить?
+ дополнение к вопросу.
Как сделать так, чтоб игрок заражался лишь тогда, когда ему полностью все хп снесут?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя iShot
сообщение 19.2.2016, 18:30
Сообщение #2


Стаж: 11 лет

Сообщений: 1340
Благодарностей: 463
Полезность: 845

Меценат Меценат

Butterfly, исходник прикрепите в спойлер.


улыбнись :)
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Butterfly
сообщение 19.2.2016, 18:39
Сообщение #3


Стаж: 11 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Цитата(eLisha @ 19.2.2016, 19:30) *
Butterfly, исходник прикрепите в спойлер.

Исходник чего, ну т.е. какого плагина?
в 5.0 их куча, а в каком именно вписывать - я не знаю)
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя iShot
сообщение 19.2.2016, 20:16
Сообщение #4


Стаж: 11 лет

Сообщений: 1340
Благодарностей: 463
Полезность: 845

Меценат Меценат

Butterfly, в главном наверное.


улыбнись :)
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Butterfly
сообщение 20.2.2016, 11:10
Сообщение #5


Стаж: 11 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Цитата(eLisha @ 19.2.2016, 21:16) *
Butterfly, в главном наверное.


zp50_core
/*===============================================================================
=

------------------------
-*- [ZP] Core/Engine -*-
------------------------

This plugin is part of Zombie Plague Mod and is distributed under the
terms of the GNU General Public License. Check ZP_ReadMe.txt for details.

================================================================================
*/

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <cs_ham_bots_api>
#include <zp50_core_const>

#define MAXPLAYERS 32

// Custom Forwards
enum _:TOTAL_FORWARDS
{
FW_USER_INFECT_PRE = 0,
FW_USER_INFECT,
FW_USER_INFECT_POST,
FW_USER_CURE_PRE,
FW_USER_CURE,
FW_USER_CURE_POST,
FW_USER_LAST_ZOMBIE,
FW_USER_LAST_HUMAN,
FW_USER_SPAWN_POST
}

#define flag_get(%1,%2) (%1 & (1 << (%2 & 31)))
#define flag_get_boolean(%1,%2) (flag_get(%1,%2) ? true : false)
#define flag_set(%1,%2) %1 |= (1 << (%2 & 31))
#define flag_unset(%1,%2) %1 &= ~(1 << (%2 & 31))

new g_MaxPlayers
new g_IsZombie
new g_IsFirstZombie
new g_IsLastZombie
new g_LastZombieForwardCalled
new g_IsLastHuman
new g_LastHumanForwardCalled
new g_RespawnAsZombie
new g_ForwardResult
new g_Forwards[TOTAL_FORWARDS]

public plugin_init()
{
register_plugin("[ZP] Core/Engine", ZP_VERSION_STRING, "ZP Dev Team")
register_dictionary("zombie_plague.txt")
register_dictionary("zombie_plague50.txt")

g_Forwards[FW_USER_INFECT_PRE] = CreateMultiForward("zp_fw_core_infect_pre", ET_CONTINUE, FP_CELL, FP_CELL)
g_Forwards[FW_USER_INFECT] = CreateMultiForward("zp_fw_core_infect", ET_IGNORE, FP_CELL, FP_CELL)
g_Forwards[FW_USER_INFECT_POST] = CreateMultiForward("zp_fw_core_infect_post", ET_IGNORE, FP_CELL, FP_CELL)

g_Forwards[FW_USER_CURE_PRE] = CreateMultiForward("zp_fw_core_cure_pre", ET_CONTINUE, FP_CELL, FP_CELL)
g_Forwards[FW_USER_CURE] = CreateMultiForward("zp_fw_core_cure", ET_IGNORE, FP_CELL, FP_CELL)
g_Forwards[FW_USER_CURE_POST] = CreateMultiForward("zp_fw_core_cure_post", ET_IGNORE, FP_CELL, FP_CELL)

g_Forwards[FW_USER_LAST_ZOMBIE] = CreateMultiForward("zp_fw_core_last_zombie", ET_IGNORE, FP_CELL)
g_Forwards[FW_USER_LAST_HUMAN] = CreateMultiForward("zp_fw_core_last_human", ET_IGNORE, FP_CELL)

g_Forwards[FW_USER_SPAWN_POST] = CreateMultiForward("zp_fw_core_spawn_post", ET_IGNORE, FP_CELL)

RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
RegisterHamBots(Ham_Spawn, "fw_PlayerSpawn_Post", 1)
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled_Post", 1)
RegisterHamBots(Ham_Killed, "fw_PlayerKilled_Post", 1)
register_forward(FM_ClientDisconnect, "fw_ClientDisconnect_Post", 1)

g_MaxPlayers = get_maxplayers()

// To help players find ZP servers
register_cvar("zp_version", ZP_VERSION_STR_LONG, FCVAR_SERVER|FCVAR_SPONLY)
set_cvar_string("zp_version", ZP_VERSION_STR_LONG)
}

public plugin_cfg()
{
// Get configs dir
new cfgdir[32]
get_configsdir(cfgdir, charsmax(cfgdir))

// Execute config file (zombieplague.cfg)
server_cmd("exec %s/zombieplague.cfg", cfgdir)
}

public plugin_natives()
{
register_library("zp50_core")
register_native("zp_core_is_zombie", "native_core_is_zombie")
register_native("zp_core_is_first_zombie", "native_core_is_first_zombie")
register_native("zp_core_is_last_zombie", "native_core_is_last_zombie")
register_native("zp_core_is_last_human", "native_core_is_last_human")
register_native("zp_core_get_zombie_count", "native_core_get_zombie_count")
register_native("zp_core_get_human_count", "native_core_get_human_count")
register_native("zp_core_infect", "native_core_infect")
register_native("zp_core_cure", "native_core_cure")
register_native("zp_core_force_infect", "native_core_force_infect")
register_native("zp_core_force_cure", "native_core_force_cure")
register_native("zp_core_respawn_as_zombie", "native_core_respawn_as_zombie")
}

public fw_ClientDisconnect_Post(id)
{
// Reset flags AFTER disconnect (to allow checking if the player was zombie before disconnecting)
flag_unset(g_IsZombie, id)
flag_unset(g_RespawnAsZombie, id)

// This should be called AFTER client disconnects (post forward)
CheckLastZombieHuman()
}

public fw_PlayerSpawn_Post(id)
{
// Not alive or didn't join a team yet
if (!is_user_alive(id) || !cs_get_user_team(id))
return;

// ZP Spawn Forward
ExecuteForward(g_Forwards[FW_USER_SPAWN_POST], g_ForwardResult, id)

// Set zombie/human attributes upon respawn
if (flag_get(g_RespawnAsZombie, id))
InfectPlayer(id, id)
else
CurePlayer(id)

// Reset flag afterwards
flag_unset(g_RespawnAsZombie, id)
}

// Ham Player Killed Post Forward
public fw_PlayerKilled_Post()
{
CheckLastZombieHuman()
}

InfectPlayer(id, attacker = 0)
{
ExecuteForward(g_Forwards[FW_USER_INFECT_PRE], g_ForwardResult, id, attacker)

// One or more plugins blocked infection
if (g_ForwardResult >= PLUGIN_HANDLED)
return;

ExecuteForward(g_Forwards[FW_USER_INFECT], g_ForwardResult, id, attacker)

flag_set(g_IsZombie, id)

if (GetZombieCount() == 1)
flag_set(g_IsFirstZombie, id)
else
flag_unset(g_IsFirstZombie, id)

ExecuteForward(g_Forwards[FW_USER_INFECT_POST], g_ForwardResult, id, attacker)

CheckLastZombieHuman()
}

CurePlayer(id, attacker = 0)
{
ExecuteForward(g_Forwards[FW_USER_CURE_PRE], g_ForwardResult, id, attacker)

// One or more plugins blocked cure
if (g_ForwardResult >= PLUGIN_HANDLED)
return;

ExecuteForward(g_Forwards[FW_USER_CURE], g_ForwardResult, id, attacker)

flag_unset(g_IsZombie, id)

ExecuteForward(g_Forwards[FW_USER_CURE_POST], g_ForwardResult, id, attacker)

CheckLastZombieHuman()
}

// Last Zombie/Human Check
CheckLastZombieHuman()
{
new id, last_zombie_id, last_human_id
new zombie_count = GetZombieCount()
new human_count = GetHumanCount()

if (zombie_count == 1)
{
for (id = 1; id <= g_MaxPlayers; id++)
{
// Last zombie
if (is_user_alive(id) && flag_get(g_IsZombie, id))
{
flag_set(g_IsLastZombie, id)
last_zombie_id = id
}
else
flag_unset(g_IsLastZombie, id)
}
}
else
{
g_LastZombieForwardCalled = false

for (id = 1; id <= g_MaxPlayers; id++)
flag_unset(g_IsLastZombie, id)
}

// Last zombie forward
if (last_zombie_id > 0 && !g_LastZombieForwardCalled)
{
ExecuteForward(g_Forwards[FW_USER_LAST_ZOMBIE], g_ForwardResult, last_zombie_id)
g_LastZombieForwardCalled = true
}

if (human_count == 1)
{
for (id = 1; id <= g_MaxPlayers; id++)
{
// Last human
if (is_user_alive(id) && !flag_get(g_IsZombie, id))
{
flag_set(g_IsLastHuman, id)
last_human_id = id
}
else
flag_unset(g_IsLastHuman, id)
}
}
else
{
g_LastHumanForwardCalled = false

for (id = 1; id <= g_MaxPlayers; id++)
flag_unset(g_IsLastHuman, id)
}

// Last human forward
if (last_human_id > 0 && !g_LastHumanForwardCalled)
{
ExecuteForward(g_Forwards[FW_USER_LAST_HUMAN], g_ForwardResult, last_human_id)
g_LastHumanForwardCalled = true
}
}

public native_core_is_zombie(plugin_id, num_params)
{
new id = get_param(1)

if (!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return -1;
}

return flag_get_boolean(g_IsZombie, id);
}

public native_core_is_first_zombie(plugin_id, num_params)
{
new id = get_param(1)

if (!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return -1;
}

return flag_get_boolean(g_IsFirstZombie, id);
}

public native_core_is_last_zombie(plugin_id, num_params)
{
new id = get_param(1)

if (!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return -1;
}

return flag_get_boolean(g_IsLastZombie, id);
}

public native_core_is_last_human(plugin_id, num_params)
{
new id = get_param(1)

if (!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return -1;
}

return flag_get_boolean(g_IsLastHuman, id);
}

public native_core_get_zombie_count(plugin_id, num_params)
{
return GetZombieCount();
}

public native_core_get_human_count(plugin_id, num_params)
{
return GetHumanCount();
}

public native_core_infect(plugin_id, num_params)
{
new id = get_param(1)

if (!is_user_alive(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}

if (flag_get(g_IsZombie, id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Player already infected (%d)", id)
return false;
}

new attacker = get_param(2)

if (attacker && !is_user_alive(attacker))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", attacker)
return false;
}

InfectPlayer(id, attacker)
return true;
}

public native_core_cure(plugin_id, num_params)
{
new id = get_param(1)

if (!is_user_alive(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}

if (!flag_get(g_IsZombie, id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Player not infected (%d)", id)
return false;
}

new attacker = get_param(2)

if (attacker && !is_user_alive(attacker))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", attacker)
return false;
}

CurePlayer(id, attacker)
return true;
}

public native_core_force_infect(plugin_id, num_params)
{
new id = get_param(1)

if (!is_user_alive(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}

InfectPlayer(id)
return true;
}

public native_core_force_cure(plugin_id, num_params)
{
new id = get_param(1)

if (!is_user_alive(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}

CurePlayer(id)
return true;
}

public native_core_respawn_as_zombie(plugin_id, num_params)
{
new id = get_param(1)

if (!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}

new respawn_as_zombie = get_param(2)

if (respawn_as_zombie)
flag_set(g_RespawnAsZombie, id)
else
flag_unset(g_RespawnAsZombie, id)

return true;
}

// Get Zombie Count -returns alive zombies number-
GetZombieCount()
{
new iZombies, id

for (id = 1; id <= g_MaxPlayers; id++)
{
if (is_user_alive(id) && flag_get(g_IsZombie, id))
iZombies++
}

return iZombies;
}

// Get Human Count -returns alive humans number-
GetHumanCount()
{
new iHumans, id

for (id = 1; id <= g_MaxPlayers; id++)
{
if (is_user_alive(id) && !flag_get(g_IsZombie, id))
iHumans++
}

return iHumans;
}



zp50_human_armor

/*===============================================================================
=

------------------------
-*- [ZP] Human Armor -*-
------------------------

This plugin is part of Zombie Plague Mod and is distributed under the
terms of the GNU General Public License. Check ZP_ReadMe.txt for details.

================================================================================
*/

#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <cs_ham_bots_api>
#include <zp50_core>
#define LIBRARY_NEMESIS "zp50_class_nemesis"
#include <zp50_class_nemesis>
#define LIBRARY_ASSASSIN "zp50_class_assassin"
#include <zp50_class_assassin>
#define LIBRARY_SURVIVOR "zp50_class_survivor"
#include <zp50_class_survivor>
#define LIBRARY_SNIPER "zp50_class_sniper"
#include <zp50_class_sniper>

// CS Player PData Offsets (win32)
const OFFSET_PAINSHOCK = 108 // ConnorMcLeod

// Some constants
const DMG_HEGRENADE = (1<<24)

// CS sounds
new const g_sound_armor_hit[] = "player/bhit_helmet-1.wav"

new cvar_human_armor_protect, cvar_human_armor_default
new cvar_armor_protect_nemesis, cvar_survivor_armor_protect,
cvar_armor_protect_assassin, cvar_sniper_armor_protect

public plugin_init()
{
register_plugin("[ZP] Human Armor", ZP_VERSION_STRING, "ZP Dev Team")

cvar_human_armor_protect = register_cvar("zp_human_armor_protect", "1")
cvar_human_armor_default = register_cvar("zp_human_armor_default", "0")

if (LibraryExists(LIBRARY_NEMESIS, LibType_Library))
cvar_armor_protect_nemesis = register_cvar("zp_armor_protect_nemesis", "1")
if (LibraryExists(LIBRARY_ASSASSIN, LibType_Library))
cvar_armor_protect_assassin = register_cvar("zp_armor_protect_assassin", "1")
if (LibraryExists(LIBRARY_SURVIVOR, LibType_Library))
cvar_survivor_armor_protect = register_cvar("zp_survivor_armor_protect", "1")
if (LibraryExists(LIBRARY_SNIPER, LibType_Library))
cvar_sniper_armor_protect = register_cvar("zp_sniper_armor_protect", "1")

RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
RegisterHamBots(Ham_TakeDamage, "fw_TakeDamage")
}

public plugin_natives()
{
set_module_filter("module_filter")
set_native_filter("native_filter")
}
public module_filter(const module[])
{
if (equal(module, LIBRARY_NEMESIS) || equal(module, LIBRARY_ASSASSIN) || equal(module, LIBRARY_SURVIVOR) || equal(module, LIBRARY_SNIPER))
return PLUGIN_HANDLED;

return PLUGIN_CONTINUE;
}
public native_filter(const name[], index, trap)
{
if (!trap)
return PLUGIN_HANDLED;

return PLUGIN_CONTINUE;
}

public plugin_precache()
{
precache_sound(g_sound_armor_hit)
}

public zp_fw_core_cure_post(id, attacker)
{
new Float:armor
pev(id, pev_armorvalue, armor)

if (armor < get_pcvar_float(cvar_human_armor_default))
set_pev(id, pev_armorvalue, get_pcvar_float(cvar_human_armor_default))
}

// Ham Take Damage Forward
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
// Non-player damage or self damage
if (victim == attacker || !is_user_alive(attacker))
return HAM_IGNORED;

// Zombie attacking human...
if (zp_core_is_zombie(attacker) && !zp_core_is_zombie(victim))
{
// Ignore damage coming from a HE grenade (bugfix)
if (damage_type & DMG_HEGRENADE)
return HAM_IGNORED;

// Does human armor need to be reduced before infecting/damaging?
if (!get_pcvar_num(cvar_human_armor_protect) || zp_core_is_last_human(victim))
return HAM_IGNORED;

// Should armor protect against nemesis attacks?
if (LibraryExists(LIBRARY_NEMESIS, LibType_Library) && !get_pcvar_num(cvar_armor_protect_nemesis) && zp_class_nemesis_get(attacker))
return HAM_IGNORED;

// Should armor protect against assassin attacks?
if (LibraryExists(LIBRARY_ASSASSIN, LibType_Library) && !get_pcvar_num(cvar_armor_protect_assassin) && zp_class_assassin_get(attacker))
return HAM_IGNORED;

// Should armor protect survivor too?
if (LibraryExists(LIBRARY_SURVIVOR, LibType_Library) && !get_pcvar_num(cvar_survivor_armor_protect) && zp_class_survivor_get(victim))
return HAM_IGNORED;

// Should armor protect sniper too?
if (LibraryExists(LIBRARY_SNIPER, LibType_Library) && !get_pcvar_num(cvar_sniper_armor_protect) && zp_class_sniper_get(victim))
return HAM_IGNORED;

// Get victim armor
static Float:armor
pev(victim, pev_armorvalue, armor)

// If he has some, block damage and reduce armor instead
if (armor > 0.0)
{
emit_sound(victim, CHAN_BODY, g_sound_armor_hit, 1.0, ATTN_NORM, 0, PITCH_NORM)

if (armor - damage > 0.0)
set_pev(victim, pev_armorvalue, armor - damage)
else
cs_set_user_armor(victim, 0, CS_ARMOR_NONE)

// Block damage, but still set the pain shock offset
set_pdata_float(victim, OFFSET_PAINSHOCK, 0.5)
return HAM_SUPERCEDE;
}
}

return HAM_IGNORED;
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Algalon
сообщение 20.2.2016, 13:12
Сообщение #6
Стаж: 11 лет

Сообщений: 163
Благодарностей: 60
Полезность: 291

Butterfly,
Все манипуляции нужно производить в файле zp50_gamemodes, а именно в фукции fw_TakeDamage строка 490

1) Удаляем блок
Код:
// Last human is killed to trigger round end
if (zp_core_get_human_count() == 1)
return HAM_IGNORED;


2) Производим замену
Код:
// Infect only if damage is done to victim
if (damage > 0.0 && GetHamReturnStatus() != HAM_SUPERCEDE)
{
// Infect victim!
zp_core_infect(victim, attacker)
return HAM_SUPERCEDE;
}

Код:
static health;
health = pev(victim, pev_health) - damage;

// Infect only if damage is done to victim
if (health <= 1 && GetHamReturnStatus() != HAM_SUPERCEDE)
{
// Infect victim!
zp_core_infect(victim, attacker)
return HAM_SUPERCEDE;
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Butterfly
сообщение 20.2.2016, 16:45
Сообщение #7


Стаж: 11 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Algalon,
Спасибо, сейчас проверю
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Butterfly
сообщение 20.2.2016, 17:05
Сообщение #8


Стаж: 11 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Algalon,
Проверил.
Всё работает, спасибо.
Вопрос.
Как сделать окончание раунда не используя других модулей?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Butterfly
сообщение 20.2.2016, 17:27
Сообщение #9


Стаж: 11 лет

Сообщений: 49
Благодарностей: 1
Полезность: 18

Хотя не важно.
Всё сделано.
Можете закрывать тему.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
  Ответить в данную темуНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: