Raised This Month: $ Target: $400
 0% 

Optimize this..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PattyBiena
BANNED
Join Date: Jul 2010
Location: Argentina
Old 07-07-2010 , 14:44   Optimize this..
Reply With Quote #1

PHP Code:
// global
new const Floatmejoria_damage[] = { 0.20.40.60.81.01.21.41.61.82.02.0}

// on takedamage
switch(get_user_weapon(attacker))
{
        case 
CSW_KNIFEdamage *= 2.0
        
case CSW_TMPdamage *= 1.0
        
case CSW_MAC10damage *= 1.1
        
case CSW_UMP45damage *= 1.1
        
case CSW_M4A1damage *= 1.2
        
case CSW_AK47damage *= 1.15
        
case CSW_SCOUTdamage *= 1.4
        
case CSW_M3damage *= 1.4
        
case CSW_P90damage *= 1.5
        
case CSW_SG552damage *= 1.3
        
case CSW_GALILdamage *= 1.4
        
case CSW_XM1014damage *= 1.4
        
case CSW_MP5NAVYdamage *= 1.4
        
case CSW_M249damage *= 1.5
        
case CSW_FAMASdamage *= 1.6
        
case CSW_AWPdamage *= 2.0
        
case CSW_AUGdamage *= 2.0
        
case CSW_SG550damage *= 3.0
}

SetHamParamFloat(4damage *= 1.0+((mejoria_damage[g_habilidades[attacker][1]])+0.1)+((g_humanclass[attacker] == 3) ? 0.5 0.1)*((g_humanclass[attacker] == 1) ? 0.3 0.1)) 
(This code is from takedamage)

And this.

PHP Code:
switch(level)
            {
                case 
0..9costo *= 1
                
case 10..19costo *= 4
                
case 20..29costo *= 6
                
case 30..39costo *= 8
                
case 40..49costo *= 10
                
case 50..59costo *= 12
                
case 60..69costo *= 14
                
case 70..79costo *= 16
                
case 80..89costo *= 18
                
case 90..99costo *= 20
                
case 100..109costo *= 22
                
case 110..119costo *= 24
                
case 120..129costo *= 26
                
case 130..139costo *= 28
                
case 140..149costo *= 30
                
case 150..159costo *= 32
                
case 160..169costo *= 34
                
case 170..179costo *= 36
                
case 180..189costo *= 38
                
case 190..199costo *= 40
                
default: costo *= 42
            


Last edited by PattyBiena; 07-07-2010 at 15:30.
PattyBiena is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-07-2010 , 16:19   Re: Optimize this..
Reply With Quote #2

For the damage formula, manage yourself, it hurts my eyes..

For the switch statements :

Use a lookup table, you have to implement all weapons, put 1.0 for no change.
PHP Code:
new const Floatg_flDamageFactor[CSW_P90+1] =
{
    
0.0,
    
1.0// CSW_P228
    
0.0,
    
1.4// CSW_SCOUT
    
etc..
}

damage *= g_flDamageFactorget_user_weapon(attacker) ] 

For the level and cost :

PHP Code:
            switch( level 10 )
            {
                case 
0costo *= 1
                
case 1costo *= 4
                
case 2costo *= 6
                
case 3costo *= 8
                etc
... 
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
PattyBiena
BANNED
Join Date: Jul 2010
Location: Argentina
Old 07-07-2010 , 16:46   Re: Optimize this..
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
For the damage formula, manage yourself, it hurts my eyes..

For the switch statements :

Use a lookup table, you have to implement all weapons, put 1.0 for no change.
PHP Code:
new const Floatg_flDamageFactor[CSW_P90+1] =
{
    
0.0,
    
1.0// CSW_P228
    
0.0,
    
1.4// CSW_SCOUT
    
etc..
}

damage *= g_flDamageFactorget_user_weapon(attacker) ] 
For the level and cost :

PHP Code:
            switch( level 10 )
            {
                case 
0costo *= 1
                
case 1costo *= 4
                
case 2costo *= 6
                
case 3costo *= 8
                etc
... 
Sorry for my English, I use google translator.

I do not understand the formula of the damage, That is fine?

PHP Code:
switch( Lvl[id] / 10 )
{
    case 
0g_extraitem_cost[item] *= 1
    
case 1g_extraitem_cost[item] *= 4
    
case 2g_extraitem_cost[item] *= 6
    
case 3g_extraitem_cost[item] *= 8
    
case 4g_extraitem_cost[item] *= 10
    
case 5g_extraitem_cost[item] *= 12
    
case 6g_extraitem_cost[item] *= 14
    
case 7g_extraitem_cost[item] *= 16
    
case 8g_extraitem_cost[item] *= 18
    
case 9g_extraitem_cost[item] *= 20
    
case 10g_extraitem_cost[item] *= 22
    
case 11g_extraitem_cost[item] *= 23
    
case 12g_extraitem_cost[item] *= 24
    
case 13g_extraitem_cost[item] *= 26
    
case 14g_extraitem_cost[item] *= 28
    
case 15g_extraitem_cost[item] *= 30
    
case 16g_extraitem_cost[item] *= 32
    
case 17g_extraitem_cost[item] *= 34
    
case 18g_extraitem_cost[item] *= 36
    
case 19g_extraitem_cost[item] *= 38
    
default: g_extraitem_cost[item] *= 40

PattyBiena is offline
PattyBiena
BANNED
Join Date: Jul 2010
Location: Argentina
Old 07-15-2010 , 18:58   Re: Optimize this..
Reply With Quote #4

Optimized:
PHP Code:
costo *= ((Lvl[id] / 10) * 2
PattyBiena is offline
Reply



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 07:09.


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