Circle ent

Сообщения
24
Реакции
0
Hi, I would like to create a circle ent and detect touch like here
.
Is it only possible by $flags 512? Is there any other way to hitbox collision?
 

Garey

ninjaCow
Сообщения
440
Реакции
1,094
Помог
11 раз(а)
faken, possible also by bsp-brush collision
 
Сообщения
459
Реакции
272
Помог
9 раз(а)
SOLID_BBOX, SetTouch, SetModel ..
 
Сообщения
459
Реакции
272
Помог
9 раз(а)
faken,
Код:
#include <amxmodx>
#include <fakemeta>
#include <reapi>

#pragma semicolon 1

#define DROP

#define MODEL "models/model.mdl" //u model

new Float: g_fLastAction[MAX_PLAYERS + 1] = { 0.0, ... };

public plugin_precache()    {
    precache_model(MODEL);
}

public plugin_init()    {
    register_clcmd("set_entity", "clcmd_action");
}

public clcmd_action(id) {
    new wtf = rg_create_entity("info_target");

    if (is_nullent(wtf))    {
        return;
    }

    set_entvar(wtf, var_classname, "wtf");
    set_entvar(wtf, var_solid, SOLID_BBOX);
    set_entvar(wtf, var_movetype, MOVETYPE_NONE);

    engfunc(EngFunc_SetModel, wtf, MODEL);
    engfunc(EngFunc_SetSize, wtf, { -30.0, -30.0, 5.0 }, { 30.0, 30.0, 5.0 });

    new Float: origin[3];
    fm_get_aim_origin(id, origin);

    engfunc(EngFunc_SetOrigin, origin);

    #if defined DROP
        engfunc(EngFunc_DropToFloor, wtf);
    #endif

    SetTouch(wtf, "touch_callback");
}

public touch_callback(const ent, const other)   {
    if (0 > other > MaxClients || !is_user_alive(other)) {
        SetTouch(ent, "");
        return;
    }

    if (g_fLastAction[other] > get_gametime())   {
        client_print(other, print_center, "*touched*");

        g_fLastAction[other] = get_gametime() + 2.0;
    }
}

//fakemeta util
stock fm_get_aim_origin(index, Float:origin[3]) {
    new Float:start[3], Float:view_ofs[3];
    pev(index, pev_origin, start);
    pev(index, pev_view_ofs, view_ofs);
    UTIL_VecAdd(start, view_ofs, start);

    new Float:dest[3];
    pev(index, pev_v_angle, dest);
    engfunc(EngFunc_MakeVectors, dest);
    global_get(glb_v_forward, dest);
    UTIL_VecMulScalar(dest, 9999.0, dest);
    UTIL_VecAdd(start, dest, dest);

    engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
    get_tr2(0, TR_vecEndPos, origin);

    return 1;
}

stock UTIL_VecAdd(const Float: fVectorA[3], const Float: fVectorB[3], Float: fOut[3])    {
    fOut[0] = fVectorA[0] + fVectorB[0];
    fOut[1] = fVectorA[1] + fVectorB[1];
    fOut[2] = fVectorA[2] + fVectorB[2];
}

stock UTIL_VecMulScalar(const Float: fVector[3], const Float: fScalar, Float: fOut[3])    {
    fOut[0] = fVector[0] * fScalar;
    fOut[1] = fVector[1] * fScalar;
    fOut[2] = fVector[2] * fScalar;
}
 
Сообщения
24
Реакции
0
faken,
Код:
#include <amxmodx>
#include <fakemeta>
#include <reapi>

#pragma semicolon 1

#define DROP

#define MODEL "models/model.mdl" //u model

new Float: g_fLastAction[MAX_PLAYERS + 1] = { 0.0, ... };

public plugin_precache()    {
    precache_model(MODEL);
}

public plugin_init()    {
    register_clcmd("set_entity", "clcmd_action");
}

public clcmd_action(id) {
    new wtf = rg_create_entity("info_target");

    if (is_nullent(wtf))    {
        return;
    }

    set_entvar(wtf, var_classname, "wtf");
    set_entvar(wtf, var_solid, SOLID_BBOX);
    set_entvar(wtf, var_movetype, MOVETYPE_NONE);

    engfunc(EngFunc_SetModel, wtf, MODEL);
    engfunc(EngFunc_SetSize, wtf, { -30.0, -30.0, 5.0 }, { 30.0, 30.0, 5.0 });

    new Float: origin[3];
    fm_get_aim_origin(id, origin);

    engfunc(EngFunc_SetOrigin, origin);

    #if defined DROP
        engfunc(EngFunc_DropToFloor, wtf);
    #endif

    SetTouch(wtf, "touch_callback");
}

public touch_callback(const ent, const other)   {
    if (0 > other > MaxClients || !is_user_alive(other)) {
        SetTouch(ent, "");
        return;
    }

    if (g_fLastAction[other] > get_gametime())   {
        client_print(other, print_center, "*touched*");

        g_fLastAction[other] = get_gametime() + 2.0;
    }
}

//fakemeta util
stock fm_get_aim_origin(index, Float:origin[3]) {
    new Float:start[3], Float:view_ofs[3];
    pev(index, pev_origin, start);
    pev(index, pev_view_ofs, view_ofs);
    UTIL_VecAdd(start, view_ofs, start);

    new Float:dest[3];
    pev(index, pev_v_angle, dest);
    engfunc(EngFunc_MakeVectors, dest);
    global_get(glb_v_forward, dest);
    UTIL_VecMulScalar(dest, 9999.0, dest);
    UTIL_VecAdd(start, dest, dest);

    engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
    get_tr2(0, TR_vecEndPos, origin);

    return 1;
}

stock UTIL_VecAdd(const Float: fVectorA[3], const Float: fVectorB[3], Float: fOut[3])    {
    fOut[0] = fVectorA[0] + fVectorB[0];
    fOut[1] = fVectorA[1] + fVectorB[1];
    fOut[2] = fVectorA[2] + fVectorB[2];
}

stock UTIL_VecMulScalar(const Float: fVector[3], const Float: fScalar, Float: fOut[3])    {
    fOut[0] = fVector[0] * fScalar;
    fOut[1] = fVector[1] * fScalar;
    fOut[2] = fVector[2] * fScalar;
}
Not working, hitbox is still cuboid. I want a wheel like in a movie. I think it is impossible, only $flags 512 in model. But if I create too many such models, the FPS drops ...
 

Garey

ninjaCow
Сообщения
440
Реакции
1,094
Помог
11 раз(а)
faken Create bsp model in editor and use it. Yes you can rotate, move model etc.
 
Сообщения
24
Реакции
0
faken Create bsp model in editor and use it. Yes you can rotate, move model etc.
I did something like this:
x.bsp = blank map with clip texture and entity info_null
x.mdl = circle model.
Код:
#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

enum _:Wut{
    BSP,
    MDL
};

new g_sWut[Wut][0xE] = {
    "maps/x.bsp",
    "models/x.mdl"
};

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_concmd("create", "_Stworz");
}

public plugin_precache() {
    for(new i ; i < Wut ; i++) precache_model(g_sWut[i]);
}

public _Stworz(id){
    new Float:fOrigin[0x3];
    entity_get_vector(id, EV_VEC_origin, fOrigin);
    fOrigin[0x2]-=36.0;
    
    new iEnt = create_entity("func_wall");
    entity_set_origin(iEnt, fOrigin);
    entity_set_int(iEnt, EV_INT_movetype, 0x7); //MOVETYPE_PUSH
    entity_set_int(iEnt, EV_INT_solid, 0x4); // SOLID_BSP
    entity_set_model(iEnt, g_sWut[BSP]);
    
    new iRendered = create_entity("info_target");
    entity_set_origin(iRendered, fOrigin);
    entity_set_model(iRendered, g_sWut[MDL]);
}
Hitbox works, but I can't move and rotate, angles etc. Any ideas how to rotate it and mix it with a working hitbox?
 

iPlague

♿️
Сообщения
230
Реакции
130
Помог
2 раз(а)
use think and rotate into this think

f.e., into think:

set_entvar(ent, var_avelocity, Float:{ 0.0, 20.0, 0.0 });
set_entvar(ent, var_nextthink, get_gametime() + 2.0);

also model has to be above the ground (don't touch, because it prevents rotating)
 

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

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