Нет урона от оружия Fuerin_weapons!

Сообщения
165
Реакции
-8
Код:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------| AT4 |-----------------------------------------------------------
//======================================= sDs|Aragon* =======================================================
#define weapon_at4        "weapon_m249"
#define CSW_AT4            CSW_M249
#define AT4_CLASS        "at4_rocket"
#define AT4_CLASS_LASERDOT    "at4_laserdot"
enum AT4Data {
    AT4_NAME = 0,
    AT4_LEVEL,
    AT4_DAMAGE,
    AT4_RADIUS,
    AT4_KNOCKBACK
}
new WPN_AT4[AT4Data][] = {
    /*Name*/     "AT4",
    /*Level*/     "60",
    /*Damage*/     "300",
    /*Radius*/     "220",
    /*KnockBack*/     "4"
},
AT4Model_V[]         = "models/Furien40/v_at4.mdl",
AT4Model_P[]         = "models/Furien40/p_at4.mdl",
AT4Model_W[]         = "models/Furien40/w_at4.mdl",
AT4Model_S[]         = "models/Furien40/s_at4.mdl",
AT4Model_L[]         = "sprites/laserdot.spr",
AT4_WeaponList[]     = "furien40_at4",
AT4_Sound[][]         = {
    "weapons/at4_shoot1.wav",
    "weapons/at4_clipin1.wav",
    "weapons/at4_clipin2.wav",
    "weapons/at4_clipin3.wav",
    "weapons/at4_draw.wav"
},
AT4_Generic[][]     = {
    "sprites/furien40_at4.txt",
    "sprites/Furien40/at4.spr"
},
AT4ID, at4_event, at4_smoke, at4_trail, at4_explode

AT4_Init() {
    AT4ID = RegisterPrimary(WPN_AT4[AT4_NAME], WPN_TEAM_CT, WPN_ACCES_ADMIN, WPN_AT4[AT4_LEVEL], weapon_at4, CSW_AT4, AT4_WeaponList, "1")
    
    if(AT4ID) {
        register_clcmd(AT4_WeaponList,                 "Hook_AT4");
        
        register_message(MSGID_CurWeapon,            "AT4_CurWeapon")
        register_message(MSGID_Crosshair,            "AT4_Crosshair")

        register_logevent("AT4_RoundStart", 2,             "1=Round_Start");
        
        register_event("CurWeapon",                 "AT4_ViewModel", "be", "1=1");
        register_event("WeapPickup",                "AT4_ViewModel","be", "1=19");

        register_forward(FM_SetModel,                 "AT4_WorldModel", 1);
        register_forward(FM_UpdateClientData,             "AT4_UpdateClientData_Post", 1);
        register_forward(FM_PlaybackEvent,            "AT4_PlaybackEvent");
        register_forward(FM_PlayerPreThink,             "AT4_PreThink");
        register_forward(FM_CmdStart,                 "AT4_CmdStart");   
        
        RegisterHam(Ham_Item_AddToPlayer, weapon_at4,         "AT4_AddToPlayer");
        RegisterHam(Ham_Item_Deploy , weapon_at4,         "AT4_Deploy_Post", 1);
        RegisterHam(Ham_Item_Holster , weapon_at4,         "AT4_Holster");
        RegisterHam(Ham_Weapon_WeaponIdle, weapon_at4,         "AT4_WeaponIdle")
        RegisterHam(Ham_Weapon_PrimaryAttack, weapon_at4,     "AT4_PrimaryAttack");
        RegisterHam(Ham_Weapon_Reload, weapon_at4,         "AT4_Reload");
        RegisterHam(Ham_Weapon_Reload, weapon_at4,         "AT4_Reload_Post", 1);
        RegisterHam(Ham_Item_PostFrame, weapon_at4,         "AT4_PostFrame");   
        
        register_think(AT4_CLASS,                 "AT4_Think");
        register_think(AT4_CLASS_LASERDOT,             "AT4_LaserDot_Think");
        register_touch(AT4_CLASS, "*",                 "AT4_Touch");
    }
}

AT4_Precache() {
    at4_smoke     = precache_model("sprites/effects/rainsplash.spr");
    at4_trail     = precache_model("sprites/xbeam3.spr");
    at4_explode     = precache_model("sprites/Furien40/explode.spr");
    
    register_forward(FM_PrecacheEvent, "AT4_PrecacheEvent_Post", 1);
    
    precache_model(AT4Model_V);
    precache_model(AT4Model_P);
    precache_model(AT4Model_W);
    precache_model(AT4Model_S);
    precache_model(AT4Model_L);
    
    for(new i = 0; i < sizeof(AT4_Sound); i++)
        engfunc(EngFunc_PrecacheSound, AT4_Sound[i]);   
    for(new i = 0; i < sizeof(AT4_Generic); i++)
        engfunc(EngFunc_PrecacheGeneric, AT4_Generic[i]);
}

AT4_Natives() {
    register_native("get_user_at4",     "get_user_at4", 1);
    register_native("set_user_at4",     "set_user_at4", 1);
    register_native("at4_id",         "at4_id", 1);
}

public AT4_CurWeapon(msg_id, msg_dest, id) {
    new Weapon = get_msg_arg_int(2);
    
    if(is_user_alive(id) && Weapon == CSW_AT4 && get_user_weapon(id) == CSW_AT4 && get_user_at4(id))
        set_msg_arg_int(3, ARG_BYTE, -1)
}

public AT4_Crosshair(msg_id, msg_dest, id) {
    if(is_user_alive(id) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {       
        if(get_msg_arg_int(1) != 0)
            set_msg_arg_int(1, ARG_BYTE, 0);
    }
}

public AT4_RoundStart() {
    remove_entity_name(AT4_CLASS);
    remove_entity_name(AT4_CLASS_LASERDOT);
}

public AT4_ViewModel(id) {
    if(is_user_alive(id) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
        new VModel[128], PModel[128];
        pev(id, pev_viewmodel2, VModel, 127),
        pev(id, pev_weaponmodel2, PModel, 127);
        
        if(!equal(VModel, AT4Model_V))
            set_pev(id, pev_viewmodel2, AT4Model_V);
        if(!equal(PModel, AT4Model_P))
            set_pev(id, pev_weaponmodel2, AT4Model_P);
    }
}

public AT4_WorldModel(entity, model[]) {
    if(is_valid_ent(entity)) {
        static ClassName[33];
        entity_get_string(entity, EV_SZ_classname, ClassName, charsmax(ClassName));
        
        if(equal(ClassName, "weaponbox")) {
            new Owner = entity_get_edict(entity, EV_ENT_owner),   
            _AT4 = find_ent_by_owner(-1, weapon_at4, entity);
            
            if(pev_valid(_AT4) && entity_get_int(_AT4, EV_INT_WeaponKey) == AT4ID) {
                set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
                entity_set_model(entity, AT4Model_W);
                new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, Owner);
                if(is_valid_ent(Laser))
                    remove_entity(Laser);
            }
        }
    }
    return FMRES_IGNORED;
}

public AT4_UpdateClientData_Post(id, sendweapons, cd_handle) {
    if(is_user_alive(id) && is_user_connected(id) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id))
        set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
    return FMRES_IGNORED;
}

public AT4_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2) {
    if(is_user_connected(invoker) && eventid == at4_event)
        playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
    return FMRES_IGNORED;
}

public AT4_PrecacheEvent_Post(type, const name[]) {
    if (equal("events/m249.sc", name))
        at4_event = get_orig_retval();
    return FMRES_IGNORED;
}

public AT4_PreThink(id) {
    if(is_user_alive(id) && is_user_connected(id)) {
        if(get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
            new _AT4 = fm_find_ent_by_owner(-1, weapon_at4, id);
            
            if(pev_valid(_AT4) && entity_get_int(_AT4, EV_INT_iuser1) == 1) {
                new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
                
                if(!is_valid_ent(Laser)) {
                    new at4_laser = create_entity("info_target");   
                    
                    if(is_valid_ent(at4_laser)) {
                        new Float:Origin[3], Float:Color[3];
                        fm_get_aim_origin(id, Origin);
                        Color[0] = 255.0,    Color[1] =0.0,    Color[2] = 0.0,
                        
                        set_pev(at4_laser, pev_classname, AT4_CLASS_LASERDOT);
                        set_pev(at4_laser, pev_owner, id);
                        engfunc(EngFunc_SetModel, at4_laser, AT4Model_L);
                        set_pev(at4_laser, pev_renderfx, kRenderFxNoDissipation);
                        set_pev(at4_laser, pev_rendermode, kRenderGlow);
                        set_pev(at4_laser, pev_rendercolor, Color);
                        set_pev(at4_laser, pev_renderamt, 255.0);
                        set_pev(at4_laser, pev_light_level, 255.0);
                        set_pev(at4_laser, pev_scale, 1.0);
                        set_pev(at4_laser, pev_movetype, MOVETYPE_FLY);
                        set_pev(at4_laser, pev_nextthink, halflife_time() + 0.001);
                    }
                }
            }
        }
    }
}

public AT4_CmdStart(id, uc_handle, seed) {
    if(is_user_alive(id) && is_user_connected(id)) {
        new _AT4 = fm_find_ent_by_owner(-1, weapon_at4, id);   
        
        if(pev_valid(_AT4) && get_user_weapon(id) == CSW_AT4 && entity_get_int(_AT4, EV_INT_WeaponKey) == AT4ID) {
            new CurButton = get_uc(uc_handle, UC_Buttons);
            
            if(CurButton & IN_ATTACK) {
                if(cs_get_weapon_ammo(_AT4) > 0 && !get_pdata_int(_AT4, 54, 4) && get_pdata_float(id, 83, 5) <= 0.0) {
                    set_weapon_anim(id, 1);
                    emit_sound(id, CHAN_WEAPON, AT4_Sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM);
                    
                    AT4_Fire(id, entity_get_int(_AT4, EV_INT_iuser1) == 1 ? 1 : 0);
                    
                    new Float:cl_pushangle[3];
                    cl_pushangle[0] = random_float(-8.0, -9.0), cl_pushangle[1] = 0.0, cl_pushangle[2] = 0.0;
                    set_pev(id, pev_punchangle, cl_pushangle);
                    
                    cs_set_weapon_ammo(_AT4, cs_get_weapon_ammo(_AT4) - 1);
                    if(cs_get_weapon_ammo(_AT4) > 0 && !get_pdata_int(_AT4, 54, 4) && get_pdata_float(id, 83, 5) <= 0.0) {
                        set_pdata_float(id, 83, 0.3, 5);
                        set_pdata_float(_AT4, 48, 0.3, 4)
                    }
                }
                CurButton &= ~IN_ATTACK;
                set_uc(uc_handle, UC_Buttons, CurButton);
            }
            
            if(CurButton & IN_ATTACK2 && !(pev(id, pev_oldbuttons) & IN_ATTACK2)) {
                if(cs_get_weapon_ammo(_AT4) > 0 && !get_pdata_int(_AT4, 54, 4) && get_pdata_float(id, 83, 5) <= 0.0) {
                    if(entity_get_int(_AT4, EV_INT_iuser1) == 1) {
                        entity_set_int(_AT4, EV_INT_iuser1, 0)
                        new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
                        
                        if(is_valid_ent(Laser))
                            remove_entity(Laser);
                    }
                    else
                        entity_set_int(_AT4, EV_INT_iuser1, 1)
                }
                CurButton &= ~IN_ATTACK2;
                set_uc(uc_handle, UC_Buttons, CurButton);
            }
        }
    }
    return FMRES_IGNORED;
}

public AT4_AddToPlayer(Weapon, id) {
    if(is_valid_ent(Weapon) && is_user_connected(id) && entity_get_int(Weapon, EV_INT_WeaponKey) == AT4ID)
        WeaponList(id, CSW_AT4, AT4_WeaponList, 0)
    else if(pev_valid(Weapon) && is_user_alive(id) && entity_get_int(id, EV_INT_WeaponKey) == AT4ID) {
        entity_set_int(Weapon, EV_INT_WeaponKey, 0);
        entity_set_int(Weapon, EV_INT_WeaponKey, AT4ID)
        ColorChat(id, "!t[!g%s!t]!g Clip:!t 1!g Damage:!t %s!g Radius:!t %s!g KnockBack:!t %s", WPN_AT4[AT4_NAME], WPN_AT4[AT4_DAMAGE], WPN_AT4[AT4_RADIUS], WPN_AT4[AT4_KNOCKBACK])
        ColorChat(id, "!t[Module 2]!g Damage:!t %d!g Clip:!t 1!g Radius:!t %s!g KnockBack:!t %s", floatround(str_to_float(WPN_AT4[AT4_DAMAGE]) * 0.60), WPN_AT4[AT4_RADIUS], WPN_AT4[AT4_KNOCKBACK])   
    }
    return HAM_IGNORED;
}

public AT4_Deploy_Post(Weapon) {
    if(pev_valid(Weapon)) {
        new Owner = get_pdata_cbase(Weapon, 41, 4);
        
        if(is_user_alive(Owner) && entity_get_int(Weapon, EV_INT_WeaponKey) == AT4ID) {
            set_pev(Owner, pev_viewmodel2, AT4Model_V);
            set_pev(Owner, pev_weaponmodel2, AT4Model_P);
            set_weapon_anim(Owner, 4)
            
            set_pdata_float(Owner, 83, 1.2, 5);
            set_pdata_float(Weapon, 48, 1.2, 4)
            set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) | (1<<6));
        }
    }
    return HAM_IGNORED;
}

public AT4_Holster(Weapon) {
    if(pev_valid(Weapon)) {
        new Owner = get_pdata_cbase(Weapon, 41, 4);
        
        if(is_user_alive(Owner) && entity_get_int(Weapon, EV_INT_WeaponKey) == AT4ID)
            set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
    }
    return HAM_IGNORED;
}

public AT4_WeaponIdle(Weapon) {
    if(pev_valid(Weapon)) {
        new Owner = get_pdata_cbase(Weapon, 41, 4);
        
        if(is_user_alive(Owner) && entity_get_int(Weapon, EV_INT_WeaponKey) == AT4ID && get_pdata_float(Weapon, 48, 4) <= 0.1)  {
            set_pdata_float(Weapon, 48, 4.0, 4)
            set_weapon_anim(Owner, 0)
        }
    }
    return HAM_IGNORED;
}

public AT4_PrimaryAttack(Weapon) {
    if(pev_valid(Weapon)) {
        new Owner = get_pdata_cbase(Weapon, 41, 4);
        if(is_user_alive(Owner) && entity_get_int(Weapon, EV_INT_WeaponKey) == AT4ID)
            return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public AT4_Reload(Weapon) {
    if(pev_valid(Weapon)) {
        new Owner = get_pdata_cbase(Weapon, 41, 4);
        
        if(is_user_alive(Owner) && entity_get_int(Weapon, EV_INT_WeaponKey) == AT4ID) {       
            if(cs_get_user_bpammo(Owner, CSW_AT4) <= 0 || get_pdata_int(Weapon, 51, 4) >= 1)
                return HAM_SUPERCEDE;
        }
    }
    return HAM_IGNORED;
}

public AT4_Reload_Post(Weapon) {
    if(pev_valid(Weapon)) {
        new Owner = get_pdata_cbase(Weapon, 41, 4);
        
        if(is_user_alive(Owner) && entity_get_int(Weapon, EV_INT_WeaponKey) == AT4ID) {           
            if(cs_get_user_bpammo(Owner, CSW_AT4) <= 0 || get_pdata_int(Weapon, 51, 4) >= 1)
                return HAM_SUPERCEDE;
            set_pdata_float(Weapon, 48, 3.66, 4);
            set_pdata_float(Owner, 83, 3.66, 5);
            set_pdata_int(Weapon, 54, 1, 4);
            set_weapon_anim(Owner, 3)
        }
    }
    return HAM_IGNORED;
}

public AT4_PostFrame(Weapon) {
    if(pev_valid(Weapon)) {
        new Owner = get_pdata_cbase(Weapon, 41, 4);
        
        if(is_user_alive(Owner) && entity_get_int(Weapon, EV_INT_WeaponKey) == AT4ID && get_pdata_int(Weapon, 54, 4) && get_pdata_float(Owner, 83, 5) <= 0.0) {
            new Temp = min(1 - get_pdata_int(Weapon, 51, 4), cs_get_user_bpammo(Owner, CSW_AT4));
            
            set_pdata_int(Weapon, 51, get_pdata_int(Weapon, 51, 4) + Temp, 4);
            cs_set_user_bpammo(Owner, CSW_AT4, cs_get_user_bpammo(Owner, CSW_AT4) - Temp);       
            set_pdata_int(Weapon, 54, 0, 4);
        }
    }
    return HAM_IGNORED;
}

public AT4_Fire(id, Type) {
    new Rocket = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
    
    if(pev_valid(Rocket)) {
        new Float:Origin[3], Float:Angles[3], Float:Velocity[3];
        engfunc(EngFunc_GetAttachment, id, 0, Origin);
        pev(id, pev_v_angle, Angles)
        
        set_pev(Rocket, pev_origin, Origin);
        set_pev(Rocket, pev_solid, SOLID_TRIGGER);
        set_pev(Rocket, pev_movetype, MOVETYPE_FLY);
        set_pev(Rocket, pev_classname, AT4_CLASS);
        
        if(Type) {
            set_pev(Rocket, pev_fuser3, 0.60);       
            set_pev(Rocket, pev_iuser3, 1);   
        }
        else {
            set_pev(Rocket, pev_fuser3, 1.0);       
            set_pev(Rocket, pev_iuser3, 0);       
        }
        set_pev(Rocket, pev_owner, id);
        engfunc(EngFunc_SetModel, Rocket, AT4Model_S);
        
        set_pev(Rocket, pev_mins, {-1.0, -1.0, -1.0});
        set_pev(Rocket, pev_maxs, {1.0, 1.0, 1.0});
        
        velocity_to_aim(id, Origin, 2000, Velocity)
        vector_to_angle(Velocity, Angles)
        set_pev(Rocket, pev_velocity, Velocity);
        set_pev(Rocket, pev_angles, Angles);
        
        set_pev(Rocket, pev_iuser4, 0);       
        set_pev(Rocket, pev_nextthink, halflife_time() + 0.1);
        
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
        write_byte(TE_BEAMFOLLOW); // TE id
        write_short(Rocket); // entity:attachment to follow
        write_short(at4_trail); // sprite index
        write_byte(3); // life in 0.1's
        write_byte(2); // line width in 0.1's
        write_byte(255); // r
        write_byte(255); // g
        write_byte(255); // b
        write_byte(200); // brightness
        message_end();
    }
}

public AT4_Think(Rocket) {
    if(is_valid_ent(Rocket)) {
        static Float:Origin[3];
        pev(Rocket, pev_origin, Origin);
        
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
        write_byte(TE_SPRITE);
        engfunc(EngFunc_WriteCoord, Origin[0]);
        engfunc(EngFunc_WriteCoord, Origin[1]);
        engfunc(EngFunc_WriteCoord, Origin[2]);
        write_short(at4_smoke);
        write_byte(2);
        write_byte(200);
        message_end();
        if(pev(Rocket, pev_iuser3) == 1) {
            if(pev(Rocket, pev_iuser4) == 0) {
                new Victim = FindClosesEnemy(Rocket);
                
                if(is_user_alive(Victim))
                    set_pev(Rocket, pev_iuser4, Victim);
            }
            else {
                new Victim = pev(Rocket, pev_iuser4);
                
                if(is_user_alive(Victim)) {
                    new Float:VictimOrigin[3], Float:Velocity[3], Float:Angles[3], Float:x;
                    pev(Victim, pev_origin, VictimOrigin);
                    
                    Velocity[0] = VictimOrigin[0] - Origin[0]
                    Velocity[1] = VictimOrigin[1] - Origin[1]
                    Velocity[2] = VictimOrigin[2] - Origin[2]
                    
                    x = floatsqroot(2000.0*2000.0 / (Velocity[0]*Velocity[0] + Velocity[1]*Velocity[1] + Velocity[2]*Velocity[2]))
                    
                    Velocity[0] *= x
                    Velocity[1] *= x
                    Velocity[2] *= x
                    
                    vector_to_angle(Velocity, Angles)
                    set_pev(Rocket, pev_velocity, Velocity);
                    set_pev(Rocket, pev_angles, Angles);
                }
                else
                    set_pev(Rocket, pev_iuser4, 0);
            }
        }
        set_pev(Rocket, pev_nextthink, halflife_time() + 0.075);
    }
}

public AT4_LaserDot_Think(LaserDot) {
    if(is_valid_ent(LaserDot)) {
        new Float:Origin[3],
        Owner = pev(LaserDot, pev_owner);
        
        if(is_user_alive(Owner) && get_user_weapon(Owner) == CSW_AT4 && get_user_at4(Owner)) {
            fm_get_aim_origin(Owner, Origin);
            
            set_pev(LaserDot, pev_origin, Origin);
            set_pev(LaserDot, pev_nextthink, halflife_time() + 0.001);
        }
        else engfunc(EngFunc_RemoveEntity, LaserDot);
    }
}

public AT4_Touch(Rocket, touch) {
    if(is_valid_ent(Rocket) && touch != pev(Rocket, pev_owner)) {
        new Float:RocketOrigin[3],
        id = pev(Rocket, pev_owner)
        pev(Rocket, pev_origin, RocketOrigin);   
        
        message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);
        write_byte(TE_EXPLOSION);
        engfunc(EngFunc_WriteCoord, RocketOrigin[0]);
        engfunc(EngFunc_WriteCoord, RocketOrigin[1]);
        engfunc(EngFunc_WriteCoord, RocketOrigin[2]);
        write_short(at4_explode);    // sprite index
        write_byte(40);            // scale in 0.1's
        write_byte(30);            // framerate
        write_byte(0);            // flags
        message_end();
        
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(TE_WORLDDECAL)
        engfunc(EngFunc_WriteCoord, RocketOrigin[0])
        engfunc(EngFunc_WriteCoord, RocketOrigin[1])
        engfunc(EngFunc_WriteCoord, RocketOrigin[2])
        write_byte(random_num(46, 48))
        message_end()   
        
        new Victim = -1;
        while((Victim = find_ent_in_sphere(Victim, RocketOrigin, str_to_float(WPN_AT4[AT4_RADIUS]))) != 0) {
            static ClassName[32];
            pev(Victim, pev_classname, ClassName, charsmax(ClassName));
            
            if(equal(ClassName, "player") && is_user_connected(Victim) && is_user_alive(Victim)) {
                if(!fm_get_user_godmode(Victim) && get_user_team(Victim) != get_user_team(id) && Victim != id) {
                    new Float:VictimOrigin[3], Float:Distance, Float:DistanceRatio, Float:Damage;
                    pev(Victim, pev_origin, VictimOrigin);
                    Distance = get_distance_f(RocketOrigin, VictimOrigin);
                    DistanceRatio = floatdiv(Distance, str_to_float(WPN_AT4[AT4_RADIUS]));
                    Damage = str_to_float(WPN_AT4[AT4_DAMAGE]) - floatround(floatmul(str_to_float(WPN_AT4[AT4_DAMAGE]), DistanceRatio)) * pev(Rocket, pev_fuser3);
                    
                    if(Victim == touch)
                        Damage = str_to_float(WPN_AT4[AT4_DAMAGE]) * pev(Rocket, pev_fuser3)
                    
                    make_blood(Victim, floatround(Damage))
                    make_knockback(Victim, RocketOrigin, str_to_float(WPN_AT4[AT4_KNOCKBACK])*Damage);   
                    
                    if(get_user_health(Victim) > Damage)
                        ExecuteHam(Ham_TakeDamage, Victim, id, id, Damage, DMG_BLAST);
                    else       
                        death_message(id, Victim, "at4");
                }
            }
            else if(is_valid_ent(Victim) && equal(ClassName, "func_breakable")) {       
                if(entity_get_float(Victim, EV_FL_health) <= str_to_float(WPN_AT4[AT4_DAMAGE]))
                    force_use(id, Victim);
            }
        }       
        engfunc(EngFunc_RemoveEntity, Rocket);
    }
}

public Hook_AT4(id) {
    engclient_cmd(id, weapon_at4);
    return PLUGIN_HANDLED
}

public get_user_at4(id)
    return get_weapon(id, weapon_at4, CSW_AT4, AT4ID)

public set_user_at4(id)
    return set_weapon(id, WPN_PRIMARY, AT4ID)

public at4_id()
    return AT4ID
    
stock FindClosesEnemy(ent) {
    new Float:Dist;
    new Float:MaxDistance = 100.0;
    for(new i = 1; i <= get_maxplayers(); i++){
        if(is_user_alive(i) && is_valid_ent(i) && can_see_fm(ent, i) && pev(ent, pev_owner) != i && cs_get_user_team(pev(ent, pev_owner)) != cs_get_user_team(i)) {
            Dist = entity_range(ent, i);
            if(Dist <= MaxDistance)
                return i;
        }   
    }   
    return 0;
}

stock bool:can_see_fm(entindex1, entindex2) {
    if(!entindex1 || !entindex2)
        return false;
    
    if(pev_valid(entindex1) && pev_valid(entindex1)) {
        new flags = pev(entindex1, pev_flags);
        if(flags & EF_NODRAW || flags & FL_NOTARGET) {
            return false;
        }
        
        new Float:lookerOrig[3];
        new Float:targetBaseOrig[3];
        new Float:targetOrig[3];
        new Float:temp[3];
        
        pev(entindex1, pev_origin, lookerOrig);
        pev(entindex1, pev_view_ofs, temp);
        lookerOrig[0] += temp[0];
        lookerOrig[1] += temp[1];
        lookerOrig[2] += temp[2];
        
        pev(entindex2, pev_origin, targetBaseOrig);
        pev(entindex2, pev_view_ofs, temp);
        targetOrig[0] = targetBaseOrig[0] + temp[0];
        targetOrig[1] = targetBaseOrig[1] + temp[1];
        targetOrig[2] = targetBaseOrig[2] + temp[2];
        
        engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the had of seen player
        if(get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater)) {
            return false;
        }
        else {
            new Float:flFraction;
            get_tr2(0, TraceResult:TR_flFraction, flFraction);
            if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
                return true;
            }
            else {
                targetOrig[0] = targetBaseOrig[0];
                targetOrig[1] = targetBaseOrig[1];
                targetOrig[2] = targetBaseOrig[2];
                engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the body of seen player
                get_tr2(0, TraceResult:TR_flFraction, flFraction);
                if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
                    return true;
                }
                else {
                    targetOrig[0] = targetBaseOrig[0];
                    targetOrig[1] = targetBaseOrig[1];
                    targetOrig[2] = targetBaseOrig[2] - 17.0;
                    engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); //  checks the legs of seen player
                    get_tr2(0, TraceResult:TR_flFraction, flFraction);
                    if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
 
Сообщения
1,420
Реакции
2,511
Помог
58 раз(а)
Если это предусмотренный функционал плагина и должно работать, то тему нужно создавать в разделе Проблемы с работой плагинов.
Если такой функционал не предусмотрен то подразумевается что это "хотелка", соответственно нужно в раздел Заказы и услуги.
В этом же разделе можно показать свои попытки в создании/модификации требуемого и получить помощь.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу