--[[ Entire script by ChrisFurry. Welcome to version 3A, I messed up my mod code I've learned a lot about lua since the last update so things are going to be different, sorry. ]]-- if(rawget(_G,"BECanimatedskincolor_api2"))then -- Sorry for my dumb print that could confuse people who add multiple mods that use this script return end -- Define the namespace local asc = { tics = 0, colors = {}, } ---@param color_id SKIN_COLOR ---@param tic_delay tic_t The delay between ramp changes. (Default 4) ---@return namespace, for chaining function asc.setDelay(color_id,tic_delay) asc.makeAnimated(color_id,tic_delay) return asc end ---@param color_id SKIN_COLOR ---@return Animated Color table. function asc.get(color_id) return asc.colors[color_id] end ---@param color_id SKIN_COLOR ---@return Animated Color's current ramp. function asc.getRamp(color_id) if(asc.colors[color_id] and #asc.colors[color_id].ramp)then local r,t = asc.colors[color_id].ramp,asc.colors[color_id].delay if(asc.tics <= 0)then return r[1] end return r[(asc.tics / t % #r) + 1] end return nil end ---@param color_id SKIN_COLOR The skin color you want to become animated. ---@param tic_delay tic_t The delay between ramp changes. (Default 4) ---@return namespace, for chaining function asc.makeAnimated(color_id,tic_delay) if(asc.colors[color_id])then asc.colors[color_id].delay = tic_delay return asc end tic_delay = tic_delay or 4 asc.colors[color_id] = { ramp = {}, delay = tic_delay } return asc end ---@param color_id SKIN_COLOR The skin color you want to add a ramp to. ---@param ramp table The color ramp you want to add to the animation. ---@param ... table Color ramps. ---@return namespace, for chaining function asc.addRamp(color_id,ramp,...) if(type(ramp) ~= "table")then return asc end if(asc.colors[color_id] == nil)then asc.makeAnimated(color_id) end table.insert(asc.colors[color_id].ramp,ramp) if(#asc.colors[color_id].ramp == 1)then skincolors[color_id].ramp = ramp end return asc.addRamp(color_id,...) end -- Animates skin colors.0 function asc.think() local limited = CV_FindVar("reducevfx").value; if limited then asc.tics = $+0 else asc.tics = $+1 for sc,data in pairs(asc.colors) do if(asc.colors[sc])then skincolors[sc].ramp = asc.getRamp(sc) or skincolors[sc].ramp end end end end -- Resets the timer, used so when you go into a replay or smth the color will appear exact as it was. function asc.resetTimer() asc.tics = 0 end -- Hooks addHook("PostThinkFrame",asc.think) addHook("IntermissionThinker",asc.think) addHook("VoteThinker",asc.think) addHook("MapChange",asc.resetTimer) -- Make the namespace is global so other scripts can use it. rawset(_G,"animatedSkinColor",asc) rawset(_G,"BECanimatedskincolor_api2",true) freeslot( "SKINCOLOR_BECHOLODESCENT", "SKINCOLOR_BECNICKELODEON", "SKINCOLOR_BECZXSPECTRUM", "SKINCOLOR_BECGRAPEJELLY", "SKINCOLOR_BECAQUAFRESH", "SKINCOLOR_BECSTUDIOPOLIS", "SKINCOLOR_BECCOTTONCANDY", "SKINCOLOR_BECKIDCORE", "SKINCOLOR_BECHOPE", "SKINCOLOR_BECRAGE" ) skincolors[SKINCOLOR_BECHOLODESCENT] = { name = "Holodescent", ramp = {73,72,83,81,1,145,145,146,140,64,177,201,203,203,192,195}, invcolor = SKINCOLOR_PLAGUE, invshade = 3, chatcolor = V_SKYMAP, accessible = true } skincolors[SKINCOLOR_BECNICKELODEON] = { name = "Nickelodeon", ramp = {0,80,88,99,98,99,66,53,53,55,67,68,79,237,239,31}, invcolor = SKINCOLOR_TAFFY, invshade= 5, chatcolor = V_PERIDOTMAP, accessible = true } skincolors[SKINCOLOR_BECZXSPECTRUM] = { name = "ZX Spectrum", ramp = {255,255,255,255,73,112,112,181,181,35,35,35,35,152,152,152}, invcolor = SKINCOLOR_BLACK, invshade = 1, chatcolor = V_WHITEMAP, accessible = true } skincolors[SKINCOLOR_BECGRAPEJELLY] = { name = "Grape Jelly", ramp = {0,252,200,201,202,202,182,182,183,183,184,184,185,167,167,168}, invcolor = SKINCOLOR_LEMONADE, invshade = 10, chatcolor = V_PURPLEMAP, accessible = true } skincolors[SKINCOLOR_BECAQUAFRESH] = { name = "Aquafresh", ramp = {0,1,2,3,120,131,133,135,136,137,33,34,37,38,60,61}, invcolor = SKINCOLOR_AQUAMARINE, invshade = 7, chatcolor = V_AQUAMAP, accessible = true } skincolors[SKINCOLOR_BECSTUDIOPOLIS] = { name = "Studiopolis", ramp = {84,84,84,188,98,98,98,220,180,180,180,146,129,129,129,121}, invcolor = SKINCOLOR_RED, invshade = 3, chatcolor = V_PINKMAP, accessible = true } skincolors[SKINCOLOR_BECCOTTONCANDY] = { name = "Cotton Candy", ramp = {80,81,129,130,131,132,133,200,201,201,202,203,183,184,185,186}, invcolor = SKINCOLOR_POPCORN, invshade = 11, chatcolor = V_PINKMAP, accessible = true } skincolors[SKINCOLOR_BECKIDCORE] = { name = "Kidcore", ramp = {80,82,83,72,73,74,146,147,148,149,34,35,36,38,41,44}, invcolor = SKINCOLOR_SKUNK, invshade = 3, chatcolor = V_YELLOWMAP, accessible = true } skincolors[SKINCOLOR_BECHOPE] = { name = "Hope", ramp = {80,81,216,49,141,142,136,137,38,39,40,41,42,175,253,139}, invcolor = SKINCOLOR_DREAM, invshade = 13, chatcolor = V_BLUEMAP, accessible = true } skincolors[SKINCOLOR_BECRAGE] = { name = "Rage", ramp = {201,202,202,203,204,205,206,206,207,207,197,198,187,187,28,30}, invcolor = SKINCOLOR_RUBY, invshade = 6, chatcolor = V_MAGENTAMAP, accessible = true } -- Make animated & Add Ramps animatedSkinColor.makeAnimated(SKINCOLOR_BECSTUDIOPOLIS,7).addRamp(SKINCOLOR_BECSTUDIOPOLIS, {84,84,84,188,98,98,98,220,180,180,180,146,129,129,129,121}, {121,121,121,84,188,188,188,98,220,220,220,180,146,146,146,129}, {129,129,129,121,84,84,84,188,98,98,98,220,180,180,180,146}, {146,146,146,129,121,121,121,84,188,188,188,98,220,220,220,180}, {180,180,180,146,129,129,129,121,84,84,84,188,98,98,98,220}, {220,220,220,180,146,146,146,129,121,121,121,84,188,188,188,98}, {98,98,98,220,180,180,180,146,129,129,129,121,84,84,84,188}, {188,188,188,98,220,220,220,180,146,146,146,129,121,121,121,84}) animatedSkinColor.makeAnimated(SKINCOLOR_BECRAGE,4).addRamp(SKINCOLOR_BECRAGE, {201,202,202,203,204,205,206,206,207,207,197,198,187,187,28,30}, {201,202,202,203,204,205,206,206,207,207,197,198,187,187,28,30}, {202,202,203,203,203,204,205,206,206,207,207,207,198,198,187,31}, {207,202,202,203,203,203,204,205,206,206,207,207,207,198,198,187}, {187,207,202,202,203,203,203,204,205,206,206,207,207,207,198,198}, {30,187,198,207,206,204,203,202,202,203,204,206,207,198,187,30}, {31,187,198,198,207,207,206,206,206,205,204,203,203,203,202,202}, {31,28,187,198,207,207,206,206,205,205,204,203,202,201,200,200}, {31,28,187,198,207,207,206,206,205,205,204,203,202,201,200,200}, {31,28,187,198,207,207,206,206,205,205,204,203,202,201,200,200}, {31,28,187,198,207,207,206,206,205,205,204,203,202,201,200,200}, {31,187,198,198,207,207,206,206,206,205,204,203,203,203,202,202}, {30,187,198,207,206,204,203,202,202,203,204,206,207,198,187,30}, {187,207,202,202,203,203,203,204,205,206,206,207,207,207,198,198}, {207,202,202,203,203,203,204,205,206,206,207,207,207,198,198,187}, {202,202,203,203,203,204,205,206,206,207,207,207,198,198,187,31}, {201,202,202,203,204,205,206,206,207,207,197,198,187,187,28,30}, {201,202,202,203,204,205,206,206,207,207,197,198,187,187,28,30})