Permalink
Browse files

jacksonmj: Move EMP triggering into SPRK_update 6ae719d

  • Loading branch information...
jacob1 committed Dec 19, 2015
1 parent bb9b35f commit 52a22bc7d6a6d5282744b9b3c0974a181b7d5f0f
Showing with 10 additions and 26 deletions.
  1. +1 −26 src/simulation/elements/EMP.cpp
  2. +9 −0 src/simulation/elements/SPRK.cpp
@@ -43,7 +43,7 @@ Element_EMP::Element_EMP()
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &Element_EMP::update;
Update = NULL;
Graphics = &Element_EMP::graphics;
}
@@ -71,31 +71,6 @@ class DeltaTempGenerator
}
};
//#TPT-Directive ElementHeader Element_EMP static int update(UPDATE_FUNC_ARGS)
int Element_EMP::update(UPDATE_FUNC_ARGS)
{
if (parts[i].life)
return 0;
for (int rx =- 2; rx <= 2; rx++)
for (int ry = -2; ry <= 2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
int r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SPRK && parts[r>>8].life > 0 && parts[r>>8].life < 4)
{
sim->emp_trigger_count++;
sim->emp_decor += 3;
if (sim->emp_decor > 40)
sim->emp_decor = 40;
parts[i].life = 220;
return 0;
}
}
return 0;
}
//#TPT-Directive ElementHeader Element_EMP static int Trigger(Simulation *sim, int triggerCount)
int Element_EMP::Trigger(Simulation *sim, int triggerCount)
{
@@ -239,6 +239,15 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
if (receiver==PT_NTCT||receiver==PT_PTCT)
continue;
}
case PT_EMP:
if (!parts[r>>8].life && parts[i].life > 0 && parts[i].life < 4)
{
sim->emp_trigger_count++;
sim->emp_decor += 3;
if (sim->emp_decor > 40)
sim->emp_decor = 40;
parts[r>>8].life = 220;
}
break;
}

0 comments on commit 52a22bc

Please sign in to comment.