1 #include "simulation/ElementCommon.h" 2 3 static int update(UPDATE_FUNC_ARGS); 4 static int graphics(GRAPHICS_FUNC_ARGS); 5 Element_EMBR()6void Element::Element_EMBR() 7 { 8 Identifier = "DEFAULT_PT_EMBR"; 9 Name = "EMBR"; 10 Colour = PIXPACK(0xFFF288); 11 MenuVisible = 0; 12 MenuSection = SC_EXPLOSIVE; 13 Enabled = 1; 14 15 Advection = 0.4f; 16 AirDrag = 0.001f * CFDS; 17 AirLoss = 0.99f; 18 Loss = 0.90f; 19 Collision = 0.0f; 20 Gravity = 0.07f; 21 Diffusion = 0.00f; 22 HotAir = 0.000f * CFDS; 23 Falldown = 1; 24 25 Flammable = 0; 26 Explosive = 0; 27 Meltable = 0; 28 Hardness = 20; 29 30 Weight = 30; 31 32 DefaultProperties.temp = 500.0f + 273.15f; 33 HeatConduct = 29; 34 Description = "Sparks. Formed by explosions."; 35 36 Properties = TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL|PROP_SPARKSETTLE; 37 38 LowPressure = IPL; 39 LowPressureTransition = NT; 40 HighPressure = IPH; 41 HighPressureTransition = NT; 42 LowTemperature = ITL; 43 LowTemperatureTransition = NT; 44 HighTemperature = ITH; 45 HighTemperatureTransition = NT; 46 47 DefaultProperties.life = 50; 48 49 Update = &update; 50 Graphics = &graphics; 51 } 52 update(UPDATE_FUNC_ARGS)53static int update(UPDATE_FUNC_ARGS) 54 { 55 int r, rx, ry; 56 for (rx=-1; rx<2; rx++) 57 for (ry=-1; ry<2; ry++) 58 if (BOUNDS_CHECK && (rx || ry)) 59 { 60 r = pmap[y+ry][x+rx]; 61 if (!r) 62 continue; 63 if ((sim->elements[TYP(r)].Properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(sim->elements[TYP(r)].Properties & PROP_SPARKSETTLE)) 64 { 65 sim->kill_part(i); 66 return 1; 67 } 68 } 69 return 0; 70 } 71 graphics(GRAPHICS_FUNC_ARGS)72static int graphics(GRAPHICS_FUNC_ARGS) 73 { 74 if (cpart->ctype&0xFFFFFF) 75 { 76 int maxComponent; 77 *colr = (cpart->ctype&0xFF0000)>>16; 78 *colg = (cpart->ctype&0x00FF00)>>8; 79 *colb = (cpart->ctype&0x0000FF); 80 maxComponent = *colr; 81 82 if (*colg>maxComponent) maxComponent = *colg; 83 if (*colb>maxComponent) maxComponent = *colb; 84 if (maxComponent<60)//make sure it isn't too dark to see 85 { 86 float multiplier = 60.0f/maxComponent; 87 *colr *= multiplier; 88 *colg *= multiplier; 89 *colb *= multiplier; 90 } 91 } 92 else if (cpart->tmp != 0) 93 { 94 *colr = *colg = *colb = 255; 95 } 96 97 bool deco = false; 98 if (ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000)) 99 { 100 if (!ren->blackDecorations) // if blackDecorations is off, always show deco 101 deco = true; 102 else if (((cpart->dcolour>>24)&0xFF) >= 250 && ((cpart->dcolour>>16)&0xFF) <= 5 && ((cpart->dcolour>>8)&0xFF) <= 5 && ((cpart->dcolour)&0xFF) <= 5) // else only render black deco 103 deco = true; 104 } 105 if (deco) 106 { 107 int a = (cpart->dcolour>>24)&0xFF; 108 *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; 109 *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; 110 *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; 111 } 112 *firer = *colr; 113 *fireg = *colg; 114 *fireb = *colb; 115 if (cpart->tmp==1) 116 { 117 *pixel_mode = FIRE_ADD | PMODE_BLEND | PMODE_GLOW; 118 *firea = (cpart->life-15)*4; 119 *cola = (cpart->life+15)*4; 120 } 121 else if (cpart->tmp==2) 122 { 123 *pixel_mode = PMODE_FLAT | FIRE_ADD; 124 *firea = 255; 125 } 126 else 127 { 128 *pixel_mode = PMODE_SPARK | PMODE_ADD; 129 if (cpart->life<64) *cola = 4*cpart->life; 130 } 131 return 0; 132 } 133