Raised This Month: $51 Target: $400
 12% 

[HELP] CSGO Weapon Physics


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaokb
Junior Member
Join Date: Apr 2021
Location: brazil
Old 06-10-2021 , 20:04   [HELP] CSGO Weapon Physics
Reply With Quote #1

hey, im having some problem with this plugin, it add's some physics to the dropped weapon when you shoot them etc, but when i drop any grenade it keeps boucing arround the map forever, how can i do to this plugin dont works with nades? thx

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <fakemeta_util>
#include <xs>
#include <csgomod>

#define PLUGIN "CS:GO Weapon Physics"
#define AUTHOR "O'Zone & Nomexous"

new const persistent[][] = { "armoury_entity" };
new const 
spawnable[][] = { "weaponbox""item_thighpack" };

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_event("HLTV""restart""a""1=0""2=0");

    
register_forward(FM_TraceLine"forward_traceline"1);

    for (new 
0sizeof persistenti++) {
        
RegisterHam(Ham_Spawnpersistent[i], "spawn_persistent_item"1);
        
RegisterHam(Ham_Touchpersistent[i], "touch_item");
        
RegisterHam(Ham_TakeDamagepersistent[i], "damage_item");
        
RegisterHam(Ham_TraceAttackpersistent[i], "shoot_item");
    }

    for (new 
0sizeof spawnablei++) {
        
RegisterHam(Ham_Spawnspawnable[i], "spawn_item"1);
        
RegisterHam(Ham_Touchspawnable[i], "touch_item");
        
RegisterHam(Ham_TakeDamagespawnable[i], "damage_item");
        
RegisterHam(Ham_TraceAttackspawnable[i], "shoot_item");
    }
}

public 
restart()
{
    for (new 
isizeof persistenti++) {
        new 
entity;

        while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"persistent[i]))) {
            static 
Float:origin[3], Float:angles[3];

            
pev(entitypev_vuser1origin);
            
pev(entitypev_vuser2angles);
            
set_pev(entitypev_anglesangles);
            
set_pev(entitypev_avelocityFloat:{0.00.00.0});
            
engfunc(EngFunc_SetOriginentityorigin);
            
engfunc(EngFunc_DropToFloorentity);
        }
    }
}

public 
spawn_item(entity)
{
    if (!
pev_valid(entity)) return HAM_IGNORED;

    static 
className[32];

    
pev(entitypev_classnameclassNamecharsmax(className));

    
set_pev(entitypev_movetypeMOVETYPE_BOUNCE);
    
set_pev(entitypev_takedamageDAMAGE_YES);
    
set_pev(entitypev_health100.0);

    return 
HAM_IGNORED;
}

public 
spawn_persistent_item(entity)
{
    if (!
pev_valid(entity)) return HAM_IGNORED;

    
set_pev(entitypev_movetypeMOVETYPE_BOUNCE);
    
set_pev(entitypev_takedamageDAMAGE_YES);
    
set_pev(entitypev_health100.0);

    new 
Float:origin[3], Float:angles[3];

    
pev(entitypev_originorigin);
    
pev(entitypev_anglesangles);
    
set_pev(entitypev_vuser1origin);
    
set_pev(entitypev_vuser2angles);

    return 
HAM_IGNORED;
}

public 
damage_item(entityinflictorattackerFloat:damagedamagebits)
{
    if (
pev(entitypev_effects) & EF_NODRAW) return HAM_IGNORED;

    static 
Float:velocity[3], Float:entityOrigin[3], Float:inflictorOrigin[3], Float:temp[3];

    
pev(entitypev_velocityvelocity);
    
pev(entitypev_originentityOrigin);
    
pev(inflictorpev_origininflictorOrigin);

    
xs_vec_sub(entityOrigininflictorOrigintemp);
    
xs_vec_normalize(temptemp);
    
xs_vec_mul_scalar(tempdamagetemp);
    
xs_vec_mul_scalar(temp30.0temp);
    
xs_vec_add(velocitytempvelocity);

    
set_pev(entitypev_velocityvelocity);

    static 
Float:avelocity[3];

    
avelocity[1] = random_float(-1000.01000.0);

    
set_pev(entitypev_avelocityavelocity);

    
SetHamParamFloat(40.0);

    return 
HAM_HANDLED;
}

public 
shoot_item(entityattackerFloat:damageFloat:direction[3], tracedamagebits)
{
    static 
Float:endpoint[3], Float:velocity[3];

    
get_tr2(traceTR_vecEndPosendpoint);

    
draw_spark(endpoint);

    
pev(entitypev_velocityvelocity);

    
xs_vec_mul_scalar(directiondamagedirection);
    
xs_vec_mul_scalar(direction15.0direction);
    
xs_vec_add(directionvelocityvelocity);
    
set_pev(entitypev_velocityvelocity);

    return 
HAM_IGNORED;
}

public 
touch_item(entitytouched)
{
    if (
pev(touchedpev_solid) < SOLID_BBOX || is_user_alive(touched)) return HAM_IGNORED;

    if (
fm_get_weaponbox_type(entity) == CSW_C4) {
        
set_pev(entitypev_movetypeMOVETYPE_TOSS);
    }

    if (!
is_shootable_entity(entity)) return HAM_IGNORED;

    static 
Float:velocity[3];

    
pev(entitypev_velocityvelocity);

    if (
xs_vec_len(velocity) > 700.0) {
        static 
Float:origin[3];

        
pev(entitypev_originorigin);

        
origin[0] += random_float(-10.010.0);
        
origin[1] += random_float(-10.010.0);
        
origin[2] += random_float(-10.010.0);

        
draw_spark(origin);

        
xs_vec_mul_scalar(velocity0.4velocity);
    } else {
        
xs_vec_mul_scalar(velocity0.1velocity);
    }

    
set_pev(entitypev_velocityvelocity);

    return 
HAM_IGNORED;
}

public 
forward_traceline(Float:start[3], Float:end[3], conditionsidtrace)
{
    if (!
pev_valid(id) || !is_user_alive(id) || is_user_alive(get_tr2(traceTR_pHit))) return FMRES_IGNORED;

    static 
Float:endPoint[3];

    
get_tr2(traceTR_vecEndPosendPoint);

    new 
entity 0traceLine 0;

    while ((
entity engfunc(EngFunc_FindEntityInSphereentityendPoint20.0))) {
        if (
is_shootable_entity(entity)) {
            
engfunc(EngFunc_TraceModelstartendHULL_POINTentitytraceLine);

            if (
pev_valid(get_tr2(traceLineTR_pHit))) {
                
get_tr2(traceLineTR_vecEndPosendPoint);
                
set_tr2(traceTR_vecEndPosendPoint);

                
set_tr2(traceTR_pHitentity);

                return 
FMRES_IGNORED;
            }
        }
    }

    return 
FMRES_IGNORED;
}

public 
is_shootable_entity(entity)
{
    static 
className[32];

    
pev(entitypev_classnameclassNamecharsmax(className));

    if (
equal(className"weaponbox") && fm_get_weaponbox_type(entity) == CSW_C4) return false;

    for (new 
isizeof spawnablei++) {
        if (
equal(classNamespawnable[i])) return true;
    }

    return 
false;
}

stock draw_spark(Float:origin[3])
{
    
message_begin(MSG_ALLSVC_TEMPENTITY);
    
write_byte(TE_SPARKS);
    
engfunc(EngFunc_WriteCoordorigin[0]);
    
engfunc(EngFunc_WriteCoordorigin[1]);
    
engfunc(EngFunc_WriteCoordorigin[2]);
    
message_end();

__________________
⠀⠀⠀⠀⠀⠀
⠀⠀kabest
joaokb is offline
Reply



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

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

Forum Jump


All times are GMT -4. The time now is 16:52.


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