AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] find entity by "gibmodel" value (https://forums.alliedmods.net/showthread.php?t=225080)

kNowo 08-31-2013 14:30

[SOLVED] find entity by "gibmodel" value
 
Is it possible to find entities by their gibmodel value?

The code below is the properties of a func_breakable entity in a map. I'd like to do some stuff to these entities and they all share one same property, which is the "gibmodel".
Code:

{
  "model" "*1"
  "rendercolor" "0 0 0"
  "gibmodel" "models/metalplategibs_green.mdl"
  "targetname" "targetb"
  "explodemagnitude" "100"
  "material" "2"
  "health" "1"
  "spawnflags" "1"
  "classname" "func_breakable"
}

Let's say I'm trying to delete those entities and I used the code below but it return those entities as invalid
PHP Code:

while((aEnt engfunc(EngFunc_FindEntityByStringaEnt"gibmodel""models/metalplategibs_green.mdl")))
{
    
engfunc(EngFunc_RemoveEntityaEnt)



ConnorMcLeod 08-31-2013 15:28

Re: find entity by "gibmodel" value
 
PHP Code:

const XO_CBREAKABLE 4;
const 
m_iszGibModel 40;

{
    while( (
aEnt find_breakable_by_gibmodel(aEnt,  "models/metalplategibs_green.mdl")) )
    {
        
remove_entity(aEnt);
    }
}
find_breakable_by_gibmodel(startent, const gibmodel[])
{
    static 
entiszGibModelszGibModel[128];
    
ent startent;
    while( (
ent find_ent_by_class(ent"func_breakable")) )
    {
        
iszGibModel get_pdata_int(entm_iszGibModelXO_CBREAKABLE);
        if( 
iszGibModel )
        {
            
global_get(glb_pStringBaseiszGibModelszGibModelcharsmax(szGibModel));
            if( 
equal(szGibModelgibmodel) )
            {
                return 
ent;
            }
        }
    }
    return 
ent;



kNowo 08-31-2013 15:42

Re: find entity by "gibmodel" value
 
Thanks ConnorMcLeod, it works flawlessly

EDIT: I need one more thing, I'd like to get all the trigger_hurt entities indexes in a map that has "damagetype" of DMG_FALL (32)

Bad English. Let me rephrase: I'd like to loop all trigger_hurt entities, and if their damagetype is 32, then do something to them. Right now I'm stuck at getting the damagetype value.

Arkshine 08-31-2013 16:15

Re: find entity by "gibmodel" value
 
You are in the scripting section, it's a good idea to show what you've done, so people can correct you and you can learn from that.

kNowo 08-31-2013 16:56

Re: find entity by "gibmodel" value
 
Quote:

Originally Posted by Arkshine (Post 2025728)
You are in the scripting section, it's a good idea to show what you've done, so people can correct you and you can learn from that.

It's just the same engine native
PHP Code:

while((ent find_ent_by_class(ent"trigger_hurt")))
{
    
//check if "damagetype" equal to 32



ConnorMcLeod 08-31-2013 17:11

Re: find entity by "gibmodel" value
 
check pdata m_bitsDamageInflict if it contains DMG_FALL, but i doubt it can be possible :)

PHP Code:

const XO_CBASETOGGLE2 5;
const 
m_bitsDamageInflict 71

PHP Code:

    if( get_pdata_int(entm_bitsDamageInflictXO_CBASETOGGLE2) & DMG_FALL 


kNowo 08-31-2013 17:33

Re: find entity by "gibmodel" value
 
Yea, it's not working. Do you have another way that you think could pull it off?

ConnorMcLeod 08-31-2013 17:45

Re: find entity by "gibmodel" value
 
Code is ok, it's just that i don't think that DMG_FALL is set on trigger_hurt

kNowo 08-31-2013 17:54

Re: find entity by "gibmodel" value
 
#define DMG_FALL (1<<5)
1<<5 equals to 32 (assuming my calculation is correct)

What I think is the pdata 71 is for something else (totally a blind guess).

ConnorMcLeod 09-01-2013 02:53

Re: find entity by "gibmodel" value
 
You don't understand, seems that damage is different from DMG_FALL, also i've never seen a trigger_hurt with DMG_FALL so far.
Which map it is ?


All times are GMT -4. The time now is 18:59.

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