Merge remote-tracking branch 'upstream/master' into fluffclean

Conflicts:
	paradise.dme
This commit is contained in:
Tigercat2000
2015-05-16 05:38:40 -07:00
231 changed files with 3508 additions and 3121 deletions
+27 -62
View File
@@ -1,66 +1,31 @@
/proc/mix_color_from_reagents(var/list/reagent_list)
if(!reagent_list || !length(reagent_list))
return 0
/*
* Returns:
* #RRGGBB(AA) on success, null on failure
*/
/proc/mix_color_from_reagents(const/list/reagent_list)
if(!istype(reagent_list))
return
var/contents = length(reagent_list)
var/list/weight = new /list(contents)
var/list/redcolor = new /list(contents)
var/list/greencolor = new /list(contents)
var/list/bluecolor = new /list(contents)
var/i
var/color
var/reagent_color
var/vol_counter = 0
var/vol_temp
// see libs/IconProcs/IconProcs.dm
for(var/datum/reagent/reagent in reagent_list)
if(reagent.id == "blood" && reagent.data["blood_colour"])
reagent_color = reagent.data["blood_colour"]
else
reagent_color = reagent.color
//fill the list of weights
for(i=1; i<=contents; i++)
var/datum/reagent/re = reagent_list[i]
var/reagentweight = re.volume
if(istype(re, /datum/reagent/paint))
reagentweight *= 20 //Paint colours a mixture twenty times as much
weight[i] = reagentweight
vol_temp = reagent.volume
vol_counter += vol_temp
if(isnull(color))
color = reagent.color
else if(length(color) >= length(reagent_color))
color = BlendRGB(color, reagent_color, vol_temp/vol_counter)
else
color = BlendRGB(reagent_color, color, vol_temp/vol_counter)
return color
//fill the lists of colours
for(i=1; i<=contents; i++)
var/datum/reagent/re = reagent_list[i]
var/hue = re.color
if(length(hue) != 7)
return 0
redcolor[i]=hex2num(copytext(hue,2,4))
greencolor[i]=hex2num(copytext(hue,4,6))
bluecolor[i]=hex2num(copytext(hue,6,8))
//mix all the colors
var/red = mixOneColor(weight,redcolor)
var/green = mixOneColor(weight,greencolor)
var/blue = mixOneColor(weight,bluecolor)
//assemble all the pieces
var/finalcolor = rgb(red, green, blue)
return finalcolor
/proc/mixOneColor(var/list/weight, var/list/color)
if (!weight || !color || length(weight)!=length(color))
return 0
var/contents = length(weight)
var/i
//normalize weights
var/listsum = 0
for(i=1; i<=contents; i++)
listsum += weight[i]
for(i=1; i<=contents; i++)
weight[i] /= listsum
//mix them
var/mixedcolor = 0
for(i=1; i<=contents; i++)
mixedcolor += weight[i]*color[i]
mixedcolor = round(mixedcolor)
//until someone writes a formal proof for this algorithm, let's keep this in
// if(mixedcolor<0x00 || mixedcolor>0xFF)
// return 0
//that's not the kind of operation we are running here, nerd
mixedcolor=min(max(mixedcolor,0),255)
return mixedcolor
+1 -1
View File
@@ -488,7 +488,7 @@ datum
R.holder = src
R.volume = amount
// SetViruses(R, data) // Includes setting data
R.data = data
if(data) R.data = data
//debug
//world << "Adding data"
//for(var/D in R.data)
+1 -1
View File
@@ -106,7 +106,7 @@ datum/reagent/charcoal
id = "charcoal"
description = "Activated charcoal helps to absorb toxins."
reagent_state = LIQUID
color = "#C8A5DC"
color = "#000000"
datum/reagent/charcoal/on_mob_life(var/mob/living/M as mob)
if(!M) M = holder.my_atom