AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Make entity breakable (https://forums.alliedmods.net/showthread.php?t=339668)

sebxx4 09-25-2022 09:19

Make entity breakable
 
Hello.
I have a KillStreak plugin for cod servers. There is one of option in it that creates a user-controlled predator missle. Below the code that creates it.
I would like to modify it to make it has eg 50HP. I mean, make this missle breakable via gun or something. Could someone give me a hand with it, please?

PHP Code:

public CreatePredator(id)
{
    if ( !
is_valid_ent(id) )
        return; 

    new 
numplayers[32];
    
get_players(playersnum"gh");
    for(new 
0numa++)
    {
        new 
players[a];
        if(
cs_get_user_team(id) != cs_get_user_team(i))
            
client_cmd(i"spk sound/mw/predator_enemy.wav");
        else
            
client_cmd(i"spk sound/mw/predator_friend.wav");
    }
    
print_info(id"Predator Missle");

    new 
Float:Origin[3], Float:Angle[3], Float:Velocity[3], ent;
    
    
velocity_by_aim(id700Velocity);

    if ( !
is_valid_ent(id) )
        return;

    
entity_get_vector(idEV_VEC_originOrigin);
    
entity_get_vector(idEV_VEC_v_angleAngle);
    
    
Angle[0] *= -1.0;
    
    
ent create_ent(id"predator""models/cod_predator.mdl"25Origin);
    
    
entity_set_vector(entEV_VEC_velocityVelocity);
    
entity_set_vector(entEV_VEC_anglesAngle);
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_BEAMFOLLOW);
    
write_short(ent);
    
write_short(cache_trail);
    
write_byte(10);
    
write_byte(5);
    
write_byte(205);
    
write_byte(237);
    
write_byte(163);
    
write_byte(200);
    
message_end();

    
licznik_zabic[id] -= predator_steps[id];

    if ( 
licznik_zabic[id] < )
        
licznik_zabic[id] = 0

    
if ( licznik_zabic[id] < predator_steps[id] )
        
predator[id] = false;
    
    
attach_view(ident);
    
user_controll[id] = ent;



sebxx4 09-26-2022 08:24

Re: Make entity breakable
 
I tried add set_pev(ent, pev_health, 100.0); and set_pev(ent, pev_takedamage, DAMAGE_YES); but it doesn't work.

JocAnis 09-26-2022 14:36

Re: Make entity breakable
 
probably it should be func_breakable

this will help by
Arkshine: https://forums.alliedmods.net/showpo...0&postcount=10
Klippy: https://forums.alliedmods.net/showpo...91&postcount=8

sebxx4 09-27-2022 12:13

Re: Make entity breakable
 
1 Attachment(s)
Well, I think in my case there is engine used, and yours is fakemeta.
Maybe could someone have a look at the original plugin? I totally dont know how to deal with entities and it's the last one thing left me to do.

Natsheh 09-27-2022 15:38

Re: Make entity breakable
 
Set entity <model>
Set entity <size>
Set entity <takedamage>
Set entity <Health>

sebxx4 09-29-2022 03:39

Re: Make entity breakable
 
1 Attachment(s)
So, first I tried to rip out the missle code to another plugin, this is what I got:
PHP Code:

#include <amxmodx>
#include <engine>

new user_controll[33];

public 
plugin_init() 
{
    
register_plugin("test""1.0""Sebxx");
    
register_touch("predator""*""touchedpredator");
    
register_clcmd("say /test""CreatePredator");
}

public 
plugin_precache()
{
    
precache_model("models/cod_predator.mdl");
}

public 
CreatePredator(id)
{
    new 
Float:Origin[3], Float:Angle[3], Float:Velocity[3], ent;
    
    
velocity_by_aim(id700Velocity);

    if ( !
is_valid_ent(id) )
        return;

    
entity_get_vector(idEV_VEC_originOrigin);
    
entity_get_vector(idEV_VEC_v_angleAngle);
    
    
Angle[0] *= -1.0;
    
    
ent create_entity("func_breakable");
    
DispatchKeyValue(ent"health"1);
    
DispatchKeyValue(ent"material""6");
    
entity_set_string(entEV_SZ_classname"predator");
    
entity_set_model(ent"models/cod_predator.mdl");
    
entity_set_float(entEV_FL_takedamageDAMAGE_YES);
    
entity_set_int(entEV_INT_solidSOLID_SLIDEBOX);
    
entity_set_int(entEV_INT_movetypeMOVETYPE_TOSS);
    
entity_set_edict(entEV_ENT_ownerid);
    
entity_set_origin(entOrigin);
    
    
entity_set_vector(entEV_VEC_velocityVelocity);
    
entity_set_vector(entEV_VEC_anglesAngle);
    
    
attach_view(ident);
    
user_controll[id] = ent;


public 
touchedpredator(entid)
{
    new 
owner entity_get_edict(entEV_ENT_owner);
    
attach_view(ownerowner);
    
user_controll[owner] = 0;

    return 
PLUGIN_CONTINUE;
}

public 
client_PreThink(id)
{   
    if(
user_controll[id])
    {
        new 
ent2 user_controll[id];

        if(
is_valid_ent(ent2))
        {
            new 
Float:Velocity[3], Float:Angle[3];
            
velocity_by_aim(id500Velocity);

            if ( !
is_valid_ent(id) )
                return 
PLUGIN_CONTINUE;

            
entity_get_vector(idEV_VEC_v_angleAngle);
            
            
entity_set_vector(ent2EV_VEC_velocityVelocity);
            
entity_set_vector(ent2EV_VEC_anglesAngle);
        }
        else
            
attach_view(idid);
    }

    return 
PLUGIN_CONTINUE;


It basicly works, I can control the missle and view is attached back to player after collision with something. I tried to change a few things, set it's HP to 1, but still cannot shoot this missle down :/
Could somebody have a look at it?

Celena Luna 09-29-2022 04:36

Re: Make entity breakable
 
you haven't set size

sebxx4 09-29-2022 05:50

Re: Make entity breakable
 
Yeah, right. So, what size to set? Or how can I check model size?

sebxx4 09-29-2022 11:00

Re: Make entity breakable
 
EDIT:
Well, I changed something and now it seems to work. But there's another problem.
I can destory this entity, but only when shooting in one specific point of this model. I think it's "bone"? Just look at the model I attached before. There are no hitboxes, just some dot in the place I have to shoot to destroy entity.

How can I deal with it?

sebxx4 10-01-2022 01:46

Re: Make entity breakable
 
Nobody?


All times are GMT -4. The time now is 07:55.

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