Saltar al contenido

[TUT] crear Habilidades Humanas y Zombie


Kirito

Publicaciones recomendadas

#include <fun>

/*esto va de bajo de los includes*/
new g_habilidad[33][2][6] // Variable de Habilidad
new g_puntos[33][2] // puntos de zombie y humano
new g_gastados[33][2] // Gastados de human y zm

enum _:HABZ { // Nombre del enum
    Name[32], // nombre de las mejoras 
    MAX_HAB // Maxima habilidad de zm
}
/* Crearemos un new const para los name dela habilidad 
y su mejora maxima */
new const hab_zm[][HABZ] =
{ 
    {"Daño", 10}, /* nombre de la habilidad Siempre debe ir ordenado por que o sino nos tirara error */
    {"Vida", 10}, /* no puede ir asi primero la máxima habilidad y luego el nombre por que les tirara error o Bug*/
    {"Velocidad", 10}, /*Y Siempre debe ir la "," si van a agregar otra habilidad*/
    {"Gravedad", 14} /*vean hay le quite la coma por la ultima habilidad*/
}

enum _:HABH { // Nombre de la habilidad h
    Nameh[33], // Name de la habilidad h
    MAX_HAB_H /*Máxima Habilidad Humana*/
}
/*Constante de la Habilidad Humana */
new const hab_hm[][HABH] = 
{ /*Hay estamos llamando la HABH del enum para poner los nombres ect*/
    {"Daño", 10}, /*lo mismo */
    {"Vida", 10},/*lo mismo */
    {"Armor", 10},/*lo mismo */
    {"Velocidad", 10},/*lo mismo */
    {"Gravedad", 10}/*lo mismo */
}

// Mejoras por Macro
#define ammount_cost(%1)        (%1 * 3) + 1 // Costo de habilidad
#define ammount_hdamage(%1)         (%1 + 1) * 0.1 // Human damage
#define ammount_hspeed(%1)         (%1 * 15) // Human speed
#define ammount_hhealth(%1)         (%1 * 10) // Human health
#define ammount_harmor(%1)         (%1 * 5) // Human armor
#define ammount_hgravity(%1)     ((%1 * 0.01) * 3) // Human gravity
#define ammount_zdamage(%1)         (%1 + 3) * 0.3 // Zombie damage
#define ammount_zspeed(%1)         (%1 * 15) // Zombie speed
#define ammount_zhealth(%1)         (%1 * 5000) // Zombie health
#define ammount_zgravity(%1)     ((%1 * 0.01) * 3) // Zombie gravity 

Ahora Crearemos el menu de mejoras

public show_menu_upgrades_human(id)
{
    static menu[999], len; len = 0

    len += formatex(menu[len], sizeof menu - 1 - len, "\yMejoras Humanos^n^n") // Titulo
    len += formatex(menu[len], sizeof menu - 1 - len, "\r-\y Tenes\w %s\y puntos humanos y\w %s\y gastados^n^n", add_point(g_puntos[id][0]), add_point(g_gastados[id][0])) // Gastados y Puntos

    for (new i; i < sizeof hab_hm; i++) // Ya mamos la Constante
    {
        if (g_habilidad[id][0][i] < hab_hm[i][MAX_HAB_H]) // Definimos la habilidad Humana
        {
            if (g_puntos[id][0] >= ammount_cost(g_habilidad[id][0][i]))
                len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s \r[\w%d-%d\r][\w%s punto%s\r]^n", i+1, hab_hm[i][Nameh], g_habilidad[id][0][i], hab_hm[i][MAX_HAB_H], add_point(ammount_cost(g_habilidad[id][0][i])), ammount_cost(g_habilidad[id][0][i]) == 1 ? "" : "s")/*si tiene puntos le deja mejorar */
            else
                len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\d %s \r[\d%d-%d\r][\d%s punto%s\r]^n", i+1, hab_hm[i][Nameh], g_habilidad[id][0][i], hab_hm[i][MAX_HAB_H], add_point(ammount_cost(g_habilidad[id][0][i])), ammount_cost(g_habilidad[id][0][i]) == 1 ? "" : "s")/*si no tiene puntos no le dejara mejorar*/
        }
        else
            len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\d %s \r[\dMAX\r]^n", i+1, hab_hm[i][Nameh]) // si ya mejoro completo 
    }

    len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w Resetear mejoras^n^n") // Podra resetear la mejoras

    len += formatex(menu[len], sizeof menu - 1 - len, "\r0.\w Salir") // Salimos del menu

    show_menu(id, KEYSMENU, menu, -1, "Menu Upgrades Human") // esto es para ya mar el menu en plugin_init
}

public show_menu_upgrades_zombie(id)// Public de las mejoras zm
{
    static menu[999], len; len = 0

    len += formatex(menu[len], sizeof menu - 1 - len, "\yMejoras Zombie^n^n") // titulo 

    len += formatex(menu[len], sizeof menu - 1 - len, "\r-\y Tenes\w %s\y puntos zombie y\w %s\y gastados^n^n", add_point(g_puntos[id][1]), add_point(g_gastados[id][1])) // Muestra gastados puntos ect de zombie

    for (new i; i < sizeof hab_zm; i++) // ya ma a la constante de zombie 
    {
        if (g_habilidad[id][1][i] < hab_zm[i][MAX_HAB]) 
        {
            if (g_puntos[id][1] >= ammount_cost(g_habilidad[id][1][i])) // si tiene puntos les dejara mejorar la habilidad
                len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s \r[\w%d-%d\r][\w%s punto%s\r]^n", i+1, hab_zm[i][Name], g_habilidad[id][1][i], hab_zm[i][MAX_HAB], add_point(ammount_cost(g_habilidad[id][1][i])), ammount_cost(g_habilidad[id][1][i]) == 1 ? "" : "s")/*Les deja mejorar*/
            else
                len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\d %s \r[\d%d-%d\r][\d%s punto%s\r]^n", i+1, hab_zm[i][Name], g_habilidad[id][1][i], hab_zm[i][MAX_HAB], add_point(ammount_cost(g_habilidad[id][1][i])), ammount_cost(g_habilidad[id][1][i]) == 1 ? "" : "s")/*No le deja mejorar */
        }
        else
            len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\d %s \r[\dMAX\r]^n", i+1, hab_zm[i][Name]) /*si la mejora ya es full*/
    }

    len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w Resetear mejoras^n^n") // podra resetear la mejora

    len += formatex(menu[len], sizeof menu - 1 - len, "\r0.\w Salir") // Salimos del menu

    show_menu(id, KEYSMENU, menu, -1, "Menu Upgrades Zombie") // ya ma la funcion del init para ya mar a menu_upgrades_zombie
}

// EL key de las mejoras humanas
public menu_upgrades_human(id, Key)
{
    switch (Key)
    {
        case 7: /*dice que con el boton 8 reseta la mejora*/
        {
            if (g_gastados[id][0] >= 1) // si gasto 1 punto le dejara resetear la habilidad
            {
                for (new i; i < sizeof hab_hm; i++) // ya mamos la constante
                {
                    g_habilidad[id][0][i] = 0 // cuando resetea la Habilidad vuelve a 0
                    g_puntos[id][0] += g_gastados[id][0] /*Aun no entendi bien lo que dice haca*/
                    g_gastados[id][0] = 0 /*lo vuelve gastados en 0 */
                }
                /*les Reseteara la habilidad*/
                show_menu_upgrades_human(id) /*esto es para qe no se cierre el menu cuando apretemos una opcion*/
            }
            else
            {
                /*esto es para que Si no Gasto ningun punto no le deja resetear*/
                show_menu_upgrades_human(id)/*no le cierra la Habilidad*/
            }
        }
    }

    if (g_habilidad[id][0][Key] < hab_hm[Key][MAX_HAB_H])
    {
        if (g_puntos[id][0] >= ammount_cost(g_habilidad[id][0][Key]))/*Ya mamos alos macros*/
        {
            g_puntos[id][0] -= ammount_cost(g_habilidad[id][0][Key])/*si les gasta los puntos*/
            g_gastados[id][0] += ammount_cost(g_habilidad[id][0][Key])/*Aumenta los Gastados*/
            g_habilidad[id][0][Key]++ /*Aumenta la Habilidad*/
            show_menu_upgrades_human(id)/*Para que no se cierre el menu*/
        }
        else
        {
            /*si no tiene puntos no le aumenta la Habilidad*/
            show_menu_upgrades_human(id)/*no le cierra el menu*/
        }
    }
    else
    {
        /*Si Ya tiene la habilidad Maxima*/
        show_menu_upgrades_human(id) /*lo Mismo*/
    }

    return PLUGIN_HANDLED;
}

public menu_upgrades_zombie(id, Key)
{
    switch (Key)
    {
        case 7: /*Podra resetear la Habilidad con la tecla 8 */
        {
            if (g_gastados[id][1] >= 1) /*Si gasto Habilidad mas de un punto le dejara resetarlo*/ 
            {
                for (new i; i < sizeof hab_zm; i++) /*ya ma la constante*/
                {
                    g_habilidad[id][1][i] = 0 /*La habilidad le Vuelve en 0*/
                    g_puntos[id][1] += g_gastados[id][1] /*Aumenta los Gastados*/
                    g_gastados[id][1] = 0/*si reseto los Gastados quedan en 0*/
                }
                /*le Resetea la habilidad */
                show_menu_upgrades_zombie(id)/*PAra qe no lo cierre el menu*/
            }
            else
            {
                /*si no tiene Puntos para Resetear*/
                show_menu_upgrades_zombie(id)
            }
        }
    }

    if (g_habilidad[id][1][Key] < hab_zm[Key][MAX_HAB])
    {
        if (g_puntos[id][1] >= ammount_cost(g_habilidad[id][1][Key])) /*ya mamos el macro cost para que cada ves qe aumenta la Habilidad le cuesta mas caro*/
        {
            g_puntos[id][1] -= ammount_cost(g_habilidad[id][1][Key]) /*sus puntos Bajan cada ves que Mejora algo*/
            g_gastados[id][1] += ammount_cost(g_habilidad[id][1][Key])/*Aumenta los Gastados*/
            g_habilidad[id][1][Key]++/*La Habilidad aumenta*/
            show_menu_upgrades_zombie(id)/*para que no cierre el menu cada ves qe mejora algo*/
        }
        else
        {
            /*si no tiene puntos no le deja aumentar*/
            show_menu_upgrades_zombie(id)
        }
    }
    else
    {
        /*Ya tiene la habilidad Maxima*/
        show_menu_upgrades_zombie(id)
    }

    return PLUGIN_HANDLED;
}

stock add_point(number)
{ 
    new count, i, str[29], str2[35], len
    num_to_str(number, str, charsmax(str))
    len = strlen(str)
    
    for (i = 0; i < len; i++)
    {
        if (i != 0 && ((len - i) %3 == 0))
        {
            add(str2, charsmax(str2), ".", 1)
            count++
            add(str2[i+count], 1, str[i], 1)
        }
        else
            add(str2[i+count], 1, str[i], 1)
    }

    return str2;
} 

y para Setear la Habilidades

/* Para Setear el Daño de humano vamos a fw_takedamage y buscamos 
// Attacker is human...
if (!g_zombie[attacker])
y Agregamos esto */
damage *= ammount_hdamage(g_habilidad[attacker][0][0]) 

/* ahora mas abajo asta encontrar esto
// Attacker is zombie... y debajo de esot Agregamos */
if (g_zombie[attacker])
SetHamParamFloat(4, damage *= ammount_zdamage(g_habilidad[attacker][1][0]))

// 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]]) + float(ammount_zspeed(g_habilidad[id][1][2])))

// y en la parte del humano 
set_pev(id, pev_maxspeed, get_pcvar_float(cvar_humanspd) + float(ammount_hspeed(g_habilidad[id][0][2]))

/*si tenemos Clases Humanas seria Haci*/
set_pev(id, pev_maxspeed, float(g_hclass_spd[g_humanclass[id]]) + float(ammount_hspeed(g_habilidad[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_hhealth(g_habilidad[id][0][1]))
set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity) - ammount_hgravity(g_habilidad[id][0][4]))
set_user_armor(id, ammount_harmor(g_habilidad[id][0][3]))

/*si tiene clases humanas es haci*/
// Set health and gravity
set_user_health(id, g_hclass_hp[g_humanclass[id]] + ammount_hhealth(g_habilidad[id][0][1]))
set_user_armor(id, g_hclass_armor[g_humanclass[id]] + ammount_harmor(g_habilidad[id][0][3]))
set_pev(id, pev_gravity, g_hclass_grav[g_humanclass[id]] - ammount_hgravity(g_habilidad[id][0][4]))

// 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_hhealth(g_habilidad[id][0][1]))
set_user_armor(id, ammount_harmor(g_habilidad[id][0][3]))
        
// Set gravity, unless frozen
if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity) - ammount_hgravity(g_habilidad[id][0][4]))

/*si tenemos Clases Humanas*/
// Set health
set_user_health(id, g_hclass_hp[g_humanclass[id]] + ammount_hhealth(g_habilidad[id][0][1]))
set_user_armor(id, g_hclass_armor[g_humanclass[id]] + ammount_harmor(g_habilidad[id][0][3]))
        
// Set gravity, unless frozen
if (!g_frozen[id]) set_pev(id, pev_gravity, g_hclass_grav[g_humanclass[id]] - ammount_hgravity(g_habilidad[id][0][4]))

/*ahora para setar la vida/speed/gravedad Vamos a 
zombieme(id, infector, nemesis, specialmode)
y cambian todo lo que Hay adentro de Hay por esto */
// Zombie Me Function (player id, infector, turn into a nemesis, special mode)
zombieme(id, infector, nemesis, specialmode)
{
    // Pre user infect forward
    ExecuteForward(g_fwUserInfected_pre, g_fwDummyResult, id, infector)
    
    // Show zombie class menu if they haven't chosen any (e.g. just connected)
    if (g_zombieclassnext[id] == ZCLASS_NONE && get_pcvar_num(cvar_zclasses))
        set_task(2.0, "show_menu_zclass", id)
    
    // Set selected zombie class
    g_zombieclass[id] = g_zombieclassnext[id]
    // If no class selected yet, use the first (default) one
    if (g_zombieclass[id] == ZCLASS_NONE) g_zombieclass[id] = 0
    
    // Way to go...
    g_zombie[id] = true
    g_survivor[id] = false
    
    // Set zombie attributes based on the mode
    if (!specialmode)
    {
        if (nemesis)
        {
            // Nemesis
            g_nemesis[id] = true
            
            // Get nemesis health setting
            static nemhealth, nembasehealth
            nemhealth = get_pcvar_num(cvar_nemhp)
            nembasehealth = get_pcvar_num(cvar_nembasehp)
            
            // Set health [0 = auto]
            if (nemhealth == 0)
            {
                if (nembasehealth == 0)
                    fm_set_user_health(id, g_zclass_hp[0]*fnGetAlive())
                else
                    fm_set_user_health(id, nembasehealth*fnGetAlive())
            }
            else
                fm_set_user_health(id, nemhealth)
            
            // Set gravity
            set_pev(id, pev_gravity, get_pcvar_float(cvar_nemgravity))
        }
        else if (fnGetZombies() == 1)
        {
            // First zombie
            g_firstzombie[id] = true
            
            // Set health and gravity
            set_user_health(id, floatround(g_zclass_hp[g_zombieclass[id]] + ammount_zhealth(g_habilidad[id][1][1] * 2.0)))
            set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]] - ammount_zgravity(g_habilidad[id][1][3]))
            
            // Infection sound
            engfunc(EngFunc_EmitSound, id, CHAN_VOICE, zombie_infect[random_num(0, sizeof zombie_infect - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
        }
        else
        {
            // Infected by someone
            
            // Set health and gravity
            set_user_health(id, g_zclass_hp[g_zombieclass[id]] + ammount_zhealth(g_habilidad[id][1][1]))
            set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]] - ammount_zgravity(g_habilidad[id][1][3]))
            
            // Infection sound
            engfunc(EngFunc_EmitSound, id, CHAN_VOICE, zombie_infect[random_num(0, sizeof zombie_infect - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
            
            // Get player's name
            static name[32]
            get_user_name(id, name, sizeof name - 1)
            
            // Show Infection HUD notice
            set_hudmessage(255, 0, 0, HUD_INFECT_X, HUD_INFECT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
            
            if (infector) // infected by someone?
            {
                static name2[32]
                get_user_name(infector, name2, sizeof name2 - 1)
                ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_INFECT2", name, name2)
            }
            else ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_INFECT", name)
        }
    }
    else
    {
        // Survivor/multi infection/swarm/plague/infection grenade
        
        // Set health and gravity
        set_user_health(id, g_zclass_hp[g_zombieclass[id]] + ammount_zhealth(g_habilidad[id][1][1]))
        set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]] - ammount_zgravity(g_habilidad[id][1][3]))
    }
/*no Hagan copi y paste por que solo es una partesita si y ahora vamos a public remove_freeze(id) 
y cambian el rotore normal gravity por esta*/
        // Restore normal gravity
    if (g_zombie[id])
        set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]] - ammount_zgravity(g_habilidad[id][1][3]))
    else
        set_pev(id, pev_gravity, g_hclass_grav[g_humanclass[id]] - ammount_hgravity(g_habilidad[id][0][4]))
/*esto fue todo si me olvide algo me digan*/ 

Se le pueden mejorar algunas cosas mas pero por el momento igual les puede servir mucho

/*como veran la variable habilidad, puntos, gastados ect... todos al segun paramento tiene 2 paramentos 
el 0 es la habilidad humana el 1 la habilidad zombie lo mismo con los gastados y puntos es igual
si agregan otra cosas que quieren mejorar tambien tiene que editar la variable*/
g_habilidad[33][2][6]/*
el 6 lo modifican por un 7 si,
ahora si van agregar otras mejoras fuera la de humano y zombie,
como nemesis 
la variable habilidad tienen que modificarla asi*/
g_habilidad[33][3][10]/*
y lo mismo con los gastados y puntos
qe daria asi*/
g_gastados[33][3],
g_puntos[33][3]
/*
hay agregamos
la habilidad
vida,
daño,
velocidad,
gravedad.
un ejemplo mas como setar las hablididade*/
// agregan un macro
#define ammount_spd_nemesis(%1)         (%1 * 15) 
/*y cambian los paramentos de la habilidad como lo esplique arriva.
hay vamos a mejorar la speed del nemesis son facil buscamos la cvar
qe se llama asi */
cvar_nemspd
/*ahora buscamos la cvar con F3 lo busca la funciones de donde estan ubicados la cvar_nemspd
vien asta al ultimo y agregamos asi*/
set_pev(id, pev_maxspeed, get_pcvar_float(cvar_nemspd) + ammount_spd_nemesis(g_habilidad[id][2][7]))/*
depende como tienen los paramentos 

les dejo como ganar puntos al matar a un nemesis o survivor ect...

// Ham Player Killed Forward
public fw_PlayerKilled(victim, attacker, shouldgib)
{

if (g_nemesis[victim])
{
    g_puntos[attacker][0]+= 2
    zp_colored_print(attacker, "^x04[ZC]^x01 Ganaste 2 Puntos ^x04Humano^x01")
    client_print(attacker, print_center, "Ganaste 2 Puntos humano")
}

if (g_survivor[victim])
{
    g_puntos[attacker][1]+= 2
    zp_colored_print(attacker, "^x04[ZC]^x01 Ganaste 2 Puntos ^x04Zombie^x01")
    client_print(attacker, print_center, "Ganaste 2 Puntos Zombie")
}
} 

para que no se les cierre el menu al presionar una opción, buscamos public plugin_init() y agregamos esto

register_menu("Menu Upgrades Zombie", KEYSMENU, "menu_upgrades_zombie")
register_menu("Menu Upgrades Human", KEYSMENU, "menu_upgrades_human") 

Espero que les sirva un poco de ayuda para sus creaciones futuras.

PD: funciona para la versión de zp 4.1 4.2 para la versión 4.3 se modifica en algunas cosas pero igual les puede servir de ayuda.

Enlace al comentario
Compartir en otros sitios web

  • 7 months later...

Crear una cuenta o conéctate para comentar

Tienes que ser miembro para dejar un comentario

Crear una cuenta

Regístrese para obtener una cuenta nueva en nuestra comunidad. ¡Es fácil!

Registrar una nueva cuenta

Conectar

¿Ya tienes una cuenta? Conéctate aquí.

Conectar ahora
×
×
  • Crear nuevo...

Información importante

Términos de Uso