new class similar to heroine class

Unpaid Requests, Public Plugins
Post Reply
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 445
Joined: 1 Year Ago
Has thanked: 18 times
Been thanked: 1 time
Contact:

new class similar to heroine class

#1

Post by czirimbolo » 1 Month Ago

Hi

I need one more class for zombies. It must working with heroine together, so thanks to this we can have 2 zombie classes chosen randomly.

New class:

Name: Dopamine (or whatever)
- this class needs 3 zombies at spawn to be activated
- HP = 120 k
- long jump ----> viewtopic.php?f=14&t=119
- a little bit faster than normal zombie
- small knockback (can't be repelled/pushed like normal zombie!)
Image

User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 540
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 44 times
Age: 19
Contact:

#2

Post by Jack GamePlay » 1 Month Ago

Code: Select all

#include <zombie_escape>

#define TASK_MAKE_DOPAMINE 20019419

new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
new const szDopamineModel[][] = { "host_zombie" }

new bool:g_bDopamine[33], bool:g_hasLongJump[33], Float:g_last_LongJump_time[33], Array:g_szDopamineModel
new g_pCvarDopamineMinZombies,
	g_pCvarDopamineHP,
	g_pCvarDopamineSpeed,
	g_pCvarDopamineKnockback,
	g_LongJump_force,
	g_LongJump_height,
	g_LongJump_cooldown

public plugin_natives()
{
	register_native("ze_is_user_dopamine", "native_ze_is_user_dopamine", 1)
	register_native("ze_set_user_dopamine", "native_ze_set_user_dopamine", 1)
}

public plugin_precache()
{
	g_szDopamineModel = ArrayCreate(32, 1)

	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Player Models", "DOPAMINE", g_szDopamineModel)
	
	new iIndex, PlayerModel[32], Model_Path[128]

	if (ArraySize(g_szDopamineModel) == 0)
	{
		for (iIndex = 0; iIndex < sizeof(szDopamineModel); iIndex++)
			ArrayPushString(g_szDopamineModel, szDopamineModel[iIndex])
		
		amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Player Models", "DOPAMINE", g_szDopamineModel)
	}

	for (iIndex = 0; iIndex < ArraySize(g_szDopamineModel); iIndex++)
	{
		ArrayGetString(g_szDopamineModel, iIndex, PlayerModel, charsmax(PlayerModel))
		formatex(Model_Path, charsmax(Model_Path), "models/player/%s/%s.mdl", PlayerModel, PlayerModel)
		precache_model(Model_Path)
	}
}

public plugin_init()
{
	register_plugin("[ZE] Addons: Dopamine", "1.0", "Jack GamePlay")
	
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage")
	
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
	
	g_pCvarDopamineMinZombies = register_cvar("ze_dopamine_min_zombies", "3")
	g_pCvarDopamineHP = register_cvar("ze_dopamine_hp", "120000")
	g_pCvarDopamineSpeed = register_cvar("ze_dopamine_speed", "400")
	g_pCvarDopamineKnockback = register_cvar("ze_dopamine_knockback", "600.0")
	g_LongJump_force = register_cvar("ze_longjump_force", "580")
	g_LongJump_height = register_cvar("ze_longjump_height", "320")
	g_LongJump_cooldown = register_cvar("ze_longjump_cooldown", "10.0")
}

public ze_zombie_release()
{
	set_task(3.0, "Make_Dopamine_Task", TASK_MAKE_DOPAMINE)
}

public Make_Dopamine_Task(taskid)
{	
	new id, Zombies = ze_get_zombies_number()
	
	if (Zombies < get_pcvar_num(g_pCvarDopamineMinZombies))
	{
		ze_colored_print(0, "!tIt's required !g%i !tzombies to activate !gDopamine class!n.", get_pcvar_num(g_pCvarDopamineMinZombies))
		remove_task(taskid)
		return
	}

	id = GetRandomDopamine(random_num(1, Zombies))
	Set_User_Dopamine(id)
	remove_task(taskid)
	return
}

public Set_User_Dopamine(id)
{
	if (!ze_is_user_zombie(id))
		ze_set_user_zombie(id)

	g_bDopamine[id] = true

	if (get_pcvar_num(g_pCvarDopamineSpeed) > 0)
	{
		ze_set_zombie_speed(id, get_pcvar_num(g_pCvarDopamineSpeed))
	}

	new DopamineModel[32]
	ArrayGetString(g_szDopamineModel, random_num(0, ArraySize(g_szDopamineModel) - 1), DopamineModel, charsmax(DopamineModel))
	rg_set_user_model(id, DopamineModel)

	if (get_pcvar_num(g_pCvarDopamineHP) > 0)
	{
		set_entvar(id, var_health, get_pcvar_float(g_pCvarDopamineHP))
	}
}

public Unset_User_Dopamine(id)
{
	if (g_bDopamine[id])
	{
		g_bDopamine[id] = false
		g_hasLongJump[id] = false

		if (get_pcvar_num(g_pCvarDopamineSpeed) > 0.0)
		{
			ze_reset_zombie_speed(id)
		}
	}
}

public client_disconnected(id)
{
	Unset_User_Dopamine(id)
	remove_task(TASK_MAKE_DOPAMINE)
}

public ze_user_infected(victim)
{
	if (!is_user_alive(victim))
		return
		
	Unset_User_Dopamine(victim)
}

public ze_user_humanized(id)
{
	if (!is_user_alive(id))
		return
		
	Unset_User_Dopamine(id)
}

public fw_PlayerPreThink(id)
{
	if (!is_user_alive(id))
		return FMRES_IGNORED
	
	if (allow_LongJump(id))
	{
		static Float:velocity[3]
		velocity_by_aim(id, get_pcvar_num(g_LongJump_force), velocity)
		
		velocity[2] = get_pcvar_float(g_LongJump_height)
		
		set_pev(id, pev_velocity, velocity)
		
		g_last_LongJump_time[id] = get_gametime()
	}
	
	return FMRES_IGNORED
}

// Check if the player can longjump
allow_LongJump(id)
{
	if (!g_hasLongJump[id])
		return false
	
	if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
		return false
	
	static buttons
	buttons = pev(id, pev_button)
	
	if (!is_user_bot(id) && (!(buttons & IN_JUMP) || !(buttons & IN_DUCK)))
		return false
	
	if (get_gametime() - g_last_LongJump_time[id] < get_pcvar_float(g_LongJump_cooldown))
		return false
	
	return true
}

public Fw_TakeDamage(victim, inflector, attacker)
{
	if (victim == attacker || !is_user_alive(victim) || !is_user_alive(attacker))
		return HC_CONTINUE

	if (g_bDopamine[victim] && get_pcvar_float(g_pCvarDopamineKnockback) > 0.0)
	{
		set_member(victim, m_flVelocityModifier, 1.0)
		
		static Float:flOrigin[3]
		pev(attacker, pev_origin, flOrigin)
		Set_Knockback(victim, flOrigin, get_pcvar_float(g_pCvarDopamineKnockback), 2)
	}

	return HC_CONTINUE
}

public ze_roundend()
{
	for (new id = 0; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if (!g_bDopamine[id])
			continue
			
		Unset_User_Dopamine(id)
		remove_task(TASK_MAKE_DOPAMINE)
	}
}

public native_ze_is_user_dopamine(id)
{
	if (!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d).", id)
		return false
	}

	return g_bDopamine[id]
}

public native_ze_set_user_dopamine(id, set)
{
	if (!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d).", id)
		return false
	}

	if (!set)
	{
		if (!g_bDopamine[id])
		{
			log_error(AMX_ERR_NATIVE, "[ZE] Player isn't dopamine (%d).", id)
			return false
		}
		
		Unset_User_Dopamine(id)
		return true
	}

	if (set)
	{
		if (g_bDopamine[id])
		{
			log_error(AMX_ERR_NATIVE, "[ZE] Player is dopamine (%d).", id)
			return false
		}

		Set_User_Dopamine(id)
		return true
	}

	return false
}

stock GetRandomDopamine(target_index)
{
	new iAliveZ, id
	
	for (id = 1; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if (is_user_alive(id) && ze_is_user_zombie(id))
			iAliveZ++
		
		if (iAliveZ == target_index)
			return id
	}
	return -1
}

// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
	static Float:velocity[3]
	pev(entity, pev_velocity, velocity)
	
	return floatround(vector_length(velocity))
}
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 445
Joined: 1 Year Ago
Has thanked: 18 times
Been thanked: 1 time
Contact:

#3

Post by czirimbolo » 3 Weeks Ago

Jack GamePlay wrote:
1 Month Ago

Code: Select all

#include <zombie_escape>

#define TASK_MAKE_DOPAMINE 20019419

new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
new const szDopamineModel[][] = { "host_zombie" }

new bool:g_bDopamine[33], bool:g_hasLongJump[33], Float:g_last_LongJump_time[33], Array:g_szDopamineModel
new g_pCvarDopamineMinZombies,
	g_pCvarDopamineHP,
	g_pCvarDopamineSpeed,
	g_pCvarDopamineKnockback,
	g_LongJump_force,
	g_LongJump_height,
	g_LongJump_cooldown

public plugin_natives()
{
	register_native("ze_is_user_dopamine", "native_ze_is_user_dopamine", 1)
	register_native("ze_set_user_dopamine", "native_ze_set_user_dopamine", 1)
}

public plugin_precache()
{
	g_szDopamineModel = ArrayCreate(32, 1)

	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Player Models", "DOPAMINE", g_szDopamineModel)
	
	new iIndex, PlayerModel[32], Model_Path[128]

	if (ArraySize(g_szDopamineModel) == 0)
	{
		for (iIndex = 0; iIndex < sizeof(szDopamineModel); iIndex++)
			ArrayPushString(g_szDopamineModel, szDopamineModel[iIndex])
		
		amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Player Models", "DOPAMINE", g_szDopamineModel)
	}

	for (iIndex = 0; iIndex < ArraySize(g_szDopamineModel); iIndex++)
	{
		ArrayGetString(g_szDopamineModel, iIndex, PlayerModel, charsmax(PlayerModel))
		formatex(Model_Path, charsmax(Model_Path), "models/player/%s/%s.mdl", PlayerModel, PlayerModel)
		precache_model(Model_Path)
	}
}

public plugin_init()
{
	register_plugin("[ZE] Addons: Dopamine", "1.0", "Jack GamePlay")
	
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage")
	
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
	
	g_pCvarDopamineMinZombies = register_cvar("ze_dopamine_min_zombies", "3")
	g_pCvarDopamineHP = register_cvar("ze_dopamine_hp", "120000")
	g_pCvarDopamineSpeed = register_cvar("ze_dopamine_speed", "400")
	g_pCvarDopamineKnockback = register_cvar("ze_dopamine_knockback", "600.0")
	g_LongJump_force = register_cvar("ze_longjump_force", "580")
	g_LongJump_height = register_cvar("ze_longjump_height", "320")
	g_LongJump_cooldown = register_cvar("ze_longjump_cooldown", "10.0")
}

public ze_zombie_release()
{
	set_task(3.0, "Make_Dopamine_Task", TASK_MAKE_DOPAMINE)
}

public Make_Dopamine_Task(taskid)
{	
	new id, Zombies = ze_get_zombies_number()
	
	if (Zombies < get_pcvar_num(g_pCvarDopamineMinZombies))
	{
		ze_colored_print(0, "!tIt's required !g%i !tzombies to activate !gDopamine class!n.", get_pcvar_num(g_pCvarDopamineMinZombies))
		remove_task(taskid)
		return
	}

	id = GetRandomDopamine(random_num(1, Zombies))
	Set_User_Dopamine(id)
	remove_task(taskid)
	return
}

public Set_User_Dopamine(id)
{
	if (!ze_is_user_zombie(id))
		ze_set_user_zombie(id)

	g_bDopamine[id] = true

	if (get_pcvar_num(g_pCvarDopamineSpeed) > 0)
	{
		ze_set_zombie_speed(id, get_pcvar_num(g_pCvarDopamineSpeed))
	}

	new DopamineModel[32]
	ArrayGetString(g_szDopamineModel, random_num(0, ArraySize(g_szDopamineModel) - 1), DopamineModel, charsmax(DopamineModel))
	rg_set_user_model(id, DopamineModel)

	if (get_pcvar_num(g_pCvarDopamineHP) > 0)
	{
		set_entvar(id, var_health, get_pcvar_float(g_pCvarDopamineHP))
	}
}

public Unset_User_Dopamine(id)
{
	if (g_bDopamine[id])
	{
		g_bDopamine[id] = false
		g_hasLongJump[id] = false

		if (get_pcvar_num(g_pCvarDopamineSpeed) > 0.0)
		{
			ze_reset_zombie_speed(id)
		}
	}
}

public client_disconnected(id)
{
	Unset_User_Dopamine(id)
	remove_task(TASK_MAKE_DOPAMINE)
}

public ze_user_infected(victim)
{
	if (!is_user_alive(victim))
		return
		
	Unset_User_Dopamine(victim)
}

public ze_user_humanized(id)
{
	if (!is_user_alive(id))
		return
		
	Unset_User_Dopamine(id)
}

public fw_PlayerPreThink(id)
{
	if (!is_user_alive(id))
		return FMRES_IGNORED
	
	if (allow_LongJump(id))
	{
		static Float:velocity[3]
		velocity_by_aim(id, get_pcvar_num(g_LongJump_force), velocity)
		
		velocity[2] = get_pcvar_float(g_LongJump_height)
		
		set_pev(id, pev_velocity, velocity)
		
		g_last_LongJump_time[id] = get_gametime()
	}
	
	return FMRES_IGNORED
}

// Check if the player can longjump
allow_LongJump(id)
{
	if (!g_hasLongJump[id])
		return false
	
	if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
		return false
	
	static buttons
	buttons = pev(id, pev_button)
	
	if (!is_user_bot(id) && (!(buttons & IN_JUMP) || !(buttons & IN_DUCK)))
		return false
	
	if (get_gametime() - g_last_LongJump_time[id] < get_pcvar_float(g_LongJump_cooldown))
		return false
	
	return true
}

public Fw_TakeDamage(victim, inflector, attacker)
{
	if (victim == attacker || !is_user_alive(victim) || !is_user_alive(attacker))
		return HC_CONTINUE

	if (g_bDopamine[victim] && get_pcvar_float(g_pCvarDopamineKnockback) > 0.0)
	{
		set_member(victim, m_flVelocityModifier, 1.0)
		
		static Float:flOrigin[3]
		pev(attacker, pev_origin, flOrigin)
		Set_Knockback(victim, flOrigin, get_pcvar_float(g_pCvarDopamineKnockback), 2)
	}

	return HC_CONTINUE
}

public ze_roundend()
{
	for (new id = 0; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if (!g_bDopamine[id])
			continue
			
		Unset_User_Dopamine(id)
		remove_task(TASK_MAKE_DOPAMINE)
	}
}

public native_ze_is_user_dopamine(id)
{
	if (!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d).", id)
		return false
	}

	return g_bDopamine[id]
}

public native_ze_set_user_dopamine(id, set)
{
	if (!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d).", id)
		return false
	}

	if (!set)
	{
		if (!g_bDopamine[id])
		{
			log_error(AMX_ERR_NATIVE, "[ZE] Player isn't dopamine (%d).", id)
			return false
		}
		
		Unset_User_Dopamine(id)
		return true
	}

	if (set)
	{
		if (g_bDopamine[id])
		{
			log_error(AMX_ERR_NATIVE, "[ZE] Player is dopamine (%d).", id)
			return false
		}

		Set_User_Dopamine(id)
		return true
	}

	return false
}

stock GetRandomDopamine(target_index)
{
	new iAliveZ, id
	
	for (id = 1; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if (is_user_alive(id) && ze_is_user_zombie(id))
			iAliveZ++
		
		if (iAliveZ == target_index)
			return id
	}
	return -1
}

// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
	static Float:velocity[3]
	pev(entity, pev_velocity, velocity)
	
	return floatround(vector_length(velocity))
}
this lon gjump doesnt work like plugin which I gave you. And can you fix this knockback? Humans can push me back like normal zombie. I want make this class hard to beat. Even ze_dopamine_knockback 200 or 50 gets nothing. I need smaller knockback, human cant push me back by guns like normal zombie
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest