AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is it possible to optimize this? (https://forums.alliedmods.net/showthread.php?t=117498)

BannedUser! 02-01-2010 19:02

Is it possible to optimize this?
 
PHP Code:

                static id
                id 
attacker
                
switch (get_user_weapon(attacker))
                {
                    case 
CSW_TMPdamage *= 1
                    
case CSW_KNIFEdamage *= 3
                    
case CSW_MAC10:
                    {
                        if (
Lvl[id] >= 5)
                            
damage *= 3
                    
}
                    case 
CSW_UMP45:
                    {
                        if (
Lvl[id] >= 10)
                            
damage *= 3
                    
}
                    case 
CSW_M4A1:
                    {
                        if (
Lvl[id] >= 15)
                            
damage *= 2.5
                    
}
                    case 
CSW_AK47:
                    {
                        if (
Lvl[id] >= 40)
                            
damage *= 2
                    
}
                    case 
CSW_SCOUT:
                    {
                        if (
Lvl[id] >= 60)
                            
damage *= 3
                    
}
                    case 
CSW_M3:
                    {
                        if (
Lvl[id] >= 100)
                            
damage *= 2.5
                    
}
                    case 
CSW_P90:
                    {
                        if (
Lvl[id] >= 140)
                            
damage *= 3
                    
}
                    case 
CSW_SG552:
                    {
                        if (
Lvl[id] >= 220)
                            
damage *= 3
                    
}
                    case 
CSW_GALIL:
                    {
                        if (
Lvl[id] >= 240)
                            
damage *= 4
                    
}
                    case 
CSW_XM1014:
                    {
                        if (
Lvl[id] >= 280)
                            
damage *= 3.5
                    
}
                    case 
CSW_MP5NAVY:
                    {
                        if (
Lvl[id] >= 300)
                            
damage *= 4
                    
}
                    case 
CSW_M249:
                    {
                        if (
Lvl[id] >= 350)
                            
damage *= 4
                        
if (g_survivor[id])
                            
damage *= 4
                    
}
                    case 
CSW_FAMAS:
                    {
                        if (
Lvl[id] >= 380)
                            
damage *= 5
                    
}
                    case 
CSW_AWP:
                    {
                        if (
Lvl[id] >= 430)
                        {
                            if (
g_awpfire[id])
                                
damage *= 5
                            
else if (g_awpfrost[id])
                                
damage *= 3
                        
}
                    }
                    case (
CSW_AUG):
                    {
                        if (
Lvl[attacker] >= 480)
                            
damage *= 30
                    
}
                    case 
CSW_SG550:
                    {
                        if (
Lvl[id] >= 480)
                            
damage *= 5
                    
}
                    case 
CSW_FIVESEVENdamage *= 2
                    
case CSW_USP:
                    {
                        if (
Lvl[id] >= 5)
                            
damage *= 3
                    
}
                    case 
CSW_DEAGLE:
                    {
                        if (
Lvl[id] >= 20)
                            
damage *= 2
                    
}
                    case 
CSW_GLOCK18:
                    {
                        if (
Lvl[id] >= 40)
                            
damage *= 4
                    
}
                    case 
CSW_P228:
                    {
                        if (
Lvl[id] >= 80)
                        {
                            if (
g_p228[id])
                                
damage *= 7
                            
else if (!g_p228[id])
                                
damage *= 5
                        
}
                    }
                    case 
CSW_ELITE:
                    {
                        if (
Lvl[id] >= 300)
                            
damage *= 4
                    
}
                } 


AfteR. 02-01-2010 19:10

Re: Is it possible to optimize this?
 
I dont really understand what are you trying to do with this my "dear" today-banned user.:

PHP Code:

                    case CSW_P228:
                    {
                        if (
Lvl[id] >= 80)
                        {
                            if (
g_p228[id])
                                
damage *= 7
                            
else if (!g_p228[id])
                                
damage *= 5
                        
}
                    } 


BannedUser! 02-01-2010 19:38

Re: Is it possible to optimize this?
 
Quote:

Originally Posted by AfteR. (Post 1075573)
I dont really understand what are you trying to do with this my "dear" today-banned user.:

PHP Code:

                    case CSW_P228:
                    {
                        if (
Lvl[id] >= 80)
                        {
                            if (
g_p228[id])
                                
damage *= 7
                            
else if (!g_p228[id])
                                
damage *= 5
                        
}
                    } 


I use the name BannedUser! In any games, forums, etc.

PHP Code:

                    case CSW_P228:
                    {
                        if (
Lvl[id] >= 80)
                        {
                            if (
g_p228[id])
                                
damage *= 7
                            
else if (!g_p228[id])
                                
damage *= 5
                        
}
                    } 

That you changed?

fysiks 02-01-2010 21:14

Re: Is it possible to optimize this?
 
Remove:

PHP Code:

 if (!g_p228[id]) 


BannedUser! 02-02-2010 01:50

Re: Is it possible to optimize this?
 
Quote:

Originally Posted by fysiks (Post 1075638)
Remove:

PHP Code:

 if (!g_p228[id]) 


Thanks.

Emp` 02-02-2010 01:59

Re: Is it possible to optimize this?
 
What you could do is instead, keep an array of the multipliers, along with an array of the necessary level.

Code:

if( Lvl[id] >= WeapLvl[weapon] )
  damage *= WeapMult[weapon];

Which could possibly remove the entire switch statement. (Though a couple weapons seem to have something else, so you could branch them off separately)


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

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