Raised This Month: $ Target: $400
 0% 

what about optimizing it?lol


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
_lol_
Senior Member
Join Date: Apr 2009
Old 05-10-2009 , 14:38   what about optimizing it?lol
Reply With Quote #1

it this posible with an array or something better?i it is ham_takedamage..

PHP Code:
switch (plrWeapId)
            {
                
// Primary Weapons
                
case (CSW_M3): damage *= 4.0
                
case (CSW_M249): damage *= 4.5
                
                
case (CSW_G3SG1): damage *= 2.5
                
case (CSW_SG550): damage *= 2.2
                
case (CSW_MP5NAVY): damage *= 4.1
                
                
case (CSW_AUG): damage *= 3.1
                
case (CSW_SG552): damage *= 3.0
                
                
case (CSW_AWP): damage *= 3.0
                
case (CSW_XM1014): damage *= 2.2
                
                
case (CSW_M4A1): damage *= 1.9
                
case (CSW_AK47): damage *= 1.9
                
                
case (CSW_SCOUT): damage *= 2.0
                
                
case (CSW_GALIL): damage *= 1.0
                
case (CSW_FAMAS): damage *= 1.0
                
                
                
//Secundary Weapons
                
case (CSW_GLOCK18): damage *= 6.7
                
case (CSW_ELITE): damage *= 3.0
                
case (CSW_FIVESEVEN): damage *= 2.0
                
case (CSW_DEAGLE): damage *= 1.7
                
case (CSW_P228): damage *= 1.3
                
case (CSW_USP): damage *= 1.0
            
}
            switch (
g_level[attacker])
            {
                case (
1): SetHamParamFloat(4damage)
                case (
2): SetHamParamFloat(4damage*1.1)
                case (
3): SetHamParamFloat(4damage*1.2)
                case (
4): SetHamParamFloat(4damage*1.3)
                case (
5): SetHamParamFloat(4damage*1.4)
                case (
6): SetHamParamFloat(4damage*1.5)
                case (
7): SetHamParamFloat(4damage*1.6)
                case (
8): SetHamParamFloat(4damage*1.7)
                case (
9): SetHamParamFloat(4damage*1.8)
                case (
10): SetHamParamFloat(4damage*1.9)
                case (
11): SetHamParamFloat(4damage*2.9)
                case (
12): SetHamParamFloat(4damage*2.1)
                case (
13): SetHamParamFloat(4damage*2.2)
                case (
14): SetHamParamFloat(4damage*2.3)
                case (
15): SetHamParamFloat(4damage*2.4)
                case (
16): SetHamParamFloat(4damage*2.5)
                case (
17): SetHamParamFloat(4damage*2.6)
                case (
18): SetHamParamFloat(4damage*2.7)
                case (
19): SetHamParamFloat(4damage*2.8)
                case (
20): SetHamParamFloat(4damage*3.0)
            } 
_lol_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-10-2009 , 14:52   Re: what about optimizing it?lol
Reply With Quote #2

PHP Code:
switch (g_level[attacker])
{
    case (
1): SetHamParamFloat(4damage)
    
// . . . 
    
case (20): SetHamParamFloat(4damage*3.0)



PHP Code:
new const Float:damage_factor[LEVELS] = { 1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.9,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,3.0 }

SetHamParamFloat(4,damage damage_factor[g_level[attacker]])) 

I'm not 100% on this but I think I've seen optimizations like this before.
You could do something similar with weapon damage factor.
__________________

Last edited by fysiks; 05-10-2009 at 14:58.
fysiks is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 05-10-2009 , 14:54   Re: what about optimizing it?lol
Reply With Quote #3

Code:
            switch (g_level[attacker])
         {
             case (1): SetHamParamFloat(4, damage)
             case (2): SetHamParamFloat(4, damage*1.1)
             case (3): SetHamParamFloat(4, damage*1.2)
             case (4): SetHamParamFloat(4, damage*1.3)
             case (5): SetHamParamFloat(4, damage*1.4)
             case (6): SetHamParamFloat(4, damage*1.5)
             case (7): SetHamParamFloat(4, damage*1.6)
             case (8): SetHamParamFloat(4, damage*1.7)
             case (9): SetHamParamFloat(4, damage*1.8)
             case (10): SetHamParamFloat(4, damage*1.9)
             case (11): SetHamParamFloat(4, damage*2.9)
             case (12): SetHamParamFloat(4, damage*2.1)
             case (13): SetHamParamFloat(4, damage*2.2)
             case (14): SetHamParamFloat(4, damage*2.3)
             case (15): SetHamParamFloat(4, damage*2.4)
             case (16): SetHamParamFloat(4, damage*2.5)
             case (17): SetHamParamFloat(4, damage*2.6)
             case (18): SetHamParamFloat(4, damage*2.7)
             case (19): SetHamParamFloat(4, damage*2.8)
             case (20): SetHamParamFloat(4, damage*3.0)
         } 
->
PHP Code:
 SetHamParamFloat(4, (g_level[attacker] * 0.1 0.9) * damage); 

Edit: Okay I see that the numbs are little different, but is it a mistake?

Last edited by SnoW; 05-10-2009 at 14:57.
SnoW is offline
Send a message via MSN to SnoW
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-10-2009 , 15:00   Re: what about optimizing it?lol
Reply With Quote #4

Quote:
Originally Posted by SnoW View Post
Edit: Okay I see that the numbs are little different, but is it a mistake?
I did the exact same thing until I realized it was inconsistent.
__________________
fysiks is offline
_lol_
Senior Member
Join Date: Apr 2009
Old 05-10-2009 , 15:17   Re: what about optimizing it?lol
Reply With Quote #5

so what should i use?what about the weapons?
_lol_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-10-2009 , 15:41   Re: what about optimizing it?lol
Reply With Quote #6

Quote:
Originally Posted by _lol_ View Post
so what should i use?what about the weapons?
The most configurable method is the one I posted along with what Bugsy posted. But if your level damage factors were consistent you could do what Snow showed.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-10-2009 , 15:25   Re: what about optimizing it?lol
Reply With Quote #7

You need to align the values in the array consistent with weapon index. This way you can pass the weapon index into the array and get the value for that weapon. Weapon_Multiplier[iWeapID]

PHP Code:
new const FloatWeapon_Multiplier[] = 
{
    
0.0//0
    
2.2//1 P228
    
0.0//2
    
2.5//3 Scout
    
0.0 //4 He grenade
    //etc
    //etc

Any weapon that you do not want to specify a value for you must still include a value for it in the array; use a value of 0.0 or whatever default value you want.
#define CSW_P228 1
#define CSW_SCOUT 3
#define CSW_HEGRENADE 4
#define CSW_XM1014 5
#define CSW_C4 6
#define CSW_MAC10 7
#define CSW_AUG 8
#define CSW_SMOKEGRENADE 9
#define CSW_ELITE 10
#define CSW_FIVESEVEN 11
#define CSW_UMP45 12
#define CSW_SG550 13
#define CSW_GALI 14
#define CSW_GALIL 14
#define CSW_FAMAS 15
#define CSW_USP 16
#define CSW_GLOCK18 17
#define CSW_AWP 18
#define CSW_MP5NAVY 19
#define CSW_M249 20
#define CSW_M3 21
#define CSW_M4A1 22
#define CSW_TMP 23
#define CSW_G3SG1 24
#define CSW_FLASHBANG 25
#define CSW_DEAGLE 26
#define CSW_SG552 27
#define CSW_AK47 28
#define CSW_KNIFE 29
#define CSW_P90 30
#define CSW_VEST 31
#define CSW_VESTHELM 32
__________________

Last edited by Bugsy; 05-10-2009 at 15:31.
Bugsy is offline
_lol_
Senior Member
Join Date: Apr 2009
Old 05-10-2009 , 15:45   Re: what about optimizing it?lol
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
The most configurable method is the one I posted along with what Bugsy posted. But if your level damage factors were consistent you could do what Snow showed.
i dont want a configurable method, i only want performance...

no, they werent consistent, but dont worry, it isnt very important.

so, lets supose the numbers ARE consistents, wich method sould i use?

your or his?
_lol_ is offline
IneedHelp
Veteran Member
Join Date: Mar 2007
Location: Argentina
Old 05-10-2009 , 15:49   Re: what about optimizing it?lol
Reply With Quote #9

both method are fine for me. I'd prefer fysiks one.
__________________
IneedHelp is offline
_lol_
Senior Member
Join Date: Apr 2009
Old 05-10-2009 , 15:58   Re: what about optimizing it?lol
Reply With Quote #10

okay ;)
_lol_ is offline
Reply


Thread Tools
Display Modes

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 01:36.


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