Raised This Month: $ Target: $400
 0% 

Entity go though wall and but still trigger when touch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-08-2022 , 17:17   Re: Entity go though wall and but still trigger when touch
Reply With Quote #1

I didn't understand your question. You want the rocket to explode when it hit objects in the world but it should not stop, instead, it will fly through the object as the spectators and will be removed when it flies out of the world "bounding box"? If so, set the entity move type to noclip as you first thought and constantly trace a monster hull. When the trace hits anything, create an explosion at the point of the collision. To determine if the entity is outside the world boundary, use CBaseEntity::IsInWorld, already implemented in engine_stocks.inc.

https://github.com/s1lentq/ReGameDLL...cbase.cpp#L856
https://github.com/alliedmodders/amx...tocks.inc#L225

If you want to prevent it from exploding if it is already within the object, check if it is the first time that the trace returns true (for that particular entity if isn't -1), may fail in some conditions but I think you will be ok. Pseudo-code:

Code:
IAmThinking()
{

	if (not IAmExplodable())
	{
		TraceALineForward()

		if (not TraceHitAnything())
		{
			MarkMeAsExplodable()
		}
	}

	TraceAHull()

	if (TraceHitAnything() and (IAmExplodable() or TraceHitEntityIsNotTheOneIAmNow()))
	{
		ExplodeMePlease()
		MarkMeAsNonExplodable()
	}
}
}
Code for testing, hit radio1 key to create a Cool Entity that will fly through everything.

Code:
#include <amxmodx> #include <engine> #include <fakemeta> new g_spriteIndexLaserBeam public plugin_init() {     register_clcmd("radio1", "CreateCoolEntity")     register_think("my_cool_entity", "CoolEntity_Think") } public plugin_precache() {     g_spriteIndexLaserBeam = precache_model("sprites/laserbeam.spr") } public CreateCoolEntity(index) {     new Float:origin[3]     entity_get_vector(index, EV_VEC_origin, origin)     new entity = create_entity("info_target")     entity_set_string(entity, EV_SZ_classname, "my_cool_entity")     entity_set_int(entity, EV_INT_solid, SOLID_BBOX)     entity_set_int(entity, EV_INT_movetype, MOVETYPE_NOCLIP)     entity_set_edict(entity, EV_ENT_owner, index)     entity_set_model(entity, "models/player/sas/sas.mdl")     entity_set_size(entity, Float:{-16.0, -16.0, -16.0}, Float:{16.0, 16.0, 16.0})     entity_set_origin(entity, origin)     new Float:velocity[3]     velocity_by_aim(index, 150, velocity)     entity_set_vector(entity, EV_VEC_velocity, velocity)     entity_set_float(entity, EV_FL_nextthink, get_gametime() + 0.1)     return PLUGIN_HANDLED } public CoolEntity_Think(entity) {     if (!IsInWorld(entity))     {         // Queue entity for deletion         // This is safier than removing the entity directly         entity_set_int(entity, EV_INT_flags, FL_KILLME)         entity_set_int(entity, EV_INT_effects, EF_NODRAW)         return     }     new Float:origin[3]     entity_get_vector(entity, EV_VEC_origin, origin)     static traceHandle     traceHandle = 0     engfunc(EngFunc_TraceMonsterHull, entity, origin, origin, DONT_IGNORE_MONSTERS, entity, traceHandle)     if (get_tr2(traceHandle, TR_StartSolid) || get_tr2(traceHandle, TR_AllSolid))     {         get_tr2(traceHandle, TR_vecEndPos, origin)         // Create an explosion here         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)         write_byte(TE_BEAMPOINTS)         write_coord_f(origin[0])         write_coord_f(origin[1])         write_coord_f(origin[2])         write_coord_f(origin[0])         write_coord_f(origin[1])         write_coord_f(origin[2] + 9999.0)         write_short(g_spriteIndexLaserBeam)         write_byte(0)         write_byte(0)         write_byte(100)         write_byte(20)         write_byte(0)         write_byte(255)         write_byte(0)         write_byte(0)         write_byte(255)         write_byte(0)         message_end()     }     entity_set_float(entity, EV_FL_nextthink, get_gametime() + 0.1) }
__________________









Last edited by CrazY.; 01-08-2022 at 18:14.
CrazY. 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 11:45.


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