Code:
//creamos constantes multidimensionales
new const g_mejoras_names[2][6][] = // como dice el nombre son los nombres de las mejoras
{
{
"Daño",
"Vitalidad",
"Velocidad",
"Chaleco", // MEJORAS HUMANAS
"Gravedad",
"Resistencia"
},
{
"Daño",
"Vitalidad",
"Velocidad", // MEJORAS ZOMBIES
"Gravedad",
"",
""
}
}
new const g_mejoras_names_max[][] = // las veces que se puede mejorar
{
{
40,
30,
20, // HUMANOS
30,
12,
5
},
{
10,
40,
30, // ZOMBIES
14
}
}
// creamos macros para el monto de las mejoras
// Mejoras
#define costo(%1) (%1 * 3) + 1 // costo de mejoras
#define ammount_damage(%1) (%1 + 3) * 0.3 // upgrade damage
#define ammount_speed(%1) (%1 * 10) // upgrade speed
#define ammount_health(%1) (%1 * 30) // upgrade health
#define ammount_armor(%1) (%1 * 20) // upgrade armor
#define ammount_gravity(%1) ((%1 * 0.01) * 4) // upgrade gravity
#define ammount_zhealth(%1) (%1 * 10000) // upgrade zombie health
#define ammount_zspeed(%1) (%1 * 5) // upgrade zombie speed
#define ammount_resistence(%1) (%1 / 1.1) // resistence upgrade
#define ammount_zdamage(%1) (%1 * 2) // zombie damage upgrade
// creamos variables multidimensionales
new g_gastados[33][2] // puntos zombie/humanos gastados
new g_skill_points[33][2][6] // contiene las mejoras zombies y humanas
new g_skill_points_type[33][2] // puntos humanos y zombies
// nos vamos al final del zp y agregamos
public menu_mejoras_h(id)
{
new menu[256], num[8], i, menu2
formatex(menu, 255, "\yMenu de mejoras humanas^n^nTienes \w%d\y puntos para gastar^n\yYa gastaste \w%d \ypuntos humanos", g_skill_points_type[id][0], g_gastados[id][0]) // titulo
menu2 = menu_create(menu, "show_menu_mejoras_h") // handler del menu
for (i = 0; i < 6; i++) // un for para obtener el nombre de las mejoras
{
if (g_skill_points[id][0][i] < g_mejoras_names_max[0][i]) // si la mejora es menor a su cantidad maxima
{
if (g_skill_points_type[id][0] >= costo(g_skill_points[id][0][i])) // si los puntos son mayores o iguales a la cantidad de puntos que pide
{
formatex(menu, charsmax(menu), "\yAumentar %s [%d/%d]\r \w(%d punto%s\w)", g_mejoras_names[0][i], g_skill_points[id][0][i], g_mejoras_names_max[0][i], costo(g_skill_points[id][0][i]), costo(g_skill_points[id][0][i]) == 1 ? "" : "s")
num_to_str(i, num, 7) // pasamos de un numero a string
menu_additem(menu2, menu, num) // agregamos el item al menu
}
else
{
formatex(menu, charsmax(menu), "\dAumentar %s [%d/%d]\r \w(%d punto%s\w)", g_mejoras_names[0][i], g_skill_points[id][0][i], g_mejoras_names_max[0][i], costo(g_skill_points[id][0][i]), costo(g_skill_points[id][0][i]) == 1 ? "" : "s")
num_to_str(i, num, 7)
menu_additem(menu2, menu, num)
}
}
else
{
formatex(menu, charsmax(menu), "\dAumentar %s [%d/%d] \w(MAX\w)" , g_mejoras_names[0][i], g_skill_points[id][0][i], g_mejoras_names_max[0][i])
num_to_str(i, num, 7)
menu_additem(menu2, menu, num)
}
}
if (g_gastados[id][0] >= 1) // si los puntos gastados humanos son mayores o iguales a 1
menu_additem(menu2, "\yResetear Mejoras", "7")
else
menu_additem(menu2, "\dResetear Mejoras", "7")
menu_setprop(menu2, MPROP_EXITNAME, "Salir") // salimos
menu_display(id, menu2)
}
public show_menu_mejoras_h(id, menu, item) // handler del menu
{
if (item == MENU_EXIT) // si selecciona la opcion para salir
{
menu_destroy(menu) // destruimos
return PLUGIN_HANDLED;
}
new Data[5], Name[33], access, callback
menu_item_getinfo(menu, item, access, Data, 4, Name, 32, callback) // obtenemos datos requeridos para el menu
new Key; Key = str_to_num(Data)
switch (Key)
{
case 7:
{
if (g_gastados[id][0] >= 1)
{
for (new i = 0; i < 6; i++) // un for para resetear todas las mejoras de una
{
g_skill_points[id][0][i] = 0 // reseteamos las mejoras
g_skill_points_type[id][0] += g_gastados[id][0] // le sumamos los puntos gastados
g_gastados[id][0] = 0 // reseteamos la variable
}
}
menu_mejoras_h(id)
}
}
if (g_skill_points[id][0][Key] < g_mejoras_names_max[0][Key]) // si la mejora no pasa su maximo
{
if (g_skill_points_type[id][0] >= costo(g_skill_points[id][0][Key])) // si tiene los puntos necesarios
{
g_skill_points_type[id][0] -= costo(g_skill_points[id][0][Key]) // le restamos los puntos
g_gastados[id][0] += costo(g_skill_points[id][0][Key]) // sumamos los puntos gastados
g_skill_points[id][0][Key]++ // aumentas la mejora
}
}
menu_destroy(menu) // destruimos
return PLUGIN_HANDLED
}
public menu_mejoras_z(id)
{
new menu2[256], pos[8], i, menu3
formatex(menu2, 255, "\yMenu de mejoras zombies^n^nTienes \w%d\y puntos para gastar^nYa gastaste \w%d \ypuntos zombies", g_skill_points_type[id][1], g_gastados[id][1])
menu3 = menu_create(menu2, "show_menu_mejoras_z")
for (i = 0; i < 4; i++)
{
if (g_skill_points[id][1][i] < g_mejoras_names_max[1][i])
{
if (g_skill_points_type[id][1] >= costo(g_skill_points[id][1][i]))
{
formatex(menu2, charsmax(menu2), "\yAumentar %s [%d/%d]\r \w(%d punto%s\w)", g_mejoras_names[1][i], g_skill_points[id][1][i], g_mejoras_names_max[1][i], costo(g_skill_points[id][1][i]), costo(g_skill_points[id][1][i]) == 1 ? "" : "s")
num_to_str(i, pos, 7)
menu_additem(menu3, menu2, pos)
}
else
{
formatex(menu2, charsmax(menu2), "\dAumentar %s [%d/%d]\r \w(%d punto%s\w)", g_mejoras_names[1][i], g_skill_points[id][1][i], g_mejoras_names_max[1][i], costo(g_skill_points[id][1][i]), costo(g_skill_points[id][1][i]) == 1 ? "" : "s")
num_to_str(i, pos, 7)
menu_additem(menu3, menu2, pos)
}
}
else
{
formatex(menu2, charsmax(menu2), "\dAumentar %s [%d/%d] \w(MAX\w)" , g_mejoras_names[1][i], g_skill_points[id][1][i], g_mejoras_names_max[1][i])
num_to_str(i, pos, 7)
menu_additem(menu3, menu2, pos)
}
}
if (g_gastados[id][0] >= 1)
menu_additem(menu3, "\yResetear Mejoras", "7")
else
menu_additem(menu3, "\dResetear Mejoras", "7")
menu_setprop(menu3, MPROP_EXITNAME, "Salir")
menu_display(id, menu3)
}
public show_menu_mejoras_z(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED;
}
new Data[5], Name[33], access, callback
menu_item_getinfo(menu, item, access, Data, 4, Name, 32, callback)
new Key; Key = str_to_num(Data)
switch (Key)
{
case 7:
{
if (g_gastados[id][1] >= 1)
{
for (new i = 0; i < 6; i++)
{
g_skill_points[id][1][i] = 0
g_skill_points_type[id][1] += g_gastados[id][1]
g_gastados[id][1] = 0
}
}
menu_mejoras_z(id)
}
}
if (g_skill_points[id][1][Key] < g_mejoras_names_max[1][Key])
{
if (g_skill_points_type[id][1] >= costo(g_skill_points[id][1][Key]))
{
g_skill_points_type[id][1] -= costo(g_skill_points[id][1][Key])
g_gastados[id][1] += costo(g_skill_points[id][1][Key])
g_skill_points[id][1][Key]++
}
}
menu_destroy(menu)
menu_mejoras_z(id)
return PLUGIN_HANDLED
}
// ahora para aplicar el daño nos vamos a fw_takedamage ahi agregamos
damage *= ammount_damage(g_skill_points[attacker][0][0])
// ahora mas abajo en la parte del chaleco agregamos
// Block the attack if he has some
if (armor > 0.0)
{
engfunc(EngFunc_EmitSound, victim, CHAN_BODY, sound_armorhit, 1.0, ATTN_NORM, 0, PITCH_NORM)
if (!g_zombie[attacker])
{
set_pev(victim, pev_armorvalue, - floatmax(0.0, armor - damage/ammount_resistence(g_skill_points[attacker][0][5])))
return HAM_SUPERCEDE;
}
else
{
set_pev(victim, pev_armorvalue, floatmax(0.0, armor - damage+ammount_zdamage(g_skill_points[attacker][1][0])))
return HAM_SUPERCEDE;
}
}
// ahora nos vamos a playerprethink
// en la parte del zombie reemplazamos lo que esta por esto
set_pev(id, pev_maxspeed, float(g_zclass_spd[g_zombieclass[id]]) + ammount_zspeed(g_skill_points[id][1][2]))
// y en la parte del humano
set_pev(id, pev_maxspeed, get_pcvar_float(cvar_humanspd) + ammount_speed(g_skill_points[id][0][2]))
// ahora nos vamos a playerspawn_post
// en la parte de setear vida/chaleco/gravedad reemplazamos eso por esto
// Set health and gravity
fm_set_user_health(id, get_pcvar_num(cvar_humanhp) + ammount_health(g_skill_points[id][0][1]))
set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity) - ammount_gravity(g_skill_points[id][0][4]))
set_user_armor(id, ammount_armor(g_skill_points[id][0][3]))
// ahora nos vamos a humanme(id, survivor) y reemplazamos la parte de setear la vida al humano por esto
// Set health
fm_set_user_health(id, get_pcvar_num(cvar_humanhp) + ammount_health(g_skill_points[id][0][1]))
set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity) - ammount_gravity(g_skill_points[id][0][4]))
set_user_armor(id, ammount_armor(g_skill_points[id][0][3]))
// Set gravity, unless frozen
if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity) - ammount_gravity(g_skill_points[id][0][4]))
// y por ultimo nos vamos a zombieme(id, infector)
// en la parte de setear la vida al zombie agregamos
// Set health and gravity
fm_set_user_health(id, floatround(g_zclass_hp[g_zombieclass[id]]*get_pcvar_float(cvar_zombiefirsthp)) + ammount_zhealth(g_skill_points[id][1][1]))
set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]] * ammount_gravity(g_skill_points[id][1][3])