Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
|
03-30-2022
, 19:33
Re: Ring Backpack
|
#2
|
PHP Code:
set_pev(iEnt, pev_nextthink, time + 0.1)
It seems that when removing that part, the model is set and not removed.
Edit: I edited some parts of the code, I know it's not the right section but I had free time to do so. I've named the changes so it's easier for you to understand 'em.
By my perspective, your code was doing some weird things besides that issue. Let me know if that code I'm providing is what you wanted, it doesn't conflict with the Weapon Physics and also skips the wall.
PHP Code:
#pragma semicolon 1
#include <amxmodx> #include <fakemeta> #include <engine> #include <xs>
new g_Backpack_SmokeSprite;
#define BOMB_PACK_ICON "sprites/backpack_smoke/backpack_ring.spr" #define RING_CLASSNAME "Bomb_Ring"
#define RING_BOMB_ENTITY pev_iuser1
new Float:fColor[][3] = { {255.0, 0.0, 0.0}, {0.0, 0.0, 255.0}, {0.0, 255.0, 0.0}, {255.0, 255.0, 6.0}, {255.0, 0.0, 255.0} };
public plugin_init() { register_plugin("C4 Smoke", "1.0", "fl0wer"); register_touch("worldspawn", "weaponbox", "weaponboxTouch"); register_think(RING_CLASSNAME, "ringThink"); }
public plugin_precache() { g_Backpack_SmokeSprite = precache_model("sprites/backpack_smoke/backpack_smoke.spr"); precache_model(BOMB_PACK_ICON); }
public weaponboxTouch(iWorldSpawn, iBombEntity) { if(!pev_valid(iBombEntity)) return PLUGIN_HANDLED; static szBombModel[32]; pev(iBombEntity, pev_model, szBombModel, charsmax(szBombModel)); if(containi(szBombModel, "w_backpack") == -1) return PLUGIN_HANDLED; if(pev(iBombEntity, pev_flags) & ~FL_ONGROUND) return PLUGIN_HANDLED; static Float:vecOrigin[3]; pev(iBombEntity, pev_origin, vecOrigin); // lie flat code ^^ static Float:fTraceTo[3], Float:fFraction; xs_vec_sub(vecOrigin, Float:{0.0, 0.0, 10.0}, fTraceTo); engfunc(EngFunc_TraceLine, vecOrigin, fTraceTo, IGNORE_MONSTERS, iBombEntity, 0); get_tr2(0, TR_flFraction, fFraction); if(fFraction == 1.0) return PLUGIN_HANDLED; static bombEntity;bombEntity = pev(iBombEntity, RING_BOMB_ENTITY); if(bombEntity) { if(bombEntity > get_maxplayers()) { remove_task(iBombEntity); set_task(0.5, "makeBombFloat", iBombEntity); } return PLUGIN_HANDLED; } switch(random_num(0, 1)) { case 0: { remove_task(iBombEntity); set_pev(iBombEntity, RING_BOMB_ENTITY, pev(iBombEntity, pev_owner)); smokeEffect(iBombEntity); } case 1: { new iEnt = create_entity("env_sprite"); if(pev_valid(iEnt)) { set_pev(iBombEntity, RING_BOMB_ENTITY, iEnt); remove_task(iBombEntity); set_task(0.5, "makeBombFloat", iBombEntity); } } } return PLUGIN_HANDLED; }
public makeBombFloat(iBombEntity) { if(!pev_valid(iBombEntity)) return; static Float:vecOrigin[3], iRingEntity;iRingEntity = pev(iBombEntity, RING_BOMB_ENTITY); pev(iBombEntity, pev_origin, vecOrigin); vecOrigin[2] += 30.0; engfunc(EngFunc_SetOrigin, iBombEntity, vecOrigin); // use this to change the ring origin, so you can make the bomb be right in the middle vecOrigin[2] += 0.0; engfunc(EngFunc_SetOrigin, iRingEntity, vecOrigin);
set_pev(iRingEntity, pev_classname, RING_CLASSNAME); engfunc(EngFunc_SetOrigin, iRingEntity, vecOrigin); engfunc(EngFunc_SetModel, iRingEntity, BOMB_PACK_ICON); set_pev(iRingEntity, pev_solid, SOLID_NOT); set_pev(iRingEntity, pev_movetype, MOVETYPE_FLY); set_pev(iRingEntity, pev_nextthink, get_gametime()); set_pev(iRingEntity, RING_BOMB_ENTITY, iBombEntity); set_pev(iRingEntity, pev_rendercolor, fColor[random_num(0, charsmax(fColor))]); }
public smokeEffect(iBombEntity) { if(!pev_valid(iBombEntity)) return; static Float:vecOrigin[3]; pev(iBombEntity, pev_origin, vecOrigin); engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin, 0); write_byte(TE_FIREFIELD); engfunc(EngFunc_WriteCoord, vecOrigin[0]); engfunc(EngFunc_WriteCoord, vecOrigin[1]); engfunc(EngFunc_WriteCoord, vecOrigin[2] += 15.0); write_short(2); write_short(g_Backpack_SmokeSprite); write_byte(1); write_byte(TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA); write_byte(10); message_end(); set_task(0.3, "smokeEffect", iBombEntity); }
public ringThink(ent) { if(!pev_valid(ent)) return; if(!pev_valid(pev(ent, RING_BOMB_ENTITY))) { remove_entity(ent); return; } set_pev(ent, pev_nextthink, get_gametime() + 0.5); }
__________________
Last edited by EFFx; 04-02-2022 at 16:35.
|
|