Advertisement
ForumTroll

nplm.c

Sep 14th, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.81 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_NPLM(UPDATE_FUNC_ARGS)
  19. {
  20.  
  21.  
  22.     int r, rx, ry;
  23.     float dx, dy;
  24.     char nplm;
  25.     int absorbChanceDenom;
  26.     if (parts[i].tmp>100) parts[i].tmp = 100;
  27.     if (parts[i].tmp<0) parts[i].tmp = 0;
  28.     absorbChanceDenom = parts[i].tmp*10 + 500;
  29.     for (rx=-2; rx<3; rx++)
  30.         for (ry=-2; ry<3; ry++)
  31.             if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
  32.             {
  33.                 r = pmap[y+ry][x+rx];
  34.                 if (!r)
  35.                     continue;
  36.  
  37.  
  38.                
  39.  
  40.                 nplm = 0;
  41.                
  42.                 //Stickness
  43.                 if ((dx*dx + dy*dy)>1.5 && (nplm || !ptypes[r&0xFF].falldown || (fabs(rx)<2 && fabs(ry)<2)))
  44.                 {
  45.                     float per, nd;
  46.                     nd = dx*dx + dy*dy - 0.5;
  47.  
  48.                     per = 5*(1 - parts[i].tmp/100)*(nd/(dx*dx + dy*dy + nd) - 0.5);
  49.                     if (ptypes[r&0xFF].state==ST_LIQUID)
  50.                         per *= 0.1;
  51.                    
  52.                     dx *= per; dy *= per;
  53.                     parts[i].vx += dx;
  54.                     parts[i].vy += dy;
  55.  
  56.                     if (ptypes[r&0xFF].properties&TYPE_PART || (r&0xFF)==PT_GOO)
  57.                     {
  58.                         parts[r>>8].vx -= dx;
  59.                         parts[r>>8].vy -= dy;
  60.                     }
  61.                 }
  62.             }
  63.  
  64.  
  65.             if ((r&0xFF)==PT_SPRK)
  66.     {
  67.         part_change_type(i,x,y,PT_FIRE);
  68.     }
  69.     //create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
  70.  
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement