AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Real bombsites count (https://forums.alliedmods.net/showthread.php?t=251781)

kiki33hun 11-19-2014 10:22

Real bombsites count
 
Hello, how to to get real bombsite count?

I use this code:
Code:

find_bomb_targets(Float:locations[BOMBSITES][3]) {
        new ent, i;
        while ( i < g_bombsitenum && (ent = find_ent_by_class(ent,"func_bomb_target") ) || i < g_bombsitenum && (ent = find_ent_by_class(ent,"info_bomb_target") )  ) {
                get_brush_entity_origin(ent, locations[i]);
                i++;
        }
       
        log_to_file("kiki.log", "Founded plants: %d", i);
}

de_dust2: L 11/19/2014 - 16:09:48: Founded plants: 2 - Its good not fake

de_torn L 11/19/2014 - 16:10:02: Founded plants: 4 - This map only have 2 plant A and B plant, how to fix this code? Any ideas?

HamletEagle 11-19-2014 11:13

Re: Real bombsites count
 
func_bomb_target just define a touch zone. If this touch zone is not found the game will check 250 units around the info_bomb_target ent. My guess is that, on de_torn there are 4 touch zones defined but only 2 info_bomb_target ents and only 2 usable bomb sites.

Arkshine 11-19-2014 11:27

Re: Real bombsites count
 
func_bomb_target is used to define a custom zone.

A bomb site can be defined either by func_bomb_target or info_bomb_target.

In case of de_torn, for each bomb site, it uses func_bomb_target to define custom zones. Technically you have 2 bomb sites, but here just that one bomb site is split in 3 custom zones and other one custom zone.

To fix that, you could check target of each entities. It should be different depending the bomb site. For example in de_torn, for site A, the three func_bomb_target have well the same target and for site B the other func_bomb_target has well a different one.

kiki33hun 11-20-2014 06:52

Re: Real bombsites count
 
Quote:

Originally Posted by Arkshine (Post 2225992)
To fix that, you could check target of each entities. It should be different depending the bomb site. For example in de_torn, for site A, the three func_bomb_target have well the same target and for site B the other func_bomb_target has well a different one.


I do not understand. How to?

Jhob94 11-20-2014 06:57

Re: Real bombsites count
 
Quote:

Originally Posted by kiki33hun (Post 2226257)
I do not understand. How to?

Get the origins of the bombsites and check the distance between them.
But there are some maps that might have bombsites very close to each others so be careful what's the distance you check for consider it 1 site only.

Arkshine 11-20-2014 07:03

Re: Real bombsites count
 
Quote:

Originally Posted by kiki33hun (Post 2226257)
I do not understand. How to?

Check pev_target.

kiki33hun 11-21-2014 04:55

Re: Real bombsites count
 
Quote:

Originally Posted by Arkshine (Post 2226264)
Check pev_target.

Okey, thanks. I need some help.

Plugin init:
PHP Code:

new ent = -1;
    while ((
ent find_ent_by_class(ent"func_bomb_target")))
    {
        
g_bombsitenum++
    }
    while ((
ent find_ent_by_class(ent"info_bomb_target")) )
    {
        
g_bombsitenum++
    } 

And new bomb site finder function:
PHP Code:

bomb_site_kereses(Float:locations[BOMBSITES][3]) 
{
    new 
entijentname[BOMBSITES][30], bool:lekerheto=false;
    while ( 
g_bombsitenum && (ent find_ent_by_class(ent,"func_bomb_target") ) || g_bombsitenum && (ent find_ent_by_class(ent,"info_bomb_target") )  ) 
    {
        
peventpev_targetentname[i], 29);
        
        for (; 
j<ij++)
        {
            if(!
equal(entname[i], entname[j])) 
            {
                
log_to_file("kiki.log""A %s nem egyezik a %s-el"entname[i], entname[j]);
                
lekerheto=true;    
            }
            else
            {
                
log_to_file("kiki.log""A %s egyezik a %s-el"entname[i], entname[j]);
                
lekerheto=false;
                
g_bombsitenum--;
                
log_to_file("kiki.log""Uj bombsitenum: %d"g_bombsitenum);
            }
        }
        
        
log_to_file("kiki.log""I: %d: %s"ientname[i]);
        if(
lekerhetoget_brush_entity_origin(entlocations[i]);
        
i++;
    }


Log:
L 11/21/2014 - 10:47:52: I: 0: squarebreak
L 11/21/2014 - 10:47:52: A templebreak nem egyezik a squarebreak-el
L 11/21/2014 - 10:47:52: I: 1: templebreak
L 11/21/2014 - 10:47:52: A squarebreak nem egyezik a templebreak-el
L 11/21/2014 - 10:47:52: I: 2: squarebreak
L 11/21/2014 - 10:47:52: A squarebreak egyezik a squarebreak-el
L 11/21/2014 - 10:47:52: Uj bombsitenum: 3
L 11/21/2014 - 10:47:52: I: 3: squarebreak

Problem: g_bombsitenum value is 3, if have 2 bombsite the map. Who the problem?
http://kepfeltoltes.hu/141121/proble...toltes.hu_.jpg

Arkshine 11-21-2014 07:13

Re: Real bombsites count
 
Code:
new entitiesList[12]; new entitiesCount; entitiesCount  = find_sphere_class(0, "func_bomb_target", 4096.0, entitiesList, sizeof entitiesList); entitiesCount += find_sphere_class(0, "info_bomb_target", 4096.0, entitiesList[entitiesCount], sizeof entitiesList - entitiesCount); new Array:targetsList = ArrayCreate(); for (new i, target; i < entitiesCount; ++i) {     target = pev(entitiesList[i], pev_target);     ArrayFindValue(targetsList, target) == -1 && ArrayPushCell(targetsList, target); } new bombSitesCount = ArraySize(targetsList); ArrayDestroy(targetsList); log_amx("Bomb site count = %d", bombSitesCount);

Code:

[test.amxx] Bomb site count = 2
This is actually kinda dumb to do that, because well, most of time you have always only 2 bomb sites.
You will have to explain what you want to do exactly. It would make more sense, for example, to store each zone origin and associating each zone with a bomb site number (generally you have only 2 bomb site, but it can be more).

kiki33hun 11-21-2014 09:34

Re: Real bombsites count
 
I want get bombsite cordinates.

Arkshine 11-21-2014 11:51

Re: Real bombsites count
 
Ah misread. Anyway, tried with get_brush_entity_origin() and it works fine for me. So debug your code.


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

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