Raised This Month: $32 Target: $400
 8% 

Entity go though wall and but still trigger when touch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 01-07-2022 , 02:14   Entity go though wall and but still trigger when touch
Reply With Quote #1

I tried to create an rocket entity that go can go though wall (I think about MOVETYPE_NOCLIP or MOVETYPE_FLY + SOLID_TRIGGER) and explode when contact. If it touch skybox, it will remove itself

For easier understanding, this is what I want to do:


I was thinking about using traceline but I wanted it to travel instead of instant explode at all position so I save that if this isn't possible.
__________________
My plugin:

Last edited by Celena Luna; 01-07-2022 at 02:14.
Celena Luna is offline
zXCaptainXz
Member
Join Date: May 2017
Old 01-07-2022 , 07:08   Re: Entity go though wall and but still trigger when touch
Reply With Quote #2

Try this out

Code:
#include <amxmodx>
#include <engine>

new Explosion;

public plugin_init()
{
    register_plugin("Test Rocket","1.0","zXCaptainXz")
    register_clcmd("create_rocket","create_rocket")
    register_touch("amxx_rocket","*","fw_touch")
}

public plugin_precache() {

	precache_model("models/rpgrocket.mdl")
	Explosion = precache_model("sprites/zerogxplode.spr")
}

public create_rocket(id)
{
    new ent = create_entity("info_target")

    if(!ent)
        return PLUGIN_HANDLED;
    
    entity_set_string(ent, EV_SZ_classname, "amxx_rocket")
    entity_set_model(ent, "models/rpgrocket.mdl")    

    new Float:min[3] = {-1.0, -1.0, -1.0}
    new Float:max[3] = {1.0, 1.0, 1.0}

    entity_set_vector(ent, EV_VEC_mins,min)
    entity_set_vector(ent, EV_VEC_maxs,max)

    new Float:origin[3]
    entity_get_vector(id, EV_VEC_origin, origin)   
    new Float:velocity[3]
    VelocityByAim(id, 50, velocity)
    new Float:angle[3]
    vector_to_angle(velocity,angle)

    entity_set_origin(ent, origin)
    entity_set_vector(ent, EV_VEC_angles,angle)
    entity_set_vector(ent, EV_VEC_velocity, velocity)   

    entity_set_int(ent, EV_INT_solid, SOLID_BBOX)
    entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY);
    entity_set_edict(ent, EV_ENT_owner, id)
    entity_set_float(ent, EV_FL_health, 10000.0)
    entity_set_float(ent, EV_FL_takedamage, 100.0)
    entity_set_float(ent, EV_FL_dmg_take, 100.0)
    
    emit_sound(ent, CHAN_WEAPON, "weapons/rocketfire1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    emit_sound(ent, CHAN_VOICE, "weapons/rocket1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    return PLUGIN_HANDLED;
}

public fw_touch(ent, touched)
{       
    if(!is_valid_ent(touched))
    {
        client_cmd(0, "stopsound")
        remove_entity(ent)        
        return
    }

    new Float:origin[3], Float:velocity[3], Float:angle[3]

    entity_get_vector(ent, EV_VEC_angles,angle)    

    entity_get_vector(ent, EV_VEC_origin, origin)    

    entity_get_vector(ent, EV_VEC_velocity, velocity)
    
    remove_entity(ent)
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(3)
    write_coord(floatround(origin[0]))
    write_coord(floatround(origin[1]))
    write_coord(floatround(origin[2]))
    write_short(Explosion)
    write_byte(100)
    write_byte(15)
    write_byte(0)
    message_end()

    ent = 0;
    ent = create_entity("info_target")
    
    if(!ent)
        return;
    
    entity_set_string(ent, EV_SZ_classname, "amxx_rocket")
    entity_set_model(ent, "models/rpgrocket.mdl")    

    new Float:min[3] = {-1.0, -1.0, -1.0}
    new Float:max[3] = {1.0, 1.0, 1.0}

    entity_set_vector(ent, EV_VEC_mins,min)
    entity_set_vector(ent, EV_VEC_maxs,max)

    entity_set_origin(ent, origin)
    entity_set_vector(ent, EV_VEC_angles,angle)
    entity_set_vector(ent, EV_VEC_velocity, velocity)   

    entity_set_int(ent, EV_INT_solid, SOLID_BBOX)
    entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY);
    entity_set_edict(ent, EV_ENT_owner, touched)
    entity_set_float(ent, EV_FL_health, 10000.0)
    entity_set_float(ent, EV_FL_takedamage, 100.0)
    entity_set_float(ent, EV_FL_dmg_take, 100.0)      
}

Last edited by zXCaptainXz; 01-07-2022 at 07:25.
zXCaptainXz is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 01-08-2022 , 12:22   Re: Entity go though wall and but still trigger when touch
Reply With Quote #3

Quote:
Originally Posted by zXCaptainXz View Post
Try this out
Spoiler
I don't think this would make the rocket go though walls
by "walls" I mean even thick wall/building
__________________
My plugin:
Celena Luna is offline
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 #4

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
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-08-2022 , 18:13   Re: Entity go though wall and but still trigger when touch
Reply With Quote #5

When you mean walls ? you mean entities or worldspawn walls?


also try zXCaptainXz code but change the movetype
PHP Code:
    entity_set_int(entEV_INT_solidSOLID_BBOX)
    
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY); 


PHP Code:
    entity_set_int(entEV_INT_solidSOLID_BBOX)
    
entity_set_int(entEV_INT_movetypeMOVETYPE_NOCLIP); 
and remove the entity when its not within the world.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-08-2022 at 18:18.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
zXCaptainXz
Member
Join Date: May 2017
Old 01-08-2022 , 23:35   Re: Entity go though wall and but still trigger when touch
Reply With Quote #6

Quote:
Originally Posted by Celena Luna View Post
I don't think this would make the rocket go though walls
by "walls" I mean even thick wall/building
My bad I thought you meant everything but worldspawn, I have an idea in mind but I feel like it's difficult for me to implement and it's not very efficient
zXCaptainXz is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 01-09-2022 , 18:07   Re: Entity go though wall and but still trigger when touch
Reply With Quote #7

Quote:
Originally Posted by Celena Luna View Post
I was thinking about using traceline but I wanted it to travel instead of instant explode at all position so I save that if this isn't possible.
Traceline, get all explosion origins and set delayed explosions with task or thinking

Last edited by baneado; 01-09-2022 at 18:12.
baneado is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 01-09-2022 , 22:12   Re: Entity go though wall and but still trigger when touch
Reply With Quote #8

Quote:
Originally Posted by CrazY. View Post
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:

Spoiler
Thank you, I will give it a try later on.
What I mean is "the rocket touch any surface or entity, it will explode. But instead of disappear, it go though that wall, explode when touch the next surface or entity"

For example:
- You stand above CT spawn (A short) in Dust2, you shoot under your feet, it will explode under your feet but also go though and explode in CT spawn.
- You stand behind the lower box that can see from Long A (usually used for silent C4) in A site. You facing the wall that face to the A site and shoot. It explode there but also go though and explode at B Window

Quote:
Originally Posted by Natsheh View Post
When you mean walls ? you mean entities or worldspawn walls
building walls, terrain, prop, entity,... All of them.
I want the entity to go though all of them but explode when it touch walls or entity. And then when it touch the skybox, remove it to prevent any crash might happened.

Quote:
Originally Posted by zXCaptainXz View Post
My bad I thought you meant everything but worldspawn, I have an idea in mind but I feel like it's difficult for me to implement and it's not very efficient
It is ok, thanks for helping out.

Quote:
Originally Posted by baneado View Post
Traceline, get all explosion origins and set delayed explosions with task or thinking
I was thinking about using Traceline so I don't have to using entity but I kind of stuck at thinking about when it get out of the walls/terrains to allow it touch and explode again.
__________________
My plugin:

Last edited by Celena Luna; 01-09-2022 at 23:36.
Celena Luna is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-10-2022 , 02:37   Re: Entity go though wall and but still trigger when touch
Reply With Quote #9

You have three types of objects
1.point entities ( player, info_targrt, sprites, etc... )
2. Brush Entities ( func_breakable, glass, door, etc.. (
3. Worldspawn which ID is 0, its not an entity.

Btw if any entity went outside of the sky/world a crash won't happen, you can tell when a player uses noclip and goes out of the map.

But if you spawn a point entity outside the world it might crash not sure.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-10-2022 at 03:24.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 01-11-2022 , 12:54   Re: Entity go though wall and but still trigger when touch
Reply With Quote #10



It is not totally correct but I think I can work out from here
Thanks for your help @CrazY. ^^
__________________
My plugin:
Celena Luna is offline
Reply


Thread Tools
Display Modes

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 22:15.


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