Raised This Month: $ Target: $400
 0% 

Solved [ H3LP ] Explode entity ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-03-2017 , 18:30   [ H3LP ] Explode entity ?
Reply With Quote #1

Hey AlliedModders, currently I am developing a simple spawn model effect. Crazy? about what you are talkig (what the hell are this) ? Well, when a player spawn, a egg model is added into the player origin. I want explode this egg, but the egg model dont have a explode animation, then I used the following code to do that, but dont work well. Any idea?

Code:
public fw_PlayerSpawn_Post(id) {     if (!is_user_alive(id) || !cs_get_user_team(id))         return;             new entity = create_entity("info_target");         if (!pev_valid(entity))         return;             new Float:origin[3];     entity_get_vector(id, EV_VEC_origin, origin);         set_pev(entity, pev_body, 1);     entity_set_model(entity, EGG_MODEL);         origin[2] -= 25;     entity_set_origin(entity, origin);         set_pev(entity, pev_owner, id);     entity_set_string(entity, EV_SZ_classname, "egg_class");     entity_set_int(entity, EV_INT_solid, 2);         if (get_cvar_num("mp_freezetime") <= 0)         explode_egg(id); } public explode_egg(id) {     if (!is_user_connected(id))         return;             new entity = find_ent_by_owner(0, "egg_class", id);         // I dont know exactly if this is correct.     set_pev(entity, pev_framerate, 1.0);         //remove_entity(entity); }
__________________









Last edited by CrazY.; 04-05-2017 at 18:23.
CrazY. is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 04-04-2017 , 02:37   Re: [ H3LP ] Explode entity ?
Reply With Quote #2

Quote:
Originally Posted by CrazY. View Post
Hey AlliedModders, currently I am developing a simple spawn model effect. Crazy? about what you are talkig (what the hell are this) ? Well, when a player spawn, a egg model is added into the player origin. I want explode this egg, but the egg model dont have a explode animation, then I used the following code to do that, but dont work well. Any idea?

Code:
public fw_PlayerSpawn_Post(id) {     if (!is_user_alive(id) || !cs_get_user_team(id))         return;             new entity = create_entity("info_target");         if (!pev_valid(entity))         return;             new Float:origin[3];     entity_get_vector(id, EV_VEC_origin, origin);         set_pev(entity, pev_body, 1);     entity_set_model(entity, EGG_MODEL);         origin[2] -= 25;     entity_set_origin(entity, origin);         set_pev(entity, pev_owner, id);     entity_set_string(entity, EV_SZ_classname, "egg_class");     entity_set_int(entity, EV_INT_solid, 2);         if (get_cvar_num("mp_freezetime") <= 0)         explode_egg(id); } public explode_egg(id) {     if (!is_user_connected(id))         return;             new entity = find_ent_by_owner(0, "egg_class", id);         // I dont know exactly if this is correct.     set_pev(entity, pev_framerate, 1.0);         //remove_entity(entity); }
When using find_ent_by_x the starting index has to be -1 not 0.

Code:
find_ent_by_owner(0, "egg_class", id);

-->

Code:
find_ent_by_owner(-1, "egg_class", id);
__________________
edon1337 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-04-2017 , 06:08   Re: [ H3LP ] Explode entity ?
Reply With Quote #3

Ok. i will test.
__________________








CrazY. is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-04-2017 , 10:30   Re: [ H3LP ] Explode entity ?
Reply With Quote #4

The egg doesn't need to have an exploding animation, there is an effect in the engine called gore/shouldgib which makes any model explode to pieces...

Search around about shoulgib/gore, i remember i did it in the past, i created an entity which when destroyed was exploding to pieces and it worked well, but i cannot find the code anymore..

Also, the pieces will not be flesh/bones etc it will actually be parts from the entity's model
__________________
Depresie is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-04-2017 , 10:49   Re: [ H3LP ] Explode entity ?
Reply With Quote #5

Ham_GibMonster exists but I don't think it will work with info_target let alone CS.
__________________

Last edited by gabuch2; 04-04-2017 at 10:50.
gabuch2 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-04-2017 , 10:50   Re: [ H3LP ] Explode entity ?
Reply With Quote #6

Hmm, nice! Thats is exactly what I need. I will search, thanks again Depresie!

@Shattered, ok.. I will test it.
__________________









Last edited by CrazY.; 04-04-2017 at 10:51.
CrazY. is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 04-04-2017 , 13:56   Re: [ H3LP ] Explode entity ?
Reply With Quote #7

How about TE_EXPLOSION (C4 explosion) ?
__________________
edon1337 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-04-2017 , 17:08   Re: [ H3LP ] Explode entity ?
Reply With Quote #8

With MSG_BROADCAST? I think dont is this that I need.. O.o but I will test it anyway.
__________________








CrazY. is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 04-04-2017 , 17:47   Re: [ H3LP ] Explode entity ?
Reply With Quote #9

From my box plugin, this is what you are looking for...

PHP Code:
public fw_HamKilled(entattackershouldgib)
{
    
// Entity not valid?
    
if(!pev_valid(ent)) return HAM_IGNORED
    
    
// Search for our entity
    
static szClass[32]
    
entity_get_classname(ent,szClass)
    
    
// Not our entity?
    
if(!equal(szClassCLASSNAME_BOX)) return HAM_IGNORED
    
    
// Entity destroy sound
    
emit_sound(entCHAN_AUTOsound_crate_destroy1.00.30PITCH_NORM)
    
    
// Get entity origin
    
new Float:origin[3]
    
entity_get_vector(entEV_VEC_originorigin)
    
    new 
stage entity_get_int(entEV_INT_iuser3)
    
    if(
stage)
    {
        
// Metal shatter
        
engfunc(EngFunc_MessageBegin,MSG_PVS,SVC_TEMPENTITY,origin,0);
        
write_byte(TE_BREAKMODEL);
        
engfunc(EngFunc_WriteCoordorigin[0]);
        
engfunc(EngFunc_WriteCoordorigin[1]);
        
engfunc(EngFunc_WriteCoordorigin[2]);
        
write_coord(16);
        
write_coord(16);
        
write_coord(16);
        
write_coord(random_num(-25,25));
        
write_coord(random_num(-25,25));
        
write_coord(25);
        
write_byte(10);
        
write_short(g_gibs_1);
        
write_byte(5);
        
write_byte(5);
        
write_byte(2);
        
message_end();
    }    
    else
    {
        
// Glass shatter
        
engfunc(EngFunc_MessageBegin,MSG_PVS,SVC_TEMPENTITY,origin,0);
        
write_byte(TE_BREAKMODEL);
        
engfunc(EngFunc_WriteCoordorigin[0]);
        
engfunc(EngFunc_WriteCoordorigin[1]);
        
engfunc(EngFunc_WriteCoordorigin[2]);
        
write_coord(16);
        
write_coord(16);
        
write_coord(16);
        
write_coord(random_num(-50,50));
        
write_coord(random_num(-50,50));
        
write_coord(25);
        
write_byte(10);
        
write_short(g_gibs_2);
        
write_byte(5);
        
write_byte(5);
        
write_byte(0);
        
message_end();        
    }
    
    
Entity_Gravity()
    
    return 
HAM_IGNORED

__________________

Last edited by Depresie; 04-04-2017 at 17:50.
Depresie is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-04-2017 , 18:19   Re: [ H3LP ] Explode entity ?
Reply With Quote #10

Ok! I will do some tests, thanks for the example.
__________________








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 17:51.


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