Advertisement
RCAProduction

VSPK Update Func

Jul 3rd, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.10 KB | None | 0 0
  1. //#TPT-Directive ElementHeader Element_VSPK static int update(UPDATE_FUNC_ARGS)
  2. int Element_VSPK::update(UPDATE_FUNC_ARGS)
  3. {
  4.     int r, rx, ry, nearp, pavg, ct = parts[i].ctype, sender, receiver;
  5.     Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
  6.  
  7.     if (parts[i].life<=0)
  8.     {
  9.         if (ct!=PT_ZRNT)
  10.         {
  11.             parts[i].temp = 5000;
  12.         }
  13.         if (ct<=0 || ct>=PT_NUM || !sim->elements[parts[i].ctype].Enabled)
  14.             sim->kill_part(i);
  15.         sim->part_change_type(i,x,y,ct);
  16.         parts[i].ctype = PT_NONE;
  17.         parts[i].life = 4;
  18.  
  19.         return 0;
  20.     }
  21.     //Kills VSPK id it has a ctype of itself.
  22.     switch(ct)
  23.     {
  24.     case PT_VSPK:
  25.         sim->kill_part(i);
  26.         return 1;
  27.     }
  28.    
  29.     for (rx=-2; rx<3; rx++)
  30.         for (ry=-2; ry<3; ry++)
  31.             if (BOUNDS_CHECK && (rx || ry))
  32.             {
  33.                 r = pmap[y+ry][x+rx];
  34.                 if (!r)
  35.                     continue;
  36.                 receiver = r&0xFF;
  37.                 sender = ct;
  38.                 pavg = sim->parts_avg(r>>8, i,PT_INSL);
  39.                 //receiver is the element VSPK is trying to conduct to
  40.                 //sender is the element the VSPK is on
  41.  
  42.                 if (pavg == PT_INSL || pavg == PT_CBNF) continue; //Insulation and CBNF blocks everything past here
  43.                 if (!((sim->elements[receiver].Properties&PROP_CONDUCTS)||receiver==PT_INST||receiver==PT_QRTZ)) continue; //Stop non-conducting receivers, allow INST and QRTZ as special cases
  44.  
  45.                 if (parts[r>>8].life==0) {
  46.                     parts[r>>8].life = parts[i].life - 1;
  47.                     parts[r>>8].ctype = receiver;
  48.                     sim->part_change_type(r>>8,x+rx,y+ry,PT_VSPK);
  49.                 //return 0;
  50.                     if (parts[r>>8].ctype!=PT_ZRNT && parts[r>>8].type!=PT_ZRNT)
  51.                     {
  52.                         parts[r>>8].temp = 4500;
  53.                         parts[i].life = parts[i].life - 300;
  54.                         parts[i].temp = 5000;
  55.                         if(parts[i].ctype==PT_ZRNT)
  56.                         {
  57.                             parts[i].temp = 273.15;
  58.                         }
  59.                     }
  60.                     if(parts[i].temp>=4500)
  61.                         sim->part_change_type(i,x,y,ct);
  62.                     //if(
  63.                 }
  64.             }
  65.     return 0;
  66. }
  67.  
  68.  
  69.  
  70. //#TPT-Directive ElementHeader Element_VSPK static int graphics(GRAPHICS_FUNC_ARGS)
  71. int Element_VSPK::graphics(GRAPHICS_FUNC_ARGS)
  72.  
  73. {
  74.     *firea = 60;
  75.     *firer = *colr/2;
  76.     *fireg = *colg/2;
  77.     *fireb = *colb/2;
  78.     *pixel_mode |= FIRE_SPARK;
  79.     return 1;
  80. }
  81.  
  82.  
  83. Element_VSPK::~Element_VSPK() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement