AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Radius Damage Stock (https://forums.alliedmods.net/showthread.php?t=163321)

bogdyuttzu 07-29-2011 05:12

Radius Damage Stock
 
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);



avril-lavigne 07-29-2011 07:21

Re: Radius Damage Stock
 
yesterday I made plugin using radius damage

look for deagle nail launcher. U can take code from there

.Dare Devil. 07-29-2011 07:36

Re: Radius Damage Stock
 
Or look lasermine, bazooka plugins :)

yokomo 07-29-2011 08:25

Re: Radius Damage Stock
 
Last night i also searching for radius damage stock and i found this 1 by OT:
PHP Code:

stock HamRadiusDamage(entFloat:radiusFloat:damagebits

    new 
target = -1Float:origin[3
    
pev(entpev_originorigin
     
    while(( 
target find_ent_in_sphere(targetoriginradius) )) 
    { 
        static 
Float:o[3
        
pev(targetpev_origino
         
        
xs_vec_sub(originoo
         
        
// Recheck if the entity is in radius 
        
if (xs_vec_len(o) > radius
            continue 
         
        
Ham_ExecDamageB(targetentpev(entpev_owner), damage * (xs_vec_len(o) / radius), HIT_GENERICbits
    } 


remember to define these 2 include in your sma:
PHP Code:

#include <hamsandwich>
#include <xs> 

Didn't test yet but i think it working.

bogdyuttzu 07-29-2011 08:37

Re: Radius Damage Stock
 
OK tnx all but i need my radius damage because have trace attack

Arkshine 07-29-2011 09:31

Re: Radius Damage Stock
 
Have you tried at least to debug yourself ? To see where it crashes. Random guess, Ham_BodyTarget.

bogdyuttzu 07-29-2011 10:04

Re: Radius Damage Stock
 
i don't think is Ham_BodyTarget the problem because i use this ham
http://forums.alliedmods.net/showthread.php?t=159814

Arkshine 07-29-2011 10:55

Re: Radius Damage Stock
 
Instead of guessing, debug and see from where it crashes.

bogdyuttzu 07-29-2011 11:36

Re: Radius Damage Stock
 
OK and... how i can debug?

Its don't show errors in console because is complect freeze

Arkshine 07-29-2011 11:39

Re: Radius Damage Stock
 
Add debug text, check value and such.


All times are GMT -4. The time now is 00:58.

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