Advertisement
ForumTroll

jacob1 fix me D:<

Sep 18th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.78 KB | None | 0 0
  1. /*
  2.  * This program is free software; you can redistribute it and/or modify
  3.  * it under the terms of the GNU General Public License as published by
  4.  * the Free Software Foundation; either version 3 of the License, or
  5.  * (at your option) any later version.
  6.  *
  7.  * This program is distributed in the hope that it will be useful,
  8.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.  * GNU General Public License for more details.
  11.  *
  12.  * You should have received a copy of the GNU General Public License
  13.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14.  */
  15.  
  16. #include <element.h>
  17.  
  18. int update_PYRO(UPDATE_FUNC_ARGS) {
  19.     int r, rx, ry, rt, t = parts[i].type;
  20.     //==============================
  21.     //Gives pressure if CTYPE is C-6
  22.     //==============================
  23.      if (parts[i].ctype = PT_CSIX)
  24.      {
  25.         ((pv[y/CELL][x/CELL] = 30.0f));
  26.      }
  27.      if (parts[i].ctype != PT_CSIX){
  28.         ((pv[y/CELL][x/CELL] = 30.0f));
  29.      }
  30.     //==============================
  31.     //hurray!  Lets make this longer
  32.     //==============================
  33.     if (t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1)
  34.     {
  35.         t = PT_NBLE;
  36.         part_change_type(i,x,y,t);
  37.         parts[i].life = 0;
  38.     }
  39.     if(t==PT_FIRE && parts[i].life <=1)
  40.     {
  41.         if (parts[i].tmp==3){
  42.             t = PT_DSTW;
  43.             part_change_type(i,x,y,t);
  44.             parts[i].life = 0;
  45.             parts[i].ctype = PT_FIRE;
  46.         }
  47.         else if (parts[i].temp<625)
  48.         {
  49.             t = PT_SMKE;
  50.             part_change_type(i,x,y,t);
  51.             parts[i].life = rand()%20+250;
  52.         }
  53.     }
  54.     if(t==PT_PLSM && parts[i].life <=1)
  55.     {
  56.         if (parts[i].tmp==3){
  57.             t = PT_DSTW;
  58.             part_change_type(i,x,y,t);
  59.             parts[i].life = 0;
  60.             parts[i].ctype = PT_FIRE;
  61.         }
  62.     }
  63.     for (rx=-2; rx<3; rx++)
  64.         for (ry=-2; ry<3; ry++)
  65.             if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
  66.             {
  67.                 r = pmap[y+ry][x+rx];
  68.                 if (!r)
  69.                     continue;
  70.                 if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM)
  71.                     continue;
  72.                 rt = parts[r>>8].type;
  73.                 if ((surround_space || ptypes[rt].explosive) &&
  74.                     (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL)) &&
  75.                     (t!=PT_PHOT || rt!=PT_INSL) &&
  76.                     (rt!=PT_SPNG || parts[r>>8].life==0) &&
  77.                     (rt!=PT_H2 || parts[r>>8].temp < 2273.15) &&
  78.                     ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000))
  79.                 {
  80.                     part_change_type(r>>8,x+rx,y+ry,PT_FIRE);
  81.                     parts[r>>8].temp = restrict_flt(ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2), MIN_TEMP, MAX_TEMP);
  82.                     parts[r>>8].life = rand()%80+180;
  83.                     parts[r>>8].tmp = parts[r>>8].ctype = 0;
  84.                     if (ptypes[rt].explosive)
  85.                         pv[y/CELL][x/CELL] += 0.25f * CFDS;
  86.                 }
  87.             }
  88.     if (legacy_enable) update_legacy_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
  89.     return 0;
  90. }
  91.  
  92. int update_legacy_PYRO(UPDATE_FUNC_ARGS) {
  93.     int r, rx, ry, rt, lpv, t = parts[i].type;
  94.     for (rx=-2; rx<3; rx++)
  95.         for (ry=-2; ry<3; ry++)
  96.             if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
  97.             {
  98.                 r = pmap[y+ry][x+rx];
  99.                 if (!r)
  100.                     continue;
  101.                 if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM)
  102.                     continue;
  103.                 rt = r&0xFF;
  104.                 lpv = (int)pv[(y+ry)/CELL][(x+rx)/CELL];
  105.                 if (lpv < 1) lpv = 1;
  106.                 if (t!=PT_SPRK && ptypes[rt].meltable  && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&
  107.                         ptypes[rt].meltable*lpv>(rand()%1000))
  108.                 {
  109.                     if (t!=PT_LAVA || parts[i].life>0)
  110.                     {
  111.                         parts[r>>8].ctype = (rt==PT_BRMT)?PT_BMTL:parts[r>>8].type;
  112.                         parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype;
  113.                         part_change_type(r>>8,x+rx,y+ry,PT_LAVA);
  114.                         parts[r>>8].life = rand()%120+240;
  115.                     }
  116.                     else
  117.                     {
  118.                         parts[i].life = 0;
  119.                         t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
  120.                         parts[i].ctype = PT_NONE;//rt;
  121.                         part_change_type(i,x,y,t);
  122.                         return 1;
  123.                     }
  124.                 }
  125.                 if (t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW))
  126.                 {
  127.                     parts[r>>8].type = PT_WATR;
  128.                     if (t==PT_FIRE)
  129.                     {
  130.                         kill_part(i);
  131.                         return 1;
  132.                     }
  133.                     if (t==PT_LAVA)
  134.                     {
  135.                         parts[i].life = 0;
  136.                         t = parts[i].type = PT_STNE;
  137.                         part_change_type(i,x,y,t);
  138.                     }
  139.                 }
  140.                 if (t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW))
  141.                 {
  142.                     kill_part(r>>8);
  143.                     if (t==PT_FIRE)
  144.                     {
  145.                         kill_part(i);
  146.                         return 1;
  147.                     }
  148.                     if (t==PT_LAVA)
  149.                     {
  150.                         parts[i].life = 0;
  151.                         t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
  152.                         parts[i].ctype = PT_NONE;
  153.                         part_change_type(i,x,y,t);
  154.                     }
  155.                 }
  156.             }
  157.     return 0;
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement