Raised This Month: $ Target: $400
 0% 

ZP Class Smoker


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sweet
Senior Member
Join Date: May 2009
Old 09-17-2009 , 06:05   ZP Class Smoker
Reply With Quote #1

You know the ZP Class Smoker? I used it, but players complain that it takes 5 minutes to download the models (I'm not using downloadurl). I tried tweaking the code to change the zombie model to zombie source, but i have no experience in ZP Plugins, and the compiler gives me errors ):.

Please, could someone help me change the code?

Code:
/*
*    -----------------------------------
*    -----[ZP] Zombie Class: Smoker-----
*    -----------------------------------
*    ------Author: 4eRT (aka pff)-------
*    -----------------------------------
*        About:
*    When Left4Dead came out i immediately thought about Zombie Class Smoker plugin.
*    More later(few days ago) I was playing on Superhero Server when i found Scorpion hero.
*    So it was the way to create this plugin.
*    -----------------------------------
*        Discription:
*    Smoker is another zombie class for zombie plague like Smoker in L4D.
*    He can drags humans by holding "V" like /\...yeah, like Smoker. If Smoker receives
*    300 damage by human drag ends. If he falls or hurts more 25 dmg drag ends to.
*    Drag speed, max drags, cooldown, autobind, drag teammates & damage to stop
*    may be customized by Cvars.
*    -----------------------------------
*        Credits:
*    yang - great thanks for his Scorpion superhero plugin where I borrow harpoon&drag code.
*    5c0r-|3i0 - for his converted Smoker sounds.
*    Anggara_nothing - for rewritting Entvars_Set_Vector from Vexd_Utilities to engine. but not very useful :/
*    xPaw - really thx for help optimization plugin. For Entity_Set_Vector.
*    frk_14 - for his Smoker model. (hope you finish it ^^)
*    -----------------------------------
*        Cvars:
*    zp_smoker_maxdrags 10 // how many times Smoker can drag player to himself? def=10
*    zp_smoker_dragspeed 160 // speed of dragging player to Smoker def=160
*    zp_smoker_cooldown 5 // time in sec before you can use drag again. def=5
*    zp_smoker_mates 0 // can Smoker drag teammates to? 1=yes 0=no def=0
*    zp_smoker_bind 1 // autobind key V to +drag. 0=no autobind 1=autobind (v) def=1
*    zp_smoker_dmg2stop 75 // damage to stop dragging def=75
*    -----------------------------------
*        History(beta):
*    0.0 (14.04.09)
*        Most of code converted from sh_scorpion. Added 3 cvars.
*    0.1 (15.04.09)
*        Added cooldown, autobind, damage to stop and its cvars.
*    0.1 (16.04.09)
*        Beta testing. First view works perfectly...<- It was wrong belief...>_<
*    0.2 (17.04.09)
*        Entvars_Set_Vector now uses engine, not Vexd_Utilities.inc
*    0.3 (19.04.09)
*        Fixed cooldown. Now it works more stably. Reduced minimum drag distance.
*    0.3.1 (21.04.09)
*        Cooldown works more, more stably. After re-infecting Smoker can use drag
*        X times(cvar_maxdrags) if drags left when he was zombie last time.
*        Hope i've fixed dragging teammates. Please test it and say: does it work?
*        Added Smoker model(+modelT.mdl precacher).
*    -----------------------------------
*        PS:
*    It's my second useful plugin for amxx so...
*/

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

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

//Main Class, modelT & Sprite Beam
new g_zclass_smoker, g_Line
new const generic_models[][] = { "models/player/zombie_smoker/zombie_smokerT.mdl" } 
//Sounds
new g_sndMiss[] = "zombie_plague/Smoker_TongueHit_miss.wav"
new g_sndDrag[] = "zombie_plague/Smoker_TongueHit_drag.wav"
//Some vars
new g_hooked[33], g_hooksLeft[33]
new Float:g_lastHook[33]
//Cvars
new cvar_maxdrags, cvar_dragspeed, cvar_cooldown, cvar_dmg2stop, cvar_mates, cvar_bind
//Smoker Atributes
new const zclass_name[] = { "Smoker" }
new const zclass_info[] = { "Can drag players" }
new const zclass_model[] = { "zombie_smoker" }
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()
{
    cvar_dragspeed = register_cvar("zp_smoker_dragspeed", "160")
    cvar_maxdrags = register_cvar("zp_smoker_maxdrags", "10")
    cvar_cooldown = register_cvar("zp_smoker_cooldown", "5")
    cvar_dmg2stop = register_cvar("zp_smoker_dmg2stop", "75")
    cvar_mates = register_cvar("zp_smoker_mates", "0")
    cvar_bind = register_cvar("zp_smoker_bind", "1")
    register_event("ResetHUD", "newSpawn", "b")
    register_event("DeathMsg", "smoker_death", "a")
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    register_clcmd("+drag","drag_start", ADMIN_USER, "bind ^"key^" ^"+drag^"")
    register_clcmd("-drag","drag_end")
}
public plugin_precache()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    g_zclass_smoker = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
    precache_sound(g_sndDrag)
    precache_sound(g_sndMiss)
    g_Line = precache_model("sprites/zbeam4.spr")
    
    for (new i = 0; i < sizeof generic_models; i++)
    precache_model(generic_models[i])
}

public zp_user_infected_post(id, infector)
{
    if (zp_get_user_zombie_class(id) == g_zclass_smoker) {
        g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
        new mode = get_pcvar_num(cvar_bind)
        
        if (mode == 1) {
            client_cmd(id, "bind v ^"+drag^"")
            client_print(id, print_chat, "[ZP] To drag player to youself hold ^'^'V^'^'")
        }
        if (mode == 0) {
            client_print(id, print_chat, "[ZP] To drag player to youself (bind ^'^'key^'^' ^'^'+drag^'^') hold binded key")
        }
    }
}

public newSpawn(id)
{
    g_lastHook[id] = get_gametime()
    
    beam_remove(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) {
        
        static Float:cdown
        cdown = get_pcvar_float(cvar_cooldown)
        
        if (!is_user_alive(id)) {
            client_print(id, print_chat, "[ZP] You can't drag if you are dead!")
            return
        }

        if (g_hooksLeft[id] <= 0) {
            client_print(id, print_chat, "[ZP] You can't drag anymore!")
            return
        }
            
        if (get_gametime() - g_lastHook[id] < cdown) {
            client_print(id, print_chat, "[ZP] Wait %.fsec. to drag again!", get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
            return
        }

        if (g_hooksLeft[id] > 0) {
            g_hooksLeft[id]--
            client_print(id, print_chat, "[ZP] You can drag player to youself %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
        }

        new hooktarget, body

        get_user_aiming(id, hooktarget, body)
        
        if (is_user_alive(hooktarget)) {
            if (get_user_team(hooktarget) != get_user_team(id)) {
                g_hooked[id] = hooktarget
                emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
            } else {
                if (get_user_team(hooktarget) == get_user_team(id)) {
                    if (get_pcvar_num(cvar_mates) == 0) {
                        client_print(id, print_chat, "[ZP] You can't drag teammates!")
                        return
                    }
                    if (get_pcvar_num(cvar_mates) == 1) {
                        g_hooked[id] = hooktarget
                        emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
                    }
                } else {
                    g_hooked[id] = 33
                    noTarget(id)
                    emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
                    return
                }
            }

            new parm[2]
            parm[0] = id
            parm[1] = hooktarget
            
            set_task(0.1, "smoker_reelin", id, parm, 2, "b")
            harpoon_target(parm)
        } else {
            g_hooked[id] = 33
            noTarget(id)
            emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
        }
    } else {
        return
    }
}

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

    if (!g_hooked[id])
        return

    if (!is_user_alive(victim)) {
        drag_end(id)
        return
    }

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

    get_user_origin(victim, vicOrigin)
    get_user_origin(id, idOrigin)

    new distance = get_distance(idOrigin, vicOrigin)

    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(victim, EV_VEC_velocity, fl_Velocity) //<- rewritten. now uses engine
}

public drag_end(id) // drags end function
{
    g_hooked[id] = 0
    beam_remove(id)
    remove_task(id)
    
    if (get_gametime() - g_lastHook[id] <= get_pcvar_float(cvar_cooldown) + 0.08) {
        return
    } else {
        g_lastHook[id] = get_gametime()
    }
}

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_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) // if take damage drag off
{
    if (victim == attacker || !is_user_connected(attacker)) {
        if (damage > 25) {
            drag_end(victim)
            return HAM_IGNORED;
        }
    }
    
    if (get_user_team(attacker) != get_user_team(victim)) {
        if (damage > get_pcvar_num(cvar_dmg2stop)) {
            drag_end(victim)
            return HAM_IGNORED;
        }
    }
        
    return HAM_IGNORED;
}

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

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

    message_begin(MSG_BROADCAST, SVC_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 noTarget(id) // set beam if target isn't player
{
    new endorigin[3]

    get_user_origin(id, endorigin, 3)

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte( TE_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_BROADCAST, SVC_TEMPENTITY)
    write_byte(99)    //TE_KILLBEAM
    write_short(id)    //entity
    message_end()
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
sweet is offline
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 09-17-2009 , 06:29   Re: ZP Class Smoker
Reply With Quote #2

Here
Code:
/*
*    -----------------------------------
*    -----[ZP] Zombie Class: Smoker-----
*    -----------------------------------
*    ------Author: 4eRT (aka pff)-------
*    -----------------------------------
*        About:
*    When Left4Dead came out i immediately thought about Zombie Class Smoker plugin.
*    More later(few days ago) I was playing on Superhero Server when i found Scorpion hero.
*    So it was the way to create this plugin.
*    -----------------------------------
*        Discription:
*    Smoker is another zombie class for zombie plague like Smoker in L4D.
*    He can drags humans by holding "V" like /\...yeah, like Smoker. If Smoker receives
*    300 damage by human drag ends. If he falls or hurts more 25 dmg drag ends to.
*    Drag speed, max drags, cooldown, autobind, drag teammates & damage to stop
*    may be customized by Cvars.
*    -----------------------------------
*        Credits:
*    yang - great thanks for his Scorpion superhero plugin where I borrow harpoon&drag code.
*    5c0r-|3i0 - for his converted Smoker sounds.
*    Anggara_nothing - for rewritting Entvars_Set_Vector from Vexd_Utilities to engine. but not very useful :/
*    xPaw - really thx for help optimization plugin. For Entity_Set_Vector.
*    frk_14 - for his Smoker model. (hope you finish it ^^)
*    -----------------------------------
*        Cvars:
*    zp_smoker_maxdrags 10 // how many times Smoker can drag player to himself? def=10
*    zp_smoker_dragspeed 160 // speed of dragging player to Smoker def=160
*    zp_smoker_cooldown 5 // time in sec before you can use drag again. def=5
*    zp_smoker_mates 0 // can Smoker drag teammates to? 1=yes 0=no def=0
*    zp_smoker_bind 1 // autobind key V to +drag. 0=no autobind 1=autobind (v) def=1
*    zp_smoker_dmg2stop 75 // damage to stop dragging def=75
*    -----------------------------------
*        History(beta):
*    0.0 (14.04.09)
*        Most of code converted from sh_scorpion. Added 3 cvars.
*    0.1 (15.04.09)
*        Added cooldown, autobind, damage to stop and its cvars.
*    0.1 (16.04.09)
*        Beta testing. First view works perfectly...<- It was wrong belief...>_<
*    0.2 (17.04.09)
*        Entvars_Set_Vector now uses engine, not Vexd_Utilities.inc
*    0.3 (19.04.09)
*        Fixed cooldown. Now it works more stably. Reduced minimum drag distance.
*    0.3.1 (21.04.09)
*        Cooldown works more, more stably. After re-infecting Smoker can use drag
*        X times(cvar_maxdrags) if drags left when he was zombie last time.
*        Hope i've fixed dragging teammates. Please test it and say: does it work?
*        Added Smoker model(+modelT.mdl precacher).
*    -----------------------------------
*        PS:
*    It's my second useful plugin for amxx so...
*/

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

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

//Main Class, modelT & Sprite Beam
new g_zclass_smoker, g_Line
new const generic_models[][] = { "models/player/zombie_source/zombie_source.mdl" } 
//Sounds
new g_sndMiss[] = "zombie_plague/Smoker_TongueHit_miss.wav"
new g_sndDrag[] = "zombie_plague/Smoker_TongueHit_drag.wav"
//Some vars
new g_hooked[33], g_hooksLeft[33]
new Float:g_lastHook[33]
//Cvars
new cvar_maxdrags, cvar_dragspeed, cvar_cooldown, cvar_dmg2stop, cvar_mates, cvar_bind
//Smoker Atributes
new const zclass_name[] = { "Smoker" }
new const zclass_info[] = { "Can drag players" }
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()
{
    cvar_dragspeed = register_cvar("zp_smoker_dragspeed", "160")
    cvar_maxdrags = register_cvar("zp_smoker_maxdrags", "10")
    cvar_cooldown = register_cvar("zp_smoker_cooldown", "5")
    cvar_dmg2stop = register_cvar("zp_smoker_dmg2stop", "75")
    cvar_mates = register_cvar("zp_smoker_mates", "0")
    cvar_bind = register_cvar("zp_smoker_bind", "1")
    register_event("ResetHUD", "newSpawn", "b")
    register_event("DeathMsg", "smoker_death", "a")
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    register_clcmd("+drag","drag_start", ADMIN_USER, "bind ^"key^" ^"+drag^"")
    register_clcmd("-drag","drag_end")
}
public plugin_precache()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    g_zclass_smoker = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
    precache_sound(g_sndDrag)
    precache_sound(g_sndMiss)
    g_Line = precache_model("sprites/zbeam4.spr")
    
    for (new i = 0; i < sizeof generic_models; i++)
    precache_model(generic_models[i])
}

public zp_user_infected_post(id, infector)
{
    if (zp_get_user_zombie_class(id) == g_zclass_smoker) {
        g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
        new mode = get_pcvar_num(cvar_bind)
        
        if (mode == 1) {
            client_cmd(id, "bind v ^"+drag^"")
            client_print(id, print_chat, "[ZP] To drag player to youself hold ^'^'V^'^'")
        }
        if (mode == 0) {
            client_print(id, print_chat, "[ZP] To drag player to youself (bind ^'^'key^'^' ^'^'+drag^'^') hold binded key")
        }
    }
}

public newSpawn(id)
{
    g_lastHook[id] = get_gametime()
    
    beam_remove(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) {
        
        static Float:cdown
        cdown = get_pcvar_float(cvar_cooldown)
        
        if (!is_user_alive(id)) {
            client_print(id, print_chat, "[ZP] You can't drag if you are dead!")
            return
        }

        if (g_hooksLeft[id] <= 0) {
            client_print(id, print_chat, "[ZP] You can't drag anymore!")
            return
        }
            
        if (get_gametime() - g_lastHook[id] < cdown) {
            client_print(id, print_chat, "[ZP] Wait %.fsec. to drag again!", get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
            return
        }

        if (g_hooksLeft[id] > 0) {
            g_hooksLeft[id]--
            client_print(id, print_chat, "[ZP] You can drag player to youself %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
        }

        new hooktarget, body

        get_user_aiming(id, hooktarget, body)
        
        if (is_user_alive(hooktarget)) {
            if (get_user_team(hooktarget) != get_user_team(id)) {
                g_hooked[id] = hooktarget
                emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
            } else {
                if (get_user_team(hooktarget) == get_user_team(id)) {
                    if (get_pcvar_num(cvar_mates) == 0) {
                        client_print(id, print_chat, "[ZP] You can't drag teammates!")
                        return
                    }
                    if (get_pcvar_num(cvar_mates) == 1) {
                        g_hooked[id] = hooktarget
                        emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
                    }
                } else {
                    g_hooked[id] = 33
                    noTarget(id)
                    emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
                    return
                }
            }

            new parm[2]
            parm[0] = id
            parm[1] = hooktarget
            
            set_task(0.1, "smoker_reelin", id, parm, 2, "b")
            harpoon_target(parm)
        } else {
            g_hooked[id] = 33
            noTarget(id)
            emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
        }
    } else {
        return
    }
}

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

    if (!g_hooked[id])
        return

    if (!is_user_alive(victim)) {
        drag_end(id)
        return
    }

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

    get_user_origin(victim, vicOrigin)
    get_user_origin(id, idOrigin)

    new distance = get_distance(idOrigin, vicOrigin)

    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(victim, EV_VEC_velocity, fl_Velocity) //<- rewritten. now uses engine
}

public drag_end(id) // drags end function
{
    g_hooked[id] = 0
    beam_remove(id)
    remove_task(id)
    
    if (get_gametime() - g_lastHook[id] <= get_pcvar_float(cvar_cooldown) + 0.08) {
        return
    } else {
        g_lastHook[id] = get_gametime()
    }
}

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_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) // if take damage drag off
{
    if (victim == attacker || !is_user_connected(attacker)) {
        if (damage > 25) {
            drag_end(victim)
            return HAM_IGNORED;
        }
    }
    
    if (get_user_team(attacker) != get_user_team(victim)) {
        if (damage > get_pcvar_num(cvar_dmg2stop)) {
            drag_end(victim)
            return HAM_IGNORED;
        }
    }
        
    return HAM_IGNORED;
}

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

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

    message_begin(MSG_BROADCAST, SVC_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 noTarget(id) // set beam if target isn't player
{
    new endorigin[3]

    get_user_origin(id, endorigin, 3)

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte( TE_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_BROADCAST, SVC_TEMPENTITY)
    write_byte(99)    //TE_KILLBEAM
    write_short(id)    //entity
    message_end()
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
Excalibur.007 is offline
sweet
Senior Member
Join Date: May 2009
Old 09-17-2009 , 07:24   Re: ZP Class Smoker
Reply With Quote #3

Nope, it still requires the model ):
sweet is offline
tempito
Senior Member
Join Date: Feb 2009
Location: Peru
Old 09-17-2009 , 10:01   Re: ZP Class Smoker
Reply With Quote #4

Try this one.

Code:
/*
*    -----------------------------------
*    -----[ZP] Zombie Class: Smoker-----
*    -----------------------------------
*    ------Author: 4eRT (aka pff)-------
*    -----------------------------------
*        About:
*    When Left4Dead came out i immediately thought about Zombie Class Smoker plugin.
*    More later(few days ago) I was playing on Superhero Server when i found Scorpion hero.
*    So it was the way to create this plugin.
*    -----------------------------------
*        Discription:
*    Smoker is another zombie class for zombie plague like Smoker in L4D.
*    He can drags humans by holding "V" like /\...yeah, like Smoker. If Smoker receives
*    300 damage by human drag ends. If he falls or hurts more 25 dmg drag ends to.
*    Drag speed, max drags, cooldown, autobind, drag teammates & damage to stop
*    may be customized by Cvars.
*    -----------------------------------
*        Credits:
*    yang - great thanks for his Scorpion superhero plugin where I borrow harpoon&drag code.
*    5c0r-|3i0 - for his converted Smoker sounds.
*    Anggara_nothing - for rewritting Entvars_Set_Vector from Vexd_Utilities to engine. but not very useful :/
*    xPaw - really thx for help optimization plugin. For Entity_Set_Vector.
*    frk_14 - for his Smoker model. (hope you finish it ^^)
*    -----------------------------------
*        Cvars:
*    zp_smoker_maxdrags 10 // how many times Smoker can drag player to himself? def=10
*    zp_smoker_dragspeed 160 // speed of dragging player to Smoker def=160
*    zp_smoker_cooldown 5 // time in sec before you can use drag again. def=5
*    zp_smoker_mates 0 // can Smoker drag teammates to? 1=yes 0=no def=0
*    zp_smoker_bind 1 // autobind key V to +drag. 0=no autobind 1=autobind (v) def=1
*    zp_smoker_dmg2stop 75 // damage to stop dragging def=75
*    -----------------------------------
*        History(beta):
*    0.0 (14.04.09)
*        Most of code converted from sh_scorpion. Added 3 cvars.
*    0.1 (15.04.09)
*        Added cooldown, autobind, damage to stop and its cvars.
*    0.1 (16.04.09)
*        Beta testing. First view works perfectly...<- It was wrong belief...>_<
*    0.2 (17.04.09)
*        Entvars_Set_Vector now uses engine, not Vexd_Utilities.inc
*    0.3 (19.04.09)
*        Fixed cooldown. Now it works more stably. Reduced minimum drag distance.
*    0.3.1 (21.04.09)
*        Cooldown works more, more stably. After re-infecting Smoker can use drag
*        X times(cvar_maxdrags) if drags left when he was zombie last time.
*        Hope i've fixed dragging teammates. Please test it and say: does it work?
*        Added Smoker model(+modelT.mdl precacher).
*    -----------------------------------
*        PS:
*    It's my second useful plugin for amxx so...
*/

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

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

//Main Class, modelT & Sprite Beam
new g_zclass_smoker, g_Line
 //Sounds
new g_sndMiss[] = "zombie_plague/Smoker_TongueHit_miss.wav"
new g_sndDrag[] = "zombie_plague/Smoker_TongueHit_drag.wav"
//Some vars
new g_hooked[33], g_hooksLeft[33]
new Float:g_lastHook[33]
//Cvars
new cvar_maxdrags, cvar_dragspeed, cvar_cooldown, cvar_dmg2stop, cvar_mates, cvar_bind
//Smoker Atributes
new const zclass_name[] = { "Smoker" }
new const zclass_info[] = { "Can drag players" }
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()
{
    cvar_dragspeed = register_cvar("zp_smoker_dragspeed", "160")
    cvar_maxdrags = register_cvar("zp_smoker_maxdrags", "10")
    cvar_cooldown = register_cvar("zp_smoker_cooldown", "5")
    cvar_dmg2stop = register_cvar("zp_smoker_dmg2stop", "75")
    cvar_mates = register_cvar("zp_smoker_mates", "0")
    cvar_bind = register_cvar("zp_smoker_bind", "1")
    register_event("ResetHUD", "newSpawn", "b")
    register_event("DeathMsg", "smoker_death", "a")
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    register_clcmd("+drag","drag_start", ADMIN_USER, "bind ^"key^" ^"+drag^"")
    register_clcmd("-drag","drag_end")
}
public plugin_precache()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    g_zclass_smoker = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
    precache_sound(g_sndDrag)
    precache_sound(g_sndMiss)
    g_Line = precache_model("sprites/zbeam4.spr")
}

public zp_user_infected_post(id, infector)
{
    if (zp_get_user_zombie_class(id) == g_zclass_smoker) {
        g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
        new mode = get_pcvar_num(cvar_bind)
        
        if (mode == 1) {
            client_cmd(id, "bind v ^"+drag^"")
            client_print(id, print_chat, "[ZP] To drag player to youself hold ^'^'V^'^'")
        }
        if (mode == 0) {
            client_print(id, print_chat, "[ZP] To drag player to youself (bind ^'^'key^'^' ^'^'+drag^'^') hold binded key")
        }
    }
}

public newSpawn(id)
{
    g_lastHook[id] = get_gametime()
    
    beam_remove(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) {
        
        static Float:cdown
        cdown = get_pcvar_float(cvar_cooldown)
        
        if (!is_user_alive(id)) {
            client_print(id, print_chat, "[ZP] You can't drag if you are dead!")
            return
        }

        if (g_hooksLeft[id] <= 0) {
            client_print(id, print_chat, "[ZP] You can't drag anymore!")
            return
        }
            
        if (get_gametime() - g_lastHook[id] < cdown) {
            client_print(id, print_chat, "[ZP] Wait %.fsec. to drag again!", get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
            return
        }

        if (g_hooksLeft[id] > 0) {
            g_hooksLeft[id]--
            client_print(id, print_chat, "[ZP] You can drag player to youself %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
        }

        new hooktarget, body

        get_user_aiming(id, hooktarget, body)
        
        if (is_user_alive(hooktarget)) {
            if (get_user_team(hooktarget) != get_user_team(id)) {
                g_hooked[id] = hooktarget
                emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
            } else {
                if (get_user_team(hooktarget) == get_user_team(id)) {
                    if (get_pcvar_num(cvar_mates) == 0) {
                        client_print(id, print_chat, "[ZP] You can't drag teammates!")
                        return
                    }
                    if (get_pcvar_num(cvar_mates) == 1) {
                        g_hooked[id] = hooktarget
                        emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
                    }
                } else {
                    g_hooked[id] = 33
                    noTarget(id)
                    emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
                    return
                }
            }

            new parm[2]
            parm[0] = id
            parm[1] = hooktarget
            
            set_task(0.1, "smoker_reelin", id, parm, 2, "b")
            harpoon_target(parm)
        } else {
            g_hooked[id] = 33
            noTarget(id)
            emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
        }
    } else {
        return
    }
}

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

    if (!g_hooked[id])
        return

    if (!is_user_alive(victim)) {
        drag_end(id)
        return
    }

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

    get_user_origin(victim, vicOrigin)
    get_user_origin(id, idOrigin)

    new distance = get_distance(idOrigin, vicOrigin)

    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(victim, EV_VEC_velocity, fl_Velocity) //<- rewritten. now uses engine
}

public drag_end(id) // drags end function
{
    g_hooked[id] = 0
    beam_remove(id)
    remove_task(id)
    
    if (get_gametime() - g_lastHook[id] <= get_pcvar_float(cvar_cooldown) + 0.08) {
        return
    } else {
        g_lastHook[id] = get_gametime()
    }
}

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_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) // if take damage drag off
{
    if (victim == attacker || !is_user_connected(attacker)) {
        if (damage > 25) {
            drag_end(victim)
            return HAM_IGNORED;
        }
    }
    
    if (get_user_team(attacker) != get_user_team(victim)) {
        if (damage > get_pcvar_num(cvar_dmg2stop)) {
            drag_end(victim)
            return HAM_IGNORED;
        }
    }
        
    return HAM_IGNORED;
}

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

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

    message_begin(MSG_BROADCAST, SVC_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 noTarget(id) // set beam if target isn't player
{
    new endorigin[3]

    get_user_origin(id, endorigin, 3)

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte( TE_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_BROADCAST, SVC_TEMPENTITY)
    write_byte(99)    //TE_KILLBEAM
    write_short(id)    //entity
    message_end()
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
__________________
My very first zp server movie.
http://www.youtube.com/watch?v=yvTmlFr_Y-4 <- now with translation in english

tempito is offline
GmTx
BANNED
Join Date: May 2009
Location: Mountains [BG/Sofia]
Old 09-17-2009 , 11:13   Re: ZP Class Smoker
Reply With Quote #5

Yeah it`s gonna requires the model because he got T model
Just write the name
new const generic_models the name of the original model this work in my server
GmTx is offline
Send a message via Skype™ to GmTx
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 09-18-2009 , 01:12   Re: ZP Class Smoker
Reply With Quote #6

Oh i know why already.
Open zp_zombieclasses.ini in the configs folder.
Change the model of smoker to zombie_source
and the hands should be v_knife_zombie
Cause ZP 4.3 uses this instead of the amxx file inside.
Excalibur.007 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:00.


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