Advertisement
tdog442

Aqua Regia for Powder Toy

Jun 7th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. #include "simulation/Elements.h"
  2. //#TPT-Directive ElementClass Element_AQRG PT_AQRG 190
  3. Element_AQRG::Element_AQRG()
  4. {
  5. Identifier = "DEFAULT_PT_AQRG";
  6. Name = "AQRG";
  7. Colour = PIXPACK(0xFF0000);
  8. MenuVisible = 1;
  9. MenuSection = SC_LIQUID;
  10. Enabled = 1;
  11.  
  12. Advection = 0.6f;
  13. AirDrag = 0.01f * CFDS;
  14. AirLoss = 0.98f;
  15. Loss = 0.95f;
  16. Collision = 0.0f;
  17. Gravity = 0.1f;
  18. Diffusion = 0.00f;
  19. HotAir = 0.000f * CFDS;
  20. Falldown = 2;
  21.  
  22. Flammable = 0;
  23. Explosive = 0;
  24. Meltable = 0;
  25. Hardness = 1;
  26.  
  27. Weight = 10;
  28.  
  29. Temperature = R_TEMP+0.0f +273.15f;
  30. HeatConduct = 34;
  31. Description = "Dissolves certain metals. Reversable with soap.";
  32.  
  33. State = ST_LIQUID;
  34. Properties = TYPE_LIQUID|PROP_DEADLY;
  35.  
  36. LowPressure = IPL;
  37. LowPressureTransition = NT;
  38. HighPressure = IPH;
  39. HighPressureTransition = NT;
  40. LowTemperature = ITL;
  41. LowTemperatureTransition = NT;
  42. HighTemperature = ITH;
  43. HighTemperatureTransition = NT;
  44.  
  45. Update = &Element_AQRG::update;
  46. Graphics = &Element_AQRG::graphics;
  47. }
  48.  
  49. //#TPT-Directive ElementHeader Element_AQRG static int update(UPDATE_FUNC_ARGS)
  50. int Element_AQRG::update(UPDATE_FUNC_ARGS)
  51. {
  52. int r, rx, ry, trade, np;
  53. for (rx=-2; rx<3; rx++)
  54. for (ry=-2; ry<3; ry++)
  55. if (BOUNDS_CHECK && (rx || ry))
  56. {
  57. r = pmap[y+ry][x+rx];
  58. if (!r)
  59. continue;
  60. if((r&0xFF)==PT_GOLD&&parts[i].life>=50)
  61. {
  62. parts[i].ctype=r&0xFF;
  63. float newtemp = ((60.0f-(float)sim->elements[r&0xFF].Hardness))*7.0f;
  64. if(newtemp < 0)
  65. {
  66. newtemp = 0;
  67. }
  68. if(!(rand()%1000))
  69. {
  70. parts[i].temp += newtemp;
  71. parts[i].life--;
  72. sim->kill_part(r>>8);
  73. }
  74. }
  75. if((r&0xFF)==PT_SOAP)
  76. {
  77. sim->part_change_type(i,x,y,parts[i].ctype);
  78. }
  79. if (parts[i].life<=50)
  80. {
  81. sim->kill_part(i);
  82. return 1;
  83. }
  84. }
  85. for ( trade = 0; trade<2; trade ++)
  86. {
  87. rx = rand()%5-2;
  88. ry = rand()%5-2;
  89. if (BOUNDS_CHECK && (rx || ry))
  90. {
  91. r = pmap[y+ry][x+rx];
  92. if (!r)
  93. continue;
  94. if ((r&0xFF)==PT_AQRG && (parts[i].life>parts[r>>8].life) && parts[i].life>0)//diffusion
  95. {
  96. int temp = parts[i].life - parts[r>>8].life;
  97. if (temp==1)
  98. {
  99. parts[r>>8].life ++;
  100. parts[i].life --;
  101. }
  102. else if (temp>0)
  103. {
  104. parts[r>>8].life += temp/2;
  105. parts[i].life -= temp/2;
  106. }
  107. }
  108. }
  109. }
  110. return 0;
  111. }
  112.  
  113. int Element_AQRG::graphics(GRAPHICS_FUNC_ARGS)
  114. {
  115. int s = cpart->life;
  116. if (s>75) s = 75; //These two should not be here.
  117. if (s<49) s = 49;
  118. s = (s-49)*3;
  119. if (s==0) s = 1;
  120. *colr += s*4;
  121. *colg += s*1;
  122. *colb += s*2;
  123. *pixel_mode |= PMODE_BLUR;
  124. return 0;
  125. }
  126.  
  127.  
  128. Element_AQRG::~Element_AQRG() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement