Ion cannon

Useless Stuffs, Spam ... etc
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

Ion cannon

#1

Post by czirimbolo » 1 Year Ago

Hello I need you help. This item can explode like a bomb but before exploding, it makes fire for X seconds (like napalm). Can some make this fire working like fire nades (slowing down and making damage)? Because at the moment this fire does nothing, its just an animation.

Second thing, can you block this item for zombies, because when human is infected, the zombies get this bomb.

Code: Select all

#include <zombie_escape>
 
#define IGNORE_MONSTERS                 1
#define IGNORE_GLASS                    0x100
 
#define ION_RADIUS  800.0
#define ION_MAXDAMAGE   15000.0
 
new const WPN_NAME[]    =   "Ion Cannon"
 
new const W_MODEL[] =       "models/w_battery.mdl"
 
new SOUND_APPROACH[]    =   "zombie_plague/ion_canon/approach.wav"
new SOUND_START_PLANT[] =   "zombie_plague/ion_canon/beacon_set.wav"
new SOUND_STOP[]    =       "vox/_comma.wav"
new SOUND_BEEP[]    =       "zombie_plague/ion_canon/beacon_beep.wav"
new SOUND_ATTACK[]  =       "zombie_plague/ion_canon/attack.wav"
new SOUND_READY[]   =       "zombie_plague/ion_canon/ready.wav"
 
new g_Target[33], i_Pitch[33]
new Float:i_BeaconTime[33]
new Float:ion_mid_origin[33][3]
new Float:beam_origin[33][8][3]
new Float:g_degrees[33][8]
new Float:g_distance[33]
new Float:ROTATION_SPEED[33]
new IonBeam, BlueFire, Shockwave, ReadyFire, BlueFlare, IonShake, LaserFlame
 
//---------------------------------------
new gItemID, bool:g_bCanBuy
new bool:gHasIon[33]
new const gCost = 30    // Item Cost
new bool:bInUse[33]
new g_msgDeathMsg
//---------------------------------------
public plugin_init ()
{
    register_plugin ( "[ZP] ExtraItem: Ion Cannon", "1.91", "A.F./ Makzz / Shidla" )
   
    gItemID     = ze_register_item ( WPN_NAME, gCost, 0)
   
    IonShake    = get_user_msgid ( "ScreenShake" )
    g_msgDeathMsg   = get_user_msgid("DeathMsg")
   
    register_forward ( FM_PlayerPreThink, "fw_PlayerPreThink" )
}
 
public client_connect(id)
{
    g_Target[id] = 0
    gHasIon[id] = false
}
 
public plugin_precache ()
{
    precache_model ( W_MODEL )
    precache_sound ( SOUND_APPROACH )
    precache_sound ( SOUND_START_PLANT )
    precache_sound ( SOUND_BEEP )
    precache_sound ( SOUND_ATTACK )
    precache_sound ( SOUND_READY )
    precache_sound ( SOUND_STOP )
    IonBeam     = precache_model("sprites/ion_canon/ionbeam.spr")
    BlueFlare   = precache_model("sprites/ion_canon/bflare.spr")
    ReadyFire   = precache_model("sprites/ion_canon/fire.spr")
    BlueFire    = precache_model("sprites/ion_canon/blueflame.spr")
    LaserFlame  = precache_model("sprites/ion_canon/ion_laserflame.spr")
    Shockwave   = precache_model("sprites/shockwave.spr")
}
 
public ion_planted ( id )
{
    id -= 5000
    client_print ( id, print_chat, "Ion cannon beacon deploy" )
   
    g_Target[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    if(!g_Target[id])
        return
   
    set_pev(g_Target[id],pev_classname,"info_target_ion")
    engfunc(EngFunc_SetModel,g_Target[id],W_MODEL)
   
    set_pev(g_Target[id],pev_owner, id)
    set_pev(g_Target[id],pev_movetype, MOVETYPE_TOSS)
    set_pev(g_Target[id],pev_solid, SOLID_TRIGGER)
   
    wpn_projectile_startpos(id,0,0,50,ion_mid_origin[id])
    set_pev(g_Target[id],pev_origin,ion_mid_origin[id])
   
    ion_beacon(id)
    //set_task(5.0,"ion_startup", id)
    set_task ( 9.0, "Trace_Ready", id )
}
 
public ion_beacon ( id )
{
    if ( !g_Target[id] )
        return
   
    i_Pitch[id] += 3
    i_BeaconTime[id] -= 0.03
    if(i_Pitch[id] > 255)
        i_Pitch[id] = 255
   
    if(i_BeaconTime[id] < 0.30)
        i_BeaconTime[id] = 0.30
   
    emit_sound(g_Target[id], CHAN_ITEM, SOUND_BEEP, VOL_NORM, ATTN_NORM, 0, i_Pitch[id])
    set_task(i_BeaconTime[id],"ion_beacon", id)
}
 
public Trace_Ready(id)
{
    remove_task(id)
    // write origin of each
    new Float:mid_origin[33][3]
    pev(g_Target[id],pev_origin,mid_origin[id]) // Target contain entity id
    // 1st
    beam_origin[id][0][0] = mid_origin[id][0] + 300.0
    beam_origin[id][0][1] = mid_origin[id][1] + 150.0
    beam_origin[id][0][2] = mid_origin[id][2]
    g_degrees[id][0] = 0.0
    // 2nd
    beam_origin[id][1][0] = mid_origin[id][0] + 300.0
    beam_origin[id][1][1] = mid_origin[id][1] - 150.0
    beam_origin[id][1][2] = mid_origin[id][2]
    g_degrees[id][1] = 45.0
    // 3rd
    beam_origin[id][2][0] = mid_origin[id][0] - 300.0
    beam_origin[id][2][1] = mid_origin[id][1] - 150.0
    beam_origin[id][2][2] = mid_origin[id][2]
    g_degrees[id][2] = 90.0
    // 4th
    beam_origin[id][3][0] = mid_origin[id][0] - 300.0
    beam_origin[id][3][1] = mid_origin[id][1] + 150.0
    beam_origin[id][3][2] = mid_origin[id][2]
    g_degrees[id][3] = 135.0
    // 5th
    beam_origin[id][4][0] = mid_origin[id][0] + 150.0
    beam_origin[id][4][1] = mid_origin[id][1] + 300.0
    beam_origin[id][4][2] = mid_origin[id][2]
    g_degrees[id][4] = 180.0
    // 6th
    beam_origin[id][5][0] = mid_origin[id][0] + 150.0
    beam_origin[id][5][1] = mid_origin[id][1] - 300.0
    beam_origin[id][5][2] = mid_origin[id][2]
    g_degrees[id][5] = 225.0
    // 7th
    beam_origin[id][6][0] = mid_origin[id][0] - 150.0
    beam_origin[id][6][1] = mid_origin[id][1] - 300.0
    beam_origin[id][6][2] = mid_origin[id][2]
    g_degrees[id][6] = 270.0
    // 8th
    beam_origin[id][7][0] = mid_origin[id][0] - 150.0
    beam_origin[id][7][1] = mid_origin[id][1] + 300.0
    beam_origin[id][7][2] = mid_origin[id][2]
    g_degrees[id][7] = 315.0
   
    // set the mid to global
    ion_mid_origin[id] = mid_origin[id]
 
    new Float:addtime
    for(new i; i < 8; i++) {
        addtime = addtime + 0.3
        new param[3]
        param[0] = i
        param[1] = id
        set_task(0.0 + addtime, "Trace_Start", _,param, 2)
    }
 
    Laser_Rotate(id) //To fix the laserdraw
   
    emit_sound ( g_Target[id], CHAN_ITEM, SOUND_READY, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
   
    for(new Float:i = 0.0; i < 7.5; i += 0.01) //Rotate for 7.5 secs.
        set_task(i+3.0, "Laser_Rotate", id)
 
    set_task(2.9,"AddSpeed", id)
    set_task(11.5,"CreateFire", id)
    set_task(12.5,"ClearLasers", id)
    set_task(15.2,"FireIonCannon", id)
    return PLUGIN_CONTINUE
}
 
public AddSpeed(id) {
    if(!g_Target[id]) return PLUGIN_CONTINUE
   
    if(ROTATION_SPEED[id] > 1.0) ROTATION_SPEED[id] = 1.0
    ROTATION_SPEED[id] += 0.1
    set_task(0.6,"AddSpeed", id)
    return PLUGIN_CONTINUE
}
 
public CreateFire(id) {
    if(!g_Target[id]) return PLUGIN_CONTINUE
 
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
    write_byte(TE_SPRITE)
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + 100)
    write_short(ReadyFire)
    write_byte(30)
    write_byte(200)
    message_end()
 
    set_task(1.5,"CreateFire", id)
    return PLUGIN_CONTINUE
}
 
public ClearLasers(id)
    remove_task(1018+id)
 
public Laser_Rotate(id)
{
    g_distance[id] -= 0.467
    for(new i; i < 8; i++) {
        // Calculate new alpha
        g_degrees[id][i] += ROTATION_SPEED[id]
        if(g_degrees[id][i] > 360.0)
            g_degrees[id][i] -= 360.0
 
        // calcul the next origin
        new Float:tmp[33][3]
        tmp[id] = ion_mid_origin[id]
 
        tmp[id][0] += floatsin(g_degrees[id][i], degrees) * g_distance[id]
        tmp[id][1] += floatcos(g_degrees[id][i], degrees) * g_distance[id]
        tmp[id][2] += 0.0 // -.-
        beam_origin[id][i] = tmp[id]
    }
}
 
public Trace_Start(param[]) {
    new i = param[0]
    new id = param[1]
 
    new Float:get_random_z,Float:SkyOrigin[33][3]
    SkyOrigin[id] = tlx_distance_to_sky(g_Target[id])
    get_random_z = random_float(300.0,SkyOrigin[id][2])
 
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, beam_origin[id][i], 0)
    write_byte(TE_SPRITE)
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][2] + get_random_z)
    write_short(BlueFire)
    write_byte(10)
    write_byte(100)
    message_end()
   
    TraceAll(param)
}
 
public TraceAll(param[]) {
    new i = param[0]
    new id = param[1]
 
    new Float:SkyOrigin[33][3]
    SkyOrigin[id] = tlx_distance_to_sky(g_Target[id])
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, beam_origin[id][i], 0)
    write_byte(TE_BEAMPOINTS)
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])      //start point (x)
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])      //start point (y)
    engfunc(EngFunc_WriteCoord, SkyOrigin[id][2])           //start point (z)
 
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])      //end point (x)
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])      //end point (y)
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][2])      //end point (z)
    write_short(IonBeam)    //model
    write_byte(0)       //startframe
    write_byte(0)       //framerate
    write_byte(1)       //life
    write_byte(50)      //width
    write_byte(0)       //noise
    write_byte(255)     //r
    write_byte(255)     //g
    write_byte(255)     //b
    write_byte(255)     //brightness
    write_byte(0)       //speed
    message_end()
   
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, beam_origin[id][i], 0)
    write_byte(TE_SPRITE)
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])
    engfunc(EngFunc_WriteCoord, beam_origin[id][i][2])
    write_short(LaserFlame)
    write_byte(5)
    write_byte(200)
    message_end()
   
    set_task(0.08,"TraceAll", 1018+id, param, 2)
}
 
public FireIonCannon(id) {
    new i = -1
    while((i = engfunc(EngFunc_FindEntityInSphere, i, ion_mid_origin[id], ION_RADIUS + 8000)) != 0)
    {
        if(pev_valid(i) && pev(i, pev_flags) & (FL_CLIENT | FL_FAKECLIENT)) {
            message_begin(MSG_ONE_UNRELIABLE, IonShake, {0,0,0}, i)
            write_short(255<<14) //ammount
            write_short(10<<14) //lasts this long
            write_short(255<<14) //frequency
            message_end()
        }
        //next player in spehre.
        continue
    }
 
    new Float:skyOrigin[33][3]
    skyOrigin[id] = tlx_distance_to_sky(g_Target[id])
 
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
    write_byte(TE_BEAMPOINTS)
    engfunc(EngFunc_WriteCoord, skyOrigin[id][0])   //start point (x)
    engfunc(EngFunc_WriteCoord, skyOrigin[id][1])   //start point (y)
    engfunc(EngFunc_WriteCoord, skyOrigin[id][2])   //start point (z)
 
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])      //end point (x)
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])      //end point (y)
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2])      //end point (z)
    write_short(IonBeam)    //model
    write_byte(0)       //startframe
    write_byte(0)       //framerate
    write_byte(15)      //life
    write_byte(255)     //width
    write_byte(0)       //noise
    write_byte(255)     //r
    write_byte(255)     //g
    write_byte(255)     //b
    write_byte(255)     //brightness
    write_byte(0)       //speed
    message_end()
 
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin, 0)
    write_byte(TE_BEAMCYLINDER)
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0]) // start X
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1]) // start Y
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2]) // start Z
 
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0]) // something X
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1]) // something Y
    engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + ION_RADIUS - 1000.0) // something Z
    write_short(Shockwave) // sprite
    write_byte(0) // startframe
    write_byte(0) // framerate
    write_byte(100) // life
    write_byte(150) // width
    write_byte(0) // noise
    write_byte(0) // red
    write_byte(100) // green
    write_byte(250) // blue
    write_byte(150) // brightness
    write_byte(0) // speed
    message_end()
 
    for(new i = 1; i < 6; i++) {
        engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
        write_byte(TE_SPRITETRAIL)  // line of moving glow sprites with gravity, fadeout, and collisions
        engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
        engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
        engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2])
        engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
        engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
        engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + 200)
        write_short(BlueFlare) // (sprite index)
        write_byte(50) // (count)
        write_byte(random_num(27,30)) // (life in 0.1's)
        write_byte(10) // byte (scale in 0.1's)
        write_byte(random_num(30,70)) // (velocity along vector in 10's)
        write_byte(40) // (randomness of velocity in 10's)
        message_end()
    }
   
    wpn_radius_damage ( g_Target[id], ION_RADIUS, ION_MAXDAMAGE )
    emit_sound ( g_Target[id], CHAN_ITEM, SOUND_ATTACK, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
   
    ResetAll(id)
}
 
ResetAll ( id )
{
    set_pev ( g_Target[id], pev_flags, FL_KILLME )
    g_Target[id] = 0
    gHasIon[id] = false
}
 
/******************** Stocks ********************/
stock Float:tlx_distance_to_sky(id) // Get entity above sky.
{
    new Float:TraceEnd[3]
    pev(id, pev_origin, TraceEnd)
 
    new Float:f_dest[3]
    f_dest[0] = TraceEnd[0]
    f_dest[1] = TraceEnd[1]
    f_dest[2] = TraceEnd[2] + 8192.0
 
    new res, Float:SkyOrigin[3]
    engfunc(EngFunc_TraceLine, TraceEnd, f_dest, IGNORE_MONSTERS + IGNORE_GLASS, id, res)
    get_tr2(res, TR_vecEndPos, SkyOrigin)
 
    return SkyOrigin
}
//return distance above us to sky
stock Float:is_user_outside(id) {
    new Float:origin[3], Float:dist
 
    pev(id, pev_origin, origin)
    dist = origin[2]
 
    while(engfunc(EngFunc_PointContents, origin) == CONTENTS_EMPTY)
        origin[2] += 5.0
    if(engfunc(EngFunc_PointContents, origin) == CONTENTS_SKY)
        return (origin[2] - dist)
 
    return 0.0
}
 
stock ProgressBar(id, seconds, position)
{
    message_begin(MSG_ONE, get_user_msgid("BarTime"), {0, 0, 0}, id)
    write_byte(seconds)
    write_byte(position)
    message_end()
}
 
public ze_game_started()
{
    g_bCanBuy = false
}
 
public ze_zombie_release()
{
    g_bCanBuy = true
}
 
public ze_select_item_pre(id, itemid)
{
    if (itemid != gItemID)
        return ZE_ITEM_AVAILABLE
 
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
 
    if (gHasIon[id] || !g_bCanBuy)
        return ZE_ITEM_UNAVAILABLE
 
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != gItemID)
        return
 
    gHasIon[id] = true
    emit_sound(id, CHAN_WEAPON, "items/gunpickup2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
    ze_colored_print(id, "You now have a %s.", WPN_NAME)
}
 
public fw_PlayerPreThink ( id )
{
    if ( !gHasIon[id] || !is_user_alive ( id ) )
        return FMRES_IGNORED
   
    if ( pev ( id, pev_button ) & IN_USE )
    {
        if ( !bInUse[id] )
        {
            bInUse[id] = true
            if ( g_Target[id] ) // ??? ????????
            {
                client_print ( id, print_center, "You already planted a beacon" )
                return FMRES_IGNORED
            }
            else if ( is_user_outside ( id ) ) // ??? ?????????
            {
                g_Target[id] = 0
                i_Pitch[id] = 97
                i_BeaconTime[id] = 1.12
                g_distance[id] = 350.0
                ROTATION_SPEED[id] = 0.0
               
                emit_sound ( id, CHAN_WEAPON, SOUND_START_PLANT, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
               
                ProgressBar ( id, 5, 0 )
                set_task ( 5.0,"ion_planted", id+5000 )
            }
            else
            {
                client_print ( id, print_center,"You need to be outside to fire with an ion cannon" )
            }
        }
    }
    else if ( bInUse[id] )
    {
        bInUse[id] = false
        emit_sound(g_Target[id], CHAN_WEAPON, SOUND_STOP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
        ProgressBar ( id, 0, 0 )
        remove_task(id+5000)
    }
    return FMRES_IGNORED
}
 
wpn_projectile_startpos ( player, forw, right, up, Float:out[3] )
{
    new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3],
    Float:vRight[3], Float:vUp[3]//, Float:vSrc[3]
   
    pev(player, pev_origin, vOrigin)
    pev(player, pev_v_angle, vAngle)
   
    engfunc(EngFunc_MakeVectors, vAngle)
   
    global_get(glb_v_forward, vForward)
    global_get(glb_v_right, vRight)
    global_get(glb_v_up, vUp)
   
    out[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
    out[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
    out[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
   
    //set_array_f(5, vSrc, 3)
}
 
stock wpn_radius_damage ( inflictor, Float:radius, Float:damage )
{
    new Float:vecSrc[3]
    pev(inflictor, pev_origin, vecSrc)
   
    new ent = -1
    new Float:tmpdmg = damage
    new hitCount = 0
    new Float:kickback = 1.0
   
    new Float:Tabsmin[3], Float:Tabsmax[3], Float:vecSpot[3],
    Float:Aabsmin[3], Float:Aabsmax[3], Float:vecSee[3]
    new trRes
    new Float:flFraction
    new Float:vecEndPos[3]
    new Float:distance
    new Float:origin[3], Float:vecPush[3]
    new Float:invlen
    new Float:velocity[3]
   
    // Calculate falloff
    new Float:falloff
    if (radius > 0.0)
        falloff = damage / radius
    else
        falloff = 1.0
   
    // Find monsters and players inside a specifiec radius
    while((ent = engfunc(EngFunc_FindEntityInSphere, ent, vecSrc, radius)) != 0)
    {
        if(!pev_valid(ent))
            continue
        if(!(pev(ent, pev_flags) & (FL_CLIENT | FL_FAKECLIENT | FL_MONSTER)))
            continue // Entity is not a player or monster, ignore it
       
        tmpdmg = damage
       
        // The following calculations are provided by Orangutanz, THANKS!
        // We use absmin and absmax for the most accurate information
        pev(ent, pev_absmin, Tabsmin)
        pev(ent, pev_absmax, Tabsmax)
        vecSpot[0] = (Tabsmin[0] + Tabsmax[0]) * 0.5
        vecSpot[1] = (Tabsmin[1] + Tabsmax[1]) * 0.5
        vecSpot[2] = (Tabsmin[2] + Tabsmax[2]) * 0.5
       
        pev(inflictor, pev_absmin, Aabsmin)
        pev(inflictor, pev_absmax, Aabsmax)
        vecSee[0] = (Aabsmin[0] + Aabsmax[0]) * 0.5
        vecSee[1] = (Aabsmin[1] + Aabsmax[1]) * 0.5
        vecSee[2] = (Aabsmin[2] + Aabsmax[2]) * 0.5
       
        engfunc(EngFunc_TraceLine, vecSee, vecSpot, 0, inflictor, trRes)
        get_tr2(trRes, TR_flFraction, flFraction)
        // Explosion can 'see' this entity, so hurt them! (or impact through objects has been enabled xD)
        if (flFraction >= 0.9 || get_tr2(trRes, TR_pHit) == ent)
        {
            // Work out the distance between impact and entity
            get_tr2(trRes, TR_vecEndPos, vecEndPos)
 
            distance = get_distance_f(vecSrc, vecEndPos) * falloff
            tmpdmg -= distance
            if (tmpdmg < 0.0)
                tmpdmg = 0.0
           
            origin[0] = vecSpot[0] - vecSee[0]
            origin[1] = vecSpot[1] - vecSee[1]
            origin[2] = vecSpot[2] - vecSee[2]
           
            invlen = 1.0/get_distance_f(vecSpot, vecSee)
            vecPush[0] = origin[0] * invlen
            vecPush[1] = origin[1] * invlen
            vecPush[2] = origin[2] * invlen
 
            pev(ent, pev_velocity, velocity)
            velocity[0] = velocity[0] + vecPush[0] * tmpdmg * kickback
            velocity[1] = velocity[1] + vecPush[1] * tmpdmg * kickback
            velocity[2] = velocity[2] + vecPush[2] * tmpdmg * kickback
 
            if (tmpdmg < 60.0)
            {
                velocity[0] *= 12.0
                velocity[1] *= 12.0
                velocity[2] *= 12.0
            }
            else
            {
                velocity[0] *= 4.0
                velocity[1] *= 4.0
                velocity[2] *= 4.0
            }
            set_pev(ent, pev_velocity, velocity)
        }
        // Send info to Damage system
        if(damage_user(ent, inflictor, floatround(tmpdmg)))
        {
            hitCount++
        }
    }
   
    return hitCount
}
 
damage_user(victim, attacker, dmg_take)
{
    new flags = pev(victim, pev_flags)
    new Float:takeDamage
    pev(victim, pev_takedamage, takeDamage)
   
   
    if(flags & FL_GODMODE || takeDamage == 0.0)
        return 0 // Player/Monster got godmode, ignore it
   
    if(flags & (FL_CLIENT | FL_FAKECLIENT))
    { // The victim's definetely a player, do a check for team attack
        if(is_team_attack(attacker, victim))
        {
            // User's attacking someone from the same team, friendlyfire's disabled
            // and it's a templay game. So don't do any damage :)
            return 0
        }
        else if(!is_user_alive(victim))
            return 0 // Victim is not alive, ignore him
    }
    // Calculate remaining health after causing the damage
    new Float:health
    pev(victim, pev_health, health)
    if(health <= 0.0)
        return 0 // No more health, player or monster's already dead, ignore it
   
    health -= float(dmg_take)
   
    set_pev(victim, pev_dmg_inflictor, attacker) // Let other things (e.g. plugins) know, who attacked this player
   
    if(health > 0) // Player or monster doesn't die after causing the damage, so just decrease his health
        set_pev(victim, pev_health, health)
    else
    {
        kill_user(victim, attacker) // Player or monster dies after causing damage, so kill him 8)
        dmg_take = -1
    }
   
    return dmg_take
}
 
kill_user(victim, attacker)
{
    new flags = pev(victim, pev_flags)
    new bool:isVictimMonster = (flags & FL_MONSTER) ? true : false
    new Float:takeDamage
    pev(victim, pev_takedamage, takeDamage)
   
    if(flags & FL_GODMODE || takeDamage == 0.0) // We do not cause any damage if the victim has godemode
        return 0
   
    if(!isVictimMonster)
    {
        if(is_team_attack(attacker, victim)) // Team attack with disabled friendly fire on a teamplay game, what the hell we're doing here?
            return 0
    }
   
    new weapon[11] = "ion_cannon"
   
    // Kill Victim
    if(isVictimMonster)
    {
        // Monster
        // set_pev(victim, pev_flags, FL_KILLME)
        set_pev(victim, pev_health, -1)
    }
    else
    { // Player
        set_msg_block(g_msgDeathMsg, BLOCK_ONCE)
        user_kill(victim, 1)
    }
   
    new Float:frags
    pev(attacker, pev_frags, frags)
    frags++
   
    set_pev(attacker, pev_frags, frags)
   
    if(isVictimMonster)
        return 1 // If the player killed a monster, we shouldn't continue on here
   
    new aname[32], aauthid[32], ateam[10]
    get_user_name(attacker, aname, 31)
    get_user_team(attacker, ateam, 9)
    get_user_authid(attacker, aauthid, 31)
   
    if(attacker != victim)
    {
        new vname[32], vauthid[32], vteam[10]
        get_user_name(victim, vname, 31)
        get_user_team(victim, vteam, 9)
        get_user_authid(victim, vauthid, 31)
       
        // Log the kill information
        log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",
            aname, get_user_userid(attacker), aauthid, ateam,
            vname, get_user_userid(victim), vauthid, vteam, weapon)
    } else {
        // User killed himself xD
        log_message("^"%s<%d><%s><%s>^" committed suicide with ^"%s^"",
            aname, get_user_userid(attacker), aauthid, ateam, weapon)
    }
    return 1
}
 
bool:is_team_attack(attacker, victim)
{
    if(!(pev(victim, pev_flags) & (FL_CLIENT | FL_FAKECLIENT)))
        return false // Victim is a monster, so definetely no team attack ;)
   
    if(get_user_team(victim) == get_user_team(attacker))
        return true // Team attack
   
    return false // No team attack or friendlyfire is disabled
}
Image

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 609
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 48 times
Age: 19
Contact:

#2

Post by Mohamed Alaa » 1 Year Ago

  1. public CreateFire(id) {
  2.     if(!g_Target[id]) return PLUGIN_CONTINUE
  3.  
  4.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
  5.     write_byte(TE_SPRITE)
  6.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
  7.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
  8.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + 100)
  9.     write_short(ReadyFire)
  10.     write_byte(30)
  11.     write_byte(200)
  12.     message_end()
  13.  
  14.     set_task(1.5,"CreateFire", id)
  15.     return PLUGIN_CONTINUE
  16. }
--->

  1. public CreateFire(id) {
  2.     if(!g_Target[id]) return PLUGIN_CONTINUE
  3.  
  4.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
  5.     write_byte(TE_SPRITE)
  6.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
  7.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
  8.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + 100)
  9.     write_short(ReadyFire)
  10.     write_byte(30)
  11.     write_byte(200)
  12.     message_end()
  13.  
  14.     ze_set_fire_grenade(id, true)
  15.  
  16.     set_task(1.5,"CreateFire", id)
  17.     return PLUGIN_CONTINUE
  18. }
  1. public ClearLasers(id)
  2.     remove_task(1018+id)
-->
  1. public ClearLasers(id)
  2. {
  3.     ze_set_fire_grenade(id, false)
  4.     remove_task(1018+id)
  5. }

Add anywhere:
  1. public ze_user_infected(victim, attacker)
  2. {
  3.     gHasIon[victim] = false
  4.     gHasIon[attacker] = false
  5. }
Want your own mod edition? PM me.
Accepting web projects.

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#3

Post by czirimbolo » 1 Year Ago

Fire works, but when I get infected I have still this bomb
Image

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#4

Post by Mark » 1 Year Ago

czirimbolo wrote:
1 Year Ago
Fire works, but when I get infected I have still this bomb
did you add this?

  1. public ze_user_infected(victim, attacker)
  2. {
  3.     gHasIon[victim] = false
  4.     gHasIon[attacker] = false
  5. }

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#5

Post by czirimbolo » 1 Year Ago

yes
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#6

Post by czirimbolo » 1 Year Ago

There is another thing, when I plant this bomb, no matter how far I am from it, I am burning like a zombie touched by fire nade. Can you block this fire making damage to human?
Image

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 609
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 48 times
Age: 19
Contact:

#7

Post by Mohamed Alaa » 1 Year Ago

  1. #include <zombie_escape>
  2.  
  3. #define IGNORE_MONSTERS                 1
  4. #define IGNORE_GLASS                    0x100
  5.  
  6. #define ION_RADIUS  800.0
  7. #define ION_MAXDAMAGE   15000.0
  8.  
  9. new const WPN_NAME[]    =   "Ion Cannon"
  10.  
  11. new const W_MODEL[] =       "models/w_battery.mdl"
  12.  
  13. new SOUND_APPROACH[]    =   "zombie_plague/ion_canon/approach.wav"
  14. new SOUND_START_PLANT[] =   "zombie_plague/ion_canon/beacon_set.wav"
  15. new SOUND_STOP[]    =       "vox/_comma.wav"
  16. new SOUND_BEEP[]    =       "zombie_plague/ion_canon/beacon_beep.wav"
  17. new SOUND_ATTACK[]  =       "zombie_plague/ion_canon/attack.wav"
  18. new SOUND_READY[]   =       "zombie_plague/ion_canon/ready.wav"
  19.  
  20. new g_Target[33], i_Pitch[33]
  21. new Float:i_BeaconTime[33]
  22. new Float:ion_mid_origin[33][3]
  23. new Float:beam_origin[33][8][3]
  24. new Float:g_degrees[33][8]
  25. new Float:g_distance[33]
  26. new Float:ROTATION_SPEED[33]
  27. new IonBeam, BlueFire, Shockwave, ReadyFire, BlueFlare, IonShake, LaserFlame
  28.  
  29. //---------------------------------------
  30. new gItemID, bool:g_bCanBuy
  31. new bool:gHasIon[33]
  32. new const gCost = 30    // Item Cost
  33. new bool:bInUse[33]
  34. new g_msgDeathMsg
  35. //---------------------------------------
  36. public plugin_init ()
  37. {
  38.     register_plugin ( "[ZP] ExtraItem: Ion Cannon", "1.91", "A.F./ Makzz / Shidla" )
  39.    
  40.     gItemID     = ze_register_item ( WPN_NAME, gCost, 0)
  41.    
  42.     IonShake    = get_user_msgid ( "ScreenShake" )
  43.     g_msgDeathMsg   = get_user_msgid("DeathMsg")
  44.    
  45.     register_forward ( FM_PlayerPreThink, "fw_PlayerPreThink" )
  46. }
  47.  
  48. public client_connect(id)
  49. {
  50.     g_Target[id] = 0
  51.     gHasIon[id] = false
  52. }
  53.  
  54. public plugin_precache ()
  55. {
  56.     precache_model ( W_MODEL )
  57.     precache_sound ( SOUND_APPROACH )
  58.     precache_sound ( SOUND_START_PLANT )
  59.     precache_sound ( SOUND_BEEP )
  60.     precache_sound ( SOUND_ATTACK )
  61.     precache_sound ( SOUND_READY )
  62.     precache_sound ( SOUND_STOP )
  63.     IonBeam     = precache_model("sprites/ion_canon/ionbeam.spr")
  64.     BlueFlare   = precache_model("sprites/ion_canon/bflare.spr")
  65.     ReadyFire   = precache_model("sprites/ion_canon/fire.spr")
  66.     BlueFire    = precache_model("sprites/ion_canon/blueflame.spr")
  67.     LaserFlame  = precache_model("sprites/ion_canon/ion_laserflame.spr")
  68.     Shockwave   = precache_model("sprites/shockwave.spr")
  69. }
  70.  
  71. public ion_planted ( id )
  72. {
  73.     id -= 5000
  74.     client_print ( id, print_chat, "Ion cannon beacon deploy" )
  75.    
  76.     g_Target[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
  77.     if(!g_Target[id])
  78.         return
  79.    
  80.     set_pev(g_Target[id],pev_classname,"info_target_ion")
  81.     engfunc(EngFunc_SetModel,g_Target[id],W_MODEL)
  82.    
  83.     set_pev(g_Target[id],pev_owner, id)
  84.     set_pev(g_Target[id],pev_movetype, MOVETYPE_TOSS)
  85.     set_pev(g_Target[id],pev_solid, SOLID_TRIGGER)
  86.    
  87.     wpn_projectile_startpos(id,0,0,50,ion_mid_origin[id])
  88.     set_pev(g_Target[id],pev_origin,ion_mid_origin[id])
  89.    
  90.     ion_beacon(id)
  91.     //set_task(5.0,"ion_startup", id)
  92.     set_task ( 9.0, "Trace_Ready", id )
  93. }
  94.  
  95. public ion_beacon ( id )
  96. {
  97.     if ( !g_Target[id] )
  98.         return
  99.    
  100.     i_Pitch[id] += 3
  101.     i_BeaconTime[id] -= 0.03
  102.     if(i_Pitch[id] > 255)
  103.         i_Pitch[id] = 255
  104.    
  105.     if(i_BeaconTime[id] < 0.30)
  106.         i_BeaconTime[id] = 0.30
  107.    
  108.     emit_sound(g_Target[id], CHAN_ITEM, SOUND_BEEP, VOL_NORM, ATTN_NORM, 0, i_Pitch[id])
  109.     set_task(i_BeaconTime[id],"ion_beacon", id)
  110. }
  111.  
  112. public Trace_Ready(id)
  113. {
  114.     remove_task(id)
  115.     // write origin of each
  116.     new Float:mid_origin[33][3]
  117.     pev(g_Target[id],pev_origin,mid_origin[id]) // Target contain entity id
  118.     // 1st
  119.     beam_origin[id][0][0] = mid_origin[id][0] + 300.0
  120.     beam_origin[id][0][1] = mid_origin[id][1] + 150.0
  121.     beam_origin[id][0][2] = mid_origin[id][2]
  122.     g_degrees[id][0] = 0.0
  123.     // 2nd
  124.     beam_origin[id][1][0] = mid_origin[id][0] + 300.0
  125.     beam_origin[id][1][1] = mid_origin[id][1] - 150.0
  126.     beam_origin[id][1][2] = mid_origin[id][2]
  127.     g_degrees[id][1] = 45.0
  128.     // 3rd
  129.     beam_origin[id][2][0] = mid_origin[id][0] - 300.0
  130.     beam_origin[id][2][1] = mid_origin[id][1] - 150.0
  131.     beam_origin[id][2][2] = mid_origin[id][2]
  132.     g_degrees[id][2] = 90.0
  133.     // 4th
  134.     beam_origin[id][3][0] = mid_origin[id][0] - 300.0
  135.     beam_origin[id][3][1] = mid_origin[id][1] + 150.0
  136.     beam_origin[id][3][2] = mid_origin[id][2]
  137.     g_degrees[id][3] = 135.0
  138.     // 5th
  139.     beam_origin[id][4][0] = mid_origin[id][0] + 150.0
  140.     beam_origin[id][4][1] = mid_origin[id][1] + 300.0
  141.     beam_origin[id][4][2] = mid_origin[id][2]
  142.     g_degrees[id][4] = 180.0
  143.     // 6th
  144.     beam_origin[id][5][0] = mid_origin[id][0] + 150.0
  145.     beam_origin[id][5][1] = mid_origin[id][1] - 300.0
  146.     beam_origin[id][5][2] = mid_origin[id][2]
  147.     g_degrees[id][5] = 225.0
  148.     // 7th
  149.     beam_origin[id][6][0] = mid_origin[id][0] - 150.0
  150.     beam_origin[id][6][1] = mid_origin[id][1] - 300.0
  151.     beam_origin[id][6][2] = mid_origin[id][2]
  152.     g_degrees[id][6] = 270.0
  153.     // 8th
  154.     beam_origin[id][7][0] = mid_origin[id][0] - 150.0
  155.     beam_origin[id][7][1] = mid_origin[id][1] + 300.0
  156.     beam_origin[id][7][2] = mid_origin[id][2]
  157.     g_degrees[id][7] = 315.0
  158.    
  159.     // set the mid to global
  160.     ion_mid_origin[id] = mid_origin[id]
  161.  
  162.     new Float:addtime
  163.     for(new i; i < 8; i++) {
  164.         addtime = addtime + 0.3
  165.         new param[3]
  166.         param[0] = i
  167.         param[1] = id
  168.         set_task(0.0 + addtime, "Trace_Start", _,param, 2)
  169.     }
  170.  
  171.     Laser_Rotate(id) //To fix the laserdraw
  172.    
  173.     emit_sound ( g_Target[id], CHAN_ITEM, SOUND_READY, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  174.    
  175.     for(new Float:i = 0.0; i < 7.5; i += 0.01) //Rotate for 7.5 secs.
  176.         set_task(i+3.0, "Laser_Rotate", id)
  177.  
  178.     set_task(2.9,"AddSpeed", id)
  179.     set_task(11.5,"CreateFire", id)
  180.     set_task(12.5,"ClearLasers", id)
  181.     set_task(15.2,"FireIonCannon", id)
  182.     return PLUGIN_CONTINUE
  183. }
  184.  
  185. public AddSpeed(id) {
  186.     if(!g_Target[id]) return PLUGIN_CONTINUE
  187.    
  188.     if(ROTATION_SPEED[id] > 1.0) ROTATION_SPEED[id] = 1.0
  189.     ROTATION_SPEED[id] += 0.1
  190.     set_task(0.6,"AddSpeed", id)
  191.     return PLUGIN_CONTINUE
  192. }
  193.  
  194. public CreateFire(id) {
  195.     if(!g_Target[id]) return PLUGIN_CONTINUE
  196.  
  197.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
  198.     write_byte(TE_SPRITE)
  199.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
  200.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
  201.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + 100)
  202.     write_short(ReadyFire)
  203.     write_byte(30)
  204.     write_byte(200)
  205.     message_end()
  206.  
  207.     set_task(1.5,"CreateFire", id)
  208.     return PLUGIN_CONTINUE
  209. }
  210.  
  211. public ClearLasers(id)
  212. {
  213.     ze_set_fire_grenade(id, false)
  214.     remove_task(1018+id)
  215. }
  216.  
  217. public Laser_Rotate(id)
  218. {
  219.     g_distance[id] -= 0.467
  220.     for(new i; i < 8; i++) {
  221.         // Calculate new alpha
  222.         g_degrees[id][i] += ROTATION_SPEED[id]
  223.         if(g_degrees[id][i] > 360.0)
  224.             g_degrees[id][i] -= 360.0
  225.  
  226.         // calcul the next origin
  227.         new Float:tmp[33][3]
  228.         tmp[id] = ion_mid_origin[id]
  229.  
  230.         tmp[id][0] += floatsin(g_degrees[id][i], degrees) * g_distance[id]
  231.         tmp[id][1] += floatcos(g_degrees[id][i], degrees) * g_distance[id]
  232.         tmp[id][2] += 0.0 // -.-
  233.         beam_origin[id][i] = tmp[id]
  234.     }
  235. }
  236.  
  237. public Trace_Start(param[]) {
  238.     new i = param[0]
  239.     new id = param[1]
  240.  
  241.     new Float:get_random_z,Float:SkyOrigin[33][3]
  242.     SkyOrigin[id] = tlx_distance_to_sky(g_Target[id])
  243.     get_random_z = random_float(300.0,SkyOrigin[id][2])
  244.  
  245.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, beam_origin[id][i], 0)
  246.     write_byte(TE_SPRITE)
  247.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])
  248.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])
  249.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][2] + get_random_z)
  250.     write_short(BlueFire)
  251.     write_byte(10)
  252.     write_byte(100)
  253.     message_end()
  254.    
  255.     TraceAll(param)
  256. }
  257.  
  258. public TraceAll(param[]) {
  259.     new i = param[0]
  260.     new id = param[1]
  261.  
  262.     new Float:SkyOrigin[33][3]
  263.     SkyOrigin[id] = tlx_distance_to_sky(g_Target[id])
  264.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, beam_origin[id][i], 0)
  265.     write_byte(TE_BEAMPOINTS)
  266.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])      //start point (x)
  267.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])      //start point (y)
  268.     engfunc(EngFunc_WriteCoord, SkyOrigin[id][2])           //start point (z)
  269.  
  270.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])      //end point (x)
  271.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])      //end point (y)
  272.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][2])      //end point (z)
  273.     write_short(IonBeam)    //model
  274.     write_byte(0)       //startframe
  275.     write_byte(0)       //framerate
  276.     write_byte(1)       //life
  277.     write_byte(50)      //width
  278.     write_byte(0)       //noise
  279.     write_byte(255)     //r
  280.     write_byte(255)     //g
  281.     write_byte(255)     //b
  282.     write_byte(255)     //brightness
  283.     write_byte(0)       //speed
  284.     message_end()
  285.    
  286.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, beam_origin[id][i], 0)
  287.     write_byte(TE_SPRITE)
  288.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])
  289.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])
  290.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][2])
  291.     write_short(LaserFlame)
  292.     write_byte(5)
  293.     write_byte(200)
  294.     message_end()
  295.    
  296.     set_task(0.08,"TraceAll", 1018+id, param, 2)
  297. }
  298.  
  299. public FireIonCannon(id) {
  300.     new i = -1
  301.     while((i = engfunc(EngFunc_FindEntityInSphere, i, ion_mid_origin[id], ION_RADIUS + 8000)) != 0)
  302.     {
  303.         if (ze_is_user_zombie(i))
  304.         {
  305.             ze_set_fire_grenade(id, true)
  306.         }
  307.  
  308.         if(pev_valid(i) && pev(i, pev_flags) & (FL_CLIENT | FL_FAKECLIENT)) {
  309.             message_begin(MSG_ONE_UNRELIABLE, IonShake, {0,0,0}, i)
  310.             write_short(255<<14) //ammount
  311.             write_short(10<<14) //lasts this long
  312.             write_short(255<<14) //frequency
  313.             message_end()
  314.         }
  315.         //next player in spehre.
  316.         continue
  317.     }
  318.  
  319.     new Float:skyOrigin[33][3]
  320.     skyOrigin[id] = tlx_distance_to_sky(g_Target[id])
  321.  
  322.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
  323.     write_byte(TE_BEAMPOINTS)
  324.     engfunc(EngFunc_WriteCoord, skyOrigin[id][0])   //start point (x)
  325.     engfunc(EngFunc_WriteCoord, skyOrigin[id][1])   //start point (y)
  326.     engfunc(EngFunc_WriteCoord, skyOrigin[id][2])   //start point (z)
  327.  
  328.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])      //end point (x)
  329.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])      //end point (y)
  330.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2])      //end point (z)
  331.     write_short(IonBeam)    //model
  332.     write_byte(0)       //startframe
  333.     write_byte(0)       //framerate
  334.     write_byte(15)      //life
  335.     write_byte(255)     //width
  336.     write_byte(0)       //noise
  337.     write_byte(255)     //r
  338.     write_byte(255)     //g
  339.     write_byte(255)     //b
  340.     write_byte(255)     //brightness
  341.     write_byte(0)       //speed
  342.     message_end()
  343.  
  344.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin, 0)
  345.     write_byte(TE_BEAMCYLINDER)
  346.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0]) // start X
  347.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1]) // start Y
  348.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2]) // start Z
  349.  
  350.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0]) // something X
  351.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1]) // something Y
  352.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + ION_RADIUS - 1000.0) // something Z
  353.     write_short(Shockwave) // sprite
  354.     write_byte(0) // startframe
  355.     write_byte(0) // framerate
  356.     write_byte(100) // life
  357.     write_byte(150) // width
  358.     write_byte(0) // noise
  359.     write_byte(0) // red
  360.     write_byte(100) // green
  361.     write_byte(250) // blue
  362.     write_byte(150) // brightness
  363.     write_byte(0) // speed
  364.     message_end()
  365.  
  366.     for(new i = 1; i < 6; i++) {
  367.         engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
  368.         write_byte(TE_SPRITETRAIL)  // line of moving glow sprites with gravity, fadeout, and collisions
  369.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
  370.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
  371.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2])
  372.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
  373.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
  374.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + 200)
  375.         write_short(BlueFlare) // (sprite index)
  376.         write_byte(50) // (count)
  377.         write_byte(random_num(27,30)) // (life in 0.1's)
  378.         write_byte(10) // byte (scale in 0.1's)
  379.         write_byte(random_num(30,70)) // (velocity along vector in 10's)
  380.         write_byte(40) // (randomness of velocity in 10's)
  381.         message_end()
  382.     }
  383.    
  384.     wpn_radius_damage ( g_Target[id], ION_RADIUS, ION_MAXDAMAGE )
  385.     emit_sound ( g_Target[id], CHAN_ITEM, SOUND_ATTACK, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  386.    
  387.     ResetAll(id)
  388. }
  389.  
  390. ResetAll ( id )
  391. {
  392.     set_pev ( g_Target[id], pev_flags, FL_KILLME )
  393.     g_Target[id] = 0
  394.     gHasIon[id] = false
  395. }
  396.  
  397. /******************** Stocks ********************/
  398. stock Float:tlx_distance_to_sky(id) // Get entity above sky.
  399. {
  400.     new Float:TraceEnd[3]
  401.     pev(id, pev_origin, TraceEnd)
  402.  
  403.     new Float:f_dest[3]
  404.     f_dest[0] = TraceEnd[0]
  405.     f_dest[1] = TraceEnd[1]
  406.     f_dest[2] = TraceEnd[2] + 8192.0
  407.  
  408.     new res, Float:SkyOrigin[3]
  409.     engfunc(EngFunc_TraceLine, TraceEnd, f_dest, IGNORE_MONSTERS + IGNORE_GLASS, id, res)
  410.     get_tr2(res, TR_vecEndPos, SkyOrigin)
  411.  
  412.     return SkyOrigin
  413. }
  414. //return distance above us to sky
  415. stock Float:is_user_outside(id) {
  416.     new Float:origin[3], Float:dist
  417.  
  418.     pev(id, pev_origin, origin)
  419.     dist = origin[2]
  420.  
  421.     while(engfunc(EngFunc_PointContents, origin) == CONTENTS_EMPTY)
  422.         origin[2] += 5.0
  423.     if(engfunc(EngFunc_PointContents, origin) == CONTENTS_SKY)
  424.         return (origin[2] - dist)
  425.  
  426.     return 0.0
  427. }
  428.  
  429. stock ProgressBar(id, seconds, position)
  430. {
  431.     message_begin(MSG_ONE, get_user_msgid("BarTime"), {0, 0, 0}, id)
  432.     write_byte(seconds)
  433.     write_byte(position)
  434.     message_end()
  435. }
  436.  
  437. public ze_game_started()
  438. {
  439.     g_bCanBuy = false
  440. }
  441.  
  442. public ze_zombie_release()
  443. {
  444.     g_bCanBuy = true
  445. }
  446.  
  447. public ze_select_item_pre(id, itemid)
  448. {
  449.     if (itemid != gItemID)
  450.         return ZE_ITEM_AVAILABLE
  451.  
  452.     if (ze_is_user_zombie(id))
  453.         return ZE_ITEM_DONT_SHOW
  454.  
  455.     if (gHasIon[id] || !g_bCanBuy)
  456.         return ZE_ITEM_UNAVAILABLE
  457.  
  458.     return ZE_ITEM_AVAILABLE
  459. }
  460.  
  461. public ze_select_item_post(id, itemid)
  462. {
  463.     if (itemid != gItemID)
  464.         return
  465.  
  466.     gHasIon[id] = true
  467.     emit_sound(id, CHAN_WEAPON, "items/gunpickup2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  468.     ze_colored_print(id, "You now have a %s.", WPN_NAME)
  469. }
  470.  
  471. public fw_PlayerPreThink ( id )
  472. {
  473.     if ( !gHasIon[id] || !is_user_alive ( id ) )
  474.         return FMRES_IGNORED
  475.    
  476.     if ( pev ( id, pev_button ) & IN_USE )
  477.     {
  478.         if ( !bInUse[id] )
  479.         {
  480.             bInUse[id] = true
  481.             if ( g_Target[id] ) // ??? ????????
  482.             {
  483.                 client_print ( id, print_center, "You already planted a beacon" )
  484.                 return FMRES_IGNORED
  485.             }
  486.             else if ( is_user_outside ( id ) ) // ??? ?????????
  487.             {
  488.                 g_Target[id] = 0
  489.                 i_Pitch[id] = 97
  490.                 i_BeaconTime[id] = 1.12
  491.                 g_distance[id] = 350.0
  492.                 ROTATION_SPEED[id] = 0.0
  493.                
  494.                 emit_sound ( id, CHAN_WEAPON, SOUND_START_PLANT, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  495.                
  496.                 ProgressBar ( id, 5, 0 )
  497.                 set_task ( 5.0,"ion_planted", id+5000 )
  498.             }
  499.             else
  500.             {
  501.                 client_print ( id, print_center,"You need to be outside to fire with an ion cannon" )
  502.             }
  503.         }
  504.     }
  505.     else if ( bInUse[id] )
  506.     {
  507.         bInUse[id] = false
  508.         emit_sound(g_Target[id], CHAN_WEAPON, SOUND_STOP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  509.         ProgressBar ( id, 0, 0 )
  510.         remove_task(id+5000)
  511.     }
  512.     return FMRES_IGNORED
  513. }
  514.  
  515. wpn_projectile_startpos ( player, forw, right, up, Float:out[3] )
  516. {
  517.     new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3],
  518.     Float:vRight[3], Float:vUp[3]//, Float:vSrc[3]
  519.    
  520.     pev(player, pev_origin, vOrigin)
  521.     pev(player, pev_v_angle, vAngle)
  522.    
  523.     engfunc(EngFunc_MakeVectors, vAngle)
  524.    
  525.     global_get(glb_v_forward, vForward)
  526.     global_get(glb_v_right, vRight)
  527.     global_get(glb_v_up, vUp)
  528.    
  529.     out[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  530.     out[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  531.     out[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  532.    
  533.     //set_array_f(5, vSrc, 3)
  534. }
  535.  
  536. stock wpn_radius_damage ( inflictor, Float:radius, Float:damage )
  537. {
  538.     new Float:vecSrc[3]
  539.     pev(inflictor, pev_origin, vecSrc)
  540.    
  541.     new ent = -1
  542.     new Float:tmpdmg = damage
  543.     new hitCount = 0
  544.     new Float:kickback = 1.0
  545.    
  546.     new Float:Tabsmin[3], Float:Tabsmax[3], Float:vecSpot[3],
  547.     Float:Aabsmin[3], Float:Aabsmax[3], Float:vecSee[3]
  548.     new trRes
  549.     new Float:flFraction
  550.     new Float:vecEndPos[3]
  551.     new Float:distance
  552.     new Float:origin[3], Float:vecPush[3]
  553.     new Float:invlen
  554.     new Float:velocity[3]
  555.    
  556.     // Calculate falloff
  557.     new Float:falloff
  558.     if (radius > 0.0)
  559.         falloff = damage / radius
  560.     else
  561.         falloff = 1.0
  562.    
  563.     // Find monsters and players inside a specifiec radius
  564.     while((ent = engfunc(EngFunc_FindEntityInSphere, ent, vecSrc, radius)) != 0)
  565.     {
  566.         if(!pev_valid(ent))
  567.             continue
  568.         if(!(pev(ent, pev_flags) & (FL_CLIENT | FL_FAKECLIENT | FL_MONSTER)))
  569.             continue // Entity is not a player or monster, ignore it
  570.        
  571.         tmpdmg = damage
  572.        
  573.         // The following calculations are provided by Orangutanz, THANKS!
  574.         // We use absmin and absmax for the most accurate information
  575.         pev(ent, pev_absmin, Tabsmin)
  576.         pev(ent, pev_absmax, Tabsmax)
  577.         vecSpot[0] = (Tabsmin[0] + Tabsmax[0]) * 0.5
  578.         vecSpot[1] = (Tabsmin[1] + Tabsmax[1]) * 0.5
  579.         vecSpot[2] = (Tabsmin[2] + Tabsmax[2]) * 0.5
  580.        
  581.         pev(inflictor, pev_absmin, Aabsmin)
  582.         pev(inflictor, pev_absmax, Aabsmax)
  583.         vecSee[0] = (Aabsmin[0] + Aabsmax[0]) * 0.5
  584.         vecSee[1] = (Aabsmin[1] + Aabsmax[1]) * 0.5
  585.         vecSee[2] = (Aabsmin[2] + Aabsmax[2]) * 0.5
  586.        
  587.         engfunc(EngFunc_TraceLine, vecSee, vecSpot, 0, inflictor, trRes)
  588.         get_tr2(trRes, TR_flFraction, flFraction)
  589.         // Explosion can 'see' this entity, so hurt them! (or impact through objects has been enabled xD)
  590.         if (flFraction >= 0.9 || get_tr2(trRes, TR_pHit) == ent)
  591.         {
  592.             // Work out the distance between impact and entity
  593.             get_tr2(trRes, TR_vecEndPos, vecEndPos)
  594.  
  595.             distance = get_distance_f(vecSrc, vecEndPos) * falloff
  596.             tmpdmg -= distance
  597.             if (tmpdmg < 0.0)
  598.                 tmpdmg = 0.0
  599.            
  600.             origin[0] = vecSpot[0] - vecSee[0]
  601.             origin[1] = vecSpot[1] - vecSee[1]
  602.             origin[2] = vecSpot[2] - vecSee[2]
  603.            
  604.             invlen = 1.0/get_distance_f(vecSpot, vecSee)
  605.             vecPush[0] = origin[0] * invlen
  606.             vecPush[1] = origin[1] * invlen
  607.             vecPush[2] = origin[2] * invlen
  608.  
  609.             pev(ent, pev_velocity, velocity)
  610.             velocity[0] = velocity[0] + vecPush[0] * tmpdmg * kickback
  611.             velocity[1] = velocity[1] + vecPush[1] * tmpdmg * kickback
  612.             velocity[2] = velocity[2] + vecPush[2] * tmpdmg * kickback
  613.  
  614.             if (tmpdmg < 60.0)
  615.             {
  616.                 velocity[0] *= 12.0
  617.                 velocity[1] *= 12.0
  618.                 velocity[2] *= 12.0
  619.             }
  620.             else
  621.             {
  622.                 velocity[0] *= 4.0
  623.                 velocity[1] *= 4.0
  624.                 velocity[2] *= 4.0
  625.             }
  626.             set_pev(ent, pev_velocity, velocity)
  627.         }
  628.         // Send info to Damage system
  629.         if(damage_user(ent, inflictor, floatround(tmpdmg)))
  630.         {
  631.             hitCount++
  632.         }
  633.     }
  634.    
  635.     return hitCount
  636. }
  637.  
  638. damage_user(victim, attacker, dmg_take)
  639. {
  640.     new flags = pev(victim, pev_flags)
  641.     new Float:takeDamage
  642.     pev(victim, pev_takedamage, takeDamage)
  643.    
  644.    
  645.     if(flags & FL_GODMODE || takeDamage == 0.0)
  646.         return 0 // Player/Monster got godmode, ignore it
  647.    
  648.     if(flags & (FL_CLIENT | FL_FAKECLIENT))
  649.     { // The victim's definetely a player, do a check for team attack
  650.         if(is_team_attack(attacker, victim))
  651.         {
  652.             // User's attacking someone from the same team, friendlyfire's disabled
  653.             // and it's a templay game. So don't do any damage :)
  654.             return 0
  655.         }
  656.         else if(!is_user_alive(victim))
  657.             return 0 // Victim is not alive, ignore him
  658.     }
  659.     // Calculate remaining health after causing the damage
  660.     new Float:health
  661.     pev(victim, pev_health, health)
  662.     if(health <= 0.0)
  663.         return 0 // No more health, player or monster's already dead, ignore it
  664.    
  665.     health -= float(dmg_take)
  666.    
  667.     set_pev(victim, pev_dmg_inflictor, attacker) // Let other things (e.g. plugins) know, who attacked this player
  668.    
  669.     if(health > 0) // Player or monster doesn't die after causing the damage, so just decrease his health
  670.         set_pev(victim, pev_health, health)
  671.     else
  672.     {
  673.         kill_user(victim, attacker) // Player or monster dies after causing damage, so kill him 8)
  674.         dmg_take = -1
  675.     }
  676.    
  677.     return dmg_take
  678. }
  679.  
  680. kill_user(victim, attacker)
  681. {
  682.     new flags = pev(victim, pev_flags)
  683.     new bool:isVictimMonster = (flags & FL_MONSTER) ? true : false
  684.     new Float:takeDamage
  685.     pev(victim, pev_takedamage, takeDamage)
  686.    
  687.     if(flags & FL_GODMODE || takeDamage == 0.0) // We do not cause any damage if the victim has godemode
  688.         return 0
  689.    
  690.     if(!isVictimMonster)
  691.     {
  692.         if(is_team_attack(attacker, victim)) // Team attack with disabled friendly fire on a teamplay game, what the hell we're doing here?
  693.             return 0
  694.     }
  695.    
  696.     new weapon[11] = "ion_cannon"
  697.    
  698.     // Kill Victim
  699.     if(isVictimMonster)
  700.     {
  701.         // Monster
  702.         // set_pev(victim, pev_flags, FL_KILLME)
  703.         set_pev(victim, pev_health, -1)
  704.     }
  705.     else
  706.     { // Player
  707.         set_msg_block(g_msgDeathMsg, BLOCK_ONCE)
  708.         user_kill(victim, 1)
  709.     }
  710.    
  711.     new Float:frags
  712.     pev(attacker, pev_frags, frags)
  713.     frags++
  714.    
  715.     set_pev(attacker, pev_frags, frags)
  716.    
  717.     if(isVictimMonster)
  718.         return 1 // If the player killed a monster, we shouldn't continue on here
  719.    
  720.     new aname[32], aauthid[32], ateam[10]
  721.     get_user_name(attacker, aname, 31)
  722.     get_user_team(attacker, ateam, 9)
  723.     get_user_authid(attacker, aauthid, 31)
  724.    
  725.     if(attacker != victim)
  726.     {
  727.         new vname[32], vauthid[32], vteam[10]
  728.         get_user_name(victim, vname, 31)
  729.         get_user_team(victim, vteam, 9)
  730.         get_user_authid(victim, vauthid, 31)
  731.        
  732.         // Log the kill information
  733.         log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",
  734.             aname, get_user_userid(attacker), aauthid, ateam,
  735.             vname, get_user_userid(victim), vauthid, vteam, weapon)
  736.     } else {
  737.         // User killed himself xD
  738.         log_message("^"%s<%d><%s><%s>^" committed suicide with ^"%s^"",
  739.             aname, get_user_userid(attacker), aauthid, ateam, weapon)
  740.     }
  741.     return 1
  742. }
  743.  
  744. bool:is_team_attack(attacker, victim)
  745. {
  746.     if(!(pev(victim, pev_flags) & (FL_CLIENT | FL_FAKECLIENT)))
  747.         return false // Victim is a monster, so definetely no team attack ;)
  748.    
  749.     if(get_user_team(victim) == get_user_team(attacker))
  750.         return true // Team attack
  751.    
  752.     return false // No team attack or friendlyfire is disabled
  753. }
Want your own mod edition? PM me.
Accepting web projects.

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#8

Post by czirimbolo » 1 Year Ago

Its not working. When I plant this bomb as a HUMAN, I get infected by FIRE as a human, no matter how far I am from this bomb.
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#9

Post by czirimbolo » 1 Year Ago

Can someone fix this?
Image

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#10

Post by Mark » 1 Year Ago

czirimbolo wrote:
1 Year Ago
Can someone fix this?
This is the best i can come up with i edit it even more try it.

Reheem or Jack can tell us if this is the best way.

Im unsure about this code but it does work but fire nades goes off more then once.
  1. public CreateFire(id)
  2. {
  3.     if( !g_Target[ id ] )
  4.     {
  5.         remove_task( id )
  6.         return PLUGIN_CONTINUE
  7.     }
  8.    
  9.     for( new id = 1; id < g_iMaxids; id++ )
  10.     {
  11.         if(ze_is_user_zombie(id))
  12.         {
  13.             ze_set_fire_grenade(id, true)
  14.         }
  15.     }
  16.  
  17.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
  18.     write_byte(TE_SPRITE)
  19.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
  20.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
  21.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + 100)
  22.     write_short(ReadyFire)
  23.     write_byte(30)
  24.     write_byte(200)
  25.     message_end()
  26.  
  27.     set_task(1.5,"CreateFire", id)
  28.     return PLUGIN_CONTINUE
  29. }








USE THIS BELOW






  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <cstrike>
  4. #include <fun>
  5. #include <fakemeta_util>
  6.  
  7.  
  8. new const PLUGIN[] = "[ZE] Extra Item:Ion Cannon"
  9. new const VERSION[] = "1.0"
  10. new const AUTHOR[] = "A.F./Mark"
  11.  
  12. //#define ION_RADIUS        2000.0
  13. //#define ION_MAXDAMAGE     54200.0
  14. #define ACTION_BLOCK        ( IN_JUMP | IN_DUCK | IN_FORWARD | IN_BACK | IN_LEFT | IN_RIGHT | IN_MOVELEFT | IN_MOVERIGHT | IN_RELOAD | IN_RUN | IN_USE)
  15.  
  16. new const V_MODEL[] = "models/v_c4.mdl"
  17. new const W_MODEL[] = "models/w_battery.mdl"
  18.  
  19. new const SOUND_APPROACH[] = "zombie_plague/ion_canon/ion_approach2.wav"
  20. new const SOUND_BEACON[] = "zombie_plague/ion_canon/ion_beacon_set.wav"
  21. new const SOUND_STOP[] = "vox/_comma.wav"
  22. new const SOUND_BEEP[] = "zombie_plague/ion_canon/ion_beep3.wav"
  23. new const SOUND_ATTACK[] = "zombie_plague/ion_canon/ion_attack.wav"
  24. new const SOUND_READY[] = "zombie_plague/ion_canon/ion_ready.wav"
  25. new const SOUND_PLANT[] = "zombie_plague/ion_canon/ion_beacon_plant2.wav"
  26.  
  27. new g_iCurrentWeapon[33]
  28. new bool:g_bHasIon[33]
  29. new bool:g_bCanBuy
  30. new bool:g_bIsFiring[33]
  31. new bool:g_bKilledByIon[33]
  32. new bool:g_bIsPlanting[33]
  33. new g_iLastWeapon[33]
  34. new g_Target[33]
  35. new i_Pitch[33]
  36. new Float:i_BeaconTime[33]
  37. new Float:ion_mid_origin[33][3]
  38. new Float:beam_origin[33][8][3]
  39. new Float:g_degrees[33][8]
  40. new Float:g_distance[33]
  41. new Float:g_Speed[33]
  42. new IonBeam, BlueFire, Shockwave, ReadyFire, BlueFlare, LaserFlame
  43. new g_iIonID
  44. new gmsgScreenShake
  45. new g_iMaxids
  46.  
  47. new cvar_barlen, cvar_maxdmg, cvar_radius, cvar_ionmode, cvar_damage
  48.  
  49. enum
  50. {
  51.     anim_idle,
  52.     anim_draw,
  53.     anim_drop,
  54.     anim_pressbutton
  55. }
  56.  
  57. public plugin_precache()
  58. {
  59.     precache_model(V_MODEL)
  60.     precache_model(W_MODEL)
  61.     precache_sound(SOUND_APPROACH)
  62.     precache_sound(SOUND_BEACON)
  63.     precache_sound(SOUND_BEEP)
  64.     precache_sound(SOUND_ATTACK)
  65.     precache_sound(SOUND_READY)
  66.     precache_sound(SOUND_PLANT)
  67.     precache_sound(SOUND_STOP)
  68.     IonBeam = precache_model("sprites/ion_canon/ionbeam.spr")
  69.     BlueFlare = precache_model("sprites/ion_canon/bflare.spr")
  70.     ReadyFire = precache_model("sprites/ion_canon/fire.spr")
  71.     BlueFire = precache_model("sprites/ion_canon/blueflame.spr")
  72.     LaserFlame = precache_model("sprites/ion_canon/ion_laserflame.spr")
  73.     Shockwave = precache_model("sprites/shockwave.spr")
  74. }
  75.  
  76. public plugin_init()
  77. {
  78.     register_plugin( PLUGIN, VERSION, AUTHOR )
  79.    
  80.     g_iIonID = ze_register_item( "Ion Cannon", 100, 0)
  81.    
  82.     register_clcmd( "drop", "fn_Drop" )
  83.    
  84.     register_event( "CurWeapon", "EV_CurWeapon", "be", "1=1" )
  85.     register_event( "DeathMsg", "EV_DeathMsg", "a" )
  86.     register_event( "HLTV", "EV_RoundStart", "a", "1=0", "2=0" )
  87.    
  88.     register_forward( FM_CmdStart, "fw_CmdStart" )
  89.     register_forward( FM_PlayerPreThink, "fw_idPreThink" )
  90.    
  91.     RegisterHam( Ham_Item_Deploy, "weapon_c4", "fw_KnifeDeploy_Post", 1 )
  92.  
  93.     register_message( get_user_msgid( "DeathMsg" ), "fn_DeathMsg" )
  94.    
  95.     gmsgScreenShake = get_user_msgid( "ScreenShake" )
  96.    
  97.     cvar_barlen = register_cvar( "ze_ion_barlen", "4" )
  98.     cvar_maxdmg = register_cvar( "ze_ion_maxdmg", "54200" )
  99.     cvar_radius = register_cvar( "ze_ion_radius", "2000" )
  100.     cvar_ionmode = register_cvar( "ze_ion_mode", "1" ) // 0 - all zm damage, 1 - radius damage
  101.     cvar_damage = register_cvar( "ze_ion_damage", "1000" ) // only if ze_ion_mode is 0
  102.    
  103.     g_iMaxids = get_maxplayers( )
  104. }
  105.  
  106. public client_connect( id )
  107. {
  108.     g_bHasIon[ id ] = false
  109.     g_bIsPlanting[ id ] = false
  110. }
  111.  
  112. public client_disconnected( id )
  113. {
  114.     g_bHasIon[ id ] = false
  115. }
  116.  
  117. public ze_game_started()
  118. {
  119.     g_bCanBuy = false
  120. }
  121.  
  122. public ze_zombie_release()
  123. {
  124.     g_bCanBuy = true
  125. }
  126.  
  127. public ze_select_item_pre(id, itemid)
  128. {
  129.     if (itemid != g_iIonID)
  130.         return ZE_ITEM_AVAILABLE
  131.  
  132.     if (ze_is_user_zombie(id))
  133.         return ZE_ITEM_DONT_SHOW
  134.  
  135.     if (g_bHasIon[id] || !g_bCanBuy)
  136.         return ZE_ITEM_UNAVAILABLE
  137.  
  138.     return ZE_ITEM_AVAILABLE
  139. }
  140.  
  141. public ze_select_item_post(id, itemid)
  142. {
  143.     if( itemid == g_iIonID )
  144.     {
  145.         if( g_bHasIon[id] )
  146.         {
  147.             client_print( id, print_chat, "[ZE] Already have Ion Cannon" )
  148.             return PLUGIN_HANDLED
  149.         }
  150.         else
  151.         {
  152.             g_bHasIon[id] = true
  153.             give_item( id, "weapon_c4" )
  154.         }
  155.     }
  156.     return PLUGIN_CONTINUE
  157. }
  158.  
  159. public ze_user_infected(iVictim, iInfector)
  160. {
  161.     emit_sound(g_Target[iVictim], CHAN_WEAPON, SOUND_STOP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  162.     ProgressBar(iVictim, 0, 0)
  163.     remove_task(iVictim+5000)
  164.     g_bHasIon[ iVictim ] = false
  165.     g_bIsFiring[ iVictim ] = false
  166.     g_bIsPlanting[ iVictim ] = false
  167.     g_Target[ iVictim ] = 0
  168. }
  169.  
  170. public ze_user_humanized(id)
  171. {
  172.     g_bHasIon[id] = false
  173.     emit_sound(g_Target[id], CHAN_WEAPON, SOUND_STOP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  174.     ProgressBar(id, 0, 0)
  175.     remove_task(id+5000)
  176.     g_bIsFiring[ id ] = false
  177.     g_bIsPlanting[ id ] = false
  178.     g_Target[ id ] = 0
  179. }
  180.  
  181. public fn_Drop( id )
  182. {
  183.     if( !is_user_alive( id ) || !g_bHasIon[ id ] )
  184.         return PLUGIN_CONTINUE
  185.    
  186.     if( g_iCurrentWeapon[ id ] == CSW_C4 )
  187.     {
  188.         client_print( id, print_center, "* You cannot drop Ion Cannon *" )
  189.         return PLUGIN_HANDLED
  190.     }
  191.     return PLUGIN_CONTINUE
  192. }
  193.  
  194. public EV_CurWeapon( id )
  195. {
  196.     if( !is_user_alive( id ) )
  197.         return PLUGIN_CONTINUE
  198.        
  199.     g_iCurrentWeapon[ id ] = read_data( 2 )
  200.    
  201.     return PLUGIN_CONTINUE
  202. }
  203.  
  204. public EV_DeathMsg( )
  205. {
  206.     static iVictim
  207.     iVictim = read_data( 2 )
  208.    
  209.     if( !is_user_connected( iVictim ) )
  210.         return
  211.        
  212.     g_bHasIon[ iVictim ] = false
  213.     g_bIsPlanting[ iVictim ] = false
  214. }
  215.  
  216. public EV_RoundStart( )
  217. {
  218.     // Remove any ion cannons
  219.     for( new i = 1; i < g_iMaxids; i++ )
  220.     {
  221.         if( g_Target[ i ] )
  222.             emit_sound(g_Target[i], CHAN_WEAPON, SOUND_STOP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  223.        
  224.         if( is_user_alive( i ) )
  225.         {
  226.             ProgressBar(i, 0, 0)
  227.             remove_task(i+5000)
  228.             g_bHasIon[ i ] = false
  229.             g_bIsFiring[ i ] = false
  230.             g_bIsPlanting[ i ] = false
  231.             g_Target[ i ] = 0
  232.         }
  233.     }
  234.    
  235.     static iEnt
  236.     iEnt = -1
  237.    
  238.     while( ( iEnt = find_ent_by_class( iEnt, "info_target_ion" ) ) > 0 )
  239.     {
  240.         engfunc( EngFunc_RemoveEntity, iEnt )
  241.     }
  242. }
  243.  
  244. public fw_CmdStart( id, UC_Handle, Seed )
  245. {
  246.     if( !is_user_alive( id ) || !g_bHasIon[ id ] || g_iCurrentWeapon[ id ] != CSW_C4 )
  247.         return FMRES_IGNORED
  248.        
  249.     static afButtons
  250.     afButtons = get_uc( UC_Handle, UC_Buttons )
  251.    
  252.     if( afButtons & IN_ATTACK )
  253.     {
  254.         afButtons &= ~IN_ATTACK
  255.         set_uc( UC_Handle, UC_Buttons, afButtons )
  256.        
  257.         if( g_bIsPlanting[ id ] )
  258.         {
  259.             //ProgressBar(id, 0, 0)
  260.             return FMRES_IGNORED
  261.         }
  262.        
  263.         if( g_Target[ id ] )
  264.         {
  265.             client_print( id, print_center, "* You already had planted Ion Cannon *" )
  266.             g_bIsPlanting[ id ] = false
  267.             return FMRES_IGNORED
  268.         }
  269.    
  270.         if( is_user_outside( id ) )
  271.         {
  272.             g_Target[ id ] = 0
  273.             i_Pitch[ id ] = 97
  274.             i_BeaconTime[ id ] = 1.12
  275.             g_distance[ id ] = 350.0
  276.             g_Speed[ id ] = 0.0
  277.            
  278.            
  279.             static iEnt
  280.             iEnt = find_ent_by_owner( -1, "weapon_c4", id )
  281.             set_pdata_float( iEnt, 48, 10.0, 4 )
  282.            
  283.             g_bIsFiring[ id ] = true
  284.             g_bIsPlanting[ id ] = true
  285.             emit_sound(id, CHAN_WEAPON, SOUND_BEACON, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  286.            
  287.             g_iCurrentWeapon[ id ] = CSW_C4
  288.            
  289.             if( get_pcvar_num( cvar_barlen ) > 0 )
  290.             {
  291.                 set_task( 3.6, "UpdateAnim" )
  292.                 SendWeaponAnim( id, anim_pressbutton )
  293.                 ProgressBar(id, get_pcvar_num( cvar_barlen ), 0)
  294.                 set_task(get_pcvar_float( cvar_barlen ),"ion_planted", id+5000)
  295.             }
  296.             else
  297.             {
  298.                 set_task(0.2,"ion_planted", id+5000)
  299.                 SendWeaponAnim( id, anim_drop )
  300.             }
  301.         }
  302.         else
  303.         {
  304.             g_bIsPlanting[ id ] = false
  305.             client_print( id, print_center, "* To plant Ion Cannon you must be outside!!!*" )
  306.             return FMRES_IGNORED
  307.         }
  308.     }
  309.     return FMRES_HANDLED
  310. }
  311.  
  312. public fw_PlayerPreThink( id )
  313. {
  314.     if( !is_user_alive( id ) || !g_bHasIon[ id ] )
  315.         return
  316.    
  317.     if( g_bIsFiring[ id ] )
  318.     {
  319.         g_iLastWeapon[ id ] = get_user_weapon( id )
  320.        
  321.         if( g_iCurrentWeapon[ id ] != CSW_C4 || g_iLastWeapon[ id ] != g_iCurrentWeapon[ id ] || get_user_button( id ) & ACTION_BLOCK )
  322.         {
  323.             emit_sound(g_Target[id], CHAN_WEAPON, SOUND_STOP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  324.             ProgressBar(id, 0, 0)
  325.             remove_task(id+5000)
  326.             g_bIsFiring[ id ] = false
  327.             g_bIsPlanting[ id ] = false
  328.         }
  329.     }
  330. }
  331.  
  332. public fw_KnifeDeploy_Post( iEnt )
  333. {
  334.     static id
  335.     id = get_pdata_cbase( iEnt, 41, 4 )
  336.    
  337.     if( g_bHasIon[ id ] )
  338.     {
  339.         set_pev( id, pev_viewmodel2, V_MODEL )
  340.         SendWeaponAnim( id, anim_draw )
  341.     }
  342. }
  343.  
  344. public fn_DeathMsg( id, Dest, iEntity )
  345. {
  346.     static iVictim, iKiller
  347.     iKiller = get_msg_arg_int( 1 )
  348.     iVictim = get_msg_arg_int( 2 )
  349.    
  350.     if( !is_user_connected( iVictim ) || iKiller == iVictim )
  351.         return PLUGIN_CONTINUE
  352.    
  353.     if ( g_bKilledByIon[ iVictim ] )
  354.     {
  355.         set_msg_arg_string ( 4, "ion cannon" )
  356.     }
  357.     return PLUGIN_CONTINUE
  358. }
  359.  
  360. public ion_planted(id)
  361. {  
  362.     id -= 5000
  363.    
  364.     if( !is_user_alive( id ) || ze_is_user_zombie( id ) )
  365.     {
  366.         remove_task( id )
  367.         return PLUGIN_CONTINUE
  368.     }
  369.    
  370.     client_print(0, print_center, "Ion Cannon has been planted!")
  371.     client_cmd(0, "spk %s", SOUND_PLANT)
  372.     g_bIsFiring[id] = false
  373.     g_bIsPlanting[ id ] = false
  374.    
  375.     static Weapon
  376.     Weapon = find_ent_by_owner( -1, "weapon_c4", id )
  377.    
  378.     ExecuteHamB( Ham_Weapon_RetireWeapon, Weapon );
  379.     ExecuteHamB( Ham_RemovePlayerItem, id, Weapon );
  380.     ExecuteHamB( Ham_Item_Kill, Weapon );
  381.  
  382.     set_pev( id, pev_weapons, pev( id, pev_weapons ) & ~( 1 << CSW_C4) );
  383.     cs_set_user_bpammo( id, CSW_C4, 0 );
  384.     g_bHasIon[ id ] = false
  385.  
  386.     g_Target[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
  387.     if(!g_Target[id]) return PLUGIN_HANDLED
  388.  
  389.     // Strings
  390.     set_pev(g_Target[id],pev_classname,"info_target_ion")
  391.     engfunc(EngFunc_SetModel,g_Target[id],W_MODEL)
  392.  
  393.     // Integer
  394.     set_pev(g_Target[id],pev_owner, id)
  395.     set_pev(g_Target[id],pev_movetype, MOVETYPE_TOSS)
  396.     set_pev(g_Target[id],pev_solid, SOLID_TRIGGER)
  397.  
  398.     entity_get_vector(id,EV_VEC_origin, ion_mid_origin[id])
  399.     //wpn_projectile_startpos(id,0,0,50,ion_mid_origin[id])
  400.     //static Float:flOrigin[ 3 ]
  401.     //pev( id, pev_origin, flOrigin )
  402.     //engfunc( EngFunc_SetOrigin, g_Target[ id ], flOrigin )
  403.     set_pev(g_Target[id],pev_origin,ion_mid_origin[id])
  404.  
  405.     ion_beacon(id)
  406.     set_task(5.0,"ion_startup", id)
  407.     return PLUGIN_CONTINUE
  408. }
  409.  
  410. public ion_beacon(id)
  411. {
  412.     if( !g_Target[ id ] )
  413.     {
  414.         remove_task( id )
  415.         return PLUGIN_CONTINUE
  416.     }
  417.  
  418.     i_Pitch[id] += 3
  419.     i_BeaconTime[id] -= 0.03
  420.     if(i_Pitch[id] > 255) i_Pitch[id] = 255
  421.     if(i_BeaconTime[id] < 0.30) i_BeaconTime[id] = 0.30
  422.     emit_sound(g_Target[id], CHAN_ITEM, SOUND_BEEP, VOL_NORM, ATTN_NORM, 0, i_Pitch[id])
  423.     set_task(i_BeaconTime[id],"ion_beacon", id)
  424.     return PLUGIN_CONTINUE
  425. }
  426.  
  427. public ion_startup(id)
  428. {
  429.     client_cmd(0, "spk ^"%s^"", SOUND_APPROACH)
  430.     client_print(0, print_chat,"Ion Cannon is approaching")
  431.     set_task(5.0,"Trace_Ready", id)
  432. }
  433.  
  434. public Trace_Ready(id)
  435. {
  436.     if( !pev_valid( id ) )
  437.     {
  438.         remove_task( id )
  439.         return PLUGIN_CONTINUE
  440.     }
  441.        
  442.     // write origin of each
  443.     new Float:mid_origin[33][3]
  444.     pev(g_Target[id],pev_origin,mid_origin[id]) // Target contain entity id
  445.     // 1st
  446.     beam_origin[id][0][0] = mid_origin[id][0] + 300.0
  447.     beam_origin[id][0][1] = mid_origin[id][1] + 150.0
  448.     beam_origin[id][0][2] = mid_origin[id][2]
  449.     g_degrees[id][0] = 0.0
  450.     // 2nd
  451.     beam_origin[id][1][0] = mid_origin[id][0] + 300.0
  452.     beam_origin[id][1][1] = mid_origin[id][1] - 150.0
  453.     beam_origin[id][1][2] = mid_origin[id][2]
  454.     g_degrees[id][1] = 45.0
  455.     // 3rd
  456.     beam_origin[id][2][0] = mid_origin[id][0] - 300.0
  457.     beam_origin[id][2][1] = mid_origin[id][1] - 150.0
  458.     beam_origin[id][2][2] = mid_origin[id][2]
  459.     g_degrees[id][2] = 90.0
  460.     // 4th
  461.     beam_origin[id][3][0] = mid_origin[id][0] - 300.0
  462.     beam_origin[id][3][1] = mid_origin[id][1] + 150.0
  463.     beam_origin[id][3][2] = mid_origin[id][2]
  464.     g_degrees[id][3] = 135.0
  465.     // 5th
  466.     beam_origin[id][4][0] = mid_origin[id][0] + 150.0
  467.     beam_origin[id][4][1] = mid_origin[id][1] + 300.0
  468.     beam_origin[id][4][2] = mid_origin[id][2]
  469.     g_degrees[id][4] = 180.0
  470.     // 6th
  471.     beam_origin[id][5][0] = mid_origin[id][0] + 150.0
  472.     beam_origin[id][5][1] = mid_origin[id][1] - 300.0
  473.     beam_origin[id][5][2] = mid_origin[id][2]
  474.     g_degrees[id][5] = 225.0
  475.     // 7th
  476.     beam_origin[id][6][0] = mid_origin[id][0] - 150.0
  477.     beam_origin[id][6][1] = mid_origin[id][1] - 300.0
  478.     beam_origin[id][6][2] = mid_origin[id][2]
  479.     g_degrees[id][6] = 270.0
  480.     // 8th
  481.     beam_origin[id][7][0] = mid_origin[id][0] - 150.0
  482.     beam_origin[id][7][1] = mid_origin[id][1] + 300.0
  483.     beam_origin[id][7][2] = mid_origin[id][2]
  484.     g_degrees[id][7] = 315.0
  485.    
  486.     // set the mid to global
  487.     ion_mid_origin[id] = mid_origin[id]
  488.  
  489.     new Float:addtime
  490.     for(new i = 0; i < 8; i++) {
  491.         addtime = addtime + 0.3
  492.         new param[3]
  493.         param[0] = i
  494.         param[1] = id
  495.         set_task(0.0 + addtime, "Trace_Start", _,param, 2)
  496.     }
  497.     Laser_Rotate(id) //To fix the laserdraw
  498.     client_cmd(0, "spk ^"%s^"", SOUND_READY)
  499.    
  500.     for(new Float:i = 0.0; i < 7.5; i += 0.01) //Rotate for 7.5 secs.
  501.         set_task(i+3.0, "Laser_Rotate", id)
  502.  
  503.     set_task(2.9,"AddSpeed", id)
  504.     set_task(11.5,"CreateFire", id)
  505.     set_task(12.5,"ClearLasers", id)
  506.     set_task(16.2,"FireIonCannon", id)
  507.     return PLUGIN_CONTINUE
  508. }
  509.  
  510. public AddSpeed(id)
  511. {
  512.     if( !g_Target[ id ] )
  513.     {
  514.         remove_task( id )
  515.         return PLUGIN_CONTINUE
  516.     }
  517.    
  518.     if(g_Speed[id] > 1.0) g_Speed[id] = 1.0
  519.     g_Speed[id] += 0.1
  520.     set_task(0.6,"AddSpeed", id)
  521.     return PLUGIN_CONTINUE
  522. }
  523.  
  524. public CreateFire(id)
  525. {
  526.     if( !g_Target[ id ] )
  527.     {
  528.         remove_task( id )
  529.         return PLUGIN_CONTINUE
  530.     }
  531.    
  532.     for( new id = 1; id < g_iMaxids; id++ )
  533.     {
  534.         if(ze_is_user_zombie(id))
  535.         {
  536.             ze_set_fire_grenade(id, true)
  537.         }
  538.     }
  539.  
  540.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
  541.     write_byte(TE_SPRITE)
  542.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
  543.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
  544.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + 100)
  545.     write_short(ReadyFire)
  546.     write_byte(30)
  547.     write_byte(200)
  548.     message_end()
  549.  
  550.     set_task(1.5,"CreateFire", id)
  551.     return PLUGIN_CONTINUE
  552. }
  553.  
  554. public ClearLasers(id)
  555. {
  556.     ze_set_fire_grenade(id, false)
  557.     remove_task(1018+id)
  558. }
  559.  
  560. public Laser_Rotate(id)
  561. {
  562.     if( !g_Target[ id ] )
  563.     {
  564.         remove_task( id )
  565.         return
  566.     }
  567.    
  568.     g_distance[id] -= 0.467
  569.     for(new i = 0; i < 8; i++) {
  570.         // Calculate new alpha
  571.         g_degrees[id][i] += g_Speed[id]
  572.         if(g_degrees[id][i] > 360.0)
  573.             g_degrees[id][i] -= 360.0
  574.  
  575.         // calcul the next origin
  576.         new Float:tmp[33][3]
  577.         tmp[id] = ion_mid_origin[id]
  578.  
  579.         tmp[id][0] += floatsin(g_degrees[id][i], degrees) * g_distance[id]
  580.         tmp[id][1] += floatcos(g_degrees[id][i], degrees) * g_distance[id]
  581.         tmp[id][2] += 0.0 // -.-
  582.         beam_origin[id][i] = tmp[id]
  583.     }
  584. }
  585.  
  586. public Trace_Start(param[])
  587. {
  588.     new i = param[0]
  589.     new id = param[1]
  590.  
  591.     if( !g_Target[ id ] )
  592.     {
  593.         remove_task( id )
  594.         return
  595.     }
  596.    
  597.     new Float:get_random_z,Float:SkyOrigin[33][3]
  598.    
  599.     if( is_user_alive( id ) )
  600.     {
  601.         SkyOrigin[id] = tlx_distance_to_sky(g_Target[id])
  602.         get_random_z = random_float(300.0,SkyOrigin[id][2])
  603.     }
  604.  
  605.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, beam_origin[id][i], 0)
  606.     write_byte(TE_SPRITE)
  607.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])
  608.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])
  609.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][2] + get_random_z)
  610.     write_short(BlueFire)
  611.     write_byte(10)
  612.     write_byte(100)
  613.     message_end()
  614.    
  615.     TraceAll(param)
  616. }
  617.  
  618. public TraceAll(param[])
  619. {
  620.     new i = param[0]
  621.     new id = param[1]
  622.    
  623.     if( !g_Target[ id ] )
  624.     {
  625.         remove_task( id )
  626.         return
  627.     }
  628.    
  629.     new Float:SkyOrigin[33][3]
  630.     SkyOrigin[id] = tlx_distance_to_sky(g_Target[id])
  631.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, beam_origin[id][i], 0)
  632.     write_byte(TE_BEAMPOINTS)
  633.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])      //start point (x)
  634.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])      //start point (y)
  635.     engfunc(EngFunc_WriteCoord, SkyOrigin[id][2])           //start point (z)
  636.  
  637.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])      //end point (x)
  638.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])      //end point (y)
  639.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][2])      //end point (z)
  640.     write_short(IonBeam)    //model
  641.     write_byte(0)       //startframe
  642.     write_byte(0)       //framerate
  643.     write_byte(1)       //life
  644.     write_byte(50)      //width
  645.     write_byte(0)       //noise
  646.     write_byte(255)     //r
  647.     write_byte(255)     //g
  648.     write_byte(255)     //b
  649.     write_byte(255)     //brightness
  650.     write_byte(0)       //speed
  651.     message_end()
  652.  
  653.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, beam_origin[id][i], 0)
  654.     write_byte(TE_SPRITE)
  655.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])
  656.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])
  657.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][2])
  658.     write_short(LaserFlame)
  659.     write_byte(5)
  660.     write_byte(200)
  661.     message_end()
  662.  
  663.     /*message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  664.     write_byte(TE_WORLDDECAL)
  665.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][0])
  666.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][1])
  667.     engfunc(EngFunc_WriteCoord, beam_origin[id][i][2])
  668.     write_byte(46)
  669.     message_end()*/
  670.  
  671.     set_task(0.08,"TraceAll", 1018+id, param, 2)
  672. }
  673.  
  674. public FireIonCannon(id)
  675. {
  676.     if( !g_Target[ id ] )
  677.     {
  678.         remove_task( id )
  679.         return
  680.     }
  681.    
  682.     new i = -1
  683.     while((i = engfunc(EngFunc_FindEntityInSphere, i, ion_mid_origin[id], get_pcvar_float( cvar_radius ) )) != 0)
  684.     {
  685.         if( !is_user_connected( i ) )
  686.             continue
  687.            
  688.         if( pev(i, pev_flags) & (FL_CLIENT | FL_FAKECLIENT))
  689.         {
  690.             message_begin(MSG_ONE_UNRELIABLE, gmsgScreenShake, {0,0,0}, i)
  691.             write_short(255<<14) //ammount
  692.             write_short(10<<14) //lasts this long
  693.             write_short(255<<14) //frequency
  694.             message_end()
  695.         }
  696.         //next player in spehre.
  697.         continue
  698.     }
  699.  
  700.     new Float:skyOrigin[33][3]
  701.     skyOrigin[id] = tlx_distance_to_sky(g_Target[id])
  702.  
  703.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
  704.     write_byte(TE_BEAMPOINTS)
  705.     engfunc(EngFunc_WriteCoord, skyOrigin[id][0])   //start point (x)
  706.     engfunc(EngFunc_WriteCoord, skyOrigin[id][1])   //start point (y)
  707.     engfunc(EngFunc_WriteCoord, skyOrigin[id][2])   //start point (z)
  708.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])      //end point (x)
  709.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])      //end point (y)
  710.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2])      //end point (z)
  711.     write_short(IonBeam)    //model
  712.     write_byte(0)       //startframe
  713.     write_byte(0)       //framerate
  714.     write_byte(15)      //life
  715.     write_byte(255)     //width
  716.     write_byte(0)       //noise
  717.     write_byte(255)     //r
  718.     write_byte(255)     //g
  719.     write_byte(255)     //b
  720.     write_byte(255)     //brightness
  721.     write_byte(0)       //speed
  722.     message_end()
  723.  
  724.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin, 0)
  725.     write_byte(TE_BEAMCYLINDER)
  726.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0]) // start X
  727.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1]) // start Y
  728.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2]) // start Z
  729.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0]) // something X
  730.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1]) // something Y
  731.     engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + get_pcvar_float( cvar_radius ) - 1000.0) // something Z
  732.     write_short(Shockwave) // sprite
  733.     write_byte(0) // startframe
  734.     write_byte(0) // framerate
  735.     write_byte(100) // life
  736.     write_byte(150) // width
  737.     write_byte(0) // noise
  738.     write_byte(0) // red
  739.     write_byte(100) // green
  740.     write_byte(250) // blue
  741.     write_byte(150) // brightness
  742.     write_byte(0) // speed
  743.     message_end()
  744.  
  745.     for(new i = 1; i < 6; i++)
  746.     {
  747.         engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ion_mid_origin[id], 0)
  748.         write_byte(TE_SPRITETRAIL)  // line of moving glow sprites with gravity, fadeout, and collisions
  749.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
  750.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
  751.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2])
  752.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][0])
  753.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][1])
  754.         engfunc(EngFunc_WriteCoord, ion_mid_origin[id][2] + 200)
  755.         write_short(BlueFlare) // (sprite index)
  756.         write_byte(50) // (count)
  757.         write_byte(random_num(27,30)) // (life in 0.1's)
  758.         write_byte(10) // byte (scale in 0.1's)
  759.         write_byte(random_num(30,70)) // (velocity along vector in 10's)
  760.         write_byte(40) // (randomness of velocity in 10's)
  761.         message_end()
  762.     }
  763.    
  764.     switch( get_pcvar_num( cvar_ionmode ) )
  765.     {
  766.         case 0:
  767.         {
  768.             for( new i = 1; i < g_iMaxids; i++ )
  769.             {
  770.                 if( is_user_alive( i ) && ze_is_user_zombie( i ) )
  771.                 {
  772.                     static Float:flHealth
  773.                     flHealth = entity_get_float( i, EV_FL_health )
  774.                
  775.                     static Float:flDamage
  776.                     flDamage = get_pcvar_float( cvar_damage )
  777.                
  778.                     if( flHealth - flDamage >= 1 )
  779.                     {
  780.                         ExecuteHamB( Ham_TakeDamage, i, g_Target[ id ], id, flDamage, DMG_BLAST )
  781.                     }
  782.                     else
  783.                     {
  784.                         g_bKilledByIon[ i ] = true
  785.                         ExecuteHamB( Ham_Killed, i, id, 2 )
  786.                         g_bKilledByIon[ i ] = false
  787.                     }
  788.                 }
  789.             }
  790.         }
  791.         case 1:
  792.         {
  793.             static victim
  794.             victim = -1
  795.            
  796.             while ( ( victim = engfunc( EngFunc_FindEntityInSphere, victim, ion_mid_origin[id], get_pcvar_float( cvar_radius ) ) ) != 0 )
  797.             {
  798.                 if( !is_user_connected( victim ) )
  799.                 {
  800.                     if( pev_valid( victim ) )
  801.                     {
  802.                         static szClassname[ 32 ]
  803.                         pev( victim, pev_classname, szClassname, 31 )
  804.                        
  805.                         if( equal( szClassname, "func_breakable" ) )
  806.                         {
  807.                             force_use( id, victim )
  808.                         }
  809.                     }
  810.                     continue
  811.                 }
  812.                
  813.                 if ( !is_user_alive( victim ) )
  814.                     continue
  815.                
  816.                 if( !ze_is_user_zombie( victim ) )
  817.                     continue
  818.            
  819.                 static Float:flOrigin[ 3 ]
  820.                 pev( victim, pev_origin, flOrigin )
  821.                
  822.                 static Float:flDistance, Float:flDamage
  823.                 flDistance = get_distance_f( ion_mid_origin[ id ], flOrigin )
  824.                
  825.                 flDamage = floatradius( get_pcvar_float( cvar_maxdmg ), get_pcvar_float( cvar_radius ), flDistance )
  826.                
  827.                 if( flDamage )
  828.                 {
  829.                     static Float:flHealth
  830.                     flHealth = entity_get_float( victim, EV_FL_health )
  831.                
  832.                     if( flHealth - flDamage >= 1 )
  833.                     {
  834.                         ExecuteHamB( Ham_TakeDamage, victim, g_Target[ id ], id, flDamage, DMG_BLAST )
  835.                     }
  836.                     else
  837.                     {
  838.                         g_bKilledByIon[ victim ] = true
  839.                         ExecuteHamB( Ham_Killed, victim, id, 2 )
  840.                         g_bKilledByIon[ victim ] = false
  841.                     }
  842.                 }
  843.             }
  844.         }
  845.     }
  846.    
  847.     client_cmd(0, "spk ^"%s^"", SOUND_ATTACK)
  848.     ResetAll(id)
  849. }
  850.  
  851. ResetAll(id)
  852. {  
  853.     if( !g_Target[ id ] )
  854.     {
  855.         remove_task( id )
  856.         return
  857.     }
  858.    
  859.     set_pev(g_Target[id], pev_flags, FL_KILLME)
  860.     g_Target[id] = 0
  861. }
  862.  
  863. /******************** Stocks ********************/
  864.  
  865. // Get entity above sky.
  866. stock Float:tlx_distance_to_sky(id)
  867. {  
  868.     new Float:TraceEnd[3]
  869.     pev(id, pev_origin, TraceEnd)
  870.        
  871.     new Float:f_dest[3]
  872.     f_dest[0] = TraceEnd[0]
  873.     f_dest[1] = TraceEnd[1]
  874.     f_dest[2] = TraceEnd[2] + 8192.0
  875.        
  876.     new res, Float:SkyOrigin[3]
  877.     engfunc(EngFunc_TraceLine, TraceEnd, f_dest, IGNORE_MONSTERS + IGNORE_GLASS, id, res)
  878.     get_tr2(res, TR_vecEndPos, SkyOrigin)
  879.    
  880.     return SkyOrigin
  881. }
  882.  
  883. //return distance above us to sky
  884. stock Float:is_user_outside(id)
  885. {
  886.     new Float:origin[3], Float:dist
  887.  
  888.     pev(id, pev_origin, origin)
  889.     dist = origin[2]
  890.  
  891.     while(engfunc(EngFunc_PointContents, origin) == CONTENTS_EMPTY)
  892.         origin[2] += 5.0
  893.     if(engfunc(EngFunc_PointContents, origin) == CONTENTS_SKY)
  894.         return (origin[2] - dist)
  895.  
  896.     return 0.0
  897. }
  898.  
  899. stock ProgressBar(id, seconds, position)
  900. {
  901.     message_begin(MSG_ONE, get_user_msgid("BarTime"), {0, 0, 0}, id)
  902.     write_byte(seconds)
  903.     write_byte(position)
  904.     message_end()
  905. }
  906.  
  907. SendWeaponAnim( id, Sequence )
  908. {
  909.     set_pev( id, pev_weaponanim, Sequence )
  910.    
  911.     message_begin( MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id )
  912.     write_byte( Sequence )
  913.     write_byte( pev( id, pev_body ) )
  914.     message_end( )
  915. }
  916.  
  917. public UpdateAnim( id )
  918. {
  919.     if( !is_user_alive( id ) || ze_is_user_zombie( id ) || !g_bHasIon[ id ] || g_iCurrentWeapon[ id ] != CSW_C4 )
  920.         return
  921.            
  922.     SendWeaponAnim( id, anim_drop )
  923. }
  924.  
  925. stock Float:floatradius(Float:flMaxAmount, Float:flRadius, Float:flDistance)
  926. {
  927.     return floatsub(flMaxAmount, floatmul(floatdiv(flMaxAmount, flRadius), flDistance))
  928. }
  929. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  930. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  931. */

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest