AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] Explode entity ? (https://forums.alliedmods.net/showthread.php?t=295759)

CrazY. 04-03-2017 18:30

[ H3LP ] Explode entity ?
 
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); }

edon1337 04-04-2017 02:37

Re: [ H3LP ] Explode entity ?
 
Quote:

Originally Posted by CrazY. (Post 2509144)
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);

CrazY. 04-04-2017 06:08

Re: [ H3LP ] Explode entity ?
 
Ok. i will test.

Depresie 04-04-2017 10:30

Re: [ H3LP ] Explode entity ?
 
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

gabuch2 04-04-2017 10:49

Re: [ H3LP ] Explode entity ?
 
Ham_GibMonster exists but I don't think it will work with info_target let alone CS.

CrazY. 04-04-2017 10:50

Re: [ H3LP ] Explode entity ?
 
Hmm, nice! Thats is exactly what I need. I will search, thanks again Depresie!

@Shattered, ok.. I will test it.

edon1337 04-04-2017 13:56

Re: [ H3LP ] Explode entity ?
 
How about TE_EXPLOSION (C4 explosion) ?

CrazY. 04-04-2017 17:08

Re: [ H3LP ] Explode entity ?
 
With MSG_BROADCAST? I think dont is this that I need.. O.o but I will test it anyway.

Depresie 04-04-2017 17:47

Re: [ H3LP ] Explode entity ?
 
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



CrazY. 04-04-2017 18:19

Re: [ H3LP ] Explode entity ?
 
Ok! I will do some tests, thanks for the example.


All times are GMT -4. The time now is 17:51.

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