Raised This Month: $ Target: $400
 0% 

Radius Damage Stock


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
bogdyuttzu
Senior Member
Join Date: Dec 2009
Location: Romania
Old 07-29-2011 , 05:12   Radius Damage Stock
Reply With Quote #1

I try to convert the radius damage from valve sdk in amxx, i do it but i have a problem.
When the stock is called the server is block instantly and server use 99% cpu

This is the stock:

PHP Code:
stock RadiusDamage(Float:vecSrc[3], pevInflictorpevAttackerFloat:flDamageFloat:flRadiusiClassIgnorebitsDamageType)
{
    static 
pEntitytrbInWater;
    static 
Float:flAdjustedDamageFloat:falloff;
    static 
Float:vecSpot;
    
    if (
flRadius)
        
falloff flDamage flRadius;
    else
        
falloff 1.0;
    
    
tr create_tr2();
    
pEntity FM_NULLENT;
    
bInWater = (engfunc(EngFunc_PointContentsvecSrc) == CONTENTS_WATER);
    
    
vecSrc[2] += 1;// in case grenade is lying on the ground
    
    
if (!pevAttacker)
        
pevAttacker pevInflictor;
        
    
// iterate on all entities in the vicinity.
    
while((pEntity fm_find_ent_in_sphere(pEntityvecSrcflRadius)) != FM_NULLENT)
    {
        if (
pev(pEntitypev_takedamage) != DAMAGE_NO)
        {
            static 
Classify;
            
Classify ExecuteHamB(Ham_ClassifypEntity);
            
            
// UNDONE: this should check a damage mask, not an ignore
            
if (iClassIgnore != && Classify == iClassIgnore)
            {
// houndeyes don't hurt other houndeyes with their attack
                
continue;
            }

            
// blast's don't tavel into or out of water
            
if (bInWater && pev(pEntitypev_waterlevel) == 0)
                continue;
                
            if (!
bInWater && pev(pEntitypev_waterlevel) == 3)
                continue;

            
ExecuteHamB(Ham_BodyTargetpEntityvecSrcvecSpot);
            
            
engfunc(EngFunc_TraceLinevecSrcvecSpotDONT_IGNORE_MONSTERSpevInflictortr);
            
            static 
Float:flFractionpHitfStartSolidFloat:vecEndPos[3];
            
get_tr2(trTR_flFractionflFraction);
            
get_tr2(trTR_pHitpHit);
            
get_tr2(trTR_StartSolidfStartSolid);
            
            if (
flFraction == 1.0 || pHit == pEntity)
            {
// the explosion can 'see' this entity, so hurt them!
                
                
if (fStartSolid)
                {
                    
// if we're stuck inside them, fixup the position and distance
                    
set_tr2(trTR_vecEndPosvecSrc)
                    
set_tr2(trTR_flFraction0.0)
                }
                
                
// decrease damage for an ent that's farther from the bomb.
                
get_tr2(trTR_vecEndPosvecEndPos);
                
xs_vec_sub(vecSrcvecEndPosvecEndPos);
                
                
flAdjustedDamage xs_vec_len(vecEndPos) * falloff
                flAdjustedDamage 
flDamage flAdjustedDamage;
            
                if (
flAdjustedDamage 0)
                {
                    
flAdjustedDamage 0.0;
                }

                if (
flFraction != 1.0)
                {
                    
get_tr2(trTR_vecEndPosvecEndPos);
                    
xs_vec_sub(vecEndPosvecSrcvecSrc);
                    
xs_vec_normalize(vecSrcvecSrc);
                    
                    
ExecuteHamB(Ham_TraceAttackpEntitypevInflictorflAdjustedDamagevecSrctrbitsDamageType);
                    
ExecuteHamB(Ham_TakeDamagepEntitypevInflictorpevAttackerflAdjustedDamagebitsDamageType);
                }
                else
                {
                    
ExecuteHamB(Ham_TakeDamagepEntitypevInflictorpevAttackerflAdjustedDamagebitsDamageType);
                }
            }
        }
    }
    
free_tr2(tr);

bogdyuttzu is offline
Send a message via Yahoo to bogdyuttzu
 



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 00:58.


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