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
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 #1

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 #2

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
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 #3

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
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