ID:172120
 
I really need some help with this code:
var/icon/C = icon('Enemy.dmi',"lvl1")
var/icon/B = icon('Bullet.dmi',"wound[rand(1,3)]")
B.Shift(NORTH,rand(8,20))
B.Shift(EAST,rand(8,20))
B.Blend(rgb(0,0,0),ICON_MULTIPLY)
C.Blend(B,ICON_ADD)
A.icon = C


It supposed to add the wound to the Enemy's icon, but cut it so it doesn't go over the edge.
but instead it does the opposite.
It takes the shape of the wound and the color of the Enemy.

I tried flipping the icon files, but then is takes the shape and the color of the wound.

All help is very helpful!
-The very confused, DarkCampainger
DarkCampainger wrote:
I really need some help with this code:
var/icon/C = icon('Enemy.dmi',"lvl1")
var/icon/B = icon('Bullet.dmi',"wound[rand(1,3)]")
B.Shift(NORTH,rand(8,20))
B.Shift(EAST,rand(8,20))
B.Blend(rgb(0,0,0),ICON_MULTIPLY)
C.Blend(B,ICON_ADD)
A.icon = C
It supposed to add the wound to the Enemy's icon, but cut it so it doesn't go over the edge.
but instead it does the opposite.
It takes the shape of the wound and the color of the Enemy.

Your problem lies in the first B.Blend() line; you're removing all the color from B (the wound) and changing it all to black. When that's added via ICON_ADD to the enemy, it will combine transparent areas of the two (hence a wound shape, clipped to the body), and since the only icon with color left is the enemy icon, only the color of the enemy is used.

It shouldn't take much to modify this though:
var/icon/C = icon('Enemy.dmi',"lvl1")
var/icon/B = icon('Bullet.dmi',"wound[rand(1,3)]")
B.Shift(NORTH,rand(8,20))
B.Shift(EAST,rand(8,20))
// now create the wound-on-body icon, but without clipping to the body shape
B.Blend(C,ICON_UNDERLAY)
// make the body-without-wound icon black, to add in a last step
C.SetIntensity(0)
// add the wounded body with color to the body shape without color
C.Blend(B,ICON_ADD)
A.icon = C

Lummox JR
In response to Lummox JR (#1)
It works! Thank you so much!!