Banned
|
Join Date: Jul 2004
Location: London
Posts: 2,029
|
|
Quote:
Originally Posted by Skyld
shared.getAlignmentColor(ap)
Returns an array of {red, green, blue} for the given AP color, allowing you to recreate the default nickname colors.
PHP Code:
shared.getAlignmentColor(player.ap);
shared.getAlignmentShadowColor(red, green, blue)
Returns an array of {red, green, blue} for the shadow of the given color, allowing you to recreate the default nickname shadows.
PHP Code:
shared.getAlignmentShadowColor(0.75, 0.1, 0.3);
|
I recently did some testing comparing the time it takes to loop through 0-100 between these shared functions and what we were using to calculate it on Classic.
It turns out that Classic's method was roughly twice as fast as the shared function, though some (wouldn't rule out all) of this time may have been down to the fact that public functions take a little bit longer.
Me/WhiteDragon then decided to try storing all of the values within an array like this:
PHP Code:
//#CLIENTSIDE function onCreated(){ this.apv = { {64,0,0}, {128,64,64}, {133,62,62}, {138,59,59}, {143,57,57}, {148,54,54}, {153,52,52}, {158,49,49}, {163,47,47}, {168,44,44}, {173,41,41}, {178,39,39}, {183,36,36}, {188,34,34}, {194,31,31}, {199,29,29}, {204,26,26}, {209,24,24}, {214,21,21}, {219,18,18}, {224,16,16}, {229,13,13}, {234,11,11}, {239,8,8}, {244,6,6}, {249,3,3}, {255,0,0}, {255,10,10}, {255,21,21}, {255,31,31}, {255,42,42}, {255,53,53}, {255,63,63}, {255,74,74}, {255,85,85}, {255,95,95}, {255,106,106}, {255,116,116}, {255,127,127}, {255,138,138}, {255,148,148}, {255,159,159}, {255,170,170}, {255,180,180}, {255,191,191}, {255,201,201}, {255,212,212}, {255,223,223}, {255,233,233}, {255,244,244}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {230,255,230}, {205,255,205}, {179,255,179}, {154,255,154}, {128,255,128}, {128,255,128}, {116,255,140}, {103,255,153}, {90,255,166}, {77,255,178}, {64,255,191}, {52,255,204}, {39,255,216}, {26,255,229}, {13,255,242}, {0,247,255}, {0,238,255}, {0,229,255}, {0,220,255}, {0,212,255}, {0,203,255}, {0,194,255}, {0,185,255}, {0,176,255}, {0,168,255}, {0,159,255}, {0,150,255}, {0,141,255}, {0,132,255}, {0,124,255}, {0,115,255}, {0,106,255}, {0,97,255}, {0,88,255}, {0,80,255}, {0,71,255}, {0,62,255}, {0,53,255}, {0,44,255}, {0,36,255}, {0,27,255}, {0,18,255}, {0,9,255}, {0,0,255}, {231,199,0} }; }
public function getAlignmentColors(temp.ap) { temp.ac = this.getAlignmentColor(temp.ap); if(temp.ap == 100){ temp.sc = {255, 255, 0}; } else{ temp.c = 255 * !(temp.ac[0]>191.25 || temp.ac[1]>191.25); temp.sc = {temp.c, temp.c, temp.ac[2]}; } return {temp.ac, temp.sc}; //Alignment Color, Shadow Color }
public function getAlignmentColor(temp.ap) { return this.apv[temp.ap]; }
I guess this would be exchanging some memory and an increased amount of weapon data sent to the client for a save on script time. This turned out to be significantly faster than what we were previously using if the class is joined within the script using it. It is also still slightly faster than our previous method if used as a public function. |
|