Guest User

New exot.c

a guest
Jun 17th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.44 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_EXOT(UPDATE_FUNC_ARGS) {
  19.     int r, rt, rx, ry, nb, rrx, rry, trade, tym, t;
  20.     t = parts[i].type;
  21.    
  22.     if (parts[i].ctype>0 && parts[i].ctype<PT_NUM) {
  23.         create_part(i, x, y, parts[i].ctype);
  24.         return 0;
  25.     }
  26.    
  27.     for (rx=-2; rx<=2; rx++)
  28.         for (ry=-2; ry<=2; ry++)
  29.             if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) {
  30.                 r = pmap[y+ry][x+rx];
  31.                 if (!r)
  32.                     continue;
  33.                 if ((r&0xFF)==PT_WARP)
  34.                 {
  35.                     if (parts[r>>8].tmp2>2000)
  36.                         if (1>rand()%100)
  37.                         {
  38.                             parts[i].tmp2 += 100;
  39.                         }
  40.                 }
  41.                 if ((r&0xFF)==PT_EXOT && parts[r>>8].life==1500)
  42.                     parts[i].life = 1500;
  43.                 if ((parts[i].tmp==1) && (parts[i].life>1000))
  44.                     if ((r&0xFF)!=PT_EXOT && (r&0xFF)!=PT_BREL && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_NBHL && (r&0xFF)!=PT_WARP && (r&0xFF)!=PT_NEUT)
  45.                     {
  46.                         parts[i].ctype = parts[r>>8].type;
  47.                     }
  48.             }
  49.     parts[i].tmp--;
  50.     parts[i].tmp2--;   
  51.     if (parts[i].tmp<1 || parts[i].tmp>250)
  52.         parts[i].tmp = 250;
  53.     if (parts[i].tmp2<1)
  54.         parts[i].tmp2 = 1;
  55.     else if (parts[i].tmp2>6000)
  56.     {
  57.         parts[i].tmp2 = 10000;
  58.         if (parts[i].life<1001)
  59.         {
  60.             part_change_type(i, x, y, PT_WARP);
  61.             return 0;
  62.         }
  63.     }
  64.     else if (parts[i].life<1001)
  65.         pv[y/CELL][x/CELL] += (parts[i].tmp2*CFDS)/160000;
  66.     if (pv[y/CELL][x/CELL]>200 && parts[i].temp>9000 && parts[i].tmp2>200)
  67.     {
  68.         parts[i].tmp2 = 6000;
  69.         part_change_type(i, x, y, PT_WARP);
  70.         return 0;
  71.     }      
  72.     if (parts[i].tmp2>100)
  73.     {
  74.         for ( trade = 0; trade<9; trade ++)
  75.         {
  76.             rx = rand()%5-2;
  77.             ry = rand()%5-2;
  78.             if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
  79.             {
  80.                 r = pmap[y+ry][x+rx];
  81.                 if (!r)
  82.                     continue;
  83.                 if ((r&0xFF)==t && (parts[i].tmp2>parts[r>>8].tmp2) && parts[r>>8].tmp2>=0 )//diffusion
  84.                 {
  85.                     tym = parts[i].tmp2 - parts[r>>8].tmp2;
  86.                     if (tym ==1)
  87.                     {
  88.                         parts[r>>8].tmp2 ++;
  89.                         parts[i].tmp2 --;
  90.                         break;
  91.                     }
  92.                     if (tym>0)
  93.                     {
  94.                         parts[r>>8].tmp2 += tym/2;
  95.                         parts[i].tmp2 -= tym/2;
  96.                         break;
  97.                     }
  98.                 }
  99.             }
  100.         }
  101.     }
  102.     if (parts[i].temp<273.15f)
  103.     {
  104.         parts[i].vx = 0;
  105.         parts[i].vy = 0;
  106.         pv[y/CELL][x/CELL] -= 0.01;
  107.         parts[i].tmp--;
  108.     }
  109.    
  110.     if (parts[i].life < 1000) {
  111.         parts[i].life += 1;
  112.     } else if(parts[i].life == 1000) {
  113.         if(rand()%7500==0) parts[i].life = 750;
  114.     }
  115.    
  116.     return 0;
  117.  
  118. }
  119. int graphics_EXOT(GRAPHICS_FUNC_ARGS)
  120. {
  121.     int q = cpart->temp;
  122.     int b = cpart->tmp;
  123.     int c = cpart->tmp2;   
  124.     if (cpart->life < 1001)
  125.     {
  126.         if ((cpart->tmp2 - 1)>rand()%1000)
  127.         {  
  128.             float frequency = 0.04045; 
  129.             *colr = (sin(frequency*c + 4) * 127 + 150);
  130.             *colg = (sin(frequency*c + 6) * 127 + 150);
  131.             *colb = (sin(frequency*c + 8) * 127 + 150);
  132.             *firea = 100;
  133.             *firer = 0;
  134.             *fireg = 0;
  135.             *fireb = 0;
  136.             *pixel_mode |= PMODE_FLAT;
  137.             *pixel_mode |= PMODE_FLARE;
  138.         }
  139.         else
  140.         {
  141.             float frequency = 0.00045; 
  142.             *colr = (sin(frequency*q + 4) * 127 + 1000-cpart->life);
  143.             *colg = (sin(frequency*q + 6) * 127 + 1000-cpart->life);
  144.             *colb = (sin(frequency*q + 8) * 127 + 1000-cpart->life);
  145.             *firea = 1000-cpart->life;
  146.             *firer = *colr;
  147.             *fireg = *colg;
  148.             *fireb = *colb;
  149.             *pixel_mode |= FIRE_ADD;
  150.             *pixel_mode |= PMODE_BLUR;
  151.         }
  152.     }
  153.     else
  154.     {
  155.         float frequency = 0.00045; 
  156.         *colr = (sin(frequency*q + 4) * 127 + (b/1.7));
  157.         *colg = (sin(frequency*q + 6) * 127 + (b/1.7));
  158.         *colb = (sin(frequency*q + 8) * 127 + (b/1.7));
  159.         *cola = cpart->tmp / 6;
  160.         *firea = *cola;
  161.         *firer = *colr;
  162.         *fireg = *colg;
  163.         *fireb = *colb;
  164.         *pixel_mode |= FIRE_ADD;
  165.         *pixel_mode |= PMODE_BLUR;
  166.  
  167.  
  168.     }
  169.     return 0;
  170. }
Advertisement
Add Comment
Please, Sign In to add comment