Guest User

BANG2

a guest
May 25th, 2014
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. #include "simulation/Elements.h"
  2. //#TPT-Directive ElementClass Element_BANG PT_BANG 139
  3. Element_BANG::Element_BANG()
  4. {
  5. Identifier = "DEFAULT_PT_BANG";
  6. Name = "TNT";
  7. Colour = PIXPACK(0xC05050);
  8. MenuVisible = 1;
  9. MenuSection = SC_EXPLOSIVE;
  10. Enabled = 1;
  11.  
  12. Advection = 0.0f;
  13. AirDrag = 0.00f * CFDS;
  14. AirLoss = 0.90f;
  15. Loss = 0.00f;
  16. Collision = 0.0f;
  17. Gravity = 0.0f;
  18. Diffusion = 0.00f;
  19. HotAir = 0.000f * CFDS;
  20. Falldown = 0;
  21.  
  22. Flammable = 0;
  23. Explosive = 1;
  24. Meltable = 0;
  25. Hardness = 1;
  26.  
  27. Weight = 100;
  28.  
  29. Temperature = R_TEMP+0.0f +273.15f;
  30. HeatConduct = 88;
  31. Description = "TNT, explodes all at once.";
  32.  
  33. State = ST_SOLID;
  34. Properties = TYPE_SOLID | PROP_NEUTPENETRATE;
  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_BANG::update;
  46.  
  47. }
  48.  
  49. //#TPT-Directive ElementHeader Element_BANG static int update(UPDATE_FUNC_ARGS)
  50. int Element_BANG::update(UPDATE_FUNC_ARGS)
  51. {
  52. int r, rx, ry, nb;
  53. if(parts[i].tmp==0)
  54. {
  55. if(parts[i].temp>=673.0f)
  56. parts[i].tmp = 1;
  57. else
  58. for (rx=-1; rx<2; rx++)
  59. for (ry=-1; ry<2; ry++)
  60. if (BOUNDS_CHECK && (rx || ry))
  61. {
  62. r = pmap[y+ry][x+rx];
  63. if (!r)
  64. r = sim->photons[y+ry][x+rx];
  65. if (!r)
  66. continue;
  67. if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_SPRK || (r&0xFF)==PT_LIGH)
  68. {
  69. parts[i].tmp = 1;
  70. }
  71. if ((r&0xFF)==PT_EXOT)
  72. {
  73. sim->part_change_type(i,x,y,PT_BBNG);
  74. }
  75. }
  76.  
  77. }
  78. else if(parts[i].tmp==1)
  79. {
  80. if ((pmap[y][x]>>8 == i))
  81. {
  82. PropertyValue value;
  83. value.Integer = 2;
  84. sim->flood_prop(x, y, offsetof(Particle, tmp), value, StructProperty::Integer);
  85. }
  86. parts[i].tmp = 2;
  87. }
  88. else if(parts[i].tmp==2)
  89. {
  90. parts[i].tmp = 3;
  91. }
  92. else
  93. {
  94. float otemp = parts[i].temp-273.15f;
  95. //Explode!!
  96. sim->pv[y/CELL][x/CELL] += 0.5f;
  97. parts[i].tmp = 0;
  98. if(!(rand()%3))
  99. {
  100. if(!(rand()%2))
  101. {
  102. sim->create_part(i, x, y, PT_FIRE);
  103. }
  104. else
  105. {
  106. sim->create_part(i, x, y, PT_SMKE);
  107. parts[i].life = rand()%50+500;
  108. }
  109. parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP);
  110. }
  111. else
  112. {
  113. if(!(rand()%15))
  114. {
  115. sim->create_part(i, x, y, PT_EMBR);
  116. parts[i].tmp = 0;
  117. parts[i].life = 50;
  118. parts[i].temp = restrict_flt((MAX_TEMP/3)+otemp, MIN_TEMP, MAX_TEMP);
  119. parts[i].vx = rand()%20-10;
  120. parts[i].vy = rand()%20-10;
  121. }
  122. else
  123. {
  124. sim->kill_part(i);
  125. }
  126. }
  127. return 1;
  128. }
  129. return 0;
  130. }
  131.  
  132.  
  133. Element_BANG::~Element_BANG() {}
Advertisement
Add Comment
Please, Sign In to add comment