AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ZP] Double ability (https://forums.alliedmods.net/showthread.php?t=251433)

neutrobox 11-12-2014 17:57

[ZP] Double ability
 
Hello, I need help with this code, is an Smoker Zombie but I want to add Ghost's Ability.

My code:

PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <zmvip>
#include <fun>

#define PLUGIN "[ZP] Class Smoker"
#define VERSION "1.3"
#define AUTHOR "4eRT"

//Main Class, modelT & Sprite Beam
new g_zclass_smokerg_Line

//Habilidad 1 - Ghost
new i_stealth_time_hud[33]
new 
g_cooldown[33]
new 
g_infections[33]
new 
Float:g_stealth_time[33]
new 
i_cooldown_time[33]
new 
g_maxplayers

// --- config ------------------------ Ghost//
new Float:g_stealth_time_standart 5.0 //first stealth time
new Float:g_stealth_cooldown_standart 45.0 //cooldown time
new const sound_ghost_stealth[] = "zombie_plague/spells/zombie_ghost/stealth.wav" //stealth sound
new const sound_ghost_stealth_end[] = "zombie_plague/spells/zombie_ghost/end_stealth.wav" //end stealth sound
// ----------------------------------- //

//Sounds
new g_sndMiss[] = "AGZombieP/ssjgohan_kamehame.wav"
new g_sndDrag[] = "AGZombieP/ssjgohan_ha.wav"
//Some vars
new g_hooked[33], g_hooksLeft[33], g_unable2move[33], g_ovr_dmg[33]
new 
Float:g_lastHook[33]
new 
boolg_bind_use[33] = falseboolg_bind_or_not[33] = falseboolg_drag_i[33] = false
//Cvars
new cvar_maxdragscvar_dragspeedcvar_cooldowncvar_dmg2stopcvar_matescvar_unb2movecvar_nemesiscvar_survivor
//Menu keys

//Smoker Atributes
new const zclass_name[] = { "Doble habilidad" }
new const 
zclass_info[] = { "Zombie con 2 habilidades" }
new const 
zclass_model[] = { "zombie_source" }
new const 
zclass_clawmodel[] = { "v_knife_zombie.mdl" }
const 
zclass_health 1400
const zclass_speed 190
const Float:zclass_gravity 1.0
const Float:zclass_knockback 1.0

public plugin_init()
{
    
register_cvar("zp_zclass_ghost_zombie",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
    
cvar_dragspeed register_cvar("zp_smoker_dragspeed""560")
    
cvar_maxdrags register_cvar("zp_smoker_maxdrags""20")
    
cvar_cooldown register_cvar("zp_smoker_cooldown""5")
    
cvar_dmg2stop register_cvar("zp_smoker_dmg2stop""300")
    
cvar_mates register_cvar("zp_smoker_mates""0")
    
cvar_unb2move register_cvar("zp_smoker_unable_move""1")
    
cvar_nemesis register_cvar("zp_smoker_nemesis""0")
    
cvar_survivor register_cvar("zp_smoker_survivor""1")
    
register_clcmd("habilidad1""use_ability_one")
    
register_concmd("habilidad1""use_ability_one")
    
register_logevent("roundStart"2"1=Round_Start")
    
register_event("ResetHUD""newSpawn""b")
    
register_event("DeathMsg""smoker_death""a")
    
register_forward(FM_PlayerPreThink"fw_PlayerPreThink")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage1")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage2")
    
register_clcmd("+habilidad2","drag_start"ADMIN_LEVEL_C"bind ^"key^" ^"+drag^"")
    
register_clcmd("-gokuzombielith","drag_end")
    
g_maxplayers get_maxplayers()
}
public 
plugin_precache()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
g_zclass_smoker zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
    
precache_sound(g_sndDrag)
    
precache_sound(g_sndMiss)
    
precache_sound(sound_ghost_stealth)
    
precache_sound(sound_ghost_stealth_end)
    
g_Line precache_model("sprites/AGZombieP/gohan_trail_blue.spr")
    

}

public 
roundStart()
{
    for (new 
1<= g_maxplayersi++)
    {
        
i_cooldown_time[i] = floatround(g_stealth_cooldown_standart)
        
g_cooldown[i] = 0
        remove_task
(i)
    }
}

public 
use_ability_one(id)
{
    if(
is_valid_ent(id) && is_user_alive(id) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && zp_get_user_zombie_class(id) == g_zclass_smoker)
    {
        if(
g_cooldown[id] == 0)
        {
            
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha0)
            
emit_sound(idCHAN_STREAMsound_ghost_stealth1.0ATTN_NORM0PITCH_NORM)
            
set_task(g_stealth_time[id],"ghost_make_visible",id)
            
set_task(g_stealth_cooldown_standart,"reset_cooldown",id)
            
g_cooldown[id] = 1
            
            i_cooldown_time
[id] = floatround(g_stealth_cooldown_standart)
            
i_stealth_time_hud[id] = floatround(g_stealth_time[id])
            
            
set_task(1.0"ShowHUD"id__"a",i_cooldown_time[id])
            
set_task(1.0"ShowHUDstealthes"id__"a",i_stealth_time_hud[id])
        }
    }
}

public 
ShowHUD(id)
{
    if(
is_valid_ent(id) && is_user_alive(id))
    {
        
i_cooldown_time[id] = i_cooldown_time[id] - 1;
        
set_hudmessage(20010000.750.9201.01.10.00.0, -1)
        
show_hudmessage(id"Invisibilidad: %d",i_cooldown_time[id])
    }else{
        
remove_task(id)
    }
}

public 
ShowHUDstealthes(id)
{
    if(
is_valid_ent(id) && is_user_alive(id))
    {
        
i_stealth_time_hud[id] = i_stealth_time_hud[id] - 1;
        
set_hudmessage(2001000, -1.00.9201.01.10.00.0, -1)
        
show_hudmessage(id"Tiempo de invisibilidad: %d",i_stealth_time_hud[id])
    }else{
        
remove_task(id)
    }
}

public 
ghost_make_visible(id)
{
    if(
is_valid_ent(id) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && zp_get_user_zombie_class(id) == g_zclass_smoker)
    {
        
set_user_rendering(idkRenderFxHologram000kRenderTransAlpha125)
        
emit_sound(idCHAN_STREAMsound_ghost_stealth_end1.0ATTN_NORM0PITCH_NORM)
    }
}

public 
reset_cooldown(id)
{
    if(
is_valid_ent(id) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && zp_get_user_zombie_class(id) == g_zclass_smoker)
    {
        
g_cooldown[id] = 0
        
        
new text[100]
        
format(text,99,"^x04[ZP]^x01 Your ability ^x04Stealth^x01 is ready.")
        
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
        
write_byte(id
        
write_string(text
        
message_end()
    }
}

public 
zp_user_infected_pre(idinfector)
{
    if ((
zp_get_user_zombie_class(id) == g_zclass_smoker) && !zp_get_user_nemesis(id) && !(get_user_flags(id) & ADMIN_LEVEL_C)) 
    {
        
zp_set_user_zombie_class(id0)
        
client_print(idprint_chat"Esta clase zombie es solo para Lithium bitch!")
        
        {
            
g_hooksLeft[infector] = g_hooksLeft[infector]
        }
        
        {
            
set_user_rendering(idkRenderFxHologram000kRenderTransAlpha125)
        
        new 
text[100]
        new 
note_cooldown floatround(g_stealth_cooldown_standart)
        new 
note_stealthtime floatround(g_stealth_time_standart)
        
format(text,99,"^x04[ZP]^x01 Your ability is ^x04Stealth^x01. Cooldown:^x04 %d ^x01seconds. Stealth time: ^x04%d^x01 seconds.",note_cooldown,note_stealthtime)
        
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
        
write_byte(id
        
write_string(text
        
message_end()
        
        
i_cooldown_time[id] = floatround(g_stealth_cooldown_standart)
        
remove_task(id)
        
        
g_stealth_time[id] = g_stealth_time_standart
        g_cooldown
[id] = 0
        g_infections
[id] = 0
        
    
}
    
    }
    
    if((
zp_get_user_zombie_class(infector) == g_zclass_smoker) && !zp_get_user_nemesis(infector))
    {
        
g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
        
g_stealth_time[infector] = g_stealth_time[infector] + 1;
        
infections_hud(infector)
        
    }
}

public 
infections_hud(id)
{
    if(
is_valid_ent(id) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && zp_get_user_zombie_class(id) == g_zclass_smoker)
    {
        new 
i_stealth_time floatround(g_stealth_time[id])
        new 
text[100]
        
format(text,99,"^x04[ZP]^x01 Your stealth time is^x04 %d ^x01seconds.",i_stealth_time)
        
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
        
write_byte(id
        
write_string(text
        
message_end() 
    }
}

public 
zp_user_humanized_post(id)
{
    
set_user_rendering(idkRenderFxNone000kRenderTransAlpha255)
    
remove_task(id)
}

public 
zp_user_unfrozen(id)
{
    if(
is_valid_ent(id) && is_user_alive(id) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && zp_get_user_zombie_class(id) == g_zclass_smoker)
    {
        
set_user_rendering(idkRenderFxHologram000kRenderTransAlpha125)
    }
}



public 
newSpawn(id)
{
    if (
g_hooked[id])
        
drag_end(id)
}

public 
drag_start(id// starts drag, checks if player is Smoker, checks cvars
{        
    if (
zp_get_user_zombie(id) && (zp_get_user_zombie_class(id) == g_zclass_smoker) && !g_drag_i[id]) {
        
        static 
Float:cdown
        cdown 
get_pcvar_float(cvar_cooldown)

        if (!
is_user_alive(id)) {
            
client_print(idprint_chat"[ZP] You can't drag if you are dead!")
            return 
PLUGIN_HANDLED
        
}

        if (
g_hooksLeft[id] <= 0) {
            
client_print(idprint_chat"[ZP] You can't drag anymore!")
            return 
PLUGIN_HANDLED
        
}

        if (
get_gametime() - g_lastHook[id] < cdown) {
            
client_print(idprint_chat"[ZP] Wait %.f0 sec. to drag again!"get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
            return 
PLUGIN_HANDLED
        
}
        
        new 
hooktargetbody
        get_user_aiming
(idhooktargetbody)
        
        if (
zp_get_user_nemesis(id) && get_pcvar_num(cvar_nemesis) == 0) {
            
client_print(idprint_chat"[ZP] You can't drag if you are Nemesis!")
            return 
PLUGIN_HANDLED
        
}
        
        if (
is_user_alive(hooktarget)) {
            if (!
zp_get_user_zombie(hooktarget))
                {
                    if (
zp_get_user_survivor(hooktarget) && get_pcvar_num(cvar_survivor) == 0) {
                        
client_print(idprint_chat"[ZP] You can't drag Survivor!")
                        return 
PLUGIN_HANDLED
                    
}
                    
                    
g_hooked[id] = hooktarget
                    emit_sound
(hooktargetCHAN_BODYg_sndDrag1.0ATTN_NORM0PITCH_HIGH)
                }
            else
                {
                    if (
get_pcvar_num(cvar_mates) == 1)
                    {
                        
g_hooked[id] = hooktarget
                        emit_sound
(hooktargetCHAN_BODYg_sndDrag1.0ATTN_NORM0PITCH_HIGH)
                    }
                    else
                    {
                        
client_print(idprint_chat"[ZP] You can't drag teammates!")
                        return 
PLUGIN_HANDLED
                    
}
                }

            if (
get_pcvar_float(cvar_dragspeed) <= 0.0)
                
cvar_dragspeed 1
            
            
new parm[2]
            
parm[0] = id
            parm
[1] = hooktarget
            
            set_task
(0.1"smoker_reelin"idparm2"b")
            
harpoon_target(parm)
            
            
g_hooksLeft[id]--
            
client_print(idprint_chat"[ZP] You can drag player to youself %d time%s"g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" "s")
            
g_drag_i[id] = true
            
            
if(get_pcvar_num(cvar_unb2move) == 1)
                
g_unable2move[hooktarget] = true
                
            
if(get_pcvar_num(cvar_unb2move) == 2)
                
g_unable2move[id] = true
                
            
if(get_pcvar_num(cvar_unb2move) == 3)
            {
                
g_unable2move[hooktarget] = true
                g_unable2move
[id] = true
            
}
        } else {
            
g_hooked[id] = 33
            noTarget
(id)
            
emit_sound(hooktargetCHAN_BODYg_sndMiss1.0ATTN_NORM0PITCH_HIGH)
            
g_drag_i[id] = true
            g_hooksLeft
[id]--
            
client_print(idprint_chat"[ZP] You can drag player to youself %d time%s"g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" "s")
        }
    }
    else
        return 
PLUGIN_HANDLED
    
    
return PLUGIN_CONTINUE
}

public 
smoker_reelin(parm[]) // dragging player to smoker
{
    new 
id parm[0]
    new 
victim parm[1]

    if (!
g_hooked[id] || !is_user_alive(victim))
    {
        
drag_end(id)
        return
    }

    new 
Float:fl_Velocity[3]
    new 
idOrigin[3], vicOrigin[3]

    
get_user_origin(victimvicOrigin)
    
get_user_origin(ididOrigin)

    new 
distance get_distance(idOriginvicOrigin)

    if (
distance 1) {
        new 
Float:fl_Time distance get_pcvar_float(cvar_dragspeed)

        
fl_Velocity[0] = (idOrigin[0] - vicOrigin[0]) / fl_Time
        fl_Velocity
[1] = (idOrigin[1] - vicOrigin[1]) / fl_Time
        fl_Velocity
[2] = (idOrigin[2] - vicOrigin[2]) / fl_Time
    
} else {
        
fl_Velocity[0] = 0.0
        fl_Velocity
[1] = 0.0
        fl_Velocity
[2] = 0.0
    
}

    
entity_set_vector(victimEV_VEC_velocityfl_Velocity//<- rewritten. now uses engine
}

public 
drag_end(id// drags end function
{
    
g_hooked[id] = 0
    beam_remove
(id)
    
remove_task(id)
    
    if (
g_drag_i[id])
        
g_lastHook[id] = get_gametime()
    
    
g_drag_i[id] = false
    g_unable2move
[id] = false
}

public 
smoker_death() // if smoker dies drag off
{
    new 
id read_data(2)
    
    
beam_remove(id)
    
    if (
g_hooked[id])
        
drag_end(id)
}

public 
fw_TakeDamage1(victiminflictorattackerFloat:damage// if take damage drag off
{
    if (
is_user_alive(attacker) && (get_pcvar_num(cvar_dmg2stop) > 0))
    {
        
g_ovr_dmg[victim] = g_ovr_dmg[victim] + floatround(damage)
        if (
g_ovr_dmg[victim] >= get_pcvar_num(cvar_dmg2stop))
        {
            
g_ovr_dmg[victim] = 0
            drag_end
(victim)
            return 
HAM_IGNORED;
        }
    }

    return 
HAM_IGNORED;
}

public 
fw_TakeDamage2(victiminflictorattackerFloat:damagedamage_type)
{
    if (!(
damage_type DMG_FALL) || !zp_get_user_zombie(victim) || zp_get_user_zombie_class(victim) != g_zclass_smoker)
        return 
HAM_IGNORED
    
    SetHamParamFloat
(40.0)
    return 
HAM_HANDLED
}

public 
fw_PlayerPreThink(id)
{
    if (!
is_user_alive(id))
        return 
FMRES_IGNORED
    
    
new button get_user_button(id)
    new 
oldbutton get_user_oldbutton(id)
    
    if (
g_bind_use[id] && zp_get_user_zombie(id) && (zp_get_user_zombie_class(id) == g_zclass_smoker))
    {
        
set_pev(idpev_flTimeStepSound999)
        if (!(
oldbutton IN_USE) && (button IN_USE))
            
drag_start(id)
        
        if ((
oldbutton IN_USE) && !(button IN_USE))
            
drag_end(id)
    }
    
    if (!
g_drag_i[id]) {
        
g_unable2move[id] = false
    
}
        
    if (
g_unable2move[id] && get_pcvar_num(cvar_unb2move) > 0)
    {
        
set_pev(idpev_maxspeed1.0)
    }
    
    return 
PLUGIN_CONTINUE
}

public 
client_disconnect(id// if client disconnects drag off
{
    if (
id <= || id 32)
        return
    
    if (
g_hooked[id])
        
drag_end(id)
    
    if(
g_unable2move[id])
        
g_unable2move[id] = false
}

public 
harpoon_target(parm[]) // set beam (ex. tongue:) if target is player
{
    new 
id parm[0]
    new 
hooktarget parm[1]

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(8)    // TE_BEAMENTS
    
write_short(id)
    
write_short(hooktarget)
    
write_short(g_Line)    // sprite index
    
write_byte(0)    // start frame
    
write_byte(0)    // framerate
    
write_byte(200)    // life
    
write_byte(8)    // width
    
write_byte(1)    // noise
    
write_byte(155)    // r, g, b
    
write_byte(155)    // r, g, b
    
write_byte(55)    // r, g, b
    
write_byte(90)    // brightness
    
write_byte(10)    // speed
    
message_end()
}

public 
bind_v_key(idkeys)
{
    
g_bind_or_not[id] = true
    
switch(keys)
    {
        case 
0:
            
client_cmd(id"bind v ^"+drag^"")
    
        case 
1:
            
client_print(idprint_chat"[ZP] To drag player to youself (bind ^'^'key^'^' ^'^'+drag^'^') hold binded key")
            
        case 
2:
            
g_bind_use[id] = true
            
        
default:
            
g_bind_or_not[id] = false
    
}
    
    return 
PLUGIN_HANDLED
}

public 
noTarget(id// set beam if target isn't player
{
    new 
endorigin[3]

    
get_user_origin(idendorigin3)

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byteTE_BEAMENTPOINT ); // TE_BEAMENTPOINT
    
write_short(id)
    
write_coord(endorigin[0])
    
write_coord(endorigin[1])
    
write_coord(endorigin[2])
    
write_short(g_Line// sprite index
    
write_byte(0)    // start frame
    
write_byte(0)    // framerate
    
write_byte(200)    // life
    
write_byte(8)    // width
    
write_byte(1)    // noise
    
write_byte(155)    // r, g, b
    
write_byte(155)    // r, g, b
    
write_byte(55)    // r, g, b
    
write_byte(75)    // brightness
    
write_byte(0)    // speed
    
message_end()
}

public 
beam_remove(id// remove beam
{
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(99)    //TE_KILLBEAM
    
write_short(id)    //entity
    
message_end()


It compiles, but the abilities don't work.


All times are GMT -4. The time now is 17:45.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.